KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateless > containermanaged > resourceref > SLSBResourceRefMethodInjection00


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: SLSBResourceRefMethodInjection00.java 990 2006-07-31 13:09:09Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.resourceref;
26
27 import static org.objectweb.easybeans.tests.common.helper.ContextHelper.checkResource;
28
29 import java.net.URL JavaDoc;
30
31 import javax.annotation.Resource;
32 import javax.ejb.EJBContext JavaDoc;
33 import javax.ejb.Remote JavaDoc;
34 import javax.ejb.SessionContext JavaDoc;
35 import javax.ejb.Stateless JavaDoc;
36 import javax.jms.ConnectionFactory JavaDoc;
37 import javax.jms.Queue JavaDoc;
38 import javax.jms.QueueConnectionFactory JavaDoc;
39 import javax.jms.Topic JavaDoc;
40 import javax.jms.TopicConnectionFactory JavaDoc;
41 import javax.mail.Session JavaDoc;
42 import javax.sql.DataSource JavaDoc;
43
44 import org.objectweb.easybeans.tests.common.ejbs.base.ItfResourceEnvRef00;
45
46
47 /**
48  * This bean is used to test injection of resource references in setter methods.
49  * @author Eduardo Studzinski Estima de Castro
50  * @author Gisele Pinheiro Souza
51  */

