User: dsundstrom
  Date: 02/04/13 18:05:09

  Modified:    src/main/org/jboss/ejb/plugins BMPPersistenceManager.java
                        CMPPersistenceManager.java
  Log:
  Moved invocation of ejbPostCreate to the new postCreateEntity method.
  This breaks the ejbCreate and ejbPostCreate into to steps to clear up
  issues with cache insertion.
  
  This should eliminate the "INSERTING AN ALREADY EXISTING BEAN" bugs.
  
  Revision  Changes    Path
  1.40      +105 -93   jboss/src/main/org/jboss/ejb/plugins/BMPPersistenceManager.java
  
  Index: BMPPersistenceManager.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/BMPPersistenceManager.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- BMPPersistenceManager.java        12 Apr 2002 19:30:42 -0000      1.39
  +++ BMPPersistenceManager.java        14 Apr 2002 01:05:08 -0000      1.40
  @@ -35,13 +35,14 @@
   import org.jboss.metadata.ConfigurationMetaData;
   
   /**
  -*   <description>
  +*  Persistence manager for BMP entites.  All calls are simply deligated
  +*  to the entity implementation class.
   *
  -*  @see <related>
   *  @author <a href="mailto:[EMAIL PROTECTED]";>Rickard Öberg</a>
   *  @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
   *  @author <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>
  -*  @version $Revision: 1.39 $
  +*  @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
  +*  @version $Revision: 1.40 $
   *
   *  <p><b>Revisions:</b>
   *  <p><b>20010709 andreas schaefer:</b>
  @@ -52,6 +53,10 @@
   *  <ul>
   *  <li>- insertion in cache upon create in now done in the instance interceptor
   *  </ul>
  +*  <p><b>20020413 dain sundstrom:</b>
  +*  <ul>
  +*  <li>- Moved ejbPostCreate call to postCreateEntity method
  +*  </ul>
   */
   public class BMPPersistenceManager
   implements EntityPersistenceManager
  @@ -201,113 +206,120 @@
      {
      }
   
  -   public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx)
  +   public void createEntity(
  +         Method m, 
  +         Object[] args, 
  +         EntityEnterpriseContext ctx) 
      throws Exception
      {
  -      try {
  +      Object id = null;
  +      try
  +      {
  +         // Call ejbCreate<METHOD)
            Method createMethod = (Method)createMethods.get(m);
  -         Method postCreateMethod = (Method)postCreateMethods.get(m);
  -
  -         Object id = null;
  -         try
  +         id = createMethod.invoke(ctx.getInstance(), args);
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite)
  +      {
  +         Throwable e = ite.getTargetException();
  +         if (e instanceof CreateException)
            {
  -            // Call ejbCreate<METHOD)
  -            id = createMethod.invoke(ctx.getInstance(), args);
  -         } catch (IllegalAccessException e)
  -         {
  -            // Throw this as a bean exception...(?)
  -            throw new EJBException(e);
  -         } catch (InvocationTargetException ite)
  +            // Rethrow exception
  +            throw (CreateException)e;
  +         }
  +         else if (e instanceof RemoteException)
            {
  -            Throwable e = ite.getTargetException();
  -            if (e instanceof CreateException)
  -            {
  -               // Rethrow exception
  -               throw (CreateException)e;
  -            }
  -            else if (e instanceof RemoteException)
  -            {
  -               // Rethrow exception
  -               throw (RemoteException)e;
  -            }
  -            else if (e instanceof EJBException)
  -            {
  -               // Rethrow exception
  -               throw (EJBException)e;
  -            }
  -            else if (e instanceof RuntimeException)
  -            {
  -               // Wrap runtime exceptions
  -               throw new EJBException((Exception)e);
  -            }
  -            else if(e instanceof Exception)
  -            {
  -               throw (Exception)e;
  -            }
  -            else
  -            {
  -               throw (Error)e;
  -            }
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         }
  +         else if(e instanceof Exception)
  +         {
  +            throw (Exception)e;
  +         }
  +         else
  +         {
  +            throw (Error)e;
            }
  +      }
   
  -         // set the id
  -         ctx.setId(id);
  +      // set the id
  +      ctx.setId(id);
   
  -         // Create a new CacheKey
  -         Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( 
id );
  +      // Create a new CacheKey
  +      Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id );
   
  -         // Give it to the context
  -         ctx.setCacheKey(cacheKey);
  +      // Give it to the context
  +      ctx.setCacheKey(cacheKey);
   
  -         // Create EJBObject
  -           // Create EJBObject
  -        if (con.getContainerInvoker() != null)
  +      // Create EJBObject
  +      if (con.getContainerInvoker() != null)
  +      {
            ctx.setEJBObject((EJBObject) 
con.getContainerInvoker().getEntityEJBObject(cacheKey));
  -        if (con.getLocalHomeClass() != null)
  +      }
  +      if (con.getLocalHomeClass() != null)
  +      {
            
ctx.setEJBLocalObject(con.getLocalContainerInvoker().getEntityEJBLocalObject(cacheKey));
  +      }
  +   }
   
  -         try
  +   public void postCreateEntity(
  +         Method m, 
  +         Object[] args, 
  +         EntityEnterpriseContext ctx) 
  +   throws Exception
  +   {
  +      try
  +      {
  +         Method postCreateMethod = (Method)postCreateMethods.get(m);
  +         postCreateMethod.invoke(ctx.getInstance(), args);
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite)
  +      {
  +         Throwable e = ite.getTargetException();
  +         if (e instanceof CreateException)
            {
  -            postCreateMethod.invoke(ctx.getInstance(), args);
  -         } catch (IllegalAccessException e)
  +            // Rethrow exception
  +            throw (CreateException)e;
  +         }
  +         else if (e instanceof RemoteException)
            {
  -            // Throw this as a bean exception...(?)
  -            throw new EJBException(e);
  -         } catch (InvocationTargetException ite)
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
            {
  -            Throwable e = ite.getTargetException();
  -            if (e instanceof CreateException)
  -            {
  -               // Rethrow exception
  -               throw (CreateException)e;
  -            }
  -            else if (e instanceof RemoteException)
  -            {
  -               // Rethrow exception
  -               throw (RemoteException)e;
  -            }
  -            else if (e instanceof EJBException)
  -            {
  -               // Rethrow exception
  -               throw (EJBException)e;
  -            }
  -            else if (e instanceof RuntimeException)
  -            {
  -               // Wrap runtime exceptions
  -               throw new EJBException((Exception)e);
  -            }
  -            else if(e instanceof Exception)
  -            {
  -               throw (Exception)e;
  -            }
  -            else
  -            {
  -               throw (Error)e;
  -            }
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         }
  +         else if(e instanceof Exception)
  +         {
  +            throw (Exception)e;
  +         }
  +         else
  +         {
  +            throw (Error)e;
            }
  -      }
  -      finally {
  -         mCreate.add();
         }
      }
   
  
  
  
  1.42      +31 -12    jboss/src/main/org/jboss/ejb/plugins/CMPPersistenceManager.java
  
  Index: CMPPersistenceManager.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/CMPPersistenceManager.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- CMPPersistenceManager.java        12 Apr 2002 19:30:42 -0000      1.41
  +++ CMPPersistenceManager.java        14 Apr 2002 01:05:08 -0000      1.42
  @@ -46,14 +46,28 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dan Christopherson</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Bill Burke</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>
  - * @version $Revision: 1.41 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
  + * @version $Revision: 1.42 $
    *
  - * Revisions:
  - * 20010621 Bill Burke: removed loadEntities call because CMP read-ahead is now
  - * done directly by the finder.
  - * 20010709 Andreas Schaefer: added statistics gathering
  - * 20011201 Dain Sundstrom: moved createBeanInstance and initEntity back into
  - * the persistence store.
  + *  <p><b>Revisions:</b>
  + *  <p><b>20010621 Bill Burke:</b>
  + *  <ul>
  + *  <li>- removed loadEntities call because CMP read-ahead is now
  + *        done directly by the finder.
  + *  </ul>
  + *  <p><b>20010709 Andreas Schaefer:</b>
  + *  <ul>
  + *  <li>- added statistics gathering
  + *  </ul>
  + *  <p><b>20011201 Dain Sundstrom:</b>
  + *  <ul>
  + *  <li>- moved createBeanInstance and initEntity back into
  + *        the persistence store.
  + *  </ul>
  + *  <p><b>20020413 dain sundstrom:</b>
  + *  <ul>
  + *  <li>- Moved ejbPostCreate call to postCreateEntity method
  + *  </ul>
    */
   public class CMPPersistenceManager
      implements EntityPersistenceManager
  @@ -197,16 +211,13 @@
      public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx)
         throws Exception
      {
  -      // Get methods
  -      Method createMethod = (Method)createMethods.get(m);
  -      Method postCreateMethod = (Method)postCreateMethods.get(m);
  -      
         // Deligate initialization of bean to persistence store
         store.initEntity(ctx);
   
         // Call ejbCreate on the target bean
         try
         {
  +         Method createMethod = (Method)createMethods.get(m);
            createMethod.invoke(ctx.getInstance(), args);
         }
         catch (IllegalAccessException e)
  @@ -259,9 +270,17 @@
         {
            
ctx.setEJBLocalObject(con.getLocalContainerInvoker().getEntityEJBLocalObject(cacheKey));
         }
  -      
  +   }
  +
  +   public void postCreateEntity(
  +         Method m, 
  +         Object[] args, 
  +         EntityEnterpriseContext ctx)
  +      throws Exception
  +   {
         try
         {
  +         Method postCreateMethod = (Method)postCreateMethods.get(m);
            postCreateMethod.invoke(ctx.getInstance(), args);
         }
         catch (IllegalAccessException e)
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to