KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > testbean > bean > StatefulSessionBean


1
2 //Title: telkel
3
//Version:
4
//Copyright: Copyright (c) 1999
5
//Author: Marc Fleury
6
//Company: telkel
7

8 /*
9   * JBoss, Home of Professional Open Source
10   * Copyright 2005, JBoss Inc., and individual contributors as indicated
11   * by the @authors tag. See the copyright.txt in the distribution for a
12   * full listing of individual contributors.
13   *
14   * This is free software; you can redistribute it and/or modify it
15   * under the terms of the GNU Lesser General Public License as
16   * published by the Free Software Foundation; either version 2.1 of
17   * the License, or (at your option) any later version.
18   *
19   * This software is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22   * Lesser General Public License for more details.
23   *
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this software; if not, write to the Free
26   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
28   */

29 package org.jboss.test.testbean.bean;
30
31 import java.rmi.*;
32 import javax.ejb.*;
33
34 public class StatefulSessionBean implements SessionBean {
35   public static org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(StatefulSessionBean.class);
36   private SessionContext sessionContext;
37   public String JavaDoc name;
38
39   public void ejbCreate() throws RemoteException, CreateException {
40     
41       log.debug("StatefulSessionBean.ejbCreate() called");
42       this.name= "noname";
43   }
44   
45   public void ejbCreate(String JavaDoc name) throws RemoteException, CreateException {
46       log.debug("StatefulSessionBean.ejbCreate("+name+") called");
47       this.name = name;
48   }
49
50   public void ejbCreate(String JavaDoc name, String JavaDoc address) throws RemoteException, CreateException {
51       log.debug("StatefulSessionBean.ejbCreate("+name+"@"+address+") called");
52       this.name = name;
53   }
54
55   public void ejbCreateMETHOD(String JavaDoc name, String JavaDoc address) throws RemoteException, CreateException {
56       log.debug("StatefulSessionBean.ejbCreateMETHOD("+name+"@"+address+") called");
57       this.name = name;
58   }
59
60   public void ejbActivate() throws RemoteException {
61       log.debug("StatefulSessionBean.ejbActivate() called");
62   }
63
64   public void ejbPassivate() throws RemoteException {
65      log.debug("StatefulSessionBean.ejbPassivate() called");
66   }
67
68   public void ejbRemove() throws RemoteException {
69      log.debug("StatefulSessionBean.ejbRemove() called");
70   }
71
72   public String JavaDoc callBusinessMethodA() {
73      log.debug("StatefulSessionBean.callBusinessMethodA() called");
74      return "I was created with Stateful String "+name;
75   }
76
77     public String JavaDoc callBusinessMethodB() {
78          log.debug("StatefulSessionBean.callBusinessMethodB() called");
79          // Check that my EJBObject is there
80
EJBObject ejbObject = sessionContext.getEJBObject();
81          if (ejbObject == null) {
82              return "ISNULL:NOT FOUND!!!!!";
83         
84          }
85          else {
86             return "OK ejbObject is "+ejbObject.toString();
87             
88          }
89   }
90   
91   
92   public String JavaDoc callBusinessMethodB(String JavaDoc words) {
93      log.debug("StatefulSessionBean.callBusinessMethodB(String) called");
94          // Check that my EJBObject is there
95
EJBObject ejbObject = sessionContext.getEJBObject();
96          if (ejbObject == null) {
97              return "ISNULL:NOT FOUND!!!!!";
98         
99          }
100          else {
101             return "OK ejbObject is "+ejbObject.toString()+" words "+words;
102             
103          }
104   
105   }
106   
107   
108   public void setSessionContext(SessionContext context) throws RemoteException {
109      log.debug("StatefulSessionBean.setSessionContext("+context+") called");
110      sessionContext = context;
111   }
112 }
113
Popular Tags