[jboss-cvs] JBossAS SVN: r101197 - in projects/jboss-jca/trunk/deployers/src: test/java/org/jboss/jca/test/deployers/spec/rars and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 19 23:55:15 EST 2010


Author: jesper.pedersen
Date: 2010-02-19 23:55:14 -0500 (Fri, 19 Feb 2010)
New Revision: 101197

Added:
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseConnectionManager.java
Modified:
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseManagedConnectionFactory.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra10dtdout/TestManagedConnectionFactory.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16asso/TestManagedConnectionFactory.java
   projects/jboss-jca/trunk/deployers/src/test/resources/logging.properties
Log:
[JBJCA-276] Associate resource adapter before use

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2010-02-20 04:51:44 UTC (rev 101196)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2010-02-20 04:55:14 UTC (rev 101197)
@@ -325,7 +325,6 @@
          ResourceAdapter resourceAdapter = null;
          List<ValidateObject> archiveValidationObjects = new ArrayList<ValidateObject>();
          List<Object> beanValidationObjects = new ArrayList<Object>();
-         List<Object> associationObjects = new ArrayList<Object>();
 
          List<String> jndiNames = null;
 
@@ -379,7 +378,7 @@
                                                                         mcf,
                                                                         cdMeta.getConfigProps()));
                         beanValidationObjects.add(mcf);
-                        associationObjects.add(mcf);
+                        associateResourceAdapter(resourceAdapter, mcf);
 
                         // TODO: add proper configuration and use it (support TxConnectionManager as well)
                         NoTxConnectionManager noTxCm = new NoTxConnectionManager();
@@ -449,7 +448,7 @@
 
                         archiveValidationObjects.add(new ValidateObject(Key.ACTIVATION_SPEC, o, cpm));
                         beanValidationObjects.add(o);
-                        associationObjects.add(o);
+                        associateResourceAdapter(resourceAdapter, o);
                      }
                   }
                }
@@ -592,9 +591,6 @@
          }
          
          // Activate deployment
-         if (resourceAdapter != null && associationObjects.size() > 0)
-            associateResourceAdapter(resourceAdapter, associationObjects);
-
          if (resourceAdapter != null)
             startContext(resourceAdapter);
 
@@ -653,15 +649,14 @@
    /**
     * Associate resource adapter with ojects if they implement ResourceAdapterAssociation
     * @param resourceAdapter The resource adapter
-    * @param associationObjects The list of possible objects
+    * @param object The of possible association object
     * @throws DeployException Thrown if the resource adapter cant be started
     */
    @SuppressWarnings("unchecked") 
