KickJava   Java API By Example, From Geeks To Geeks.

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


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: SLSBResourceRefDeclaration00.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 javax.annotation.Resource;
30 import javax.annotation.Resources;
31 import javax.ejb.Remote JavaDoc;
32 import javax.ejb.SessionContext JavaDoc;
33 import javax.ejb.Stateless JavaDoc;
34
35 import org.objectweb.easybeans.tests.common.ejbs.base.ItfResourceEnvRef00;
36
37 /**
38  * This bean is used to test the "resource" annotation on the bean class. Resources will be declared in the
39  * environment, but they will not be injected.
40  * @author Eduardo Studzinski Estima de Castro
41  * @author Gisele Pinheiro Souza
42  */

43 @Stateless JavaDoc(name = "SLSBResourceRefDeclaration00")
44 @Remote JavaDoc(ItfResourceEnvRef00.class)
45 @Resources({@Resource(name = "jdbc/ds00", type = javax.sql.DataSource JavaDoc.class),
46         @Resource(name = "jdbc/ds01", type = javax.sql.DataSource JavaDoc.class, mappedName="jdbc_1"),
47         @Resource(name = "jms/cf00", type = javax.jms.ConnectionFactory JavaDoc.class),
48         @Resource(name = "jms/qcf00", type = javax.jms.QueueConnectionFactory JavaDoc.class),
49         @Resource(name = "jms/tcf00", type = javax.jms.TopicConnectionFactory JavaDoc.class),
50         @Resource(name = "mail/mail00", type = javax.mail.Session JavaDoc.class),
51         @Resource(name = "url/url00", type = java.net.URL JavaDoc.class),
52         @Resource(name = "ejbctx/ctx00", type = javax.ejb.EJBContext JavaDoc.class),
53         @Resource(name = "jms/queue00", type = javax.jms.Queue JavaDoc.class),
54         @Resource(name = "jms/topic00", type = javax.jms.Topic JavaDoc.class)})
55 @Resource(name = "url/url01", type = java.net.URL JavaDoc.class)
56 public class SLSBResourceRefDeclaration00 implements ItfResourceEnvRef00{
57
58     /**
59      * SessionContext.
60      */

61     @Resource
62     private SessionContext JavaDoc sessionContext;
63
64     /**
65      * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
66      */

67     public void checkJDBC() {
68         checkResource(sessionContext, "jdbc/ds00");
69         checkResource(sessionContext, "jdbc/ds01");
70     }
71
72     /**
73      * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
74      */

75     public void checkJMSConFactory() {
76         checkResource(sessionContext, "jms/cf00");
77     }
78
79     /**
80      * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
81      */

82     public void checkJMSQueueConFactory() {
83         checkResource(sessionContext, "jms/qcf00");
84     }
85
86     /**
87      * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
88      */

89     public void checkJMSTopicConFactory() {
90         checkResource(sessionContext, "jms/tcf00");
91     }
92
93     /**
94      * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
95      */

96     public void checkMailSession() {
97         checkResource(sessionContext, "mail/mail00");
98     }
99
100     /**
101      * Checks if the annotations @Resource and @Resources
102      * are working properly. The resource was declared on the bean class.
103      */

104     public void checkUrl() {
105         checkResource(sessionContext, "url/url00");
106         checkResource(sessionContext, "url/url01");
107     }
108
109     /**
110      * Checks if the annotations @Resource and @Resources
111      * are working properly. The resource was declared on the bean class.
112      */

113     public void checkEJBContext() {
114         checkResource(sessionContext, "ejbctx/ctx00");
115     }
116
117     /**
118      * Checks if the annotations @Resource and @Resources
119      * are working properly. The resource was declared on the bean class.
120      */

121     public void checkJMSQueue() {
122         checkResource(sessionContext, "jms/queue00");
123     }
124
125     /**
126      * Checks if the annotations @Resource and @Resources
127      * are working properly. The resource was declared on the bean class.
128      */

129     public void checkJMSTopic() {
130         checkResource(sessionContext, "jms/topic00");
131     }
132
133 }
134
Popular Tags