User: user57 Date: 01/07/12 21:10:15 Modified: src/main/org/jboss/ejb EntityEnterpriseContext.java Log: cleaned up Revision Changes Path 1.21 +197 -191 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.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- EntityEnterpriseContext.java 2001/07/03 22:55:29 1.20 +++ EntityEnterpriseContext.java 2001/07/13 04:10:15 1.21 @@ -1,9 +1,9 @@ /* -* JBoss, the OpenSource EJB server -* -* Distributable under LGPL license. -* See terms of license at gnu.org. -*/ + * JBoss, the OpenSource EJB server + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ package org.jboss.ejb; import java.rmi.RemoteException; @@ -20,194 +20,200 @@ import javax.transaction.Transaction; /** -* The EntityEnterpriseContext is used to associate EntityBean instances with metadata about it. -* -* @see EnterpriseContext -* @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.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> -*/ + * The EntityEnterpriseContext is used to associate EntityBean instances + * with metadata about it. + * + * @see EnterpriseContext + * + * @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.21 $ + * + * <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 + extends EnterpriseContext { - // 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 -------------------------------------------------------- - - public void clear() { - - super.clear(); - 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 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 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() - { + // 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 -------------------------------------------------------- + + public void clear() { + super.clear(); + + 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 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 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(); + } + } - 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; - } + return ejbObject; + } - public Object getPrimaryKey() - { - return id; - } - } + 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