52 @Stateless JavaDoc(name = "SLSBResourceRefMethodInjection00")
53 @Remote JavaDoc(ItfResourceEnvRef00.class)
54 public class SLSBResourceRefMethodInjection00 implements ItfResourceEnvRef00{
55
56     /**
57      * SessionContext.
58      */

59     @Resource
60     private SessionContext JavaDoc sessionContext;
61
62     /**
63      * The reference must be injected by the container.
64      */

65     private DataSource JavaDoc dsInjection00;
66
67     /**
68      * Setter method. It is an injection target.
69      * @param ds Data Source
70      */

71     @Resource(name = "jdbc/ds00")
72     public void setJDBC00(final DataSource JavaDoc ds){
73         dsInjection00 = ds;
74     }
75
76     /**
77      * The reference must be injected by the container.
78      */

79     private DataSource JavaDoc dsInjection01;
80
81     /**
82      * Setter method. It is an injection target.
83      * @param ds Data Source
84      */

85     @Resource(name = "jdbc/ds01", mappedName = "jdbc_1")
86     public void setJDBC01(final DataSource JavaDoc ds){
87         dsInjection01 = ds;
88     }
89
90     /**
91      * The reference must be injected by the container.
92      */

93     private DataSource JavaDoc dsInjection02;
94
95     /**
96      * Setter method. It is an injection target.
97      * @param ds Data Source
98      */

99     @Resource(name = "jdbc/ds02", shareable = true)
100     public void setJDBC02(final DataSource JavaDoc ds){
101         dsInjection02 = ds;
102     }
103
104     /**
105      * The reference must be injected by the container.
106      */

107     private DataSource JavaDoc ds03;
108
109     /**
110      * Setter method. It is an injection target.
111      * @param ds Data Source
112      */

113     @Resource
114     public void setDs03(final DataSource JavaDoc ds){
115         ds03 = ds;
116     }
117
118     /**
119      * The reference must be injected by the container.
120      */

121     private ConnectionFactory JavaDoc cfInjection00;
122
123     /**
124      * Setter method. It is an injection target.
125      * @param con Connection Factory
126      */

127     @Resource(name = "jms/cf00")
128     public void setConFactory00(final ConnectionFactory JavaDoc con){
129         cfInjection00 = con;
130     }
131
132     /**
133      * The reference must be injected by the container.
134      */

135     private ConnectionFactory JavaDoc conFactory01;
136
137     /**
138      * Setter method. It is an injection target.
139      * @param con Connection Factory
140      */

141     @Resource(type=ConnectionFactory JavaDoc.class)
142     public void setConFactory01(final ConnectionFactory JavaDoc con){
143         conFactory01 = con;
144     }
145
146     /**
147      * The reference must be injected by the container.
148      */

149
150     private QueueConnectionFactory JavaDoc queueConFactory00;
151
152     /**
153      * Setter method. It is an injection target.
154      * @param con Queue Connection Factory
155      */

156     @Resource(name = "jms/qcf00")
157     public void setQueueConFactory00(final QueueConnectionFactory JavaDoc con){
158         queueConFactory00 = con;
159     }
160
161     /**
162      * The reference must be injected by the container.
163      */

164
165     private TopicConnectionFactory JavaDoc topicConFactory00;
166
167     /**
168      * Setter method. It is an injection target.
169      * @param con Topic Connection Factory
170      */

171     @Resource(name = "jms/tcf00")
172     public void setTopicConFactory00(final TopicConnectionFactory JavaDoc con){
173         topicConFactory00 = con;
174     }
175
176     /**
177      * The reference must be injected by the container.
178      */

179
180     private Queue JavaDoc queue00;
181
182     /**
183      * Setter method. It is an injection target.
184      * @param q queueu
185      */

186     @Resource(name = "jms/queue00")
187     public void setQueue00(final Queue JavaDoc q){
188         queue00 = q;
189     }
190
191     /**
192      * The reference must be injected by the container.
193      */

194
195     private Topic JavaDoc topic00;
196
197     /**
198      * Setter method. It is an injection target.
199      * @param t topic
200      */

201     @Resource(name = "jms/topic00")
202     public void setQueue00(final Topic JavaDoc t){
203         topic00 = t;
204     }
205
206     /**
207      * The reference must be injected by the container.
208      */

209     private Session JavaDoc mail00;
210
211     /**
212      * Setter method. It is an injection target.
213      * @param session Mail Session
214      */

215     @Resource(name = "mail/mail00")
216     public void setTopicConFactory00(final Session JavaDoc session){
217         mail00 = session;
218     }
219
220     /**
221      * The reference must be injected by the container.
222      */

223     private URL JavaDoc url00;
224
225     /**
226      * Setter method. It is an injection target.
227      * @param url url
228      */

229     @Resource(name = "url/url00")
230     public void setUrl00(final URL JavaDoc url){
231         url00 = url;
232     }
233
234     /**
235      * The reference must be injected by the container.
236      */

237     private EJBContext JavaDoc ctx00;
238
239     /**
240      * Setter method. It is an injection target.
241      * @param ctx reference
242      */

243     @Resource(name = "ejbctx/ctx00")
244     public void setCtx00(final EJBContext JavaDoc ctx){
245         ctx00 = ctx;
246     }
247
248     /**
249      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
250      */

251     public void checkJDBC() {
252         checkResource(sessionContext, dsInjection00, "jdbc/ds00");
253         checkResource(sessionContext, dsInjection01, "jdbc/ds01");
254         checkResource(sessionContext, dsInjection02, "jdbc/ds02");
255         checkResource(sessionContext, ds03, "org.objectweb.easybeans.tests.common."
256                 + "ejbs.stateless.containermanaged.resourceref.SLSBResourceRefMethodInjection00/ds03");
257     }
258
259     /**
260      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
261      */

262     public void checkJMSConFactory() {
263         checkResource(sessionContext, cfInjection00, "jms/cf00");
264         checkResource(sessionContext, conFactory01, "org.objectweb.easybeans.tests."
265                 + "common.ejbs.stateless.containermanaged.resourceref.SLSBResourceRefMethodInjection00/conFactory01");
266     }
267
268     /**
269      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
270      */

271     public void checkJMSQueueConFactory() {
272         checkResource(sessionContext, queueConFactory00, "jms/qcf00");
273     }
274
275     /**
276      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
277      */

278     public void checkJMSTopicConFactory() {
279         checkResource(sessionContext, topicConFactory00, "jms/tcf00");
280     }
281
282     /**
283      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
284      */

285     public void checkMailSession() {
286         checkResource(sessionContext, mail00, "mail/mail00");
287     }
288
289     /**
290      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
291      */

292     public void checkUrl() {
293         checkResource(sessionContext, url00, "url/url00");
294     }
295
296     /**
297      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
298      */

299     public void checkEJBContext() {
300         checkResource(sessionContext, ctx00, "ejbctx/ctx00");
301     }
302
303     /**
304      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
305      */

306     public void checkJMSQueue() {
307         checkResource(sessionContext, queue00, "jms/queue00");
308     }
309
310     /**
311      * Checks if the annotation @Resource on a method is working properly to ejb context resource.
312      */

313     public void checkJMSTopic() {
314         checkResource(sessionContext, topic00, "jms/topic00");
315     }
316 }
317
Popular Tags