KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateless > containermanaged > listeners > SLSBListenerTester04


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: SLSBListenerTester04.java 591 2006-06-05 14:44:15Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.listeners;
26
27 import javax.ejb.Remote JavaDoc;
28 import javax.ejb.Stateless JavaDoc;
29 import javax.persistence.EntityManager;
30 import javax.persistence.PersistenceContext;
31
32 import org.objectweb.easybeans.tests.common.ejbs.entity.geometricforms.FormType;
33 import org.objectweb.easybeans.tests.common.ejbs.entity.geometricforms.Isosceles;
34 import org.objectweb.easybeans.tests.common.ejbs.entity.geometricforms.Triangle;
35 import org.objectweb.easybeans.tests.common.listeners.FormsListener00;
36
37 /**
38  * Verifies if the container manages the override of callback methods.
39  * @author Gisele Pinheiro Souza
40  * @author Eduardo Studzinski Estima de Castro
41  *
42  */

43 @Stateless JavaDoc
44 @Remote JavaDoc(ItfListenerTester.class)
45 public class SLSBListenerTester04 extends ListenerTesterBase {
46
47     /**
48      * The number of listener methods that will be called.
49      */

50     private static final int LISTENER_NUMBER = 3;
51
52     /**
53      * The entity manager used to manages the entities.
54      */

55     @PersistenceContext
56     private EntityManager entityManager;
57
58
59     /**
60      * Creates and modifies an isosceles triangle.
61      */

62     @Override JavaDoc
63     protected void createAndModifyEntity() {
64         Isosceles isosceles = new Isosceles();
65         isosceles.setBase(1);
66         isosceles.setFormType(FormType.TRIANGLE_ISOSCELES);
67         entityManager.persist(isosceles);
68         entityManager.flush();
69
70         isosceles.setBase(2);
71         entityManager.flush();
72
73     }
74
75     /**
76      * Creates and refreshes an isosceles triangle.
77      */

78     @Override JavaDoc
79     protected void createAndRefreshEntity() {
80         Isosceles isosceles = new Isosceles();
81         isosceles.setBase(1);
82         isosceles.setFormType(FormType.TRIANGLE_ISOSCELES);
83         entityManager.persist(isosceles);
84         entityManager.flush();
85
86         entityManager.refresh(isosceles);
87     }
88
89     /**
90      * Creates and removes an isosceles triangle.
91      */

92     @Override JavaDoc
93     protected void createAndRemoveEntity() {
94         Isosceles isosceles = new Isosceles();
95         isosceles.setBase(1);
96         isosceles.setFormType(FormType.TRIANGLE_ISOSCELES);
97         entityManager.persist(isosceles);
98         entityManager.flush();
99
100         entityManager.remove(isosceles);
101         entityManager.flush();
102     }
103
104     /**
105      * Creates an isosceles triangle.
106      */

107     @Override JavaDoc
108     protected void createEntity() {
109         Isosceles isosceles = new Isosceles();
110         isosceles.setBase(1);
111         isosceles.setFormType(FormType.TRIANGLE_ISOSCELES);
112         entityManager.persist(isosceles);
113         entityManager.flush();
114     }
115
116     /**
117      * Creates the list of listeners that are called for the entity isosceles.
118      * The list is order by the callback invocation order.
119      * @return the list of listeners ordered by the invocation order.
120      */

121     private String JavaDoc[] createListenersList(){
122         String JavaDoc[] strListeners = new String JavaDoc[LISTENER_NUMBER];
123         strListeners[0] = FormsListener00.class.getName();
124         strListeners[1] = Triangle.class.getName();
125         strListeners[2] = Isosceles.class.getName();
126         return strListeners;
127     }
128
129     /**
130      * Creates the list of listeners that are called for the entity isosceles.
131      * The list is order by the callback invocation order.
132      * @return the list of listeners ordered by the invocation order.
133      */

134     @Override JavaDoc
135     protected String JavaDoc[] createListLoadListeners() {
136         return createListenersList();
137     }
138
139     /**
140      * Creates the list of listeners that are called for the entity isosceles.
141      * The list is order by the callback invocation order.
142      * @return the list of listeners ordered by the invocation order.
143      */

144     @Override JavaDoc
145     protected String JavaDoc[] createListPersistListeners() {
146         return createListenersList();
147     }
148
149     /**
150      * Creates the list of listeners that are called for the entity isosceles.
151      * The list is order by the callback invocation order.
152      * @return the list of listeners ordered by the invocation order.
153      */

154     @Override JavaDoc
155     protected String JavaDoc[] createListRemoveListeners() {
156         return createListenersList();
157     }
158
159     /**
160      * Creates the list of listeners that are called for the entity isosceles.
161      * The list is order by the callback invocation order.
162      * @return the list of listeners ordered by the invocation order.
163      */

164     @Override JavaDoc
165     protected String JavaDoc[] createListUpdateListeners() {
166         return createListenersList();
167     }
168
169     /**
170      * Returns the name of the entity class that the listeners are defined, in
171      * this case isosceles.
172      * @return the class name.
173      */

174     @Override JavaDoc
175     protected String JavaDoc getFormName() {
176         return Isosceles.class.getName();
177     }
178
179
180 }
181
Popular Tags