1 22 package org.jboss.test.cmp2.passivation.ejb; 23 24 import java.rmi.RemoteException ; 25 26 import javax.ejb.CreateException ; 27 import javax.ejb.EJBException ; 28 import javax.ejb.EntityBean ; 29 import javax.ejb.EntityContext ; 30 import javax.ejb.RemoveException ; 31 import javax.ejb.EJBObject ; 32 import javax.ejb.EJBLocalObject ; 33 34 import org.jboss.logging.Logger; 35 36 71 public abstract class RapidlyPassivatedEntityBean implements EntityBean 72 { 73 75 private static Logger log = Logger.getLogger(RapidlyPassivatedEntityBean.class); 76 77 private EntityContext mEntityContext; 78 79 80 82 86 public abstract String getData(); 87 public abstract void setData(String data); 88 89 90 92 96 public Object getIdViaEJBLocalObject() 97 { 98 Object key = mEntityContext.getPrimaryKey(); 99 EJBLocalObject local = mEntityContext.getEJBLocalObject(); 100 Object lkey = local.getPrimaryKey(); 101 log.info("key: "+key+", lkey: "+lkey+", local: "+local); 102 return (Object )mEntityContext.getEJBLocalObject().getPrimaryKey(); 103 } 104 105 106 110 public Object getIdViaEJBObject() 111 { 112 try 113 { 114 return (Object )mEntityContext.getEJBObject().getPrimaryKey(); 115 } 116 catch (RemoteException e) 117 { 118 throw new EJBException (e); 119 } 120 } 121 122 123 125 128 public Object ejbCreate(String s) 129 throws CreateException 130 { 131 setData(s); 132 return null; } 134 135 public void ejbPostCreate(String s) 136 { 137 log.info("ejbPostCreate, ctx:"+mEntityContext 138 +", pk:"+mEntityContext.getPrimaryKey() 139 +", local:"+mEntityContext.getEJBLocalObject()); 140 } 141 142 143 public void ejbActivate() throws EJBException , RemoteException 144 { 145 log.info("ejbActivate, ctx:"+mEntityContext 146 +", pk:"+mEntityContext.getPrimaryKey() 147 +", local:"+mEntityContext.getEJBLocalObject()); 148 } 149 150 public void ejbLoad() throws EJBException , RemoteException 151 { 152 log.info("ejbLoad, ctx:"+mEntityContext 153 +", pk:"+mEntityContext.getPrimaryKey() 154 +", local:"+mEntityContext.getEJBLocalObject()); 155 } 156 157 public void ejbPassivate() throws EJBException , RemoteException 158 { 159 log.info("ejbPassivate, ctx:"+mEntityContext 160 +", pk:"+mEntityContext.getPrimaryKey() 161 +", local:"+mEntityContext.getEJBLocalObject()); 162 } 163 164 public void ejbRemove() 165 throws RemoveException , EJBException , RemoteException 166 { 167 } 168 169 public void ejbStore() throws EJBException , RemoteException 170 { 171 } 172 173 public void setEntityContext(EntityContext ctx) 174 throws EJBException , RemoteException 175 { 176 mEntityContext = ctx; 177 } 178 179 public void unsetEntityContext() throws EJBException , RemoteException 180 { 181 mEntityContext = null; 182 } 183 184 } 185 | Popular Tags |