KickJava   Java API By Example, From Geeks To Geeks.

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


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: SLSBListenerTester01.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.Circle;
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 listeners invocation when the entity
38  * has only superclass listener.
39  * @author Gisele Pinheiro Souza
40  * @author Eduardo Studzinski Estima de Castro
41  */

42 @Stateless JavaDoc
43 @Remote JavaDoc(ItfListenerTester.class)
44 public class SLSBListenerTester01 extends ListenerTesterBase {
45
46     /**
47      * Used to manages the entity.
48      */

49     @PersistenceContext
50     private EntityManager entityManager;
51
52     /**
53      * Creates a circle and modifies it.
54      */

55     @Override JavaDoc
56     protected void createAndModifyEntity() {
57         Circle c = new Circle();
58         c.setRadius(1);
59         c.setFormType(FormType.CIRCLE);
60         entityManager.persist(c);
61         entityManager.flush();
62
63         c.setRadius(2);
64         entityManager.flush();
65     }
66
67     /**
68      * Creates a Circle and refreshes it.
69      */

70     @Override JavaDoc
71     protected void createAndRefreshEntity() {
72         Circle c = new Circle();
73         c.setRadius(1);
74         c.setFormType(FormType.CIRCLE);
75         entityManager.persist(c);
76         entityManager.flush();
77
78         entityManager.refresh(c);
79     }
80
81     /**
82      * Creates a circle and removes it.
83      */

84     @Override JavaDoc
85     protected void createAndRemoveEntity() {
86         Circle c = new Circle();
87         c.setRadius(1);
88         c.setFormType(FormType.CIRCLE);
89         entityManager.persist(c);
90         entityManager.flush();
91
92         entityManager.remove(c);
93         entityManager.flush();
94     }
95
96     /**
97      * Creates a circle.
98      */

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

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

125     @Override JavaDoc
126     protected String JavaDoc[] createListLoadListeners() {
127         return createListenersList();
128     }
129
130     /**
131      * Creates the list of listeners that are called for the entity Circle.
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[] createListPersistListeners() {
137         return createListenersList();
138     }
139
140     /**
141      * Creates the list of listeners that are called for the entity Circle.
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[] createListRemoveListeners() {
147         return createListenersList();
148     }
149
150     /**
151      * Creates the list of listeners that are called for the entity Circle.
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[] createListUpdateListeners() {
157         return createListenersList();
158     }
159
160     /**
161      * Returns the name of the entity class that the listeners are defined, in
162      * this case Circle.
163      * @return the class name.
164      */

165     @Override JavaDoc
166     protected String JavaDoc getFormName() {
167         return Circle.class.getName();
168     }
169
170 }
171
Popular Tags