User: starksm 
  Date: 01/11/25 19:12:26

  Modified:    src/main/org/jboss/ejb/plugins/cmp/jdbc
                        JDBCCommandFactory.java
                        JDBCDefinedFinderCommand.java
                        JDBCEJBQLFinderCommand.java
                        JDBCFindEntitiesCommand.java JDBCFinderCommand.java
                        JDBCRelationInterceptor.java JDBCStoreManager.java
  Log:
  Drop the org.jboss.ejb.DeploymentException in favor of the
  org.jboss.deployment.DeploymentException class.
  
  Clean up the org.jboss.logging.Logger to use the Logger.getLogger
  factory method.
  
  Revision  Changes    Path
  1.10      +2 -3      
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
  
  Index: JDBCCommandFactory.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JDBCCommandFactory.java   2001/11/24 22:31:09     1.9
  +++ JDBCCommandFactory.java   2001/11/26 03:12:26     1.10
  @@ -9,8 +9,7 @@
   
   
   
  -import org.jboss.ejb.DeploymentException;
  - 
  +import org.jboss.deployment.DeploymentException;
   import org.jboss.ejb.plugins.cmp.CommandFactory;
   import org.jboss.ejb.plugins.cmp.InitCommand;
   import org.jboss.ejb.plugins.cmp.StartCommand;
  @@ -38,7 +37,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Justin Forder</a>
    * @author <a href="[EMAIL PROTECTED]">danch (Dan Christopherson</a>
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.10 $
    */
   public class JDBCCommandFactory implements CommandFactory
   {
  
  
  
  1.6       +2 -2      
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCDefinedFinderCommand.java
  
  Index: JDBCDefinedFinderCommand.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCDefinedFinderCommand.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JDBCDefinedFinderCommand.java     2001/11/06 04:18:09     1.5
  +++ JDBCDefinedFinderCommand.java     2001/11/26 03:12:26     1.6
  @@ -7,7 +7,7 @@
   
   package org.jboss.ejb.plugins.cmp.jdbc;
   
  -import org.jboss.ejb.DeploymentException;
  +import org.jboss.deployment.DeploymentException;
   
   import org.jboss.ejb.Container;
   import org.jboss.ejb.EntityContainer;
  @@ -25,7 +25,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Justin Forder</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Michel de Groot</a>
    * @author <a href="[EMAIL PROTECTED]">danch (Dan Christopherson</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class JDBCDefinedFinderCommand extends JDBCFinderCommand {
      
  
  
  
  1.9       +2 -2      
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLFinderCommand.java
  
  Index: JDBCEJBQLFinderCommand.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLFinderCommand.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JDBCEJBQLFinderCommand.java       2001/11/24 22:31:09     1.8
  +++ JDBCEJBQLFinderCommand.java       2001/11/26 03:12:26     1.9
  @@ -7,7 +7,7 @@
   
   package org.jboss.ejb.plugins.cmp.jdbc;
   
  -import org.jboss.ejb.DeploymentException;
  +import org.jboss.deployment.DeploymentException;
   import org.jboss.ejb.plugins.cmp.ejbql.Assembly;
   import org.jboss.ejb.plugins.cmp.ejbql.Parser;
   import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMPFieldBridge;
  @@ -24,7 +24,7 @@
    * clause. This code has been cleaned up to improve readability.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
  - * @version $Revision: 1.8 $
  + * @version $Revision: 1.9 $
    */
   public class JDBCEJBQLFinderCommand extends JDBCFinderCommand {
   
  
  
  
  1.13      +2 -2      
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntitiesCommand.java
  
  Index: JDBCFindEntitiesCommand.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntitiesCommand.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JDBCFindEntitiesCommand.java      2001/11/24 22:31:09     1.12
  +++ JDBCFindEntitiesCommand.java      2001/11/26 03:12:26     1.13
  @@ -18,7 +18,7 @@
   import javax.ejb.FinderException;
   
   import org.jboss.ejb.EntityEnterpriseContext;
  -import org.jboss.ejb.DeploymentException;
  +import org.jboss.deployment.DeploymentException;
   import org.jboss.ejb.plugins.cmp.FindEntitiesCommand;
   import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCAutomaticQueryMetaData;
   import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCQueryMetaData;
  @@ -38,7 +38,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Joe Shevland</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Justin Forder</a>
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
    */
   public class JDBCFindEntitiesCommand implements FindEntitiesCommand {
      private final Map knownFinderCommands = new HashMap();
  
  
  
  1.11      +2 -2      
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCFinderCommand.java
  
  Index: JDBCFinderCommand.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCFinderCommand.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JDBCFinderCommand.java    2001/11/24 22:31:09     1.10
  +++ JDBCFinderCommand.java    2001/11/26 03:12:26     1.11
  @@ -25,7 +25,7 @@
   
   import org.jboss.ejb.ContainerInvoker;
   import org.jboss.ejb.LocalContainerInvoker;
  -import org.jboss.ejb.DeploymentException;
  +import org.jboss.deployment.DeploymentException;
   import org.jboss.ejb.EntityContainer;
   import org.jboss.ejb.EntityEnterpriseContext;
   import org.jboss.ejb.plugins.cmp.FindEntitiesCommand;
  @@ -44,7 +44,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Joe Shevland</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Justin Forder</a>
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    */
   public abstract class JDBCFinderCommand
      extends JDBCQueryCommand
  
  
  
  1.7       +136 -101  
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCRelationInterceptor.java
  
  Index: JDBCRelationInterceptor.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCRelationInterceptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JDBCRelationInterceptor.java      2001/11/24 21:39:10     1.6
  +++ JDBCRelationInterceptor.java      2001/11/26 03:12:26     1.7
  @@ -1,9 +1,9 @@
   /**
  -* JBoss, the OpenSource J2EE webOS
  -*
  -* Distributable under LGPL license.
  -* See terms of license at gnu.org.
  -*/
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.ejb.plugins.cmp.jdbc;
   
   import java.lang.reflect.Method;
  @@ -26,205 +26,234 @@
   import org.jboss.logging.Logger;
   
   /**
  -*
  -* The role of this interceptor relationship messages from a related CMR field
  -* and invoke the specified message on this container's cmr field of the
  -* relationship.  This interceptor also manages the relation table data.
  -*
  -* @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
  -* @version $Revision: 1.6 $
  -*/
  -public class JDBCRelationInterceptor extends AbstractInterceptor {
  + *
  + * The role of this interceptor relationship messages from a related CMR field
  + * and invoke the specified message on this container's cmr field of the
  + * relationship.  This interceptor also manages the relation table data.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
  + * @version $Revision: 1.7 $
  + */
  +public class JDBCRelationInterceptor extends AbstractInterceptor
  +{
      // Constants -----------------------------------------------------
      protected static final Method GET_RELATED_ID;
      protected static final Method ADD_RELATION;
      protected static final Method REMOVE_RELATION;
  -   protected static Logger log = Logger.create(
  -         JDBCRelationInterceptor.class.getName());
  -
  -   static {
  -      try {
  +   
  +   static
  +   {
  +      try
  +      {
            final Class empty[] = {};
            final Class type = CMRMessage.class;
  -
  -         GET_RELATED_ID = type.getMethod("getRelatedId", new Class[] {
  +         
  +         GET_RELATED_ID = type.getMethod("getRelatedId", new Class[]
  +         {
               EntityEnterpriseContext.class,
               JDBCCMRFieldBridge.class
            });
  -
  -         ADD_RELATION = type.getMethod("addRelation", new Class[] {
  +         
  +         ADD_RELATION = type.getMethod("addRelation", new Class[]
  +         {
               EntityEnterpriseContext.class,
               Object.class
            });
  -
  -         REMOVE_RELATION = type.getMethod("removeRelation", new Class[] {
  +         
  +         REMOVE_RELATION = type.getMethod("removeRelation", new Class[]
  +         {
               EntityEnterpriseContext.class,
               Object.class
            });
         }
  -      catch (Exception e) {
  +      catch (Exception e)
  +      {
            e.printStackTrace();
            throw new ExceptionInInitializerError(e);
         }
      }
  -
  +   
      // Attributes ----------------------------------------------------
  -
  +   
      /**
       *  The container of this interceptor.
       */
      protected EntityContainer container;
  -
  +   
      // Static --------------------------------------------------------
  -
  +   
      // Constructors --------------------------------------------------
  -
  +   
      // Public --------------------------------------------------------
  -   public void setContainer(Container container) {
  +   public void setContainer(Container container)
  +   {
         this.container = (EntityContainer)container;
      }
  -
  -   public Container getContainer() {
  +   
  +   public Container getContainer()
  +   {
         return container;
      }
  -
  +   
      // Interceptor implementation --------------------------------------
  -
  -   public Object invoke(MethodInvocation mi) throws Exception {
  +   
  +   public Object invoke(MethodInvocation mi) throws Exception
  +   {
         // We are going to work with the context a lot
         EntityEnterpriseContext ctx = 
(EntityEnterpriseContext)mi.getEnterpriseContext();
  -
  +      
         // The Tx coming as part of the Method Invocation
         Transaction tx = mi.getTransaction();
  -
  -      try {
  -         if(GET_RELATED_ID.equals(mi.getMethod())) {
  -
  +      
  +      try
  +      {
  +         if(GET_RELATED_ID.equals(mi.getMethod()))
  +         {
  +            
               // call getRelateId
               JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)mi.getArguments()[0];
               return cmrField.getRelatedId(ctx);
  -
  -         } else if(ADD_RELATION.equals(mi.getMethod())) {
  -
  +            
  +         } else if(ADD_RELATION.equals(mi.getMethod()))
  +         {
  +            
               // call addRelation
               JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)mi.getArguments()[0];
  -
  +            
               Object relatedId = mi.getArguments()[1];
               cmrField.addRelation(ctx, relatedId);
  -
  +            
               RelationData relationData = getRelationData(cmrField, tx);
               relationData.addRelation(cmrField, ctx.getId(), 
cmrField.getRelatedCMRField(), relatedId);
               return null;
  -
  -         } else if(REMOVE_RELATION.equals(mi.getMethod())) {
  -
  +            
  +         } else if(REMOVE_RELATION.equals(mi.getMethod()))
  +         {
  +            
               // call removeRelation
               JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)mi.getArguments()[0];
  -
  +            
               Object relatedId = mi.getArguments()[1];
               cmrField.removeRelation(ctx, relatedId);
  -
  +            
               RelationData relationData = getRelationData(cmrField, tx);
               relationData.removeRelation(cmrField, ctx.getId(), 
cmrField.getRelatedCMRField(), relatedId);
               return null;
  -
  -         } else {
  +            
  +         } else
  +         {
               // No a message. Invoke down the chain
               return getNext().invoke(mi);
            }
  -
  -      } finally {
  +         
  +      } finally
  +      {
            register(tx);
         }
      }
  -
  -   protected RelationData getRelationData(JDBCCMRFieldBridge cmrField, Transaction 
tx) {
  +   
  +   protected RelationData getRelationData(JDBCCMRFieldBridge cmrField, Transaction 
tx)
  +   {
         Map txDataMap = cmrField.getJDBCStoreManager().getTxDataMap();
         Map txData = (Map)txDataMap.get(tx);
  -      if(txData == null) {
  +      if(txData == null)
  +      {
            txData = new HashMap();
            txDataMap.put(tx, txData);
         }
  -
  +      
         JDBCRelationMetaData relationMetaData = 
cmrField.getMetaData().getRelationMetaData();
         RelationData relationData = (RelationData)txData.get(relationMetaData);
  -      if(relationData == null) {
  +      if(relationData == null)
  +      {
            relationData = new RelationData(cmrField, cmrField.getRelatedCMRField());
            txData.put(relationMetaData, relationData);
         }
         return relationData;
      }
  -
  +   
      // Private  ----------------------------------------------------
  -
  +   
      /**
  -   *  Register a transaction synchronization callback with a context.
  -   */
  -   private void register(Transaction tx) {
  +    *  Register a transaction synchronization callback with a context.
  +    */
  +   private void register(Transaction tx)
  +   {
         // Create a new synchronization
         RelationSynchronization synch = new RelationSynchronization(tx);
  -
  -      try {
  +      
  +      try
  +      {
            // We want to be notified when the transaction commits
            tx.registerSynchronization(synch);
  -      } catch(EJBException e) {
  +      } catch(EJBException e)
  +      {
            throw e;
  -      } catch(Exception e) {
  +      } catch(Exception e)
  +      {
            throw new EJBException(e);
         }
      }
  -
  +   
      // Inner classes -------------------------------------------------
  -
  -   private class RelationSynchronization implements Synchronization {
  +   
  +   private class RelationSynchronization implements Synchronization
  +   {
         /**
          *  The transaction we follow.
          */
         private Transaction tx;
  -
  +      
         /**
          *  Create a new instance synchronization instance.
          */
  -      private RelationSynchronization(Transaction tx) {
  -          this.tx = tx;
  +      private RelationSynchronization(Transaction tx)
  +      {
  +         this.tx = tx;
         }
  -
  +      
         // Synchronization implementation -----------------------------
  -
  +      
         /**
          * Saves all of the relations changed in this transaction.
          */
  -      public void beforeCompletion() {
  +      public void beforeCompletion()
  +      {
            // This is an independent point of entry. We need to make sure the
            // thread is associated with the right context class loader
            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(container.getClassLoader());
  -
  -         try {
  +         
  +         try
  +         {
               // Get the manager
               CMPPersistenceManager cmpPM = 
(CMPPersistenceManager)container.getPersistenceManager();
               JDBCStoreManager manager = 
(JDBCStoreManager)cmpPM.getPersistenceStore();
  -
  +            
               // Save each relation
               Map txDataMap = manager.getTxDataMap();
               Map txData = (Map)txDataMap.get(tx);
  -            if(txData != null) {
  +            if(txData != null)
  +            {
                  Iterator iterator = txData.values().iterator();
  -               while(iterator.hasNext()) {
  +               while(iterator.hasNext())
  +               {
                     Object obj = iterator.next();
  -                  if(obj instanceof RelationData) {
  +                  if(obj instanceof RelationData)
  +                  {
                        RelationData relationData = (RelationData) obj;
  -
  +                     
                        // only need to bother if neither side has a foreign key
                        if(!relationData.getLeftCMRField().hasForeignKey() &&
  -                           !relationData.getRightCMRField().hasForeignKey()) {
  -
  +                     !relationData.getRightCMRField().hasForeignKey())
  +                     {
  +                        
                           // delete all removed pairs from relation table
                           manager.deleteRelations(relationData);
  -
  +                        
                           // insert all added pairs into the relation table
                           manager.insertRelations(relationData);
  -
  +                        
                           relationData.addedRelations.clear();
                           relationData.removedRelations.clear();
                           relationData.notRelatedPairs.clear();
  @@ -232,26 +261,32 @@
                     }
                  }
               }
  -         } catch (Exception e) {
  +         } catch (Exception e)
  +         {
               log.error("ex", e);
  -
  +            
               // Store failed -> rollback!
  -            try {
  -                tx.setRollbackOnly();
  -            } catch (SystemException ex) {
  -                // DEBUG ex.printStackTrace();
  -            } catch (IllegalStateException ex) {
  -                // DEBUG ex.printStackTrace();
  +            try
  +            {
  +               tx.setRollbackOnly();
  +            } catch (SystemException ex)
  +            {
  +               // DEBUG ex.printStackTrace();
  +            } catch (IllegalStateException ex)
  +            {
  +               // DEBUG ex.printStackTrace();
               }
  -         } finally {
  +         } finally
  +         {
               Thread.currentThread().setContextClassLoader(oldCl);
            }
         }
  -
  +      
         /**
          * Unused
          */
  -      public void afterCompletion(int status) {
  +      public void afterCompletion(int status)
  +      {
         }
      }
   }
  
  
  
  1.13      +2 -2      
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
  
  Index: JDBCStoreManager.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JDBCStoreManager.java     2001/11/24 21:39:10     1.12
  +++ JDBCStoreManager.java     2001/11/26 03:12:26     1.13
  @@ -21,7 +21,7 @@
   import javax.naming.NamingException;
   import javax.transaction.Transaction;
   import javax.transaction.TransactionManager;
  -import org.jboss.ejb.DeploymentException;
  +import org.jboss.deployment.DeploymentException;
   import org.jboss.ejb.EntityEnterpriseContext;
   import org.jboss.ejb.ListCacheKey;
   import org.jboss.ejb.plugins.cmp.CMPStoreManager;
  @@ -54,7 +54,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
    * @see org.jboss.ejb.EntityPersistenceStore
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
    */
   public class JDBCStoreManager extends CMPStoreManager {
      /**
  
  
  

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

Reply via email to