KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > interceptors > invocationcontext > BeanDescriptor


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: BeanDescriptor.java 928 2006-07-25 13:11:32Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.interceptors.invocationcontext;
26
27 import java.io.Serializable JavaDoc;
28
29 /**
30  * This class is used to store a bean reference and an intercepted method.
31  * @author Eduardo Studzinski Estima de Castro
32  * @author Gisele Pinheiro Souza
33  */

34 public class BeanDescriptor implements Serializable JavaDoc {
35
36     /**
37      * Serial ID.
38      */

39     private static final long serialVersionUID = -1807144244407143163L;
40
41     /**
42      * Referenced bean.
43      */

44     private int intHashCode;
45
46     /**
47      * Intercepted method.
48      */

49     private String JavaDoc mtIntercepted;
50
51     /**
52      * Default constructor.
53      */

54     public BeanDescriptor() {
55         setHashCode(0);
56         setInterceptedMethod("");
57     }
58
59     /**
60      * Default args-constructor.
61      * @param hashCode the bean hash code.
62      * @param methodSignature intercepted method signature.
63      */

64     public BeanDescriptor(final int hashCode, final String JavaDoc methodSignature) {
65         setHashCode(hashCode);
66         setInterceptedMethod(methodSignature);
67     }
68
69     /**
70      * Gets the bean hash code.
71      * @return Returns the bean hash code.
72      */

73     public int getHashCode() {
74         return intHashCode;
75     }
76
77     /**
78      * Sets the bean hash code.
79      * @param hashCode The bean hash code to set.
80      */

81     public void setHashCode(final int hashCode) {
82         this.intHashCode = hashCode;
83     }
84
85     /**
86      * Gets the intercepted method.
87      * @return Returns the intercepted method.
88      */

89     public String JavaDoc getInterceptedMethod() {
90         return mtIntercepted;
91     }
92
93     /**
94      * Sets the intercepted method.
95      * @param m The intercepted method to set.
96      */

97     public void setInterceptedMethod(final String JavaDoc m) {
98         this.mtIntercepted = m;
99
100     }
101
102     /**
103      * Indicates whether some other object is "equal to" this one.
104      * @param obj object to compare.
105      * @return true, if equals.
106      * @throws Exception if a problem occurs.
107      */

108     public boolean equalsWithException(final Object JavaDoc obj) throws Exception JavaDoc {
109         boolean bResult = false;
110
111         BeanDescriptor refExt = (BeanDescriptor) obj;
112
113         if (refExt.getHashCode() == intHashCode){
114                  bResult = true;
115         }else{
116             throw new Exception JavaDoc("The bean hashcodes aren't equal.");
117         }
118
119         return bResult;
120     }
121 }
122
Popular Tags