KickJava   Java API By Example, From Geeks To Geeks.

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


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: SLSBListenerTester02.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.Square;
34
35
36 /**
37  * Verifies if the container manages a bean that has the annotation
38  * ExcludeSuperclassListeners.
39  * @author Gisele Pinheiro Souza
40  * @author Eduardo Studzinski Estima de Castro
41  */

42 @Stateless JavaDoc
43 @Remote JavaDoc(ItfListenerTester.class)
44 public class SLSBListenerTester02 extends ListenerTesterBase {
45
46
47     /**
48      * The persistence context used to manipulate the entity.
49      */

50     @PersistenceContext
51     private EntityManager entityManager;
52
53     /**
54      * Creates a new instance of Square and modifies it.
55      */

56     @Override JavaDoc
57     protected void createAndModifyEntity() {
58         Square square = new Square();
59         square.setSide(1);
60         square.setFormType(FormType.SQUARE);
61         entityManager.persist(square);
62         entityManager.flush();
63
64         square.setSide(2);
65         entityManager.flush();
66
67     }
68
69     /**
70      * Creates a new instance of the Square and refreshes it.
71      */

72     @Override JavaDoc
73     protected void createAndRefreshEntity() {
74         Square square = new Square();
75         square.setSide(1);
76         square.setFormType(FormType.SQUARE);
77         entityManager.persist(square);
78         entityManager.flush();
79
80         entityManager.refresh(square);
81     }
82
83     /**
84      * Creates a Square and removes it.
85      */

86     @Override JavaDoc
87     protected void createAndRemoveEntity() {
88         Square square = new Square();
89         square.setSide(1);
90         square.setFormType(FormType.SQUARE);
91         entityManager.persist(square);
92         entityManager.flush();
93
94         entityManager.remove(square);
95         entityManager.flush();
96     }
97
98     /**
99      * Creates a Square.
100      */

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

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

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

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

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

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

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