dain        2004/04/12 00:11:52

  Modified:    modules/core/src/java/org/openejb/entity/cmp
                        CMPContainerBuilder.java CMPInstanceContext.java
                        CMPInstanceContextFactory.java
  Log:

  Added ejbLoad fault handler
  Fixed exception handling of ejbLoad
  
  Revision  Changes    Path
  1.8       +2 -2      
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPContainerBuilder.java
  
  Index: CMPContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPContainerBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CMPContainerBuilder.java  12 Apr 2004 02:23:56 -0000      1.7
  +++ CMPContainerBuilder.java  12 Apr 2004 04:11:52 -0000      1.8
  @@ -201,7 +201,7 @@
   
           // build the instance factory
           Map instanceMap = buildInstanceMap(beanClass, cmpFieldAccessors);
  -        InstanceContextFactory contextFactory = new 
CMPInstanceContextFactory(getContainerId(), proxyFactory, cacheTable, identityDefiner, 
primaryKeyTransform, beanClass, instanceMap);
  +        InstanceContextFactory contextFactory = new 
CMPInstanceContextFactory(getContainerId(), proxyFactory, primaryKeyTransform, 
faultHandler, beanClass, instanceMap);
           EntityInstanceFactory instanceFactory = new 
EntityInstanceFactory(getComponentContext(), contextFactory);
   
           // build the pool
  
  
  
  1.6       +23 -19    
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPInstanceContext.java
  
  Index: CMPInstanceContext.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPInstanceContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CMPInstanceContext.java   11 Apr 2004 16:58:04 -0000      1.5
  +++ CMPInstanceContext.java   12 Apr 2004 04:11:52 -0000      1.6
  @@ -50,7 +50,7 @@
   import java.lang.reflect.Method;
   import javax.ejb.EnterpriseBean;
   import javax.ejb.EntityBean;
  -import javax.ejb.NoSuchObjectLocalException;
  +import javax.ejb.NoSuchEntityException;
   
   import org.apache.geronimo.transaction.TransactionContext;
   
  @@ -59,12 +59,11 @@
   import org.openejb.entity.EntityInstanceContext;
   import org.openejb.proxy.EJBProxyFactory;
   import org.tranql.cache.CacheRow;
  -import org.tranql.cache.CacheTable;
  -import org.tranql.cache.InTxCache;
   import org.tranql.cache.CacheRowState;
  -import org.tranql.identity.IdentityTransform;
  +import org.tranql.cache.FaultHandler;
  +import org.tranql.cache.InTxCache;
   import org.tranql.identity.GlobalIdentity;
  -import org.tranql.identity.IdentityDefiner;
  +import org.tranql.identity.IdentityTransform;
   
   /**
    *
  @@ -74,17 +73,15 @@
   public final class CMPInstanceContext extends EntityInstanceContext implements 
MethodInterceptor {
       private final EntityBean instance;
       private final InstanceOperation[] itable;
  -    private final IdentityDefiner identityDefiner;
  +    private final FaultHandler loadFault;
       private final IdentityTransform primaryKeyTransform;
       private CacheRow cacheRow;
       private TransactionContext transactionContext;
  -    private final CacheTable cacheTable;
   
  -    public CMPInstanceContext(Object containerId, EJBProxyFactory proxyFactory, 
InstanceOperation[] itable, CacheTable cacheTable, IdentityDefiner identityDefiner, 
IdentityTransform primaryKeyTransform, CMPInstanceContextFactory contextFactory) 
throws Exception {
  +    public CMPInstanceContext(Object containerId, EJBProxyFactory proxyFactory, 
InstanceOperation[] itable, FaultHandler loadFault, IdentityTransform 
primaryKeyTransform, CMPInstanceContextFactory contextFactory) throws Exception {
           super(containerId, proxyFactory);
           this.itable = itable;
  -        this.cacheTable = cacheTable;
  -        this.identityDefiner = identityDefiner;
  +        this.loadFault = loadFault;
           this.primaryKeyTransform = primaryKeyTransform;
           instance = contextFactory.createCMPBeanInstance(this);
       }
  @@ -122,14 +119,21 @@
               GlobalIdentity globalId = primaryKeyTransform.getGlobalIdentity(id);
               InTxCache inTxCache = transactionContext.getInTxCache();
               cacheRow = inTxCache.get(globalId);
  -            if (cacheRow != null) {
  -                if(cacheRow.getState() == CacheRowState.REMOVED) {
  -                    throw new NoSuchObjectLocalException("Entity has been reomved");
  -                }
  -            } else {
  -                cacheRow = cacheTable.newRow(globalId);
  -                identityDefiner.injectIdentity(cacheRow);
  -                inTxCache.associate(cacheRow);
  +
  +            // if we don't already have the row execute the load fault handler
  +            if (cacheRow == null) {
  +                loadFault.rowFault(inTxCache, globalId);
  +                cacheRow = inTxCache.get(globalId);
  +            }
  +
  +            // if we still don't have a row, we can only assume that they have an 
old ref to the ejb
  +            if(cacheRow == null) {
  +                throw new NoSuchEntityException("Entity not found");
  +            }
  +
  +            // check that the row is not tagged as removed
  +            if(cacheRow.getState() == CacheRowState.REMOVED) {
  +                throw new NoSuchEntityException("Entity has been reomved");
               }
           }
           super.associate();
  
  
  
  1.6       +9 -12     
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPInstanceContextFactory.java
  
  Index: CMPInstanceContextFactory.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPInstanceContextFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CMPInstanceContextFactory.java    11 Apr 2004 16:58:04 -0000      1.5
  +++ CMPInstanceContextFactory.java    12 Apr 2004 04:11:52 -0000      1.6
  @@ -64,13 +64,12 @@
   import net.sf.cglib.proxy.MethodInterceptor;
   import net.sf.cglib.proxy.NoOp;
   import net.sf.cglib.reflect.FastClass;
  +import org.openejb.InstanceContextFactory;
   import org.openejb.dispatch.MethodHelper;
   import org.openejb.dispatch.MethodSignature;
  -import org.openejb.InstanceContextFactory;
   import org.openejb.proxy.EJBProxyFactory;
  +import org.tranql.cache.FaultHandler;
   import org.tranql.identity.IdentityTransform;
  -import org.tranql.identity.IdentityDefiner;
  -import org.tranql.cache.CacheTable;
   
   /**
    *
  @@ -80,20 +79,18 @@
   public class CMPInstanceContextFactory implements InstanceContextFactory, 
Serializable {
       private final Object containerId;
       private final EJBProxyFactory proxyFactory;
  -    private final CacheTable cacheTable;
  -    private final IdentityDefiner identityDefiner;
       private final IdentityTransform primaryKeyTransform;
  +    private final FaultHandler loadFault;
       private final Class beanClass;
       private final Map imap;
  -    private final InstanceOperation[] itable;
  +    private transient final InstanceOperation[] itable;
       private transient final Enhancer enhancer;
   
  -    public CMPInstanceContextFactory(Object containerId, EJBProxyFactory 
proxyFactory, CacheTable cacheTable, IdentityDefiner identityDefiner, 
IdentityTransform primaryKeyTransform, Class beanClass, Map imap) throws 
ClassNotFoundException {
  +    public CMPInstanceContextFactory(Object containerId, EJBProxyFactory 
proxyFactory, IdentityTransform primaryKeyTransform, FaultHandler loadFault, Class 
beanClass, Map imap) throws ClassNotFoundException {
           this.containerId = containerId;
           this.proxyFactory = proxyFactory;
  -        this.cacheTable = cacheTable;
  -        this.identityDefiner = identityDefiner;
           this.primaryKeyTransform = primaryKeyTransform;
  +        this.loadFault = loadFault;
           this.beanClass = beanClass;
           this.imap = imap;
   
  @@ -117,7 +114,7 @@
       }
   
       public synchronized InstanceContext newInstance() throws Exception {
  -        return new CMPInstanceContext(containerId, proxyFactory, itable, 
cacheTable, identityDefiner, primaryKeyTransform, this);
  +        return new CMPInstanceContext(containerId, proxyFactory, itable, loadFault, 
primaryKeyTransform, this);
       }
   
       public synchronized EntityBean createCMPBeanInstance(CMPInstanceContext 
instanceContext) {
  @@ -136,7 +133,7 @@
   
       private Object readResolve() throws ObjectStreamException {
           try {
  -            return new CMPInstanceContextFactory(containerId, proxyFactory, 
cacheTable, identityDefiner, primaryKeyTransform, beanClass, imap);
  +            return new CMPInstanceContextFactory(containerId, proxyFactory, 
primaryKeyTransform, loadFault, beanClass, imap);
           } catch (ClassNotFoundException e) {
               throw (InvalidClassException) new InvalidClassException("Cound not load 
method argument class").initCause(e);
           }
  
  
  

Reply via email to