[jboss-cvs] JBossAS SVN: r112304 - in projects/jboss-jca/trunk: core/src/main/java/org/jboss/jca/core/rar and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 11 13:06:06 EDT 2011


Author: jesper.pedersen
Date: 2011-10-11 13:06:05 -0400 (Tue, 11 Oct 2011)
New Revision: 112304

Added:
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/TestResourceAdapter.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/package.html
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/testcases/Ra16TestCase.java
Modified:
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ra/common/ResourceAdapter1516Impl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/rar/SimpleResourceAdapterRepository.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/rar/ResourceAdapterRepository.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java
Log:
[JBJCA-680] Pure ResourceAdapter class deployment aren't working

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ra/common/ResourceAdapter1516Impl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ra/common/ResourceAdapter1516Impl.java	2011-10-10 23:10:58 UTC (rev 112303)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ra/common/ResourceAdapter1516Impl.java	2011-10-11 17:06:05 UTC (rev 112304)
@@ -329,7 +329,7 @@
           this.getResourceadapterClass() != null)
          inboundOrOutbound = true;
 
-      if (!inboundOrOutbound)
+      if (!inboundOrOutbound && (this.resourceadapterClass == null || this.resourceadapterClass.trim().equals("")))
          throw new ValidateException(bundle.invalidMetadataForResourceAdapter());
    }
 

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/rar/SimpleResourceAdapterRepository.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/rar/SimpleResourceAdapterRepository.java	2011-10-10 23:10:58 UTC (rev 112303)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/rar/SimpleResourceAdapterRepository.java	2011-10-11 17:06:05 UTC (rev 112304)
@@ -162,6 +162,28 @@
    /**
     * {@inheritDoc}
     */
+   public ResourceAdapter getResourceAdapter(String uniqueId) throws NotFoundException
+   {
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
+
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
+
+      if (!rars.containsKey(uniqueId))
+         throw new NotFoundException(bundle.keyNotRegistered(uniqueId));
+
+      WeakReference<ResourceAdapter> ra = rars.get(uniqueId);
+
+      if (ra.get() == null)
+         throw new NotFoundException(bundle.keyNotRegistered(uniqueId));
+
+      return ra.get();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public synchronized Set<String> getResourceAdapters()
    {
       return Collections.unmodifiableSet(rars.keySet());

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/rar/ResourceAdapterRepository.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/rar/ResourceAdapterRepository.java	2011-10-10 23:10:58 UTC (rev 112303)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/rar/ResourceAdapterRepository.java	2011-10-11 17:06:05 UTC (rev 112304)
@@ -49,6 +49,14 @@
    public void unregisterResourceAdapter(String key) throws NotFoundException;
 
    /**
+    * Get the resource adapter instance based on the unique id
+    * @param uniqueId An unique id that represents the deployment
+    * @return The resource adapter
+    * @exception NotFoundException Thrown if the unique id isn't registered
+    */
+   public ResourceAdapter getResourceAdapter(String uniqueId) throws NotFoundException;
+
+   /**
     * Get the resource adapters unique ids registered
     * @return The unique ids
     */

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-10-10 23:10:58 UTC (rev 112303)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-10-11 17:06:05 UTC (rev 112304)
@@ -890,7 +890,7 @@
                               }
                               else
                               {
-                                  log.adminObjectNotBound(aoMeta.getAdminobjectClass().getValue());
+                                 log.adminObjectNotBound(aoMeta.getAdminobjectClass().getValue());
                               }
                            }
                         }
@@ -1433,7 +1433,7 @@
                         }
                         else
                         {
-                            log.connectionFactoryNotBound(mcf.getClass().getName());
+                           log.connectionFactoryNotBound(mcf.getClass().getName());
                         }
                      }
                   }
