User: fleury  
  Date: 00/09/26 11:44:06

  Modified:    src/main/org/jboss/ejb/plugins EntityInstancePool.java
  Log:
  The new pool let's instances die if associated with a transaction
  
  Revision  Changes    Path
  1.5       +78 -74    jboss/src/main/org/jboss/ejb/plugins/EntityInstancePool.java
  
  Index: EntityInstancePool.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/EntityInstancePool.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EntityInstancePool.java   2000/08/12 00:40:46     1.4
  +++ EntityInstancePool.java   2000/09/26 18:44:05     1.5
  @@ -1,74 +1,78 @@
  -/*
  - * jBoss, the OpenSource EJB server
  - *
  - * Distributable under GPL license.
  - * See terms of license at gnu.org.
  - */
  -package org.jboss.ejb.plugins;
  -
  -import java.rmi.RemoteException;
  -
  -import org.jboss.ejb.Container;
  -import org.jboss.ejb.EnterpriseContext;
  -import org.jboss.ejb.EntityEnterpriseContext;
  -
  -/**
  - *   <description> 
  - *      
  - *   @see <related>
  - *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.4 $
  - */
  -public class EntityInstancePool
  -   extends AbstractInstancePool
  -{
  -   // Constants -----------------------------------------------------
  -    
  -   // Attributes ----------------------------------------------------
  -   
  -   // Static --------------------------------------------------------
  -   
  -   // Constructors --------------------------------------------------
  -   
  -   // Public --------------------------------------------------------
  -   /**
  -    *   Return an instance to the free pool. Reset state
  -    *
  -    *   Called in 3 cases:
  -    *   a) Done with finder method
  -    *   b) Removed
  -    *   c) Passivated
  -    *
  -    * @param   ctx  
  -    */
  -   public synchronized void free(EnterpriseContext ctx)
  -   {
  -      // Reset instance
  -      ((EntityEnterpriseContext)ctx).setValid(false);
  -      ((EntityEnterpriseContext)ctx).setInvoked(false);
  -      
  -      super.free(ctx);
  -   }
  -   
  -   // Z implementation ----------------------------------------------
  -   public void start()
  -      throws Exception
  -   {
  -   }
  -    
  -   // Package protected ---------------------------------------------
  -    
  -   // Protected -----------------------------------------------------
  -   protected EnterpriseContext create(Object instance, Container con)
  -      throws RemoteException
  -   {
  -        // MF FIXME why pass con and then use getContainer()
  -      return new EntityEnterpriseContext(instance, getContainer());
  -   }
  -    
  -   // Private -------------------------------------------------------
  -
  -   // Inner classes -------------------------------------------------
  -
  -}
  -
  +/*
  + * jBoss, the OpenSource EJB server
  + *
  + * Distributable under GPL license.
  + * See terms of license at gnu.org.
  + */
  +package org.jboss.ejb.plugins;
  +
  +import java.rmi.RemoteException;
  +
  +import org.jboss.ejb.Container;
  +import org.jboss.ejb.EnterpriseContext;
  +import org.jboss.ejb.EntityEnterpriseContext;
  +
  +/**
  + *   <description> 
  + *      
  + *   @see <related>
  + *   @author Rickard �berg ([EMAIL PROTECTED])
  + *  @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
  + *   @version $Revision: 1.5 $
  + */
  +public class EntityInstancePool
  +   extends AbstractInstancePool
  +{
  +   // Constants -----------------------------------------------------
  +    
  +   // Attributes ----------------------------------------------------
  +   
  +   // Static --------------------------------------------------------
  +   
  +   // Constructors --------------------------------------------------
  +   
  +   // Public --------------------------------------------------------
  +   /**
  +    *   Return an instance to the free pool. Reset state
  +    *
  +    *   Called in 3 cases:
  +    *   a) Done with finder method
  +    *   b) Removed
  +    *   c) Passivated
  +    *
  +    * @param   ctx  
  +    */
  +   public synchronized void free(EnterpriseContext ctx)
  +   {
  +       // If transaction still present don't do anything (let the instance be GC)
  +       if (ctx.getTransaction() != null) return ;
  +           
  +      // Reset instance
  +      ((EntityEnterpriseContext)ctx).setValid(false);
  +      ((EntityEnterpriseContext)ctx).setInvoked(false);
  +      
  +      super.free(ctx);
  +   }
  +   
  +   // Z implementation ----------------------------------------------
  +   public void start()
  +      throws Exception
  +   {
  +   }
  +    
  +   // Package protected ---------------------------------------------
  +    
  +   // Protected -----------------------------------------------------
  +   protected EnterpriseContext create(Object instance, Container con)
  +      throws RemoteException
  +   {
  +       // MF FIXME why pass con and then use getContainer()
  +      return new EntityEnterpriseContext(instance, getContainer());
  +   }
  +    
  +   // Private -------------------------------------------------------
  +
  +   // Inner classes -------------------------------------------------
  +
  +}
  +
  
  
  

Reply via email to