KickJava   Java API By Example, From Geeks To Geeks.

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


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: SLSBListenerTester03.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.Equilateral;
33 import org.objectweb.easybeans.tests.common.ejbs.entity.geometricforms.FormType;
34 import org.objectweb.easybeans.tests.common.listeners.FormsListener00;
35
36 /**
37  * Verifies if the container manages the override of callback methods.
38  * @author Gisele Pinheiro Souza
39  * @author Eduardo Studzinski Estima de Castro
40  *
41  */

42 @Stateless JavaDoc
43 @Remote JavaDoc(ItfListenerTester.class)
44 public class SLSBListenerTester03 extends ListenerTesterBase {
45
46     /**
47      * The entity manager used to manages the entities.
48      */

49     @PersistenceContext
50     private EntityManager entityManager;
51
52
53     /**
54      * Creates and modifies an equilateral triangle.
55      */

56     @Override JavaDoc
57     protected void createAndModifyEntity() {
58         Equilateral equilateral = new Equilateral();
59         equilateral.setBase(1);
60         equilateral.setFormType(FormType.TRIANGLE_EQUILATERAL);
61         entityManager.persist(equilateral);
62         entityManager.flush();
63
64         equilateral.setBase(2);
65         entityManager.flush();
66
67     }
68
69     /**
70      * Creates and refreshes an equilateral triangle.
71      */

72     @Override JavaDoc
73     protected void createAndRefreshEntity() {
74         Equilateral equilateral = new Equilateral();
75         equilateral.setBase(1);
76         equilateral.setFormType(FormType.TRIANGLE_EQUILATERAL);
77         entityManager.persist(equilateral);
78         entityManager.flush();
79
80         entityManager.refresh(equilateral);
81     }
82
83     /**
84      * Creates and removes an equilateral triangle.
85      */

86     @Override JavaDoc
87     protected void createAndRemoveEntity() {
88         Equilateral equilateral = new Equilateral();
89         equilateral.setBase(1);
90         equilateral.setFormType(FormType.TRIANGLE_EQUILATERAL);
91         entityManager.persist(equilateral);
92         entityManager.flush();
93
94         entityManager.remove(equilateral);
95         entityManager.flush();
96     }
97
98     /**
99      * Creates an equilateral triangle.
100      */

101     @Override JavaDoc
102     protected void createEntity() {
103         Equilateral equilateral = new Equilateral();
104         equilateral.setBase(1);
105         equilateral.setFormType(FormType.TRIANGLE_EQUILATERAL);
106         entityManager.persist(equilateral);
107         entityManager.flush();
108     }
109
110     /**
111      * Creates the list of listeners that are called for the entity Equilateral.
112      * The list is order by the callback invocation order.
113      * @return the list of listeners ordered by the invocation order.
114      */

115     private String JavaDoc[] createListenersList(){
116         String JavaDoc[] strListeners = new String JavaDoc[2];
117         strListeners[0] = FormsListener00.class.getName();
118         strListeners[1] = Equilateral.class.getName();
119         return strListeners;
120     }
121
122     /**
123      * Creates the list of listeners that are called for the entity Equilateral.
124      * The list is order by the callback invocation order.
125      * @return the list of listeners ordered by the invocation order.
126      */

127     @Override JavaDoc
128     protected String JavaDoc[] createListLoadListeners() {
129         return createListenersList();
130     }
131
132     /**
133      * Creates the list of listeners that are called for the entity Equilateral.
134      * The list is order by the callback invocation order.
135      * @return the list of listeners ordered by the invocation order.
136      */

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

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

157     @Override JavaDoc
158     protected String JavaDoc[] createListUpdateListeners() {
159         return createListenersList();
160     }
161
162     /**
163      * Returns the name of the entity class that the listeners are defined, in
164      * this case Equilateral.
165      * @return the class name.
166      */

167     @Override JavaDoc
168     protected String JavaDoc getFormName() {
169         return Equilateral.class.getName();
170     }
171
172
173 }
174
Popular Tags