1 22 package org.jboss.test.lock.bean; 23 24 import java.rmi.*; 25 import javax.ejb.*; 26 27 import org.jboss.test.lock.interfaces.EnterpriseEntityHome; 28 import org.jboss.test.lock.interfaces.EnterpriseEntity; 29 30 public class EnterpriseEntityBean 31 implements EntityBean 32 { 33 static org.jboss.logging.Logger log = 34 org.jboss.logging.Logger.getLogger(EnterpriseEntityBean.class); 35 36 private EntityContext entityContext; 37 38 public String name; 39 public String field; 40 public EnterpriseEntity nextEntity; 41 public String lastEntity = "UNKNOWN!!!!"; 42 43 public String ejbCreate(final String name) 44 throws RemoteException, CreateException 45 { 46 this.name = name; 47 return null; 48 } 49 50 public void ejbPostCreate(String name) 51 throws RemoteException, CreateException 52 { 53 } 55 56 public void ejbActivate() throws RemoteException 57 { 58 } 60 61 public void ejbLoad() throws RemoteException 62 { 63 } 65 66 public void ejbPassivate() throws RemoteException 67 { 68 } 70 71 public void ejbRemove() throws RemoteException, RemoveException 72 { 73 } 75 76 public void ejbStore() throws RemoteException 77 { 78 } 80 81 public void setField(String field) throws RemoteException 82 { 83 this.field = field; 85 } 86 87 public String getField() throws RemoteException 88 { 89 return field; 90 } 91 92 public void setAndCopyField(String field) throws RemoteException 93 { 94 96 log.debug("setAndCopyField"); 97 setField(field); 98 if (nextEntity == null) 99 { 100 log.error("nextEntity is null!!!!!!!!, lastEntity: " + lastEntity); 101 } 102 nextEntity.setField(field); 103 } 104 105 public void setNextEntity(String beanName) throws RemoteException 106 { 107 try 108 { 109 log.debug("setNextEntity: " + beanName); 110 EJBObject ejbObject = entityContext.getEJBObject(); 111 EnterpriseEntityHome home = (EnterpriseEntityHome) ejbObject.getEJBHome(); 112 try 113 { 114 nextEntity = home.findByPrimaryKey(beanName); 115 } 116 catch (FinderException e) 117 { 118 nextEntity = home.create(beanName); 119 } 120 lastEntity = beanName; 121 } 122 catch (Exception e) 123 { 124 log.debug("failed", e); 125 throw new RemoteException 126 ("create entity did not work check messages"); 127 } 128 } 129 130 public void setEntityContext(EntityContext context) 131 throws RemoteException 132 { 133 entityContext = context; 134 } 135 136 public void unsetEntityContext() throws RemoteException 137 { 138 entityContext = null; 139 } 140 141 public void sleep(long time) throws InterruptedException 142 { 143 Thread.sleep(time); 144 } 145 } 146 | Popular Tags |