-   private void associateResourceAdapter(ResourceAdapter resourceAdapter, 
-                                         List<Object> associationObjects)
+   private void associateResourceAdapter(ResourceAdapter resourceAdapter, Object object)
       throws DeployException
    {
-      for (Object object : associationObjects)
+      if (resourceAdapter != null && object != null)
       {
          if (object instanceof ResourceAdapterAssociation)
          {

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseConnectionManager.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseConnectionManager.java	2010-02-20 04:55:14 UTC (rev 101197)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.test.deployers.spec.rars;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnectionFactory;
+
+import org.jboss.logging.Logger;
+
+/**
+ * BaseConnectionManager
+ *
+ * @author  <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>.
+ * @version $Revision: $
+ */
+public class BaseConnectionManager implements ConnectionManager
+{
+   private static final long serialVersionUID = 1L;
+   private static Logger log = Logger.getLogger(BaseConnectionManager.class);
+
+   /**
+    * Constructor
+    */
+   public BaseConnectionManager()
+   {
+   }
+
+   /**
+    * Allocate a connection
+    * @param mcf The managed connection factory
+    * @param cri The connection request information
+    * @return The connection
+    * @exception ResourceException Thrown if an error occurs
+    */
+   public Object allocateConnection(ManagedConnectionFactory mcf,
+                                    ConnectionRequestInfo cxRequestInfo)
+      throws ResourceException
+   {
+      return null;
+   }
+}

Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseManagedConnectionFactory.java	2010-02-20 04:51:44 UTC (rev 101196)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseManagedConnectionFactory.java	2010-02-20 04:55:14 UTC (rev 101197)
@@ -29,6 +29,8 @@
 import javax.resource.spi.ConnectionRequestInfo;
 import javax.resource.spi.ManagedConnection;
 import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterAssociation;
 import javax.security.auth.Subject;
 
 import org.jboss.logging.Logger;
@@ -39,13 +41,24 @@
  * @author  <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a>.
  * @version $Revision: $
  */
-public class BaseManagedConnectionFactory implements
-      ManagedConnectionFactory
+public class BaseManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation
 {
    private static final long serialVersionUID = 1L;
    private static Logger log = Logger.getLogger(BaseManagedConnectionFactory.class);
 
+   private ResourceAdapter ra;
+   private PrintWriter logwriter;
+
    /**
+    * Constructor
+    */
+   public BaseManagedConnectionFactory()
+   {
+      ra = null;
+      logwriter = null;
+   }
+
+   /**
     * Creates a Connection Factory instance. 
     *
     *  @param    cxManager    ConnectionManager to be associated with created EIS connection factory instance
@@ -54,6 +67,9 @@
     */
    public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
    {
+      if (ra == null)
+         throw new IllegalStateException("RA is null");
+
       log.debug("call createConnectionFactory");
       return new BaseCciConnectionFactory();
    }
@@ -66,8 +82,11 @@
     */
    public Object createConnectionFactory() throws ResourceException
    {
+      if (ra == null)
+         throw new IllegalStateException("RA is null");
+
       log.debug("call createConnectionFactory");
-      return createConnectionFactory((ConnectionManager)null);
+      return createConnectionFactory(new BaseConnectionManager());
    }
 
    /** 
@@ -79,8 +98,12 @@
     *  @return  ManagedConnection instance
     */
    public ManagedConnection createManagedConnection(Subject subject,
-         ConnectionRequestInfo cxRequestInfo) throws ResourceException
+                                                    ConnectionRequestInfo cxRequestInfo) 
+      throws ResourceException
    {
+      if (ra == null)
+         throw new IllegalStateException("RA is null");
+
       log.debug("call createManagedConnection");
       return null;
    }
@@ -95,9 +118,13 @@
     *  @return  ManagedConnection     if resource adapter finds an acceptable match otherwise null
     **/
    public ManagedConnection matchManagedConnections(Set connectionSet,
-      Subject subject, ConnectionRequestInfo cxRequestInfo)
+                                                    Subject subject, 
+                                                    ConnectionRequestInfo cxRequestInfo)
       throws ResourceException
    {
+      if (ra == null)
+         throw new IllegalStateException("RA is null");
+
       log.debug("call matchManagedConnections");
       return null;
    }
@@ -110,7 +137,7 @@
    public PrintWriter getLogWriter() throws ResourceException
    {
       log.debug("call getLogWriter");
-      return null;
+      return logwriter;
    }
 
    /** 
@@ -122,10 +149,30 @@
    public void setLogWriter(PrintWriter out) throws ResourceException
    {
       log.debug("call setLogWriter");
+      logwriter = out;
+   }
 
+   /**
+    * Get the resource adapter
+    * @return The handle
+    */
+   public ResourceAdapter getResourceAdapter()
+   {
+      log.debug("call getResourceAdapter");
+      return ra;
    }
 
    /**
+    * Set the resource adapter
+    * @param ra The handle
+    */
+   public void setResourceAdapter(ResourceAdapter ra)
+   {
+      log.debug("call setResourceAdapter(" + ra + ")");
+      this.ra = ra;
+   }
+
+   /**
     * Hash code
     * @return The hash
     */

Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra10dtdout/TestManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra10dtdout/TestManagedConnectionFactory.java	2010-02-20 04:51:44 UTC (rev 101196)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra10dtdout/TestManagedConnectionFactory.java	2010-02-20 04:55:14 UTC (rev 101197)
@@ -21,8 +21,15 @@
  */
 package org.jboss.jca.test.deployers.spec.rars.ra10dtdout;
 
+import org.jboss.jca.test.deployers.spec.rars.BaseCciConnectionFactory;
+import org.jboss.jca.test.deployers.spec.rars.BaseConnectionManager;
 import org.jboss.jca.test.deployers.spec.rars.BaseManagedConnectionFactory;
 
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+import org.jboss.logging.Logger;
+
 /**
  * TestManagedConnectionFactory
  * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a>
@@ -31,4 +38,32 @@
 public class TestManagedConnectionFactory extends BaseManagedConnectionFactory
 {
    private static final long serialVersionUID = 1L;
+   private static Logger log = Logger.getLogger(TestManagedConnectionFactory.class);
+
+   /**
+    * Creates a Connection Factory instance. 
+    *
+    *  @param    cxManager    ConnectionManager to be associated with created EIS connection factory instance
+    *  @return   EIS-specific Connection Factory instance or javax.resource.cci.ConnectionFactory instance
+    *  @throws   ResourceException     Generic exception
+    */
+   @Override
+   public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
+   {
+      log.debug("call createConnectionFactory");
+      return new BaseCciConnectionFactory();
+   }
+
+   /**
+    * Creates a Connection Factory instance. 
+    *
+    *  @return   EIS-specific Connection Factory instance or javax.resource.cci.ConnectionFactory instance
+    *  @throws   ResourceException     Generic exception
+    */
+   @Override
+   public Object createConnectionFactory() throws ResourceException
+   {
+      log.debug("call createConnectionFactory");
+      return createConnectionFactory(new BaseConnectionManager());
+   }
 }

Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16asso/TestManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16asso/TestManagedConnectionFactory.java	2010-02-20 04:51:44 UTC (rev 101196)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16asso/TestManagedConnectionFactory.java	2010-02-20 04:55:14 UTC (rev 101197)
@@ -23,43 +23,19 @@
 
 import org.jboss.jca.test.deployers.spec.rars.BaseManagedConnectionFactory;
 
-import javax.resource.spi.ResourceAdapter;
-import javax.resource.spi.ResourceAdapterAssociation;
-
 /**
  * TestManagedConnectionFactory
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  * @version $Revision: $
  */
-public class TestManagedConnectionFactory extends BaseManagedConnectionFactory implements ResourceAdapterAssociation
+public class TestManagedConnectionFactory extends BaseManagedConnectionFactory
 {
    private static final long serialVersionUID = 1L;
 
-   private ResourceAdapter ra;
-
    /**
     * Constructor
     */
    public TestManagedConnectionFactory()
    {
-      this.ra = null;
    }
-
-   /**
-    * Get the resource adapter handle
-    * @return The handle
-    */
-   public ResourceAdapter getResourceAdapter()
-   {
-      return ra;
-   }
-
-   /**
-    * Set the resource adapter handle
-    * @param ra The handle
-    */
-   public void setResourceAdapter(ResourceAdapter ra)
-   {
-      this.ra = ra;
-   }
 }

Modified: projects/jboss-jca/trunk/deployers/src/test/resources/logging.properties
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/resources/logging.properties	2010-02-20 04:51:44 UTC (rev 101196)
+++ projects/jboss-jca/trunk/deployers/src/test/resources/logging.properties	2010-02-20 04:55:14 UTC (rev 101197)
@@ -30,7 +30,7 @@
 logger.handlers=CONSOLE, FILE
 
 # org.jboss.jca
-logger.org.jboss.jca.level=DEBUG
+logger.org.jboss.jca.level=TRACE
 
 # org.jboss
 logger.org.jboss.level=INFO
@@ -50,7 +50,7 @@
 
 # File handler configuration
 handler.FILE=org.jboss.logmanager.handlers.FileHandler
-handler.FILE.level=${jboss.jca.log.file.level:DEBUG}
+handler.FILE.level=${jboss.jca.log.file.level:TRACE}
 handler.FILE.properties=autoFlush,fileName
 handler.FILE.autoFlush=true
 handler.FILE.fileName=${test.dir}/deployers/test.log




More information about the jboss-cvs-commits mailing list