001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.testbean.bean;
023:
024: import java.rmi.*;
025: import javax.ejb.*;
026:
027: /**
028: * @author Marc Fleury
029: */
030: public class StatefulSessionBean implements SessionBean {
031: public static org.apache.log4j.Category log = org.apache.log4j.Category
032: .getInstance(StatefulSessionBean.class);
033: private SessionContext sessionContext;
034: public String name;
035:
036: public void ejbCreate() throws RemoteException, CreateException {
037:
038: log.debug("StatefulSessionBean.ejbCreate() called");
039: this .name = "noname";
040: }
041:
042: public void ejbCreate(String name) throws RemoteException,
043: CreateException {
044: log.debug("StatefulSessionBean.ejbCreate(" + name + ") called");
045: this .name = name;
046: }
047:
048: public void ejbCreate(String name, String address)
049: throws RemoteException, CreateException {
050: log.debug("StatefulSessionBean.ejbCreate(" + name + "@"
051: + address + ") called");
052: this .name = name;
053: }
054:
055: public void ejbCreateMETHOD(String name, String address)
056: throws RemoteException, CreateException {
057: log.debug("StatefulSessionBean.ejbCreateMETHOD(" + name + "@"
058: + address + ") called");
059: this .name = name;
060: }
061:
062: public void ejbActivate() throws RemoteException {
063: log.debug("StatefulSessionBean.ejbActivate() called");
064: }
065:
066: public void ejbPassivate() throws RemoteException {
067: log.debug("StatefulSessionBean.ejbPassivate() called");
068: }
069:
070: public void ejbRemove() throws RemoteException {
071: log.debug("StatefulSessionBean.ejbRemove() called");
072: }
073:
074: public String callBusinessMethodA() {
075: log.debug("StatefulSessionBean.callBusinessMethodA() called");
076: return "I was created with Stateful String " + name;
077: }
078:
079: public String callBusinessMethodB() {
080: log.debug("StatefulSessionBean.callBusinessMethodB() called");
081: // Check that my EJBObject is there
082: EJBObject ejbObject = sessionContext.getEJBObject();
083: if (ejbObject == null) {
084: return "ISNULL:NOT FOUND!!!!!";
085:
086: } else {
087: return "OK ejbObject is " + ejbObject.toString();
088:
089: }
090: }
091:
092: public String callBusinessMethodB(String words) {
093: log
094: .debug("StatefulSessionBean.callBusinessMethodB(String) called");
095: // Check that my EJBObject is there
096: EJBObject ejbObject = sessionContext.getEJBObject();
097: if (ejbObject == null) {
098: return "ISNULL:NOT FOUND!!!!!";
099:
100: } else {
101: return "OK ejbObject is " + ejbObject.toString()
102: + " words " + words;
103:
104: }
105:
106: }
107:
108: public void setSessionContext(SessionContext context)
109: throws RemoteException {
110: log.debug("StatefulSessionBean.setSessionContext(" + context
111: + ") called");
112: sessionContext = context;
113: }
114: }
|