[jboss-cvs] JBossAS SVN: r108231 - in projects/jboss-jca/trunk/deployers: src/main/java/org/jboss/jca/deployers/fungal and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Sep 20 14:14:39 EDT 2010
Author: jesper.pedersen
Date: 2010-09-20 14:14:39 -0400 (Mon, 20 Sep 2010)
New Revision: 108231
Added:
projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/IronJacamarTestCase.java
projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/
projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/
projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/ironjacamar.xml
projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/ra.xml
Modified:
projects/jboss-jca/trunk/deployers/build.xml
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/RADeployment.java
Log:
[JBJCA-416] Activate deployment in RADeployer if ironjacamar.xml has enough information
Modified: projects/jboss-jca/trunk/deployers/build.xml
===================================================================
--- projects/jboss-jca/trunk/deployers/build.xml 2010-09-20 17:06:18 UTC (rev 108230)
+++ projects/jboss-jca/trunk/deployers/build.xml 2010-09-20 18:14:39 UTC (rev 108231)
@@ -310,6 +310,13 @@
includes="org/jboss/jca/test/deployers/spec/rars/ra16asso/*.class"/>
<fileset dir="src/test/resources/ra16asso.rar"/>
</jar>
+ <jar destfile="${build.deployers.dir}/ra15outironjacamar.rar">
+ <fileset dir="${build.deployers.dir}/test"
+ includes="org/jboss/jca/test/deployers/spec/rars/*.class"/>
+ <fileset dir="${build.deployers.dir}/test"
+ includes="org/jboss/jca/test/deployers/spec/rars/ra15out/*.class"/>
+ <fileset dir="src/test/resources/ra15outironjacamar.rar"/>
+ </jar>
</target>
<!-- =================================
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-09-20 17:06:18 UTC (rev 108230)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2010-09-20 18:14:39 UTC (rev 108231)
@@ -191,11 +191,12 @@
List<Failure> partialFailures = null;
List<Object> beanValidationObjects = new ArrayList<Object>();
Object[] cfs = null;
+ String[] jndiNames = null;
String deploymentName = f.getName().substring(0, f.getName().indexOf(".rar"));
// Check metadata for JNDI information and activate explicit
- boolean activateDeployment = false;
+ boolean activateDeployment = checkActivation(cmd, ijmd);
// Create objects and inject values
if (cmd != null)
@@ -248,15 +249,11 @@
if (activateDeployment)
{
- org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD = null;
-
- if (ijmd != null)
- {
- ijCD = findConnectionDefinition(ra10.getManagedConnectionFactoryClass().getValue(),
- ijmd.getConnectionDefinitions());
- }
+ org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD =
+ findConnectionDefinition(ra10.getManagedConnectionFactoryClass().getValue(),
+ ijmd.getConnectionDefinitions());
- if (ijmd == null || ijCD == null || ijCD.isEnabled())
+ if (ijCD.isEnabled())
{
ManagedConnectionFactory mcf =
(ManagedConnectionFactory) initAndInject(ra10.getManagedConnectionFactoryClass().getValue(),
@@ -397,10 +394,13 @@
if (cf != null && cf instanceof Serializable && cf instanceof Referenceable)
{
- String[] jndis = bindConnectionFactory(url, deploymentName, cf);
+ String jndiName = ijCD.getJndiName();
+
+ bindConnectionFactory(url, deploymentName, cf, jndiName);
cfs = new Object[] {cf};
-
- cm.setJndiName(jndis[0]);
+ jndiNames = new String[] {jndiName};
+
+ cm.setJndiName(jndiName);
}
}
}
@@ -414,8 +414,13 @@
List<ConnectionDefinition> cdMetas = ra.getOutboundResourceadapter().getConnectionDefinitions();
if (cdMetas.size() > 0)
{
- for (ConnectionDefinition cdMeta : cdMetas)
+ cfs = new Object[cdMetas.size()];
+ jndiNames = new String[cdMetas.size()];
+
+ for (int cdIndex = 0; cdIndex < cdMetas.size(); cdIndex++)
{
+ org.jboss.jca.common.api.metadata.ra.ConnectionDefinition cdMeta = cdMetas.get(cdIndex);
+
partialFailures =
validateArchive(url, Arrays
.asList((Validate) new ValidateClass(Key.MANAGED_CONNECTION_FACTORY, cdMeta
@@ -432,15 +437,11 @@
{
if (activateDeployment)
{
- org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD = null;
-
- if (ijmd != null)
- {
- ijCD = findConnectionDefinition(cdMeta.getManagedConnectionFactoryClass().getValue(),
- ijmd.getConnectionDefinitions());
- }
+ org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD =
+ findConnectionDefinition(cdMeta.getManagedConnectionFactoryClass().getValue(),
+ ijmd.getConnectionDefinitions());
- if (ijmd == null || ijCD == null || ijCD.isEnabled())
+ if (ijCD.isEnabled())
{
ManagedConnectionFactory mcf =
(ManagedConnectionFactory) initAndInject(cdMeta.getManagedConnectionFactoryClass()
@@ -584,18 +585,13 @@
if (cf != null && cf instanceof Serializable && cf instanceof Referenceable)
{
- if (cdMetas.size() == 1)
- {
- deploymentName = f.getName().substring(0, f.getName().indexOf(".rar"));
- String[] jndis = bindConnectionFactory(url, deploymentName, cf);
- cfs = new Object[] {cf};
-
- cm.setJndiName(jndis[0]);
- }
- else
- {
- log.warn("NYI: There are multiple connection factories for: " + f.getName());
- }
+ String jndiName = ijCD.getJndiName();
+
+ bindConnectionFactory(url, deploymentName, cf, jndiName);
+ cfs[cdIndex] = cf;
+ jndiNames[cdIndex] = jndiName;
+
+ cm.setJndiName(jndiName);
}
}
}
@@ -799,6 +795,7 @@
getConfiguration().getJndiStrategy(),
getConfiguration().getMetadataRepository(),
cfs,
+ jndiNames,
destination,
cl,
log);
@@ -828,4 +825,68 @@
SecurityActions.setThreadContextClassLoader(oldTCCL);
}
}
+
+ /**
+ * Check if the resource adapter should be activated based on the ironjacamar.xml input
+ * @param cmd The connector metadata
+ * @param ijmd The IronJacamar metadata
+ * @return True if the deployment should be activated; otherwise false
+ */
+ private boolean checkActivation(Connector cmd, IronJacamar ijmd)
+ {
+ if (cmd != null && ijmd != null)
+ {
+ Set<String> raClasses = new HashSet<String>();
+ Set<String> ijClasses = new HashSet<String>();
+
+ if (cmd.getVersion() == Version.V_10)
+ {
+ ResourceAdapter10 ra10 = (ResourceAdapter10)cmd.getResourceadapter();
+ raClasses.add(ra10.getManagedConnectionFactoryClass().getValue());
+ }
+ else
+ {
+ ResourceAdapter1516 ra = (ResourceAdapter1516)cmd.getResourceadapter();
+ if (ra != null && ra.getOutboundResourceadapter() != null &&
+ ra.getOutboundResourceadapter().getConnectionDefinitions() != null)
+ {
+ List<ConnectionDefinition> cdMetas = ra.getOutboundResourceadapter().getConnectionDefinitions();
+ if (cdMetas.size() > 0)
+ {
+ for (ConnectionDefinition cdMeta : cdMetas)
+ {
+ raClasses.add(cdMeta.getManagedConnectionFactoryClass().getValue());
+ }
+ }
+ }
+ }
+
+ if (raClasses.size() == 0)
+ return false;
+
+ if (ijmd.getConnectionDefinitions() != null)
+ {
+ for (org.jboss.jca.common.api.metadata.common.CommonConnDef def : ijmd.getConnectionDefinitions())
+ {
+ String clz = def.getClassName();
+
+ if (clz == null && raClasses.size() == 1)
+ return true;
+
+ if (clz != null)
+ ijClasses.add(clz);
+ }
+ }
+
+ for (String clz : raClasses)
+ {
+ if (!ijClasses.contains(clz))
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
}
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java 2010-09-20 17:06:18 UTC (rev 108230)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java 2010-09-20 18:14:39 UTC (rev 108231)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2008-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.
*
@@ -67,6 +67,9 @@
/** The connection factories */
private Object[] cfs;
+ /** The JNDI names of the connection factories */
+ private String[] jndis;
+
/** The temporary directory */
private File tmpDirectory;
@@ -82,6 +85,7 @@
* @param jndiStrategy The JNDI strategy
* @param metadataRepository The metadata repository
* @param cfs The connection factories
+ * @param jndis The JNDI names of the connection factories
* @param tmpDirectory The temporary directory
* @param cl The classloader for the deployment
* @param log The logger
@@ -93,6 +97,7 @@
JndiStrategy jndiStrategy,
MetadataRepository metadataRepository,
Object[] cfs,
+ String[] jndis,
File tmpDirectory,
ClassLoader cl,
Logger log)
@@ -104,6 +109,7 @@
this.jndiStrategy = jndiStrategy;
this.mdr = metadataRepository;
this.cfs = cfs;
+ this.jndis = jndis;
this.tmpDirectory = tmpDirectory;
this.cl = cl;
this.log = log;
@@ -148,11 +154,22 @@
{
log.debug("Undeploying: " + deployment.toExternalForm());
- if (cfs != null)
+ if (mdr != null && cfs != null && jndis != null)
{
+ for (int i = 0; i < cfs.length; i++)
+ {
+ String cf = cfs[i].getClass().getName();
+ String jndi = jndis[i];
+
+ mdr.unregisterJndiMapping(deployment, cf, jndi);
+ }
+ }
+
+ if (cfs != null && jndis != null)
+ {
try
{
- jndiStrategy.unbindConnectionFactories(deploymentName, cfs);
+ jndiStrategy.unbindConnectionFactories(deploymentName, cfs, jndis);
}
catch (Throwable t)
{
Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/IronJacamarTestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/IronJacamarTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/IronJacamarTestCase.java 2010-09-20 18:14:39 UTC (rev 108231)
@@ -0,0 +1,152 @@
+/*
+ * 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;
+
+import org.jboss.jca.embedded.EmbeddedJCA;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Test cases for deploying resource adapter archives (.RAR) using ironjacamar.xml files
+ * for activation
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+public class IronJacamarTestCase
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static Logger log = Logger.getLogger(IronJacamarTestCase.class);
+
+ private static final String JNDI_PREFIX = "java:/eis/";
+
+ /*
+ * Embedded
+ */
+ private static EmbeddedJCA embedded;
+
+ // --------------------------------------------------------------------------------||
+ // Tests --------------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * ra15outironjacamar.rar
+ * @throws Throwable throwable exception
+ */
+ @Test
+ public void testRa15out() throws Throwable
+ {
+ URL archive = getURL("ra15outironjacamar.rar");
+ Context context = null;
+
+ try
+ {
+ embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "ra15outironjacamar-explicit");
+ assertNotNull(o);
+ }
+ catch (Throwable t)
+ {
+ log.error(t.getMessage(), t);
+ fail(t.getMessage());
+ }
+ finally
+ {
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
+ embedded.undeploy(archive);
+ }
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Lifecycle start, before the suite is executed
+ * @throws Throwable throwable exception
+ */
+ @BeforeClass
+ public static void beforeClass() throws Throwable
+ {
+ // Create and set an embedded JCA instance
+ embedded = new EmbeddedJCA();
+
+ // Startup
+ embedded.startup();
+ }
+
+ /**
+ * Lifecycle stop, after the suite is executed
+ * @throws Throwable throwable exception
+ */
+ @AfterClass
+ public static void afterClass() throws Throwable
+ {
+ // Shutdown embedded
+ embedded.shutdown();
+
+ // Set embedded to null
+ embedded = null;
+ }
+
+ /**
+ * Get the URL for a test archive
+ * @param archive The name of the test archive
+ * @return The URL to the archive
+ * @throws Throwable throwable exception
+ */
+ public URL getURL(String archive) throws Throwable
+ {
+ File f = new File(System.getProperty("archives.dir") + File.separator + archive);
+ return f.toURI().toURL();
+ }
+}
Added: projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/ironjacamar.xml
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/ironjacamar.xml (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/ironjacamar.xml 2010-09-20 18:14:39 UTC (rev 108231)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id $ -->
+
+<ironjacamar>
+
+ <connection-definitions>
+ <connection-definition jndi-name="java:/eis/ra15outironjacamar-explicit"
+ class-name="org.jboss.jca.test.deployers.spec.rars.ra15out.TestManagedConnectionFactory"/>
+ </connection-definitions>
+
+</ironjacamar>
Added: projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/ra.xml
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/ra.xml (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/resources/ra15outironjacamar.rar/META-INF/ra.xml 2010-09-20 18:14:39 UTC (rev 108231)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id $ -->
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Test RA</eis-type>
+ <resourceadapter-version>0.1</resourceadapter-version>
+
+ <resourceadapter>
+ <resourceadapter-class>org.jboss.jca.test.deployers.spec.rars.ra15out.TestResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>org.jboss.jca.test.deployers.spec.rars.ra15out.TestManagedConnectionFactory</managedconnectionfactory-class>
+
+ <connectionfactory-interface>javax.resource.spi.ManagedConnection</connectionfactory-interface>
+ <connectionfactory-impl-class>org.jboss.jca.test.deployers.spec.rars.ra15out.TestManagedConnection</connectionfactory-impl-class>
+ <connection-interface>org.jboss.jca.test.deployers.spec.rars.TestConnectionInterface</connection-interface>
+ <connection-impl-class>org.jboss.jca.test.deployers.spec.rars.TestConnection</connection-impl-class>
+ </connection-definition>
+ <transaction-support>LocalTransaction</transaction-support>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
More information about the jboss-cvs-commits
mailing list