[jboss-cvs] JBossAS SVN: r108608 - in projects/jboss-jca/trunk: deployers/src/main/java/org/jboss/jca/deployers/common and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 15 14:25:24 EDT 2010
Author: maeste
Date: 2010-10-15 14:25:24 -0400 (Fri, 15 Oct 2010)
New Revision: 108608
Added:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
Modified:
projects/jboss-jca/trunk/.gitignore
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/DsXmlDeployer.java
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/RaXmlDeployer.java
projects/jboss-jca/trunk/tools/findbugs/filter.xml
Log:
JBJCA-443 Refactor RaXmlDeployer and DsXmlDeployer
Modified: projects/jboss-jca/trunk/.gitignore
===================================================================
--- projects/jboss-jca/trunk/.gitignore 2010-10-15 17:08:22 UTC (rev 108607)
+++ projects/jboss-jca/trunk/.gitignore 2010-10-15 18:25:24 UTC (rev 108608)
@@ -2,6 +2,7 @@
.settings
.classpath
standalone/**
+build.debug.xml
# /
/build
/target
Copied: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java (from rev 108581, projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java)
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java 2010-10-15 18:25:24 UTC (rev 108608)
@@ -0,0 +1,485 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.deployers.common;
+
+import org.jboss.jca.common.api.metadata.common.CommonPool;
+import org.jboss.jca.common.api.metadata.common.CommonTimeOut;
+import org.jboss.jca.common.api.metadata.common.CommonValidation;
+import org.jboss.jca.common.api.metadata.ds.DataSource;
+import org.jboss.jca.common.api.metadata.ds.DataSources;
+import org.jboss.jca.common.api.metadata.ds.XaDataSource;
+import org.jboss.jca.common.api.metadata.ra.ConfigProperty;
+import org.jboss.jca.common.api.metadata.ra.ConnectionDefinition;
+import org.jboss.jca.common.api.metadata.ra.Connector;
+import org.jboss.jca.common.api.metadata.ra.ResourceAdapter1516;
+import org.jboss.jca.common.metadata.merge.Merger;
+import org.jboss.jca.core.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
+import org.jboss.jca.core.connectionmanager.pool.api.Pool;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
+import org.jboss.jca.core.spi.mdr.MetadataRepository;
+import org.jboss.jca.deployers.fungal.DsXmlDeployer;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
+import javax.transaction.TransactionManager;
+
+import org.jboss.logging.Logger;
+
+/**
+ *
+ * A AbstractDsDeployer.
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public abstract class AbstractDsDeployer
+{
+ /** log **/
+ protected static final Logger log = Logger.getLogger(DsXmlDeployer.class);
+
+ /** jdbcLocal **/
+ protected String jdbcLocal;
+
+ /** jdbcXA **/
+ protected String jdbcXA;
+
+ /** The transaction manager */
+ protected TransactionManager transactionManager;
+
+ /** Metadata repository */
+ protected MetadataRepository mdr;
+
+ /**
+ *
+ * Create a new AbstractDsDeployer.
+ *
+ */
+ public AbstractDsDeployer()
+ {
+ super();
+ }
+
+ /**
+ * Set the name for the JDBC Local resource adapter
+ * @param value The value
+ */
+ public void setJDBCLocal(String value)
+ {
+ jdbcLocal = value;
+ }
+
+ /**
+ * Get the name for the JDBC Local resource adapter
+ * @return The value
+ */
+ public String getJDBCLocal()
+ {
+ return jdbcLocal;
+ }
+
+ /**
+ * Set the name for the JDBC XA resource adapter
+ * @param value The value
+ */
+ public void setJDBCXA(String value)
+ {
+ jdbcXA = value;
+ }
+
+ /**
+ * Get the name for the JDBC Xa resource adapter
+ * @return The value
+ */
+ public String getJDBCXA()
+ {
+ return jdbcXA;
+ }
+
+ /**
+ * Set the transaction manager
+ * @param value The value
+ */
+ public void setTransactionManager(TransactionManager value)
+ {
+ transactionManager = value;
+ }
+
+ /**
+ * Get the transaction manager
+ * @return The value
+ */
+ public TransactionManager getTransactionManager()
+ {
+ return transactionManager;
+ }
+
+ /**
+ * Set the metadata repository
+ * @param value The value
+ */
+ public void setMetadataRepository(MetadataRepository value)
+ {
+ mdr = value;
+ }
+
+ /**
+ * Get the metadata repository
+ * @return The handle
+ */
+ public MetadataRepository getMetadataRepository()
+ {
+ return mdr;
+ }
+
+ /**
+ *
+ * create objects and inject value for this depployment. it is a general method returning a {@link CommonDeployment}
+ * to be used to exchange objects needed to real injection in the container
+ *
+ * @param url url
+ * @param deploymentName deploymentName
+ * @param parentClassLoader cl
+ * @param raDeployments resource adapters deployments
+ * @param dataSources datasources metadata defined in xml
+ * @return return the exchange POJO with value useful for injection in the container (fungal or AS)
+ * @throws DeployException DeployException
+ */
+ protected CommonDeployment createObjectsAndInjectValue(URL url, String deploymentName, Set<String> raDeployments,
+ DataSources dataSources, ClassLoader parentClassLoader) throws DeployException
+ {
+ try
+ {
+ URL urlJdbcLocal = null;
+ URL urlJdbcXA = null;
+
+ for (String s : raDeployments)
+ {
+ if (s.endsWith(jdbcLocal))
+ {
+ urlJdbcLocal = new URL(s);
+ }
+ else if (s.endsWith(jdbcXA))
+ {
+ urlJdbcXA = new URL(s);
+ }
+ }
+
+ List<Object> cfs = new ArrayList<Object>(1);
+ List<String> jndis = new ArrayList<String>(1);
+
+ if (urlJdbcLocal != null)
+ {
+ List<DataSource> ds = dataSources.getDataSource();
+ if (ds != null)
+ {
+ ClassLoader jdbcLocalDeploymentCl = getDeploymentCl(urlJdbcLocal);
+
+ for (DataSource dataSource : ds)
+ {
+ try
+ {
+ String jndiName = dataSource.getJndiName();
+
+ if (!jndiName.startsWith("java:/"))
+ jndiName = "java:/" + jndiName;
+
+ Object cf = deployDataSource(dataSource, jndiName, urlJdbcLocal, jdbcLocalDeploymentCl);
+
+ bindConnectionFactory(deploymentName, jndiName, cf);
+
+ cfs.add(cf);
+ jndis.add(jndiName);
+ }
+ catch (Throwable t)
+ {
+ log.error("Error during the deployment of " + dataSource.getJndiName(), t);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (dataSources.getDataSource() != null && dataSources.getDataSource().size() > 0)
+ log.error("Deployment of datasources disabled since jdbc-local.rar couldn't be found");
+ }
+
+ if (urlJdbcXA != null)
+ {
+ List<XaDataSource> xads = dataSources.getXaDataSource();
+ if (xads != null)
+ {
+ ClassLoader jdbcXADeploymentCl = getDeploymentCl(urlJdbcXA);
+
+ for (XaDataSource xaDataSource : xads)
+ {
+ try
+ {
+ String jndiName = xaDataSource.getJndiName();
+
+ if (!jndiName.startsWith("java:/"))
+ jndiName = "java:/" + jndiName;
+
+ Object cf = deployXADataSource(xaDataSource, jndiName, urlJdbcXA, jdbcXADeploymentCl);
+
+ bindConnectionFactory(deploymentName, jndiName, cf);
+
+ cfs.add(cf);
+ jndis.add(jndiName);
+ }
+ catch (Throwable t)
+ {
+ log.error("Error during the deployment of " + xaDataSource.getJndiName(), t);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (dataSources.getXaDataSource() != null && dataSources.getXaDataSource().size() > 0)
+ log.error("Deployment of XA datasources disabled since jdbc-xa.rar couldn't be found");
+ }
+
+ return new CommonDeployment(url, deploymentName, true, null, cfs.toArray(new Object[cfs.size()]),
+ parentClassLoader, log, jndis.toArray(new String[jndis.size()]));
+ }
+ catch (Throwable t)
+ {
+ throw new DeployException("Deployment " + url.toExternalForm() + " failed", t);
+ }
+ }
+
+ /**
+ * Deploy a datasource
+ * @param ds The datasource
+ * @param jndiName The JNDI name
+ * @param ra The resource adapter
+ * @param cl The class loader
+ * @return The connection factory
+ * @exception Throwable Thrown if an error occurs during deployment
+ */
+ private Object deployDataSource(DataSource ds, String jndiName, URL ra, ClassLoader cl) throws Throwable
+ {
+ log.debug("DataSource=" + ds);
+
+ Merger merger = new Merger();
+
+ Connector md = mdr.getResourceAdapter(ra.toExternalForm());
+ md = merger.mergeConnectorAndDs(ds, md);
+
+ // Get the first connection definition as there is only one
+ ResourceAdapter1516 ra1516 = (ResourceAdapter1516) md.getResourceadapter();
+ List<ConnectionDefinition> cds = ra1516.getOutboundResourceadapter().getConnectionDefinitions();
+ ConnectionDefinition cd = cds.get(0);
+
+ // ManagedConnectionFactory
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cd.getManagedConnectionFactoryClass()
+ .getValue(), cd.getConfigProperties(), cl);
+ // Create the pool
+ PoolConfiguration pc = createPoolConfiguration(ds.getPool(), ds.getTimeOut(), ds.getValidation());
+
+ PoolFactory pf = new PoolFactory();
+ Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, false);
+
+ // Connection manager properties
+ Integer allocationRetry = null;
+ Long allocationRetryWaitMillis = null;
+
+ if (ds.getTimeOut() != null)
+ {
+ allocationRetry = ds.getTimeOut().getAllocationRetry();
+ allocationRetryWaitMillis = ds.getTimeOut().getAllocationRetryWaitMillis();
+ }
+
+ // Select the correct connection manager
+ TransactionSupportLevel tsl = TransactionSupportLevel.LocalTransaction;
+ ConnectionManagerFactory cmf = new ConnectionManagerFactory();
+ ConnectionManager cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
+ getTransactionManager(), null, null, null, null, null);
+
+ cm.setJndiName(jndiName);
+
+ // ConnectionFactory
+ return mcf.createConnectionFactory(cm);
+ }
+
+ /**
+ * Deploy an XA datasource
+ * @param ds The datasource
+ * @param jndiName The JNDI name
+ * @param ra The resource adapter
+ * @param cl The class loader
+ * @return The connection factory
+ * @exception Throwable Thrown if an error occurs during deployment
+ */
+ private Object deployXADataSource(XaDataSource ds, String jndiName, URL ra, ClassLoader cl) throws Throwable
+ {
+ log.debug("XaDataSource=" + ds);
+
+ Merger merger = new Merger();
+
+ Connector md = mdr.getResourceAdapter(ra.toExternalForm());
+ md = merger.mergeConnectorAndDs(ds, md);
+
+ // Get the first connection definition as there is only one
+ ResourceAdapter1516 ra1516 = (ResourceAdapter1516) md.getResourceadapter();
+ List<ConnectionDefinition> cds = ra1516.getOutboundResourceadapter().getConnectionDefinitions();
+ ConnectionDefinition cd = cds.get(0);
+
+ // ManagedConnectionFactory
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cd.getManagedConnectionFactoryClass()
+ .getValue(), cd.getConfigProperties(), cl);
+ // Create the pool
+ PoolConfiguration pc = createPoolConfiguration(ds.getXaPool(), ds.getTimeOut(), ds.getValidation());
+
+ Boolean noTxSeparatePool = Boolean.FALSE;
+
+ if (ds.getXaPool() != null && ds.getXaPool().isNoTxSeparatePool() != null)
+ noTxSeparatePool = ds.getXaPool().isNoTxSeparatePool();
+
+ PoolFactory pf = new PoolFactory();
+ Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, noTxSeparatePool.booleanValue());
+
+ // Connection manager properties
+ Integer allocationRetry = null;
+ Long allocationRetryWaitMillis = null;
+ Boolean interleaving = null;
+ Integer xaResourceTimeout = null;
+ Boolean isSameRMOverride = null;
+ Boolean wrapXAResource = null;
+ Boolean padXid = null;
+
+ if (ds.getTimeOut() != null)
+ {
+ allocationRetry = ds.getTimeOut().getAllocationRetry();
+ allocationRetryWaitMillis = ds.getTimeOut().getAllocationRetryWaitMillis();
+ xaResourceTimeout = ds.getTimeOut().getXaResourceTimeout();
+ }
+
+ if (ds.getXaPool() != null)
+ {
+ interleaving = ds.getXaPool().isInterleaving();
+ isSameRMOverride = ds.getXaPool().isSameRmOverride();
+ wrapXAResource = ds.getXaPool().isWrapXaDataSource();
+ padXid = ds.getXaPool().isPadXid();
+ }
+
+ // Select the correct connection manager
+ TransactionSupportLevel tsl = TransactionSupportLevel.XATransaction;
+ ConnectionManagerFactory cmf = new ConnectionManagerFactory();
+ ConnectionManager cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
+ getTransactionManager(), interleaving, xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
+
+ cm.setJndiName(jndiName);
+
+ // ConnectionFactory
+ return mcf.createConnectionFactory(cm);
+ }
+
+ /**
+ * Create an instance of the pool configuration based on the input
+ * @param pp The pool parameters
+ * @param tp The timeout parameters
+ * @param vp The validation parameters
+ * @return The configuration
+ */
+ private PoolConfiguration createPoolConfiguration(CommonPool pp, CommonTimeOut tp, CommonValidation vp)
+ {
+ PoolConfiguration pc = new PoolConfiguration();
+
+ if (pp != null)
+ {
+ if (pp.getMinPoolSize() != null)
+ pc.setMinSize(pp.getMinPoolSize().intValue());
+
+ if (pp.getMaxPoolSize() != null)
+ pc.setMaxSize(pp.getMaxPoolSize().intValue());
+
+ if (pp.isPrefill() != null)
+ pc.setPrefill(pp.isPrefill());
+
+ if (pp.isUseStrictMin() != null)
+ pc.setStrictMin(pp.isUseStrictMin());
+ }
+
+ if (tp != null)
+ {
+ if (tp.getBlockingTimeoutMillis() != null)
+ pc.setBlockingTimeout(tp.getBlockingTimeoutMillis().longValue());
+
+ if (tp.getIdleTimeoutMinutes() != null)
+ pc.setIdleTimeout(tp.getIdleTimeoutMinutes().longValue());
+ }
+
+ if (vp != null)
+ {
+ if (vp.isBackgroundValidation() != null)
+ pc.setBackgroundValidation(vp.isBackgroundValidation().booleanValue());
+
+ if (vp.getBackgroundValidationMinutes() != null)
+ pc.setBackgroundValidationMinutes(vp.getBackgroundValidationMinutes().intValue());
+
+ if (vp.isUseFastFail() != null)
+ pc.setUseFastFail(vp.isUseFastFail());
+ }
+
+ return pc;
+ }
+
+ /**
+ *
+ * provide classloader of passed deployment url
+ *
+ * @param urlJdbcXA the url used to identify deployment
+ * @return the classloader used by this deployment
+ */
+ protected abstract ClassLoader getDeploymentCl(URL urlJdbcXA);
+
+ /**
+ * Bind connection factory into JNDI
+ * @param deployment The deployment name
+ * @param cf The connection factory
+ * @param jndi passed jndi name
+ * @return The JNDI names bound
+ * @exception Throwable Thrown if an error occurs
+ */
+ protected abstract String[] bindConnectionFactory(String deployment, String jndi, Object cf) throws Throwable;
+
+ /**
+ * Initialize and inject configuration properties
+ * @param className The fully qualified class name
+ * @param configs The configuration properties
+ * @param cl The class loader
+ * @return The object
+ * @throws DeployException Thrown if the object cant be initialized
+ */
+ protected abstract Object initAndInject(String className, List<? extends ConfigProperty> configs, ClassLoader cl)
+ throws DeployException;
+
+}
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 2010-10-15 17:08:22 UTC (rev 108607)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java 2010-10-15 18:25:24 UTC (rev 108608)
@@ -584,25 +584,32 @@
}
/**
- * Check if the resource adapter should be activated based on the ironjacamar.xml input
- * @param cmd cmd cmd The connector metadata
- * @param ijmd ijmd ijmd The IronJacamar metadata
- * @return True if the deployment should be activated; otherwise false
- */
- protected abstract boolean checkActivation(Connector cmd, IronJacamar ijmd);
+ *
+ * create objects and inject value for this depployment. it is a general method returning a {@link CommonDeployment}
+ * to be used to exchange objects needed to real injection in the container
+ *
+ * @param url url
+ * @param deploymentName deploymentName
+ * @param root root
+ * @param cl cl
+ * @param cmd connector md
+ * @param ijmd ironjacamar md
+ * @return return the exchange POJO with value useful for injection in the container (fungal or AS)
+ * @throws DeployException DeployException
+ * @throws ResourceException ResourceException
+ * @throws ValidatorException ValidatorException
+ * @throws AlreadyExistsException AlreadyExistsException
+ * @throws ClassNotFoundException ClassNotFoundException
+ * @throws Throwable Throwable
+ */
+ protected CommonDeployment createObjectsAndInjectValue(URL url, String deploymentName, File root, ClassLoader cl,
+ Connector cmd, IronJacamar ijmd) throws DeployException, ResourceException, ValidatorException,
+ AlreadyExistsException, ClassNotFoundException, Throwable
+ {
+ return createObjectsAndInjectValue(url, deploymentName, root, cl, cmd, ijmd, null);
+ }
/**
- * Initialize and inject configuration properties into container
- * @param value value
- * @param cpm confi properties
- * @param cl The class loader
- * @return The object
- * @throws DeployException DeployException Thrown if the object cant be initialized
- */
- protected abstract Object initAndInject(String value, List<? extends ConfigProperty> cpm, ClassLoader cl)
- throws DeployException;
-
- /**
*
* create objects and inject value for this depployment. it is a general method returning a {@link CommonDeployment}
* to be used to exchange objects needed to real injection in the container
@@ -613,6 +620,7 @@
* @param cl cl
* @param cmd connector md
* @param ijmd ironjacamar md
+ * @param raxml Resource Adapter from -ra.xml definition
* @return return the exchange POJO with value useful for injection in the container (fungal or AS)
* @throws DeployException DeployException
* @throws ResourceException ResourceException
@@ -622,8 +630,9 @@
* @throws Throwable Throwable
*/
protected CommonDeployment createObjectsAndInjectValue(URL url, String deploymentName, File root, ClassLoader cl,
- Connector cmd, IronJacamar ijmd) throws DeployException, ResourceException, ValidatorException,
- AlreadyExistsException, ClassNotFoundException, Throwable
+ Connector cmd, IronJacamar ijmd, org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml)
+ throws DeployException, ResourceException, ValidatorException, AlreadyExistsException, ClassNotFoundException,
+ Throwable
{
Set<Failure> failures = null;
try
@@ -685,7 +694,12 @@
if (activateDeployment)
{
CommonConnDef ijCD = null;
-
+ CommonConnDef cdRaXml = null;
+ if (raxml != null)
+ {
+ cdRaXml = findConnectionDefinition(ra10.getManagedConnectionFactoryClass().getValue(),
+ raxml.getConnectionDefinitions());
+ }
if (ijmd != null)
{
ijCD = findConnectionDefinition(ra10.getManagedConnectionFactoryClass().getValue(),
@@ -693,7 +707,7 @@
}
//
// if (ijmd == null || ijCD == null || ijCD.isEnabled())
- if (ijCD == null || ijCD.isEnabled())
+ if (ijCD == null || ijCD.isEnabled() || (cdRaXml != null && cdRaXml.isEnabled()))
{
ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(ra10
.getManagedConnectionFactoryClass().getValue(), ra10.getConfigProperties(), cl);
@@ -711,15 +725,32 @@
.getConfigProperties()));
beanValidationObjects.add(mcf);
associateResourceAdapter(resourceAdapter, mcf);
-
// Create the pool
- PoolConfiguration pc = createPoolConfiguration(ijCD != null ? ijCD.getPool() : null,
- ijCD != null ? ijCD.getTimeOut() : null, ijCD != null ? ijCD.getValidation() : null);
+ PoolConfiguration pc = null;
+ if (cdRaXml != null)
+ {
+ pc = createPoolConfiguration(cdRaXml.getPool(), cdRaXml.getTimeOut(), cdRaXml.getValidation());
+ }
+ else if (ijCD != null)
+ {
+ pc = createPoolConfiguration(ijCD.getPool(), ijCD.getTimeOut(), ijCD.getValidation());
+ }
+ else
+ {
+ // Default default settings
+ pc = createPoolConfiguration(null, null, null);
+ }
PoolFactory pf = new PoolFactory();
Boolean noTxSeparatePool = Boolean.FALSE;
+ if (cdRaXml != null && cdRaXml.getPool() != null && cdRaXml.isXa())
+ {
+ CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
- if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
+ if (ijXaPool != null)
+ noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
+ }
+ else if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
{
CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
@@ -734,9 +765,12 @@
ConnectionManager cm = null;
TransactionSupportEnum tsmd = TransactionSupportEnum.NoTransaction;
-
- if (ijmd != null && ijmd.getTransactionSupport() != null)
+ if (raxml != null && raxml.getTransactionSupport() != null)
{
+ tsmd = raxml.getTransactionSupport();
+ }
+ else if (ijmd != null && ijmd.getTransactionSupport() != null)
+ {
tsmd = ijmd.getTransactionSupport();
}
else
@@ -766,11 +800,19 @@
// Connection manager properties
Integer allocationRetry = null;
Long allocationRetryWaitMillis = null;
+ if (cdRaXml != null && cdRaXml.getTimeOut() != null)
+ {
+ allocationRetry = cdRaXml.getTimeOut().getAllocationRetry();
+ allocationRetryWaitMillis = cdRaXml.getTimeOut().getAllocationRetryWaitMillis();
+ }
if (ijCD != null && ijCD.getTimeOut() != null)
{
- allocationRetry = ijCD.getTimeOut().getAllocationRetry();
- allocationRetryWaitMillis = ijCD.getTimeOut().getAllocationRetryWaitMillis();
+ if (allocationRetry == null)
+ allocationRetry = ijCD.getTimeOut().getAllocationRetry();
+
+ if (allocationRetryWaitMillis == null)
+ allocationRetryWaitMillis = ijCD.getTimeOut().getAllocationRetryWaitMillis();
}
// Select the correct connection manager
@@ -785,17 +827,33 @@
Boolean isSameRMOverride = null;
Boolean wrapXAResource = null;
Boolean padXid = null;
+ if (cdRaXml != null && cdRaXml.isXa())
+ {
+ CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
+ interleaving = ijXaPool.isInterleaving();
+ isSameRMOverride = ijXaPool.isSameRmOverride();
+ wrapXAResource = ijXaPool.isWrapXaDataSource();
+ padXid = ijXaPool.isPadXid();
+ }
+
if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
{
CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
if (ijXaPool != null)
{
- interleaving = ijXaPool.isInterleaving();
- isSameRMOverride = ijXaPool.isSameRmOverride();
- wrapXAResource = ijXaPool.isWrapXaDataSource();
- padXid = ijXaPool.isPadXid();
+ if (interleaving == null)
+ interleaving = ijXaPool.isInterleaving();
+
+ if (isSameRMOverride == null)
+ isSameRMOverride = ijXaPool.isSameRmOverride();
+
+ if (wrapXAResource == null)
+ wrapXAResource = ijXaPool.isWrapXaDataSource();
+
+ if (padXid == null)
+ padXid = ijXaPool.isPadXid();
}
}
@@ -824,9 +882,13 @@
if (cf != null && cf instanceof Serializable && cf instanceof Referenceable)
{
- if (ijCD != null)
+ if (cdRaXml != null || ijCD != null)
{
- String jndiName = ijCD.getJndiName();
+ String jndiName;
+ if (cdRaXml != null)
+ jndiName = cdRaXml.getJndiName();
+ else
+ jndiName = ijCD.getJndiName();
bindConnectionFactory(url, deploymentName, cf, jndiName);
cfs = new Object[]{cf};
@@ -875,7 +937,13 @@
if (activateDeployment)
{
org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD = null;
+ org.jboss.jca.common.api.metadata.common.CommonConnDef cdRaXml = null;
+ if (raxml != null)
+ {
+ cdRaXml = findConnectionDefinition(cdMeta.getManagedConnectionFactoryClass()
+ .getValue(), raxml.getConnectionDefinitions());
+ }
if (ijmd != null)
{
ijCD = findConnectionDefinition(
@@ -885,7 +953,7 @@
// if (ijmd == null || ijCD == null || ijCD.isEnabled())
// {
- if (ijCD == null || ijCD.isEnabled())
+ if (ijCD == null || ijCD.isEnabled() || (cdRaXml != null && cdRaXml.isEnabled()))
{
ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cdMeta
.getManagedConnectionFactoryClass().getValue(), cdMeta.getConfigProperties(), cl);
@@ -903,17 +971,35 @@
cdMeta.getConfigProperties()));
beanValidationObjects.add(mcf);
associateResourceAdapter(resourceAdapter, mcf);
+ // Create the pool
+ PoolConfiguration pc = null;
+ if (cdRaXml != null && cdRaXml.getPool() != null)
+ {
+ pc = createPoolConfiguration(cdRaXml.getPool(), cdRaXml.getTimeOut(),
+ cdRaXml.getValidation());
+ }
+ else if (ijCD != null)
+ {
+ pc = createPoolConfiguration(ijCD.getPool(), ijCD.getTimeOut(),
+ ijCD.getValidation());
+ }
+ else
+ {
+ // Default default settings
+ pc = createPoolConfiguration(null, null, null);
+ }
- // Create the pool
- PoolConfiguration pc = createPoolConfiguration(ijCD != null ? ijCD.getPool() : null,
- ijCD != null ? ijCD.getTimeOut() : null, ijCD != null
- ? ijCD.getValidation()
- : null);
PoolFactory pf = new PoolFactory();
Boolean noTxSeparatePool = Boolean.FALSE;
+ if (cdRaXml != null && cdRaXml.getPool() != null && cdRaXml.isXa())
+ {
+ CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
- if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
+ if (ijXaPool != null)
+ noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
+ }
+ else if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
{
CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
@@ -929,9 +1015,12 @@
ConnectionManager cm = null;
TransactionSupportLevel tsl = TransactionSupportLevel.NoTransaction;
TransactionSupportEnum tsmd = TransactionSupportEnum.NoTransaction;
-
- if (ijmd != null && ijmd.getTransactionSupport() != null)
+ if (raxml != null && raxml.getTransactionSupport() != null)
{
+ tsmd = raxml.getTransactionSupport();
+ }
+ else if (ijmd != null && ijmd.getTransactionSupport() != null)
+ {
tsmd = ijmd.getTransactionSupport();
}
else
@@ -959,11 +1048,19 @@
// Connection manager properties
Integer allocationRetry = null;
Long allocationRetryWaitMillis = null;
+ if (cdRaXml != null && cdRaXml.getTimeOut() != null)
+ {
+ allocationRetry = cdRaXml.getTimeOut().getAllocationRetry();
+ allocationRetryWaitMillis = cdRaXml.getTimeOut().getAllocationRetryWaitMillis();
+ }
if (ijCD != null && ijCD.getTimeOut() != null)
{
- allocationRetry = ijCD.getTimeOut().getAllocationRetry();
- allocationRetryWaitMillis = ijCD.getTimeOut().getAllocationRetryWaitMillis();
+ if (allocationRetry == null)
+ allocationRetry = ijCD.getTimeOut().getAllocationRetry();
+
+ if (allocationRetryWaitMillis == null)
+ allocationRetryWaitMillis = ijCD.getTimeOut().getAllocationRetryWaitMillis();
}
// Select the correct connection manager
@@ -979,10 +1076,9 @@
Boolean isSameRMOverride = null;
Boolean wrapXAResource = null;
Boolean padXid = null;
-
- if (ijCD != null && ijCD.isXa())
+ if (cdRaXml != null && cdRaXml.isXa())
{
- CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
interleaving = ijXaPool.isInterleaving();
isSameRMOverride = ijXaPool.isSameRmOverride();
@@ -990,6 +1086,23 @@
padXid = ijXaPool.isPadXid();
}
+ if (ijCD != null && ijCD.isXa())
+ {
+ CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
+
+ if (interleaving == null)
+ interleaving = ijXaPool.isInterleaving();
+
+ if (isSameRMOverride == null)
+ isSameRMOverride = ijXaPool.isSameRmOverride();
+
+ if (wrapXAResource == null)
+ wrapXAResource = ijXaPool.isWrapXaDataSource();
+
+ if (padXid == null)
+ padXid = ijXaPool.isPadXid();
+ }
+
cm = cmf.createTransactional(tsl, pool, allocationRetry,
allocationRetryWaitMillis, getTransactionManager(), interleaving,
xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
@@ -1016,9 +1129,13 @@
if (cf != null && cf instanceof Serializable && cf instanceof Referenceable)
{
- if (ijCD != null)
+ if (cdRaXml != null || ijCD != null)
{
- String jndiName = ijCD.getJndiName();
+ String jndiName;
+ if (cdRaXml != null)
+ jndiName = cdRaXml.getJndiName();
+ else
+ jndiName = ijCD.getJndiName();
bindConnectionFactory(url, deploymentName, cf, jndiName);
cfs[cdIndex] = cf;
@@ -1107,8 +1224,14 @@
if (resourceAdapter != null)
{
String bootstrapIdentifier = null;
+ if (raxml != null && raxml.getBootstrapContext() != null &&
+ !raxml.getBootstrapContext().trim().equals(""))
+ {
+ bootstrapIdentifier = raxml.getBootstrapContext();
+ }
- if (ijmd != null)
+ if (bootstrapIdentifier == null && ijmd != null && ijmd.getBootstrapContext() != null &&
+ !ijmd.getBootstrapContext().trim().equals(""))
{
bootstrapIdentifier = ijmd.getBootstrapContext();
}
@@ -1219,4 +1342,23 @@
*/
protected abstract boolean checkConfigurationIsValid();
+ /**
+ * Check if the resource adapter should be activated based on the ironjacamar.xml input
+ * @param cmd cmd cmd The connector metadata
+ * @param ijmd ijmd ijmd The IronJacamar metadata
+ * @return True if the deployment should be activated; otherwise false
+ */
+ protected abstract boolean checkActivation(Connector cmd, IronJacamar ijmd);
+
+ /**
+ * Initialize and inject configuration properties into container
+ * @param value value
+ * @param cpm confi properties
+ * @param cl The class loader
+ * @return The object
+ * @throws DeployException DeployException Thrown if the object cant be initialized
+ */
+ protected abstract Object initAndInject(String value, List<? extends ConfigProperty> cpm, ClassLoader cl)
+ throws DeployException;
+
}
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java 2010-10-15 17:08:22 UTC (rev 108607)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java 2010-10-15 18:25:24 UTC (rev 108608)
@@ -22,43 +22,22 @@
package org.jboss.jca.deployers.fungal;
-import org.jboss.jca.common.api.metadata.common.CommonPool;
-import org.jboss.jca.common.api.metadata.common.CommonTimeOut;
-import org.jboss.jca.common.api.metadata.common.CommonValidation;
-import org.jboss.jca.common.api.metadata.ds.DataSource;
import org.jboss.jca.common.api.metadata.ds.DataSources;
-import org.jboss.jca.common.api.metadata.ds.XaDataSource;
import org.jboss.jca.common.api.metadata.ra.ConfigProperty;
-import org.jboss.jca.common.api.metadata.ra.ConnectionDefinition;
-import org.jboss.jca.common.api.metadata.ra.Connector;
-import org.jboss.jca.common.api.metadata.ra.ResourceAdapter1516;
import org.jboss.jca.common.metadata.ds.DsParser;
-import org.jboss.jca.common.metadata.merge.Merger;
-import org.jboss.jca.core.connectionmanager.ConnectionManager;
-import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
-import org.jboss.jca.core.connectionmanager.pool.api.Pool;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
import org.jboss.jca.core.naming.ExplicitJndiStrategy;
-import org.jboss.jca.core.spi.mdr.MetadataRepository;
import org.jboss.jca.core.spi.naming.JndiStrategy;
+import org.jboss.jca.deployers.common.AbstractDsDeployer;
+import org.jboss.jca.deployers.common.CommonDeployment;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import javax.resource.spi.ManagedConnectionFactory;
-import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
-import javax.transaction.TransactionManager;
-
-import org.jboss.logging.Logger;
-
import com.github.fungal.api.Kernel;
import com.github.fungal.api.util.Injection;
import com.github.fungal.spi.deployers.DeployException;
@@ -69,24 +48,11 @@
* The -ds.xml deployer for JCA/SJC
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
*/
-public final class DsXmlDeployer implements Deployer
+public final class DsXmlDeployer extends AbstractDsDeployer implements Deployer
{
- private static Logger log = Logger.getLogger(DsXmlDeployer.class);
- private static boolean trace = log.isTraceEnabled();
-
- private String jdbcLocal;
-
- private String jdbcXA;
-
- /** The transaction manager */
- private TransactionManager transactionManager;
-
- /** Metadata repository */
- private MetadataRepository mdr;
-
/** The kernel */
- private Kernel kernel;
+ Kernel kernel;
/**
* Constructor
@@ -101,78 +67,6 @@
}
/**
- * Set the name for the JDBC Local resource adapter
- * @param value The value
- */
- public void setJDBCLocal(String value)
- {
- jdbcLocal = value;
- }
-
- /**
- * Get the name for the JDBC Local resource adapter
- * @return The value
- */
- public String getJDBCLocal()
- {
- return jdbcLocal;
- }
-
- /**
- * Set the name for the JDBC XA resource adapter
- * @param value The value
- */
- public void setJDBCXA(String value)
- {
- jdbcXA = value;
- }
-
- /**
- * Get the name for the JDBC Xa resource adapter
- * @return The value
- */
- public String getJDBCXA()
- {
- return jdbcXA;
- }
-
- /**
- * Set the transaction manager
- * @param value The value
- */
- public void setTransactionManager(TransactionManager value)
- {
- transactionManager = value;
- }
-
- /**
- * Get the transaction manager
- * @return The value
- */
- public TransactionManager getTransactionManager()
- {
- return transactionManager;
- }
-
- /**
- * Set the metadata repository
- * @param value The value
- */
- public void setMetadataRepository(MetadataRepository value)
- {
- mdr = value;
- }
-
- /**
- * Get the metadata repository
- * @return The handle
- */
- public MetadataRepository getMetadataRepository()
- {
- return mdr;
- }
-
- /**
* Set the kernel
* @param value The value
*/
@@ -222,100 +116,9 @@
String deploymentName = f.getName();
Set<String> raDeployments = mdr.getResourceAdapters();
- URL urlJdbcLocal = null;
- URL urlJdbcXA = null;
+ CommonDeployment c = createObjectsAndInjectValue(url, deploymentName, raDeployments, dataSources, parent);
- for (String s : raDeployments)
- {
- if (s.endsWith(jdbcLocal))
- {
- urlJdbcLocal = new URL(s);
- }
- else if (s.endsWith(jdbcXA))
- {
- urlJdbcXA = new URL(s);
- }
- }
-
- List<Object> cfs = new ArrayList<Object>(1);
- List<String> jndis = new ArrayList<String>(1);
-
- if (urlJdbcLocal != null)
- {
- List<DataSource> ds = dataSources.getDataSource();
- if (ds != null)
- {
- Deployment jdbcLocalDeployment = kernel.getDeployment(urlJdbcLocal);
-
- for (DataSource dataSource : ds)
- {
- try
- {
- String jndiName = dataSource.getJndiName();
-
- if (!jndiName.startsWith("java:/"))
- jndiName = "java:/" + jndiName;
-
- Object cf = deployDataSource(dataSource, jndiName, urlJdbcLocal,
- jdbcLocalDeployment.getClassLoader());
-
- bindConnectionFactory(deploymentName, jndiName, cf);
-
- cfs.add(cf);
- jndis.add(jndiName);
- }
- catch (Throwable t)
- {
- log.error("Error during the deployment of " + dataSource.getJndiName(), t);
- }
- }
- }
- }
- else
- {
- if (dataSources.getDataSource() != null && dataSources.getDataSource().size() > 0)
- log.error("Deployment of datasources disabled since jdbc-local.rar couldn't be found");
- }
-
- if (urlJdbcXA != null)
- {
- List<XaDataSource> xads = dataSources.getXaDataSource();
- if (xads != null)
- {
- Deployment jdbcXADeployment = kernel.getDeployment(urlJdbcXA);
-
- for (XaDataSource xaDataSource : xads)
- {
- try
- {
- String jndiName = xaDataSource.getJndiName();
-
- if (!jndiName.startsWith("java:/"))
- jndiName = "java:/" + jndiName;
-
- Object cf = deployXADataSource(xaDataSource, jndiName, urlJdbcXA,
- jdbcXADeployment.getClassLoader());
-
- bindConnectionFactory(deploymentName, jndiName, cf);
-
- cfs.add(cf);
- jndis.add(jndiName);
- }
- catch (Throwable t)
- {
- log.error("Error during the deployment of " + xaDataSource.getJndiName(), t);
- }
- }
- }
- }
- else
- {
- if (dataSources.getXaDataSource() != null && dataSources.getXaDataSource().size() > 0)
- log.error("Deployment of XA datasources disabled since jdbc-xa.rar couldn't be found");
- }
-
- return new DsXmlDeployment(url, deploymentName, cfs.toArray(new Object[cfs.size()]),
- jndis.toArray(new String[jndis.size()]), parent);
+ return new DsXmlDeployment(c.getURL(), c.getDeploymentName(), c.getCfs(), c.getJndiNames(), c.getCl());
}
catch (DeployException de)
{
@@ -345,192 +148,16 @@
}
/**
- * Deploy a datasource
- * @param ds The datasource
- * @param jndiName The JNDI name
- * @param ra The resource adapter
- * @param cl The class loader
- * @return The connection factory
- * @exception Throwable Thrown if an error occurs during deployment
- */
- private Object deployDataSource(DataSource ds, String jndiName, URL ra, ClassLoader cl) throws Throwable
- {
- log.debug("DataSource=" + ds);
-
- Merger merger = new Merger();
-
- Connector md = mdr.getResourceAdapter(ra.toExternalForm());
- md = merger.mergeConnectorAndDs(ds, md);
-
- // Get the first connection definition as there is only one
- ResourceAdapter1516 ra1516 = (ResourceAdapter1516) md.getResourceadapter();
- List<ConnectionDefinition> cds = ra1516.getOutboundResourceadapter().getConnectionDefinitions();
- ConnectionDefinition cd = cds.get(0);
-
- // ManagedConnectionFactory
- ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cd.getManagedConnectionFactoryClass()
- .getValue(), cd.getConfigProperties(), cl);
- // Create the pool
- PoolConfiguration pc = createPoolConfiguration(ds.getPool(), ds.getTimeOut(), ds.getValidation());
-
- PoolFactory pf = new PoolFactory();
- Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, false);
-
- // Connection manager properties
- Integer allocationRetry = null;
- Long allocationRetryWaitMillis = null;
-
- if (ds.getTimeOut() != null)
- {
- allocationRetry = ds.getTimeOut().getAllocationRetry();
- allocationRetryWaitMillis = ds.getTimeOut().getAllocationRetryWaitMillis();
- }
-
- // Select the correct connection manager
- TransactionSupportLevel tsl = TransactionSupportLevel.LocalTransaction;
- ConnectionManagerFactory cmf = new ConnectionManagerFactory();
- ConnectionManager cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
- getTransactionManager(), null, null, null, null, null);
-
- cm.setJndiName(jndiName);
-
- // ConnectionFactory
- return mcf.createConnectionFactory(cm);
- }
-
- /**
- * Deploy an XA datasource
- * @param ds The datasource
- * @param jndiName The JNDI name
- * @param ra The resource adapter
- * @param cl The class loader
- * @return The connection factory
- * @exception Throwable Thrown if an error occurs during deployment
- */
- private Object deployXADataSource(XaDataSource ds, String jndiName, URL ra, ClassLoader cl) throws Throwable
- {
- log.debug("XaDataSource=" + ds);
-
- Merger merger = new Merger();
-
- Connector md = mdr.getResourceAdapter(ra.toExternalForm());
- md = merger.mergeConnectorAndDs(ds, md);
-
- // Get the first connection definition as there is only one
- ResourceAdapter1516 ra1516 = (ResourceAdapter1516) md.getResourceadapter();
- List<ConnectionDefinition> cds = ra1516.getOutboundResourceadapter().getConnectionDefinitions();
- ConnectionDefinition cd = cds.get(0);
-
- // ManagedConnectionFactory
- ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cd.getManagedConnectionFactoryClass()
- .getValue(), cd.getConfigProperties(), cl);
- // Create the pool
- PoolConfiguration pc = createPoolConfiguration(ds.getXaPool(), ds.getTimeOut(), ds.getValidation());
-
- Boolean noTxSeparatePool = Boolean.FALSE;
-
- if (ds.getXaPool() != null && ds.getXaPool().isNoTxSeparatePool() != null)
- noTxSeparatePool = ds.getXaPool().isNoTxSeparatePool();
-
- PoolFactory pf = new PoolFactory();
- Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, noTxSeparatePool.booleanValue());
-
- // Connection manager properties
- Integer allocationRetry = null;
- Long allocationRetryWaitMillis = null;
- Boolean interleaving = null;
- Integer xaResourceTimeout = null;
- Boolean isSameRMOverride = null;
- Boolean wrapXAResource = null;
- Boolean padXid = null;
-
- if (ds.getTimeOut() != null)
- {
- allocationRetry = ds.getTimeOut().getAllocationRetry();
- allocationRetryWaitMillis = ds.getTimeOut().getAllocationRetryWaitMillis();
- xaResourceTimeout = ds.getTimeOut().getXaResourceTimeout();
- }
-
- if (ds.getXaPool() != null)
- {
- interleaving = ds.getXaPool().isInterleaving();
- isSameRMOverride = ds.getXaPool().isSameRmOverride();
- wrapXAResource = ds.getXaPool().isWrapXaDataSource();
- padXid = ds.getXaPool().isPadXid();
- }
-
- // Select the correct connection manager
- TransactionSupportLevel tsl = TransactionSupportLevel.XATransaction;
- ConnectionManagerFactory cmf = new ConnectionManagerFactory();
- ConnectionManager cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
- getTransactionManager(), interleaving, xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
-
- cm.setJndiName(jndiName);
-
- // ConnectionFactory
- return mcf.createConnectionFactory(cm);
- }
-
- /**
- * Create an instance of the pool configuration based on the input
- * @param pp The pool parameters
- * @param tp The timeout parameters
- * @param vp The validation parameters
- * @return The configuration
- */
- private PoolConfiguration createPoolConfiguration(CommonPool pp, CommonTimeOut tp, CommonValidation vp)
- {
- PoolConfiguration pc = new PoolConfiguration();
-
- if (pp != null)
- {
- if (pp.getMinPoolSize() != null)
- pc.setMinSize(pp.getMinPoolSize().intValue());
-
- if (pp.getMaxPoolSize() != null)
- pc.setMaxSize(pp.getMaxPoolSize().intValue());
-
- if (pp.isPrefill() != null)
- pc.setPrefill(pp.isPrefill());
-
- if (pp.isUseStrictMin() != null)
- pc.setStrictMin(pp.isUseStrictMin());
- }
-
- if (tp != null)
- {
- if (tp.getBlockingTimeoutMillis() != null)
- pc.setBlockingTimeout(tp.getBlockingTimeoutMillis().longValue());
-
- if (tp.getIdleTimeoutMinutes() != null)
- pc.setIdleTimeout(tp.getIdleTimeoutMinutes().longValue());
- }
-
- if (vp != null)
- {
- if (vp.isBackgroundValidation() != null)
- pc.setBackgroundValidation(vp.isBackgroundValidation().booleanValue());
-
- if (vp.getBackgroundValidationMinutes() != null)
- pc.setBackgroundValidationMinutes(vp.getBackgroundValidationMinutes().intValue());
-
- if (vp.isUseFastFail() != null)
- pc.setUseFastFail(vp.isUseFastFail());
- }
-
- return pc;
- }
-
- /**
* Initialize and inject configuration properties
* @param className The fully qualified class name
* @param configs The configuration properties
* @param cl The class loader
* @return The object
- * @throws DeployException Thrown if the object cant be initialized
+ * @throws org.jboss.jca.deployers.common.DeployException Thrown if the object cant be initialized
*/
- private Object initAndInject(String className, List<? extends ConfigProperty> configs, ClassLoader cl)
- throws DeployException
+ @Override
+ public Object initAndInject(String className, List<? extends ConfigProperty> configs, ClassLoader cl)
+ throws org.jboss.jca.deployers.common.DeployException
{
try
{
@@ -552,7 +179,7 @@
}
catch (Throwable t)
{
- throw new DeployException("Deployment " + className + " failed", t);
+ throw new org.jboss.jca.deployers.common.DeployException("Deployment " + className + " failed", t);
}
}
@@ -562,9 +189,10 @@
* @param jndi The JNDI name
* @param cf The connection factory
* @return The JNDI names bound
- * @exception Exception thrown if an error occurs
+ * @throws Throwable thrown if an error occurs
*/
- private String[] bindConnectionFactory(String deployment, String jndi, Object cf) throws Throwable
+ @Override
+ protected String[] bindConnectionFactory(String deployment, String jndi, Object cf) throws Throwable
{
JndiStrategy js = new ExplicitJndiStrategy();
@@ -585,4 +213,10 @@
if (kernel == null)
throw new IllegalStateException("Kernel not defined");
}
+
+ @Override
+ protected ClassLoader getDeploymentCl(URL urlJdbc)
+ {
+ return kernel.getDeployment(urlJdbc).getClassLoader();
+ }
}
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 2010-10-15 17:08:22 UTC (rev 108607)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java 2010-10-15 18:25:24 UTC (rev 108608)
@@ -33,7 +33,6 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.jboss.logging.Logger;
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java 2010-10-15 17:08:22 UTC (rev 108607)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java 2010-10-15 18:25:24 UTC (rev 108608)
@@ -22,51 +22,24 @@
package org.jboss.jca.deployers.fungal;
-import org.jboss.jca.common.api.metadata.common.CommonXaPool;
-import org.jboss.jca.common.api.metadata.common.TransactionSupportEnum;
import org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar;
-import org.jboss.jca.common.api.metadata.ra.AdminObject;
-import org.jboss.jca.common.api.metadata.ra.ConfigProperty;
import org.jboss.jca.common.api.metadata.ra.Connector;
-import org.jboss.jca.common.api.metadata.ra.Connector.Version;
-import org.jboss.jca.common.api.metadata.ra.MessageListener;
-import org.jboss.jca.common.api.metadata.ra.ResourceAdapter1516;
-import org.jboss.jca.common.api.metadata.ra.ra10.ResourceAdapter10;
import org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapters;
import org.jboss.jca.common.metadata.merge.Merger;
import org.jboss.jca.common.metadata.resourceadapter.ResourceAdapterParser;
-import org.jboss.jca.core.connectionmanager.ConnectionManager;
-import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
-import org.jboss.jca.core.connectionmanager.pool.api.Pool;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
import org.jboss.jca.core.spi.mdr.MetadataRepository;
-import org.jboss.jca.deployers.common.BeanValidation;
-import org.jboss.jca.validator.Failure;
-import org.jboss.jca.validator.Key;
-import org.jboss.jca.validator.Severity;
-import org.jboss.jca.validator.Validate;
-import org.jboss.jca.validator.ValidateObject;
-import org.jboss.jca.validator.Validator;
-import org.jboss.jca.validator.ValidatorException;
+import org.jboss.jca.core.spi.naming.JndiStrategy;
+import org.jboss.jca.deployers.common.CommonDeployment;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import javax.resource.Referenceable;
-import javax.resource.spi.ManagedConnectionFactory;
-import javax.resource.spi.TransactionSupport;
-import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
-
import org.jboss.logging.Logger;
import com.github.fungal.api.Kernel;
@@ -92,8 +65,6 @@
{
private static Logger log = Logger.getLogger(RaXmlDeployer.class);
- private static boolean trace = log.isTraceEnabled();
-
/** The kernel */
private Kernel kernel;
@@ -279,8 +250,6 @@
private Deployment doDeploy(URL url, org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml,
ClassLoader parent) throws DeployException
{
- Set<Failure> failures = null;
-
ClassLoader oldTCCL = SecurityActions.getThreadContextClassLoader();
try
{
@@ -319,641 +288,31 @@
}
SecurityActions.setThreadContextClassLoader(cl);
- javax.resource.spi.ResourceAdapter resourceAdapter = null;
- List<Validate> archiveValidationObjects = new ArrayList<Validate>();
- List<Failure> partialFailures = null;
- List<Object> beanValidationObjects = new ArrayList<Object>();
-
String deploymentName = archive.substring(0, archive.indexOf(".rar"));
- Object[] cfs = null;
- String[] jndiNames = null;
- // Create objects and inject values
- if (cmd != null)
- {
- // ResourceAdapter
- if (cmd.getVersion() != Version.V_10)
- {
- ResourceAdapter1516 ra1516 = (ResourceAdapter1516) cmd.getResourceadapter();
- if (ra1516 != null && ra1516.getResourceadapterClass() != null)
- {
- resourceAdapter = (javax.resource.spi.ResourceAdapter) initAndInject(
- ra1516.getResourceadapterClass(), ra1516.getConfigProperties(), cl);
-
- if (trace)
- {
- log.trace("ResourceAdapter: " + resourceAdapter.getClass().getName());
- log.trace("ResourceAdapter defined in classloader: " +
- resourceAdapter.getClass().getClassLoader());
- }
-
- archiveValidationObjects.add(new ValidateObject(Key.RESOURCE_ADAPTER, resourceAdapter, ra1516
- .getConfigProperties()));
- beanValidationObjects.add(resourceAdapter);
- }
- }
-
- // ManagedConnectionFactory
- if (cmd.getVersion() == Version.V_10)
- {
-
- org.jboss.jca.common.api.metadata.common.CommonConnDef cdRaXml = findConnectionDefinition(
- ((ResourceAdapter10) cmd.getResourceadapter()).getManagedConnectionFactoryClass().getValue(),
- raxml.getConnectionDefinitions());
-
- if (cdRaXml != null && cdRaXml.isEnabled())
- {
- ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(
- ((ResourceAdapter10) cmd.getResourceadapter()).getManagedConnectionFactoryClass().getValue(),
- ((ResourceAdapter10) cmd.getResourceadapter()).getConfigProperties(), cl);
-
- if (trace)
- {
- log.trace("ManagedConnectionFactory: " + mcf.getClass().getName());
- log.trace("ManagedConnectionFactory defined in classloader: " + mcf.getClass().getClassLoader());
- }
-
- org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD = null;
-
- if (ijmd != null)
- {
- ijCD = findConnectionDefinition(mcf.getClass().getName(), ijmd.getConnectionDefinitions());
- }
-
- mcf.setLogWriter(new PrintWriter(((RAConfiguration) getConfiguration()).getPrintStream()));
-
- archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY, mcf,
- ((ResourceAdapter10) cmd.getResourceadapter())
- .getConfigProperties()));
- beanValidationObjects.add(mcf);
- associateResourceAdapter(resourceAdapter, mcf);
-
- // Create the pool
- PoolConfiguration pc = null;
-
- if (cdRaXml.getPool() != null || cdRaXml.getPool() != null || cdRaXml.getPool() != null)
- {
- pc = createPoolConfiguration(cdRaXml.getPool(), cdRaXml.getTimeOut(), cdRaXml.getValidation());
- }
- else if (ijCD != null)
- {
- pc = createPoolConfiguration(ijCD.getPool(), ijCD.getTimeOut(), ijCD.getValidation());
- }
- else
- {
- // Default default settings
- pc = createPoolConfiguration(null, null, null);
- }
-
- PoolFactory pf = new PoolFactory();
-
- Boolean noTxSeparatePool = Boolean.FALSE;
-
- if (cdRaXml.getPool() != null && cdRaXml.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
-
- if (ijXaPool != null)
- noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
- }
- else if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
-
- if (ijXaPool != null)
- noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
- }
-
- Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, noTxSeparatePool.booleanValue());
-
- // Add a connection manager
- ConnectionManagerFactory cmf = new ConnectionManagerFactory();
- ConnectionManager cm = null;
-
- TransactionSupportLevel tsl = TransactionSupportLevel.NoTransaction;
- TransactionSupportEnum tsmd = TransactionSupportEnum.NoTransaction;
-
- if (raxml.getTransactionSupport() != null)
- {
- tsmd = raxml.getTransactionSupport();
- }
- else if (ijmd != null && ijmd.getTransactionSupport() != null)
- {
- tsmd = ijmd.getTransactionSupport();
- }
- else
- {
- tsmd = ((ResourceAdapter10) cmd.getResourceadapter()).getTransactionSupport();
- }
-
- if (tsmd == TransactionSupportEnum.NoTransaction)
- {
- tsl = TransactionSupportLevel.NoTransaction;
- }
- else if (tsmd == TransactionSupportEnum.LocalTransaction)
- {
- tsl = TransactionSupportLevel.LocalTransaction;
- }
- else if (tsmd == TransactionSupportEnum.XATransaction)
- {
- tsl = TransactionSupportLevel.XATransaction;
- }
-
- // Section 7.13 -- Read from metadata -> overwrite with specified value if present
- if (mcf instanceof TransactionSupport)
- tsl = ((TransactionSupport) mcf).getTransactionSupport();
-
- // Connection manager properties
- Integer allocationRetry = null;
- Long allocationRetryWaitMillis = null;
-
- if (cdRaXml.getTimeOut() != null)
- {
- allocationRetry = cdRaXml.getTimeOut().getAllocationRetry();
- allocationRetryWaitMillis = cdRaXml.getTimeOut().getAllocationRetryWaitMillis();
- }
-
- if (ijCD != null && ijCD.getTimeOut() != null)
- {
- if (allocationRetry == null)
- allocationRetry = ijCD.getTimeOut().getAllocationRetry();
-
- if (allocationRetryWaitMillis == null)
- allocationRetryWaitMillis = ijCD.getTimeOut().getAllocationRetryWaitMillis();
- }
-
- // Select the correct connection manager
- if (tsl == TransactionSupportLevel.NoTransaction)
- {
- cm = cmf.createNonTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis);
- }
- else
- {
- Boolean interleaving = null;
- Integer xaResourceTimeout = null;
- Boolean isSameRMOverride = null;
- Boolean wrapXAResource = null;
- Boolean padXid = null;
-
- if (cdRaXml.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
-
- interleaving = ijXaPool.isInterleaving();
- isSameRMOverride = ijXaPool.isSameRmOverride();
- wrapXAResource = ijXaPool.isWrapXaDataSource();
- padXid = ijXaPool.isPadXid();
- }
-
- if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
-
- if (ijXaPool != null)
- {
- if (interleaving == null)
- interleaving = ijXaPool.isInterleaving();
-
- if (isSameRMOverride == null)
- isSameRMOverride = ijXaPool.isSameRmOverride();
-
- if (wrapXAResource == null)
- wrapXAResource = ijXaPool.isWrapXaDataSource();
-
- if (padXid == null)
- padXid = ijXaPool.isPadXid();
- }
- }
-
- cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
- ((RAConfiguration) getConfiguration()).getTransactionManager(), interleaving,
- xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
- }
-
- // ConnectionFactory
- Object cf = mcf.createConnectionFactory(cm);
-
- if (cf == null)
- {
- log.error("ConnectionFactory is null");
- }
- else
- {
- if (trace)
- {
- log.trace("ConnectionFactory: " + cf.getClass().getName());
- log.trace("ConnectionFactory defined in classloader: " + cf.getClass().getClassLoader());
- }
- }
-
- archiveValidationObjects.add(new ValidateObject(Key.CONNECTION_FACTORY, cf));
-
- if (cf != null && cf instanceof Serializable && cf instanceof Referenceable)
- {
- org.jboss.jca.common.api.metadata.common.CommonConnDef cd = findConnectionDefinition(mcf
- .getClass().getName(), raxml.getConnectionDefinitions());
-
- String jndiName = cd.getJndiName();
-
- bindConnectionFactory(deployment, deploymentName, cf, jndiName);
- cfs = new Object[]{cf};
- jndiNames = new String[]{jndiName};
-
- cm.setJndiName(jndiName);
- }
- }
- }
- else
- {
- ResourceAdapter1516 ra = (ResourceAdapter1516) cmd.getResourceadapter();
- if (ra != null && ra.getOutboundResourceadapter() != null &&
- ra.getOutboundResourceadapter().getConnectionDefinitions() != null)
- {
- List<org.jboss.jca.common.api.metadata.ra.ConnectionDefinition> cdMetas = ra
- .getOutboundResourceadapter().getConnectionDefinitions();
-
- if (cdMetas.size() > 0)
- {
- 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);
-
- org.jboss.jca.common.api.metadata.common.CommonConnDef cdRaXml = findConnectionDefinition(
- cdMeta.getManagedConnectionFactoryClass().getValue(), raxml.getConnectionDefinitions());
-
- if (cdRaXml != null && cdRaXml.isEnabled())
- {
- ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cdMeta
- .getManagedConnectionFactoryClass().getValue(), cdMeta.getConfigProperties(), cl);
-
- if (trace)
- {
- log.trace("ManagedConnectionFactory: " + mcf.getClass().getName());
- log.trace("ManagedConnectionFactory defined in classloader: " +
- mcf.getClass().getClassLoader());
- }
-
- org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD = null;
-
- if (ijmd != null)
- {
- ijCD = findConnectionDefinition(mcf.getClass().getName(),
- ijmd.getConnectionDefinitions());
- }
-
- mcf.setLogWriter(new PrintWriter(((RAConfiguration) getConfiguration()).getPrintStream()));
-
- archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY, mcf,
- cdMeta.getConfigProperties()));
- beanValidationObjects.add(mcf);
- associateResourceAdapter(resourceAdapter, mcf);
-
- // Create the pool
- PoolConfiguration pc = null;
-
- if (cdRaXml.getPool() != null || cdRaXml.getPool() != null || cdRaXml.getPool() != null)
- {
- pc = createPoolConfiguration(cdRaXml.getPool(), cdRaXml.getTimeOut(),
- cdRaXml.getValidation());
- }
- else if (ijCD != null)
- {
- pc = createPoolConfiguration(ijCD.getPool(), ijCD.getTimeOut(), ijCD.getValidation());
- }
- else
- {
- // Default default settings
- pc = createPoolConfiguration(null, null, null);
- }
-
- PoolFactory pf = new PoolFactory();
-
- Boolean noTxSeparatePool = Boolean.FALSE;
-
- if (cdRaXml.getPool() != null && cdRaXml.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
-
- if (ijXaPool != null)
- noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
- }
- else if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
-
- if (ijXaPool != null)
- noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
- }
-
- Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, noTxSeparatePool.booleanValue());
-
- // Add a connection manager
- ConnectionManagerFactory cmf = new ConnectionManagerFactory();
- ConnectionManager cm = null;
- TransactionSupportLevel tsl = TransactionSupportLevel.NoTransaction;
- TransactionSupportEnum tsmd = TransactionSupportEnum.NoTransaction;
-
- if (raxml.getTransactionSupport() != null)
- {
- tsmd = raxml.getTransactionSupport();
- }
- else if (ijmd != null && ijmd.getTransactionSupport() != null)
- {
- tsmd = ijmd.getTransactionSupport();
- }
- else
- {
- tsmd = ra.getOutboundResourceadapter().getTransactionSupport();
- }
-
- if (tsmd == TransactionSupportEnum.NoTransaction)
- {
- tsl = TransactionSupportLevel.NoTransaction;
- }
- else if (tsmd == TransactionSupportEnum.LocalTransaction)
- {
- tsl = TransactionSupportLevel.LocalTransaction;
- }
- else if (tsmd == TransactionSupportEnum.XATransaction)
- {
- tsl = TransactionSupportLevel.XATransaction;
- }
-
- // Section 7.13 -- Read from metadata -> overwrite with specified value if present
- if (mcf instanceof TransactionSupport)
- tsl = ((TransactionSupport) mcf).getTransactionSupport();
-
- // Connection manager properties
- Integer allocationRetry = null;
- Long allocationRetryWaitMillis = null;
-
- if (cdRaXml.getTimeOut() != null)
- {
- allocationRetry = cdRaXml.getTimeOut().getAllocationRetry();
- allocationRetryWaitMillis = cdRaXml.getTimeOut().getAllocationRetryWaitMillis();
- }
-
- if (ijCD != null && ijCD.getTimeOut() != null)
- {
- if (allocationRetry == null)
- allocationRetry = ijCD.getTimeOut().getAllocationRetry();
-
- if (allocationRetryWaitMillis == null)
- allocationRetryWaitMillis = ijCD.getTimeOut().getAllocationRetryWaitMillis();
- }
-
- // Select the correct connection manager
- if (tsl == TransactionSupportLevel.NoTransaction)
- {
- cm = cmf.createNonTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis);
- }
- else
- {
- Boolean interleaving = null;
- Integer xaResourceTimeout = null;
- Boolean isSameRMOverride = null;
- Boolean wrapXAResource = null;
- Boolean padXid = null;
-
- if (cdRaXml.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
-
- interleaving = ijXaPool.isInterleaving();
- isSameRMOverride = ijXaPool.isSameRmOverride();
- wrapXAResource = ijXaPool.isWrapXaDataSource();
- padXid = ijXaPool.isPadXid();
- }
-
- if (ijCD != null && ijCD.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
-
- if (interleaving == null)
- interleaving = ijXaPool.isInterleaving();
-
- if (isSameRMOverride == null)
- isSameRMOverride = ijXaPool.isSameRmOverride();
-
- if (wrapXAResource == null)
- wrapXAResource = ijXaPool.isWrapXaDataSource();
-
- if (padXid == null)
- padXid = ijXaPool.isPadXid();
- }
-
- cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
- ((RAConfiguration) getConfiguration()).getTransactionManager(), interleaving,
- xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
- }
-
- // ConnectionFactory
- Object cf = mcf.createConnectionFactory(cm);
-
- if (cf == null)
- {
- log.error("ConnectionFactory is null");
- }
- else
- {
- if (trace)
- {
- log.trace("ConnectionFactory: " + cf.getClass().getName());
- log.trace("ConnectionFactory defined in classloader: " +
- cf.getClass().getClassLoader());
- }
- }
-
- archiveValidationObjects.add(new ValidateObject(Key.CONNECTION_FACTORY, cf));
-
- if (cf != null && cf instanceof Serializable && cf instanceof Referenceable)
- {
- String jndiName = cdRaXml.getJndiName();
-
- bindConnectionFactory(deployment, deploymentName, cf, jndiName);
- cfs[cdIndex] = cf;
- jndiNames[cdIndex] = jndiName;
-
- cm.setJndiName(jndiName);
- }
- }
- }
- }
- }
- }
-
- // ActivationSpec
- if (cmd.getVersion() != Version.V_10)
- {
- ResourceAdapter1516 ra1516 = (ResourceAdapter1516) cmd.getResourceadapter();
- if (ra1516 != null && ra1516.getInboundResourceadapter() != null &&
- ra1516.getInboundResourceadapter().getMessageadapter() != null &&
- ra1516.getInboundResourceadapter().getMessageadapter().getMessagelisteners() != null)
- {
- List<MessageListener> mlMetas = ra1516.getInboundResourceadapter().getMessageadapter()
- .getMessagelisteners();
-
- if (mlMetas.size() > 0)
- {
- for (MessageListener mlMeta : mlMetas)
- {
- if (mlMeta.getActivationspec() != null &&
- mlMeta.getActivationspec().getActivationspecClass().getValue() != null)
- {
- List<? extends ConfigProperty> cpm = mlMeta.getActivationspec().getConfigProperties();
-
- Object o = initAndInject(mlMeta.getActivationspec().getActivationspecClass().getValue(),
- cpm, cl);
-
- if (trace)
- {
- log.trace("ActivationSpec: " + o.getClass().getName());
- log.trace("ActivationSpec defined in classloader: " + o.getClass().getClassLoader());
- }
-
- archiveValidationObjects.add(new ValidateObject(Key.ACTIVATION_SPEC, o, cpm));
- beanValidationObjects.add(o);
- associateResourceAdapter(resourceAdapter, o);
- }
- }
- }
- }
- }
-
- // AdminObject
- if (cmd.getVersion() != Version.V_10)
- {
- ResourceAdapter1516 ra1516 = (ResourceAdapter1516) cmd.getResourceadapter();
- if (ra1516 != null && ra1516.getAdminObjects() != null)
- {
- List<AdminObject> aoMetas = ((ResourceAdapter1516) cmd.getResourceadapter()).getAdminObjects();
- if (aoMetas.size() > 0)
- {
- for (AdminObject aoMeta : aoMetas)
- {
- if (aoMeta.getAdminobjectClass() != null && aoMeta.getAdminobjectClass().getValue() != null)
- {
- Object o = initAndInject(aoMeta.getAdminobjectClass().getValue(),
- aoMeta.getConfigProperties(), cl);
-
- if (trace)
- {
- log.trace("AdminObject: " + o.getClass().getName());
- log.trace("AdminObject defined in classloader: " + o.getClass().getClassLoader());
- }
-
- archiveValidationObjects.add(new ValidateObject(Key.ADMIN_OBJECT, o, aoMeta
- .getConfigProperties()));
- beanValidationObjects.add(o);
- }
- }
- }
- }
- }
- }
-
- // Archive validation
- failures = validateArchive(url, archiveValidationObjects, failures);
-
- if ((((RAConfiguration) getConfiguration()).getArchiveValidationFailOnWarn() && hasFailuresLevel(failures,
- Severity.WARNING)) ||
- (((RAConfiguration) getConfiguration()).getArchiveValidationFailOnError() && hasFailuresLevel(failures,
- Severity.ERROR)))
- {
- throw new ValidatorException(printFailuresLog(url.getPath(), new Validator(), failures, null), failures);
- }
- else
- {
- printFailuresLog(url.getPath(), new Validator(), failures, null);
- }
-
- // Bean validation
- if (((RAConfiguration) getConfiguration()).getBeanValidation())
- {
- List<Class> groupsClasses = null;
-
- if (raxml.getBeanValidationGroups() != null && raxml.getBeanValidationGroups().size() > 0)
- {
- List<String> groups = raxml.getBeanValidationGroups();
-
- groupsClasses = new ArrayList<Class>(groups.size());
- for (String group : groups)
- {
- groupsClasses.add(Class.forName(group, true, cl));
- }
- }
-
- if (groupsClasses == null && ijmd != null && ijmd.getBeanValidationGroups() != null &&
- ijmd.getBeanValidationGroups().size() > 0)
- {
- List<String> groups = ijmd.getBeanValidationGroups();
-
- groupsClasses = new ArrayList<Class>(groups.size());
- for (String group : groups)
- {
- groupsClasses.add(Class.forName(group, true, cl));
- }
- }
-
- if (beanValidationObjects.size() > 0)
- {
- BeanValidation beanValidator = new BeanValidation();
- for (Object o : beanValidationObjects)
- {
- beanValidator.validate(o, groupsClasses);
- }
- }
- }
-
- // Activate deployment
- if (resourceAdapter != null)
- {
- String bootstrapIdentifier = null;
-
- if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().trim().equals(""))
- {
- bootstrapIdentifier = raxml.getBootstrapContext();
- }
-
- if (bootstrapIdentifier == null && ijmd != null && ijmd.getBootstrapContext() != null &&
- !ijmd.getBootstrapContext().trim().equals(""))
- {
- bootstrapIdentifier = ijmd.getBootstrapContext();
- }
-
- startContext(resourceAdapter, bootstrapIdentifier);
- }
-
- log.info("Deployed: " + url.toExternalForm());
-
- return new RaXmlDeployment(url, deployment, deploymentName, resourceAdapter,
- ((RAConfiguration) getConfiguration()).getJndiStrategy(),
- ((RAConfiguration) getConfiguration()).getMetadataRepository(), cfs, jndiNames,
- cl, log);
+ CommonDeployment c = createObjectsAndInjectValue(url, deploymentName, root, cl, cmd, ijmd, raxml);
+ JndiStrategy jndiStrategy = ((RAConfiguration) getConfiguration()).getJndiStrategy();
+ MetadataRepository metadataRepository = ((RAConfiguration) getConfiguration()).getMetadataRepository();
+ return new RaXmlDeployment(c.getURL(), deployment, c.getDeploymentName(), c.getResourceAdapter(),
+ jndiStrategy, metadataRepository, c.getCfs(), c.getJndiNames(),
+ c.getCl(), c.getLog());
}
catch (DeployException de)
{
- // Just rethrow
+ //just rethrow
throw de;
}
+ catch (org.jboss.jca.deployers.common.DeployException cde)
+ {
+ throw new DeployException(cde.getMessage(), cde.getCause());
+ }
catch (Throwable t)
{
- if ((((RAConfiguration) getConfiguration()).getArchiveValidationFailOnWarn() && hasFailuresLevel(failures,
- Severity.WARNING)) ||
- (((RAConfiguration) getConfiguration()).getArchiveValidationFailOnError() && hasFailuresLevel(failures,
- Severity.ERROR)))
- throw new DeployException("Deployment " + url.toExternalForm() + " failed",
- new ValidatorException(printFailuresLog(url.getPath(), new Validator(),
- failures, null), failures));
- else
- {
- printFailuresLog(url.getPath(), new Validator(), failures, null);
- throw new DeployException("Deployment " + url.toExternalForm() + " failed", t);
- }
+
+ throw new DeployException("Deployment " + url.toExternalForm() + " failed", t);
+
}
+
finally
{
SecurityActions.setThreadContextClassLoader(oldTCCL);
Modified: projects/jboss-jca/trunk/tools/findbugs/filter.xml
===================================================================
--- projects/jboss-jca/trunk/tools/findbugs/filter.xml 2010-10-15 17:08:22 UTC (rev 108607)
+++ projects/jboss-jca/trunk/tools/findbugs/filter.xml 2010-10-15 18:25:24 UTC (rev 108608)
@@ -32,11 +32,15 @@
<Method name="mergeConnectorAndDs" />
<Bug code="NP"/>
</Match>
-<Match>
+ <Match>
<Class name="org.jboss.jca.common.metadata.merge.Merger"/>
<Method name="mergeConnectorWithProperties" />
<Bug code="NP"/>
</Match>
+ <Match>
+ <Class name="org.jboss.jca.deployers.common.CommonDeployment"/>
+ <Bug code="PZLA"/>
+ </Match>
<!-- org.jboss.jca.core filter -->
<Match>
More information about the jboss-cvs-commits
mailing list