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$
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.sbinterface;
025:
026: import java.rmi.RemoteException;
027:
028: import javax.ejb.EJB;
029: import javax.ejb.EJBException;
030: import javax.ejb.Remote;
031: import javax.ejb.Remove;
032: import javax.ejb.SessionBean;
033: import javax.ejb.SessionContext;
034: import javax.ejb.Stateful;
035:
036: import org.ow2.easybeans.tests.common.ejbs.base.ItfCheck02;
037: import org.ow2.easybeans.tests.common.ejbs.base.ItfOneMethod01;
038: import org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType;
039: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.BaseInsertCallbackEvent;
040:
041: /**
042: * This class is used as base to test the sessionbean interface.
043: * @author Eduardo Studzinski Estima de Castro
044: * @author Gisele Pinheiro Souza
045: */
046: @Stateful(name="SFSBSessionBeanItf")
047: @Remote(ItfCheck02.class)
048: @EJB(name="ejb/bean00",beanName="EJBInjectionBean",beanInterface=ItfOneMethod01.class)
049: public class SFSBSessionBeanItf extends BaseInsertCallbackEvent
050: implements SessionBean, ItfCheck02 {
051:
052: /**
053: * ID.
054: */
055: private static final long serialVersionUID = 1L;
056:
057: /**
058: * SessionContext.
059: */
060: private SessionContext ctx;
061:
062: /**
063: * ejbActivate method.
064: * @throws EJBException if a problem occurs.
065: * @throws RemoteException if a problem occurs.
066: */
067: public void ejbActivate() throws EJBException, RemoteException {
068: //TODO: test case
069: super .log(SFSBSessionBeanItf.class.getName(),
070: CallbackType.POST_ACTIVATE, SFSBSessionBeanItf.class
071: .getName());
072: }
073:
074: /**
075: * ejbPassivate method.
076: * @throws EJBException if a problem occurs.
077: * @throws RemoteException if a problem occurs.
078: */
079: public void ejbPassivate() throws EJBException, RemoteException {
080: //TODO: test case
081: super .log(SFSBSessionBeanItf.class.getName(),
082: CallbackType.PRE_PASSIVATE, SFSBSessionBeanItf.class
083: .getName());
084: }
085:
086: /**
087: * ejbRemove method.
088: * @throws EJBException if a problem occurs.
089: * @throws RemoteException if a problem occurs.
090: */
091: public void ejbRemove() throws EJBException, RemoteException {
092: super .log(SFSBSessionBeanItf.class.getName(),
093: CallbackType.PRE_DESTROY, SFSBSessionBeanItf.class
094: .getName());
095: }
096:
097: /**
098: * Sets the SessionContext.
099: * @param ctx SessionContext
100: * @throws EJBException if a problem occurs.
101: * @throws RemoteException if a problem occurs.
102: */
103: public void setSessionContext(final SessionContext ctx)
104: throws EJBException, RemoteException {
105: this .ctx = ctx;
106: }
107:
108: /**
109: * Check the SessionContext.
110: * @throws Exception if a problem occurs.
111: */
112: public void check() throws Exception {
113: if (ctx != null) {
114: ItfOneMethod01 bean = (ItfOneMethod01) ctx
115: .lookup("ejb/bean00");
116: bean.getBool();
117: } else {
118: throw new Exception("SessionContext should be initialized.");
119: }
120: }
121:
122: /**
123: * Bean remove.
124: */
125: @Remove
126: public void remove() {
127: }
128:
129: }
|