001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: SLSBResourceRefDeclaration00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.resourceref;
025:
026: import static org.ow2.easybeans.tests.common.helper.ContextHelper.checkResource;
027:
028: import javax.annotation.Resource;
029: import javax.annotation.Resources;
030: import javax.ejb.Remote;
031: import javax.ejb.SessionContext;
032: import javax.ejb.Stateless;
033:
034: import org.ow2.easybeans.tests.common.ejbs.base.ItfResourceEnvRef00;
035:
036: /**
037: * This bean is used to test the "resource" annotation on the bean class. Resources will be declared in the
038: * environment, but they will not be injected.
039: * @author Eduardo Studzinski Estima de Castro
040: * @author Gisele Pinheiro Souza
041: */
042: @Stateless(name="SLSBResourceRefDeclaration00")
043: @Remote(ItfResourceEnvRef00.class)
044: @Resources({@Resource(name="jdbc/ds00",type=javax.sql.DataSource.class),@Resource(name="jdbc/ds01",type=javax.sql.DataSource.class,mappedName="jdbc_1"),@Resource(name="jms/cf00",type=javax.jms.ConnectionFactory.class),@Resource(name="jms/qcf00",type=javax.jms.QueueConnectionFactory.class),@Resource(name="jms/tcf00",type=javax.jms.TopicConnectionFactory.class),@Resource(name="mail/mail00",type=javax.mail.Session.class),@Resource(name="url/url00",type=java.net.URL.class),@Resource(name="ejbctx/ctx00",type=javax.ejb.EJBContext.class),@Resource(name="jms/queue00",type=javax.jms.Queue.class),@Resource(name="jms/topic00",type=javax.jms.Topic.class)})
045: @Resource(name="url/url01",type=java.net.URL.class)
046: public class SLSBResourceRefDeclaration00 implements
047: ItfResourceEnvRef00 {
048:
049: /**
050: * SessionContext.
051: */
052: @Resource
053: private SessionContext sessionContext;
054:
055: /**
056: * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
057: */
058: public void checkJDBC() {
059: checkResource(sessionContext, "jdbc/ds00");
060: checkResource(sessionContext, "jdbc/ds01");
061: }
062:
063: /**
064: * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
065: */
066: public void checkJMSConFactory() {
067: checkResource(sessionContext, "jms/cf00");
068: }
069:
070: /**
071: * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
072: */
073: public void checkJMSQueueConFactory() {
074: checkResource(sessionContext, "jms/qcf00");
075: }
076:
077: /**
078: * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
079: */
080: public void checkJMSTopicConFactory() {
081: checkResource(sessionContext, "jms/tcf00");
082: }
083:
084: /**
085: * Checks if the annotation @Resource is working properly. The resource was declared on the bean class.
086: */
087: public void checkMailSession() {
088: checkResource(sessionContext, "mail/mail00");
089: }
090:
091: /**
092: * Checks if the annotations @Resource and @Resources
093: * are working properly. The resource was declared on the bean class.
094: */
095: public void checkUrl() {
096: checkResource(sessionContext, "url/url00");
097: checkResource(sessionContext, "url/url01");
098: }
099:
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 checkEJBContext() {
105: checkResource(sessionContext, "ejbctx/ctx00");
106: }
107:
108: /**
109: * Checks if the annotations @Resource and @Resources
110: * are working properly. The resource was declared on the bean class.
111: */
112: public void checkJMSQueue() {
113: checkResource(sessionContext, "jms/queue00");
114: }
115:
116: /**
117: * Checks if the annotations @Resource and @Resources
118: * are working properly. The resource was declared on the bean class.
119: */
120: public void checkJMSTopic() {
121: checkResource(sessionContext, "jms/topic00");
122: }
123:
124: }
|