1 2 8 29 package org.jboss.test.testbean.bean; 30 31 import java.rmi.*; 32 import javax.ejb.*; 33 34 import org.jboss.test.testbean.interfaces.EnterpriseEntityHome; 35 import org.jboss.test.testbean.interfaces.EnterpriseEntity; 36 37 public class EnterpriseEntityBean implements EntityBean { 38 org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(getClass()); 39 private EntityContext entityContext; 40 public String name; 41 public int otherField = 0; 42 43 44 public String ejbCreate(String name) throws RemoteException, CreateException { 45 46 log.debug("EntityBean.ejbCreate("+name+") called"); 47 this.name = name; 48 return null; 49 } 50 51 public String ejbCreateMETHOD(String name) throws RemoteException, CreateException { 52 53 log.debug("EntityBean.ejbCreateMETHOD("+name+") called"); 54 this.name = name; 55 return null; 56 } 57 58 public void ejbPostCreate(String name) throws RemoteException, CreateException { 59 60 log.debug("EntityBean.ejbPostCreate("+name+") called"); 61 62 EJBObject ejbObject = entityContext.getEJBObject(); 63 64 if (ejbObject == null) { 65 log.debug("******************************* NULL EJBOBJECT in ejbPostCreate"); 66 } 67 else { 68 log.debug("&&&&&&&&&&&&&&&& EJBObject found in ejbPostCreate id is "+ejbObject.getPrimaryKey()); 69 } 70 71 } 72 73 public void ejbPostCreateMETHOD(String name) throws RemoteException, CreateException { 74 75 log.debug("EntityBean.ejbPostCreateMETHOD("+name+") called"); 76 77 EJBObject ejbObject = entityContext.getEJBObject(); 78 79 if (ejbObject == null) { 80 log.debug("******************************* NULL EJBOBJECT in ejbPostCreateMETHOD"); 81 } 82 else { 83 log.debug("&&&&&&&&&&&&&&&& EJBObject found in ejbPostCreateMETHOD id is "+ejbObject.getPrimaryKey()); 84 } 85 86 } 87 88 public void ejbActivate() throws RemoteException { 89 log.debug("EntityBean.ejbActivate() called"); 90 } 91 92 public void ejbLoad() throws RemoteException { 93 log.debug("EntityBean.ejbLoad() called"); 94 } 95 96 public void ejbPassivate() throws RemoteException { 97 98 log.debug("EntityBean.ejbPassivate() called"); 99 } 100 101 public void ejbRemove() throws RemoteException, RemoveException { 102 log.debug("EntityBean.ejbRemove() called "+hashCode()); 103 } 104 105 public void ejbStore() throws RemoteException { 106 107 log.debug("EntityBean.ejbStore() called "+hashCode()); 108 } 109 110 public String callBusinessMethodA() { 111 112 log.debug("EntityBean.callBusinessMethodA() called"); 113 return "EntityBean.callBusinessMethodA() called, my primaryKey is "+ 114 entityContext.getPrimaryKey().toString(); 115 } 116 117 public String callBusinessMethodB() { 118 119 log.debug("EntityBean.callBusinessMethodB() called"); 120 121 EJBObject ejbObject = entityContext.getEJBObject(); 122 123 if (ejbObject == null) 124 return "NULL EJBOBJECT"; 125 126 else 127 return ejbObject.toString(); 128 } 129 130 131 public String callBusinessMethodB(String words) { 132 133 log.debug("EntityBean.callBusinessMethodB(String) called"); 134 135 EJBObject ejbObject = entityContext.getEJBObject(); 136 137 if (ejbObject == null) 138 return "NULL EJBOBJECT"; 139 140 else 141 return ejbObject.toString()+ " words "+words; 142 143 } 144 public void setOtherField(int value) { 145 146 log.debug("EntityBean.setOtherField("+value+")"); 147 otherField = value; 148 } 149 150 public int getOtherField() { 151 log.debug("EntityBean.getOtherField() called"); 152 return otherField; 153 } 154 155 public EnterpriseEntity createEntity(String newName) throws RemoteException { 156 157 log.debug("EntityBean.createEntity() called"); 158 EnterpriseEntity newBean; 159 try{ 160 EJBObject ejbObject = entityContext.getEJBObject(); 161 if (ejbObject == null) 162 log.debug("************************** NULL EJBOBJECT"); 163 else 164 log.debug("************************** OK EJBOBJECT"); 165 166 EnterpriseEntityHome home = (EnterpriseEntityHome)entityContext.getEJBObject().getEJBHome(); 167 newBean = (EnterpriseEntity)home.create(newName); 168 169 170 }catch(Exception e) 171 { 172 log.debug("failed", e); 173 throw new RemoteException("create entity did not work check messages"); 174 } 175 176 return newBean; 177 } 178 179 public void setEntityContext(EntityContext context) throws RemoteException { 180 log.debug("EntityBean.setSessionContext() called"); 181 entityContext = context; 182 } 183 184 public void unsetEntityContext() throws RemoteException { 185 log.debug("EntityBean.unsetSessionContext() called"); 186 entityContext = null; 187 } 188 } 189 | Popular Tags |