1 22 package org.jboss.ejb3.test.clusteredsession; 23 24 import org.jboss.annotation.ejb.Clustered; 25 26 import javax.ejb.Local ; 27 import javax.ejb.Remote ; 28 import javax.ejb.Stateless ; 29 import javax.persistence.EntityManager; 30 import javax.persistence.PersistenceContext; 31 import java.rmi.dgc.VMID ; 32 33 38 @Stateless 39 @Remote (StatelessRemote.class) 40 @Local (StatelessLocal.class) 41 public class StatelessSessionBean implements StatelessLocal, StatelessRemote 42 { 43 @PersistenceContext EntityManager em; 44 45 public transient VMID myId = null; 46 47 public void update(Customer c) 48 { 49 c.setName("Bill Jr."); 50 } 51 52 public void findAndUpdate(long id) 53 { 54 Customer cust = find(id); 55 cust.setName("stateless modified"); 56 } 57 58 public Customer find(long id) 59 { 60 return em.find(Customer.class, id); 61 } 62 63 public boolean isDestroyed() 64 { 65 return ContainedBean.destroyed; 66 } 67 68 public void clearDestroyed() 69 { 70 ContainedBean.destroyed = false; 71 } 72 73 public boolean isPassivated() 74 { 75 return ContainedBean.passivated; 76 } 77 78 public void clearPassivated() 79 { 80 ContainedBean.passivated = false; 81 } 82 83 public NodeAnswer getNodeState() { 84 if(myId == null) 85 { 86 myId = new VMID (); 87 } 88 return new NodeAnswer(this.myId, "test"); 89 } 90 } 91 | Popular Tags |