KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > deployment > annotations > JClassInterceptor


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: JClassInterceptor.java 841 2006-07-12 09:03:06Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.deployment.annotations;
27
28
29 /**
30  * This class defines a Bean interceptor with the name of the class and the
31  * method which is the interceptor.
32  * @author Florent Benoit
33  */

34 public class JClassInterceptor {
35
36     /**
37      * String name of the class (internal name) where is the interceptor.
38      */

39     private String JavaDoc className = null;
40
41     /**
42      * Method with @{@link javax.interceptor.AroundInvoke} annotation.
43      */

44     private JMethod jMethod = null;
45
46     /**
47      * NO ID.
48      */

49     private static final int NO_ID = -1;
50
51     /**
52      * Id of this interceptor (0 = no id).
53      */

54     private int id = NO_ID;
55
56     /**
57      * Constructor.
58      * @param className String name of the class (internal name).
59      * @param jMethod the method with aroundInvoke annotation.
60      * @param id the id of this interceptor
61      */

62     public JClassInterceptor(final String JavaDoc className, final JMethod jMethod, final int id) {
63         this.className = className;
64         this.jMethod = jMethod;
65         this.id = id;
66     }
67
68     /**
69      * Constructor.
70      * @param className String name of the class (internal name).
71      * @param jMethod the method with aroundInvoke annotation.
72      */

73     public JClassInterceptor(final String JavaDoc className, final JMethod jMethod) {
74        this(className, jMethod, NO_ID);
75     }
76
77     /**
78      * @return class (internal name) where is the interceptor.
79      */

80     public String JavaDoc getClassName() {
81         return className;
82     }
83
84     /**
85      * @return Method with @{@link javax.interceptor.AroundInvoke} annotation
86      */

87     public JMethod getJMethod() {
88         return jMethod;
89     }
90
91     /**
92      * Equals method.
93      * @param another object to compare.
94      * @return true if the objects are the same.
95      */

96     @Override JavaDoc
97     public boolean equals(final Object JavaDoc another) {
98         if (!(another instanceof JClassInterceptor)) {
99             return false;
100         }
101         JClassInterceptor anotherItcp = (JClassInterceptor) another;
102         if (id == NO_ID) {
103             return (anotherItcp.className.equals(className) && anotherItcp.jMethod.equals(jMethod));
104         }
105         return (anotherItcp.className.equals(className) && anotherItcp.jMethod.equals(jMethod) && anotherItcp.id == id);
106     }
107
108     /**
109      * @return hashCode of the object.
110      */

111     @Override JavaDoc
112     public int hashCode() {
113         return className.hashCode() + jMethod.hashCode();
114     }
115
116 }
117
Popular Tags