View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  package org.apache.directory.server.config.beans;
21  
22  
23  import org.apache.directory.server.config.ConfigurationElement;
24  
25  
26  /**
27   * A class used to store the Interceptors configuration.
28   *
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   */
31  public class InterceptorBean extends AdsBaseBean implements Comparable<InterceptorBean>
32  {
33      /** The Interceptor ID */
34      @ConfigurationElement(attributeType = "ads-interceptorId", isRdn = true)
35      private String interceptorId;
36  
37      /** The interceptor FQCN */
38      @ConfigurationElement(attributeType = "ads-interceptorClassName")
39      private String interceptorClassName;
40  
41      /** The interceptor position in the chain */
42      @ConfigurationElement(attributeType = "ads-interceptorOrder")
43      private int interceptorOrder;
44  
45  
46      /**
47       * Creates a new InterceptorBean
48       */
49      public InterceptorBean()
50      {
51      }
52  
53  
54      /**
55       * Compares the order of the interceptor with the given one
56       * @param o An interceptor 
57       * @return -1 if the current interceptor is below the given one, 1 if 
58       * it's above, 0 if it's equal
59       */
60      public int compareTo( InterceptorBean o )
61      {
62          if ( interceptorOrder > o.interceptorOrder )
63          {
64              return 1;
65          }
66          else if ( interceptorOrder < o.interceptorOrder )
67          {
68              return -1;
69          }
70  
71          return 0;
72      }
73  
74  
75      /**
76       * @return the id
77       */
78      public String getInterceptorId()
79      {
80          return interceptorId;
81      }
82  
83  
84      /**
85       * @param id the id to set
86       */
87      public void setInterceptorId( String id )
88      {
89          this.interceptorId = id;
90      }
91  
92  
93      /**
94       * @return the interceptor Order
95       */
96      public int getInterceptorOrder()
97      {
98          return interceptorOrder;
99      }
100 
101 
102     /**
103      * @param interceptorOrder the interceptor Order to set
104      */
105     public void setInterceptorOrder( int interceptorOrder )
106     {
107         this.interceptorOrder = interceptorOrder;
108     }
109 
110 
111     /**
112      * @return the interceptor ClassName
113      */
114     public String getInterceptorClassName()
115     {
116         return interceptorClassName;
117     }
118 
119 
120     /**
121      * @param interceptorClassName the interceptor ClassName to set
122      */
123     public void setInterceptorClassName( String interceptorClassName )
124     {
125         this.interceptorClassName = interceptorClassName;
126     }
127 
128 
129     /**
130      * {@inheritDoc}
131      */
132     @Override
133     public String toString( String tabs )
134     {
135         StringBuilder sb = new StringBuilder();
136 
137         sb.append( tabs ).append( "interceptor[" ).append( interceptorOrder ).append( "] : " ).append( '\n' );
138         sb.append( tabs ).append( "  interceptor id : " ).append( interceptorId ).append( '\n' );
139         sb.append( tabs ).append( "  class name : " ).append( interceptorClassName ).append( '\n' );
140 
141         return sb.toString();
142     }
143 
144 
145     /**
146      * {@inheritDoc}
147      */
148     @Override
149     public String toString()
150     {
151         return toString( "" );
152     }
153 }