KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateful > containermanaged > interceptorxml > SFSBInterceptorXML


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

25 package org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptorxml;
26
27 import java.util.List JavaDoc;
28
29 import javax.ejb.EJB JavaDoc;
30 import javax.interceptor.InvocationContext;
31
32 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType;
33 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
34 import org.objectweb.easybeans.tests.common.helper.InterceptorHelper;
35
36 /**
37  * Used to verifies if the listeners can be defined by the deployment
38  * descriptor.
39  * @author Gisele Pinheiro Souza
40  * @author Eduardo Studzinski Estima de Castro
41  */

42 public class SFSBInterceptorXML implements ItfInterceptorXML {
43
44     /**
45      * The number of the interceptor called. Says that the
46      */

47     public static final Integer JavaDoc ORDER = new Integer JavaDoc(0);
48
49     /**
50      * Bean used to log the callback methods.
51      */

52     @EJB JavaDoc(beanName = "SLSBCallbackLoggerAccess")
53     private ItfCallbackLoggerAccess clBean;
54
55     /**
56      * Used to verify if the post construct was called.
57      */

58     private boolean bolPostConstruct = false;
59
60     /**
61      * Creates an instance of SFSBInterceptorXML.
62      */

63     public SFSBInterceptorXML() {
64         bolPostConstruct = false;
65     }
66
67     /**
68      * Appends a value in the end of the list.
69      * @param par the lists that the value will be appended.
70      * @return the list with the value added.
71      */

72     public List JavaDoc<Integer JavaDoc> insertOrder1(final List JavaDoc<Integer JavaDoc> par) {
73         par.add(ORDER);
74         return par;
75     }
76
77     /**
78      * Appends a value in the end of the list.
79      * @param par the lists that the value will be appended.
80      * @return the list with the value added.
81      */

82     public List JavaDoc<Integer JavaDoc> insertOrder2(final List JavaDoc<Integer JavaDoc> par) {
83         par.add(ORDER);
84         return par;
85     }
86
87     /**
88      * Appends a value in the end of the list.
89      * @param par the lists that the value will be appended.
90      * @param dummy a parmeter used to differ two methods with the same name.
91      * @return the list with the value added.
92      */

93     public List JavaDoc<Integer JavaDoc> insertOrder2(final List JavaDoc<Integer JavaDoc> par, final int dummy) {
94         par.add(ORDER);
95         return par;
96     }
97
98     /**
99      * Appends a value in the end of the list.
100      * @param par the lists that the value will be appended.
101      * @return the list with the value added.
102      */

103     public List JavaDoc<Integer JavaDoc> insertOrder3(final List JavaDoc<Integer JavaDoc> par) {
104         par.add(ORDER);
105         return par;
106     }
107
108     /**
109      * Sets a variable as true.
110      */

111     public void postConstruct() {
112         bolPostConstruct = true;
113     }
114
115     /**
116      * Registers in the database that the method was called.
117      */

118     public void preDestroy() {
119         clBean.insertCallbackLogger(this.getClass().getName(), CallbackType.PRE_DESTROY, this.getClass().getName());
120     }
121
122     /**
123      * Used to verify if a prePassivate callback method can be defined by the
124      * deployment descriptor.
125      */

126     public void prePassivate() {
127         // TODO - how to test the pre-passivate?
128
}
129
130     /**
131      * Used to verify if a postActivate callback method can be defined by the
132      * deployment descriptor.
133      */

134     public void postActivate() {
135         // TODO - how to test the post-activate?
136
}
137
138     /**
139      * Used to remove the bean and to verifyif the preDestroy was called.
140      */

141     public void remove(){
142
143     }
144
145     /**
146      * Says if the postContruct method was called.
147      * @return true if the postConstruct was called, false otherwise.
148      */

149     public boolean calledPostConstruct() {
150         return bolPostConstruct;
151     }
152
153     /**
154      * Appends a value in the end of the list.
155      * @param invocationContext the incocation context.
156      * @return the list with the value added.
157      * @throws Exception if an error occurs during the insertion.
158      */

159     public Object JavaDoc aroundInvoke(final InvocationContext invocationContext) throws Exception JavaDoc {
160         return InterceptorHelper.addValue(invocationContext, ORDER, this.getClass().getName());
161
162     }
163 }
164
Popular Tags