1 22 package org.jboss.test.testbeancluster.bean; 23 24 import javax.ejb.*; 25 26 import java.rmi.RemoteException ; 27 import java.rmi.dgc.VMID ; 28 29 import org.jboss.test.testbeancluster.interfaces.NodeAnswer; 30 31 35 public class StatefulSessionBean extends org.jboss.test.testbean.bean.StatefulSessionBean 36 { 37 38 40 42 public transient VMID myId = null; 43 44 46 48 public void ejbCreate(String name) throws RemoteException , CreateException 49 { 50 super.ejbCreate(name); 51 52 this.myId = new VMID (); 53 log.debug("My ID: " + this.myId); 54 } 55 56 public void ejbActivate() throws RemoteException 57 { 58 super.ejbActivate(); 59 if (this.myId == null) 60 { 61 this.myId = new VMID (); 63 } 64 log.debug("Activate. My ID: " + this.myId + " name: " + this.name); 65 } 66 67 public void ejbPassivate() throws RemoteException 68 { 69 super.ejbPassivate(); 70 log.debug("Passivate. My ID: " + this.myId + " name: " + this.name); 71 } 72 74 76 public NodeAnswer getNodeState() throws RemoteException 77 { 78 NodeAnswer state = new NodeAnswer(this.myId, this.name); 79 log.debug("getNodeState, " + state); 80 return state; 81 } 82 83 public void setName(String name) throws RemoteException 84 { 85 this.name = name; 86 log.debug("Name set to " + name); 87 } 88 89 public void setNameOnlyOnNode(String name, VMID node) throws RemoteException 90 { 91 if (node.equals(this.myId)) 92 this.setName(name); 93 else 94 throw new EJBException("Trying to assign value on node " + this.myId + " but this node expected: " + node); 95 } 96 97 99 101 103 105 107 } 108 | Popular Tags |