@@ -1911,7 +1911,7 @@
                                     }
                                     else
                                     {
-                                        log.connectionFactoryNotBound(mcf.getClass().getName());
+                                       log.connectionFactoryNotBound(mcf.getClass().getName());
                                     }
                                  }
                               }

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java	2011-10-10 23:10:58 UTC (rev 112303)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java	2011-10-11 17:06:05 UTC (rev 112304)
@@ -152,9 +152,10 @@
       if (enabled)
       {
          MetadataRepository mdr = ((RAConfiguration) getConfiguration()).getMetadataRepository();
+         ResourceAdapterRepository rar = ((RAConfiguration) getConfiguration()).getResourceAdapterRepository();
 
          Set<String> rarDeployments = mdr.getResourceAdapters();
-         Set<String> configuredRars = getConfiguredResourceAdapters(mdr);
+         Set<String> configuredRars = getConfiguredResourceAdapters(mdr, rar);
 
          for (String deployment : rarDeployments)
          {
@@ -228,9 +229,10 @@
    /**
     * Get the set of configured resource adapters
     * @param mdr The metadata repository
+    * @param rar The resource adapter repository
     * @return The resource adapters
     */
-   private Set<String> getConfiguredResourceAdapters(MetadataRepository mdr)
+   private Set<String> getConfiguredResourceAdapters(MetadataRepository mdr, ResourceAdapterRepository rar)
    {
       Set<String> configured = new HashSet<String>();
 
@@ -244,8 +246,15 @@
       {
          if (deployment.endsWith(".rar"))
          {
-            if (mdr.hasJndiMappings(deployment))
-               configured.add(deployment);
+            try
+            {
+               if (mdr.hasJndiMappings(deployment) || hasResourceAdapter(rar, mdr.getResourceAdapter(deployment)))
+                  configured.add(deployment);
+            }
+            catch (Throwable t)
+            {
+               // Ignore
+            }
          }
          else if (deployment.endsWith("-ra.xml"))
          {
@@ -422,6 +431,41 @@
    }
 
    /**
+    * Has a resource adapter instance deployed
+    * @param rar The resource adapter repository
+    * @param c The connector definition
+    */
+   private boolean hasResourceAdapter(ResourceAdapterRepository rar, Connector c)
+   {
+      if (rar != null && c != null &&
+          c.getResourceadapter() != null && c.getResourceadapter() instanceof ResourceAdapter1516)
+      {
+         ResourceAdapter1516 ra = (ResourceAdapter1516)c.getResourceadapter();
+
+         if (ra.getResourceadapterClass() != null)
+         {
+            String clz = ra.getResourceadapterClass();
+
+            for (String deployment : rar.getResourceAdapters())
+            {
+               try
+               {
+                  javax.resource.spi.ResourceAdapter instance = rar.getResourceAdapter(deployment);
+                  if (clz.equals(instance.getClass().getName()))
+                     return true;
+               }
+               catch (Throwable t)
+               {
+                  // Ignore deployment
+               }
+            }
+         }
+      }
+
+      return false;
+   }
+
+   /**
     * Deploy
     * @param url The url
     * @param parent The parent classloader

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/TestResourceAdapter.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/TestResourceAdapter.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/TestResourceAdapter.java	2011-10-11 17:06:05 UTC (rev 112304)
@@ -0,0 +1,49 @@
+/*
+ * 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.test.deployers.spec.rars.ra16;
+
+import org.jboss.jca.test.deployers.spec.rars.BaseResourceAdapter;
+
+import javax.resource.spi.AuthenticationMechanism;
+import javax.resource.spi.AuthenticationMechanism.CredentialInterface;
+import javax.resource.spi.Connector;
+import javax.resource.spi.TransactionSupport;
+
+/**
+ * TestResourceAdapter
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+ at Connector(
+      description = { "Test RA" },
+      displayName = { "displayName" },
+      smallIcon = { "smallIcon" },
+      largeIcon = { "largeIcon" },
+      vendorName = "Red Hat Middleware LLC",
+      eisType = "Test RA",
+      version = "0.1",
+      licenseDescription = { "licenseDescription" },
+      licenseRequired = true,
+      authMechanisms = { @AuthenticationMechanism(credentialInterface = CredentialInterface.GSSCredential) },
+      transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction)
+public class TestResourceAdapter extends BaseResourceAdapter
+{
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/package.html
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/ra16/package.html	2011-10-11 17:06:05 UTC (rev 112304)
@@ -0,0 +1,3 @@
+<body>
+Test for only RA class deployment
+</body>

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/testcases/Ra16TestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/testcases/Ra16TestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/testcases/Ra16TestCase.java	2011-10-11 17:06:05 UTC (rev 112304)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-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.test.deployers.spec.rars.testcases;
+
+import org.jboss.jca.core.spi.mdr.MetadataRepository;
+import org.jboss.jca.embedded.arquillian.Inject;
+import org.jboss.jca.test.deployers.spec.ArquillianJCATestUtils;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test cases for deploying resource adapter archives (.RAR) using -ra.xml files
+ * for activation
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class Ra16TestCase
+{
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- GIVEN --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   /**
+    * Define the deployment
+    * @return The deployment archive
+    * @throws Exception in case of errors
+    */
+   @Deployment
+   public static ResourceAdapterArchive createDeployment() throws Exception
+   {
+      String archiveName = "ra16.rar";
+      String packageName = "org.jboss.jca.test.deployers.spec.rars.ra16";
+      return ArquillianJCATestUtils.buidShrinkwrapRa(archiveName, packageName);
+   }
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- WHEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   @Inject(name = "MDR")
+   private MetadataRepository mdr;
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- THEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Basic
+    * @exception Throwable Thrown if case of an error
+    */
+   @Test
+   public void testBasic() throws Throwable
+   {
+      assertNotNull(mdr);
+      assertNotNull(mdr.getResourceAdapters());
+      assertTrue(mdr.getResourceAdapters().size() == 1);
+   }
+}



More information about the jboss-cvs-commits mailing list