KickJava   Java API By Example, From Geeks To Geeks.

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


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: SLSBListenerTester06.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.Rectangle;
34 import org.objectweb.easybeans.tests.common.listeners.FormsListener00;
35 import org.objectweb.easybeans.tests.common.listeners.FormsListener01;
36 import org.objectweb.easybeans.tests.common.listeners.FormsListener02;
37
38 /**
39  * Verifies if the container manages multiples listeners that are defined in the
40  * superclass adn in the class.
41  * @author Gisele Pinheiro Souza
42  * @author Eduardo Studzinski Estima de Castro
43  */

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

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

56     @PersistenceContext
57     private EntityManager entityManager;
58
59
60     /**
61      * Creates and modifies a rectangle.
62      */

63     @Override JavaDoc
64     protected void createAndModifyEntity() {
65         Rectangle rectangle = new Rectangle();
66         rectangle.setSide1(1);
67         rectangle.setFormType(FormType.RECTANGLE);
68         entityManager.persist(rectangle);
69         entityManager.flush();
70
71         rectangle.setSide1(2);
72         entityManager.flush();
73
74     }
75
76     /**
77      * Creates and refreshes a rectangle.
78      */

79     @Override JavaDoc
80     protected void createAndRefreshEntity() {
81         Rectangle rectangle = new Rectangle();
82         rectangle.setSide1(1);
83         rectangle.setFormType(FormType.RECTANGLE);
84         entityManager.persist(rectangle);
85         entityManager.flush();
86
87         entityManager.refresh(rectangle);
88     }
89
90     /**
91      * Creates and removes a rectangle.
92      */

93     @Override JavaDoc
94     protected void createAndRemoveEntity() {
95         Rectangle rectangle = new Rectangle();
96         rectangle.setSide1(1);
97         rectangle.setFormType(FormType.RECTANGLE);
98         entityManager.persist(rectangle);
99         entityManager.flush();
100
101         entityManager.remove(rectangle);
102         entityManager.flush();
103     }
104
105     /**
106      * Creates a rectangle.
107      */

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

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

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

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

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

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

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