[jboss-cvs] JBossAS SVN: r97554 - in projects/jboss-jca/trunk: core/src/main/java/org/jboss/jca/core/api and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 8 13:53:26 EST 2009


Author: jesper.pedersen
Date: 2009-12-08 13:53:26 -0500 (Tue, 08 Dec 2009)
New Revision: 97554

Added:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/CloneableBootstrapContext.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/BaseCloneableBootstrapContext.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/package.html
Modified:
   projects/jboss-jca/trunk/core/src/main/resources/deployment/jca.xml
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
   projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml
   projects/jboss-jca/trunk/embedded/src/main/resources/transaction.xml
   projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/jca.xml
   projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/transaction.xml
Log:
[JBJCA-236] Provide BootstrapContext implementation

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/CloneableBootstrapContext.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/CloneableBootstrapContext.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/CloneableBootstrapContext.java	2009-12-08 18:53:26 UTC (rev 97554)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.core.api;
+
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+
+/**
+ * The cloneable bootstrap context interface which defines
+ * the contract for all BootstrapContext implementations
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface CloneableBootstrapContext extends Cloneable, BootstrapContext
+{
+   /**
+    * Set the transaction synchronization registry
+    * @param tsr The handle
+    */
+   public void setTransactionSynchronizationRegistry(TransactionSynchronizationRegistry tsr);
+
+   /**
+    * Set the work manager
+    * @param wm The handle
+    */
+   public void setWorkManager(WorkManager wm);
+
+   /**
+    * Set the XA terminator
+    * @param xt The handle
+    */
+   public void setXATerminator(XATerminator xt);
+
+   /**
+    * Clone the BootstrapContext implementation
+    * @return A copy of the implementation
+    * @exception CloneNotSupportedException Thrown if the copy operation isn't supported
+    *  
+    */
+   public CloneableBootstrapContext clone() throws CloneNotSupportedException;
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/BaseCloneableBootstrapContext.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/BaseCloneableBootstrapContext.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/BaseCloneableBootstrapContext.java	2009-12-08 18:53:26 UTC (rev 97554)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.core.bootstrapcontext;
+
+import org.jboss.jca.core.api.CloneableBootstrapContext;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Timer;
+
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.HintsContext;
+import javax.resource.spi.work.SecurityContext;
+import javax.resource.spi.work.TransactionContext;
+import javax.resource.spi.work.WorkContext;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+
+/**
+ * The base implementation of the cloneable bootstrap context
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class BaseCloneableBootstrapContext implements CloneableBootstrapContext
+{
+   /** Transaction synchronization registry */
+   private TransactionSynchronizationRegistry transactionSynchronizationRegistry;
+
+   /** Work Manager */
+   private WorkManager workManager;
+
+   /** XATerminator */
+   private XATerminator xaTerminator;
+
+   /** Supported contexts */
+   private Set<Class> supportedContexts;
+
+   /**
+    * Constructor
+    */
+   public BaseCloneableBootstrapContext()
+   {
+      this.transactionSynchronizationRegistry = null;
+      this.workManager = null;
+      this.xaTerminator = null;
+      this.supportedContexts = new HashSet<Class>(3);
+
+      this.supportedContexts.add(HintsContext.class);
+      this.supportedContexts.add(SecurityContext.class);
+      this.supportedContexts.add(TransactionContext.class);
+   }
+
+   /**
+    * Get the transaction synchronization registry
+    * @return The handle
+    */
+   public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
+   {
+      return transactionSynchronizationRegistry;
+   }
+
+   /**
+    * Set the transaction synchronization registry
+    * @param tsr The handle
+    */
+   public void setTransactionSynchronizationRegistry(TransactionSynchronizationRegistry tsr)
+   {
+      this.transactionSynchronizationRegistry = tsr;
+   }
+
+   /**
+    * Get the work manager
+    * @return The handle
+    */
+   public WorkManager getWorkManager()
+   {
+      return workManager;
+   }
+
+   /**
+    * Set the work manager
+    * @param wm The handle
+    */
+   public void setWorkManager(WorkManager wm)
+   {
+      this.workManager = wm;
+   }
+
+   /**
+    * Get the XA terminator
+    * @return The handle
+    */
+   public XATerminator getXATerminator()
+   {
+      return xaTerminator;
+   }
+
+   /**
+    * Set the XA terminator
+    * @param xt The handle
+    */
+   public void setXATerminator(XATerminator xt)
+   {
+      this.xaTerminator = xt;
+   }
+
+   /**
+    * Create a timer
+    * @return The timer
+    */
+   public Timer createTimer()
+   {
+      return new Timer(true);
+   }
+
+   /**
+    * Is the work context supported ?
+    * @param workContextClass The work context class
+    * @return True if supported; otherwise false
+    */
+   public boolean isContextSupported(Class<? extends WorkContext> workContextClass)
+   {
+      return supportedContexts.contains(workContextClass);
+   }
+
+   /**
+    * Clone the BootstrapContext implementation
+    * @return A copy of the implementation
+    * @exception CloneNotSupportedException Thrown if the copy operation isn't supported
+    *  
+    */
+   public CloneableBootstrapContext clone() throws CloneNotSupportedException
+   {
+      BaseCloneableBootstrapContext bcbc = new BaseCloneableBootstrapContext();
+      bcbc.setTransactionSynchronizationRegistry(getTransactionSynchronizationRegistry());
+      bcbc.setWorkManager(getWorkManager());
+      bcbc.setXATerminator(getXATerminator());
+
+      return bcbc;
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/bootstrapcontext/package.html	2009-12-08 18:53:26 UTC (rev 97554)
@@ -0,0 +1,6 @@
+<body>
+This package contains implementations of the BootstrapContext interface.
+<p>
+JBoss JCA extends javax.resource.spi.BootstrapContext with a org.jboss.jca.core.api.CloneableBootstrapContext
+interface in order to allow different implementations to be used for the resource adapter deployments.
+</body>

Modified: projects/jboss-jca/trunk/core/src/main/resources/deployment/jca.xml
===================================================================
--- projects/jboss-jca/trunk/core/src/main/resources/deployment/jca.xml	2009-12-08 17:36:49 UTC (rev 97553)
+++ projects/jboss-jca/trunk/core/src/main/resources/deployment/jca.xml	2009-12-08 18:53:26 UTC (rev 97554)
@@ -28,5 +28,20 @@
     <!-- The XA terminator -->
     <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
   </bean>
+
+  <!-- Default Bootstrap context -->
+  <bean name="DefaultBootstrapContext" 
+        interface="org.jboss.jca.core.api.CloneableBootstrapContext"
+        class="org.jboss.jca.core.bootstrapcontext.BaseCloneableBootstrapContext">
+
+    <!-- The Transaction Synchronization Registry -->
+    <property name="TransactionSynchronizationRegistry"><inject bean="TransactionSynchronizationRegistry"/></property>
+
+    <!-- The Work Manager -->
+    <property name="WorkManager"><inject bean="WorkManager"/></property>
+
+    <!-- The XA terminator -->
+    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+  </bean>
   
 </deployment>

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	2009-12-08 17:36:49 UTC (rev 97553)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2009-12-08 18:53:26 UTC (rev 97554)
@@ -22,6 +22,7 @@
 
 package org.jboss.jca.deployers.fungal;
 
+import org.jboss.jca.core.api.CloneableBootstrapContext;
 import org.jboss.jca.deployers.common.validator.Failure;
 import org.jboss.jca.deployers.common.validator.FailureHelper;
 import org.jboss.jca.deployers.common.validator.Key;
@@ -40,6 +41,7 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -48,6 +50,9 @@
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+
 import org.jboss.logging.Logger;
 
 import org.jboss.metadata.rar.jboss.BvGroupMetaData;
@@ -87,6 +92,9 @@
    /** Archive validation: Fail on Error */
    private static AtomicBoolean archiveValidationFailOnError = new AtomicBoolean(true);
 
+   /** Default bootstrap context */
+   private static CloneableBootstrapContext defaultBootstrapContext = null;
+
    /**
     * Constructor
     */
@@ -167,6 +175,24 @@
    }
    
    /**
+    * Set the default bootstrap context
+    * @param value The value
+    */
+   public synchronized void setDefaultBootstrapContext(CloneableBootstrapContext value)
+   {
+      defaultBootstrapContext = value;
+   }
+   
+   /**
+    * Get the default bootstrap context
+    * @return The handle
+    */
+   public synchronized CloneableBootstrapContext getDefaultBootstrapContext()
+   {
+      return defaultBootstrapContext;
+   }
+   
+   /**
     * Deploy
     * @param url The url
     * @param parent The parent classloader
@@ -252,7 +278,7 @@
          // Merge metadata
          cmd = metadataHandler.merge(cmd, jrmd);
 
-
+         ResourceAdapter resourceAdapter = null;
          List<ValidateObject> archiveValidationObjects = new ArrayList<ValidateObject>();
          List<Object> beanValidationObjects = new ArrayList<Object>();
 
@@ -262,9 +288,10 @@
             // ResourceAdapter
             if (cmd.getRa() != null && cmd.getRa().getRaClass() != null)
             {
-               Object o = initAndInject(cmd.getRa().getRaClass(), cmd.getRa().getConfigProperty(), cl);
-               archiveValidationObjects.add(new ValidateObject(Key.RESOURCE_ADAPTER, o));
-               beanValidationObjects.add(o);
+               resourceAdapter =
+                  (ResourceAdapter)initAndInject(cmd.getRa().getRaClass(), cmd.getRa().getConfigProperty(), cl);
+               archiveValidationObjects.add(new ValidateObject(Key.RESOURCE_ADAPTER, resourceAdapter));
+               beanValidationObjects.add(resourceAdapter);
             }
             
             // ManagedConnectionFactory
@@ -439,6 +466,8 @@
          }
          
          // Activate deployment
+         if (resourceAdapter != null)
+            startContext(resourceAdapter);
 
          log.info("Deployed: " + url.toExternalForm());
 
@@ -460,6 +489,28 @@
    }
 
    /**
+    * Start the resource adapter
+    * @param resourceAdapter The resource adapter
+    * @throws DeployException Thrown if the resource adapter cant be started
+    */
+   private void startContext(ResourceAdapter resourceAdapter) throws DeployException
+   {
+      try 
+      {
+         Class clz = resourceAdapter.getClass();
+         Method start = clz.getMethod("start", new Class[] {BootstrapContext.class});
+
+         CloneableBootstrapContext cbc = defaultBootstrapContext.clone();
+
+         start.invoke(resourceAdapter, new Object[] {cbc});
+      }
+      catch (Throwable t)
+      {
+         throw new DeployException("Unable to start " + resourceAdapter.getClass().getName(), t);
+      }
+   }
+
+   /**
     * Initialize and inject configuration properties
     * @param className The fully qualified class name
     * @param configs The configuration properties

Modified: projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml	2009-12-08 17:36:49 UTC (rev 97553)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml	2009-12-08 18:53:26 UTC (rev 97554)
@@ -29,10 +29,25 @@
     <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
   </bean>
   
+  <!-- Default Bootstrap context -->
+  <bean name="DefaultBootstrapContext" 
+        interface="org.jboss.jca.core.api.CloneableBootstrapContext"
+        class="org.jboss.jca.core.bootstrapcontext.BaseCloneableBootstrapContext">
+
+    <!-- The Transaction Synchronization Registry -->
+    <property name="TransactionSynchronizationRegistry"><inject bean="TransactionSynchronizationRegistry"/></property>
+
+    <!-- The Work Manager -->
+    <property name="WorkManager"><inject bean="WorkManager"/></property>
+
+    <!-- The XA terminator -->
+    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+  </bean>
+
   <!-- RA deployer -->
   <bean name="RADeployer" interface="org.jboss.jca.fungal.deployers.Deployer" class="org.jboss.jca.deployers.fungal.RADeployer">
+    <property name="DefaultBootstrapContext"><inject bean="DefaultBootstrapContext"/></property>
     <depends>BeanValidation</depends>
-    <depends>WorkManager</depends>
   </bean>
 
 </deployment>

Modified: projects/jboss-jca/trunk/embedded/src/main/resources/transaction.xml
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/transaction.xml	2009-12-08 17:36:49 UTC (rev 97553)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/transaction.xml	2009-12-08 18:53:26 UTC (rev 97554)
@@ -13,4 +13,8 @@
     <depends>NamingServer</depends>
   </bean>
 
+  <!-- Transaction synchronization registry -->
+  <bean name="TransactionSynchronizationRegistry" 
+        class="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple"/>
+
 </deployment>

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/jca.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/jca.xml	2009-12-08 17:36:49 UTC (rev 97553)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/jca.xml	2009-12-08 18:53:26 UTC (rev 97554)
@@ -29,10 +29,25 @@
     <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
   </bean>
   
+  <!-- Default Bootstrap context -->
+  <bean name="DefaultBootstrapContext" 
+        interface="org.jboss.jca.core.api.CloneableBootstrapContext"
+        class="org.jboss.jca.core.bootstrapcontext.BaseCloneableBootstrapContext">
+
+    <!-- The Transaction Synchronization Registry -->
+    <property name="TransactionSynchronizationRegistry"><inject bean="TransactionSynchronizationRegistry"/></property>
+
+    <!-- The Work Manager -->
+    <property name="WorkManager"><inject bean="WorkManager"/></property>
+
+    <!-- The XA terminator -->
+    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+  </bean>
+
   <!-- RA deployer -->
   <bean name="RADeployer" interface="org.jboss.jca.fungal.deployers.Deployer" class="org.jboss.jca.deployers.fungal.RADeployer">
+    <property name="DefaultBootstrapContext"><inject bean="DefaultBootstrapContext"/></property>
     <depends>BeanValidation</depends>
-    <depends>WorkManager</depends>
   </bean>
 
 </deployment>

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/transaction.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/transaction.xml	2009-12-08 17:36:49 UTC (rev 97553)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/transaction.xml	2009-12-08 18:53:26 UTC (rev 97554)
@@ -13,4 +13,8 @@
     <depends>NamingServer</depends>
   </bean>
 
+  <!-- Transaction synchronization registry -->
+  <bean name="TransactionSynchronizationRegistry" 
+        class="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple"/>
+
 </deployment>




More information about the jboss-cvs-commits mailing list