User: mnf999 Date: 01/07/03 15:55:29 Modified: src/main/org/jboss/ejb EntityEnterpriseContext.java Log: We explicitely name the registration "is TxRegistered" much clearer a name and that is its real usage, Revision Changes Path 1.20 +164 -158 jboss/src/main/org/jboss/ejb/EntityEnterpriseContext.java Index: EntityEnterpriseContext.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/EntityEnterpriseContext.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- EntityEnterpriseContext.java 2001/06/18 20:01:21 1.19 +++ EntityEnterpriseContext.java 2001/07/03 22:55:29 1.20 @@ -26,182 +26,188 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a> * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> * @author <a href="mailto:[EMAIL PROTECTED]">Daniel OConnor</a> -* @version $Revision: 1.19 $ +* @version $Revision: 1.20 $ +* +* <p><b>Revisions</b> +* <p>20010703 marcf +* <ol> +* <li>- setInvoked replaced by "isTxSynchronized", the reason being that we use it for Tx registration +* </ol> */ public class EntityEnterpriseContext extends EnterpriseContext { - // Attributes ---------------------------------------------------- - EJBObject ejbObject; - EJBLocalObject ejbLocalObject; - EntityContext ctx; - - // True if this instance has been invoked since it was synchronized with DB - // If true, then we have to store it to synch back to DB - boolean invoked = false; - - // True if this instances' state is valid - // when a bean is called the state is not synchronized with the DB - // but "valid" as long as the transaction runs - boolean valid = false; - - // The persistence manager may attach any metadata it wishes to this context here - private Object persistenceCtx; - + // Attributes ---------------------------------------------------- + EJBObject ejbObject; + EJBLocalObject ejbLocalObject; + EntityContext ctx; + + // True if this instance has been registered with the TM for transactional demarcation + boolean isTxSynchronized = false; + + // True if this instances' state is valid + // when a bean is called the state is not synchronized with the DB + // but "valid" as long as the transaction runs + boolean valid = false; + + // The persistence manager may attach any metadata it wishes to this context here + private Object persistenceCtx; + //The cacheKey for this context CacheKey key; - - // Constructors -------------------------------------------------- - public EntityEnterpriseContext(Object instance, Container con) - throws RemoteException - { - super(instance, con); - ctx = new EntityContextImpl(); - ((EntityBean)instance).setEntityContext(ctx); - } - - // Public -------------------------------------------------------- - + + // Constructors -------------------------------------------------- + public EntityEnterpriseContext(Object instance, Container con) + throws RemoteException + { + super(instance, con); + ctx = new EntityContextImpl(); + ((EntityBean)instance).setEntityContext(ctx); + } + + // Public -------------------------------------------------------- + public void clear() { - + super.clear(); - this.invoked = false; + this.isTxSynchronized = false; this.valid = false; key = null; persistenceCtx = null; ejbObject = null; + } + + public void discard() + throws RemoteException + { + ((EntityBean)instance).unsetEntityContext(); + } + + public EJBContext getEJBContext() + { + return ctx; + } + + public void setEJBObject(EJBObject eo) + { + ejbObject = eo; + } + + public EJBObject getEJBObject() + { + // Context can have no EJBObject (created by finds) in which case we need to wire it at call time + + return ejbObject; } - - public void discard() - throws RemoteException - { - ((EntityBean)instance).unsetEntityContext(); - } - - public EJBContext getEJBContext() - { - return ctx; - } - - public void setEJBObject(EJBObject eo) - { - ejbObject = eo; - } - - public EJBObject getEJBObject() - { - // Context can have no EJBObject (created by finds) in which case we need to wire it at call time - - return ejbObject; - } - - public void setEJBLocalObject( EJBLocalObject eo ) - { - ejbLocalObject = eo; - } - - public EJBLocalObject getEJBLocalObject() - { - return ejbLocalObject; - } - + + public void setEJBLocalObject( EJBLocalObject eo ) + { + ejbLocalObject = eo; + } + + public EJBLocalObject getEJBLocalObject() + { + return ejbLocalObject; + } + public void setCacheKey(Object key) { this.key = (CacheKey) key; } - + public CacheKey getCacheKey() { return key; } - - public void setPersistenceContext(Object ctx) - { - this.persistenceCtx = ctx; - } - - public Object getPersistenceContext() - { - return persistenceCtx; - } -/* - public void setCacheContext(Object ctx) - { - this.cacheCtx = ctx; - } - - public Object getCacheContext() - { - return cacheCtx; - } -*/ - public void setInvoked(boolean invoked) - { - - this.invoked = invoked; - } - - public boolean isInvoked() - { - return invoked; - } - - public void setValid(boolean valid) - { - - this.valid = valid; - } - - public boolean isValid() - { - return valid; - } - - - // Inner classes ------------------------------------------------- - protected class EntityContextImpl - extends EJBContextImpl - implements EntityContext - { - public EJBObject getEJBObject() - { - - if (((EntityContainer)con).getContainerInvoker()==null) - throw new IllegalStateException( "No remote interface defined." ); - if (ejbObject == null) { - - try { - - // Create a new CacheKey - Object cacheKey = ((EntityCache) ((EntityContainer) con).getInstanceCache()).createCacheKey( id ); - - ejbObject = ((EntityContainer)con).getContainerInvoker().getEntityEJBObject(cacheKey); - } - catch (RemoteException re) { - // ... - throw new IllegalStateException(); - } - } - - return ejbObject; - } - - public EJBLocalObject getEJBLocalObject() - { - if (con.getLocalHomeClass()==null) - throw new IllegalStateException( "No local interface for bean." ); - if (ejbLocalObject == null) - { - Object cacheKey = ((EntityCache) ((EntityContainer) con).getInstanceCache()) - .createCacheKey( id ); - ejbLocalObject = ((EntityContainer)con).getLocalContainerInvoker() - .getEntityEJBLocalObject(cacheKey); - } - return ejbLocalObject; - } - - public Object getPrimaryKey() - { - return id; - } - } + + public void setPersistenceContext(Object ctx) + { + this.persistenceCtx = ctx; + } + + public Object getPersistenceContext() + { + return persistenceCtx; + } + + /* + public void setCacheContext(Object ctx) + { + this.cacheCtx = ctx; + } + + public Object getCacheContext() + { + return cacheCtx; + } + */ + public void setTxSynchronized(boolean value) + { + + isTxSynchronized = value; + } + + public boolean isTxSynchronized() + { + return isTxSynchronized; + } + + public void setValid(boolean valid) + { + + this.valid = valid; + } + + public boolean isValid() + { + return valid; + } + + + // Inner classes ------------------------------------------------- + protected class EntityContextImpl + extends EJBContextImpl + implements EntityContext + { + public EJBObject getEJBObject() + { + + if (((EntityContainer)con).getContainerInvoker()==null) + throw new IllegalStateException( "No remote interface defined." ); + if (ejbObject == null) { + + try { + + // Create a new CacheKey + Object cacheKey = ((EntityCache) ((EntityContainer) con).getInstanceCache()).createCacheKey( id ); + + ejbObject = ((EntityContainer)con).getContainerInvoker().getEntityEJBObject(cacheKey); + } + catch (RemoteException re) { + // ... + throw new IllegalStateException(); + } + } + + return ejbObject; + } + + public EJBLocalObject getEJBLocalObject() + { + if (con.getLocalHomeClass()==null) + throw new IllegalStateException( "No local interface for bean." ); + if (ejbLocalObject == null) + { + Object cacheKey = ((EntityCache) ((EntityContainer) con).getInstanceCache()) + .createCacheKey( id ); + ejbLocalObject = ((EntityContainer)con).getLocalContainerInvoker() + .getEntityEJBLocalObject(cacheKey); + } + return ejbLocalObject; + } + + public Object getPrimaryKey() + { + return id; + } + } } _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-development
