[jboss-cvs] JBossAS SVN: r108909 - in projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers: fungal and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 25 15:13:28 EDT 2010
Author: jesper.pedersen
Date: 2010-10-25 15:13:28 -0400 (Mon, 25 Oct 2010)
New Revision: 108909
Modified:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
Log:
Use unique ids instead of URL's
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java 2010-10-25 18:54:26 UTC (rev 108908)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java 2010-10-25 19:13:28 UTC (rev 108909)
@@ -52,23 +52,16 @@
import org.jboss.logging.Logger;
/**
+ * An abstract deployer implementation for datasources
*
- * A AbstractDsDeployer.
- *
* @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
- *
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
*/
public abstract class AbstractDsDeployer
{
/** log **/
protected Logger log;
- /** jdbcLocal **/
- protected String jdbcLocal;
-
- /** jdbcXA **/
- protected String jdbcXA;
-
/** The transaction manager */
protected TransactionManager transactionManager;
@@ -82,45 +75,11 @@
public AbstractDsDeployer(Logger log)
{
this.log = log;
+ this.transactionManager = null;
+ this.mdr = null;
}
/**
- * 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
*/
@@ -169,35 +128,25 @@
* @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
+ protected CommonDeployment createObjectsAndInjectValue(URL url,
+ String deploymentName,
+ String uniqueJdbcLocalId,
+ String uniqueJdbcXAId,
+ 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)
+ if (uniqueJdbcLocalId != null)
{
List<DataSource> ds = dataSources.getDataSource();
if (ds != null)
{
- ClassLoader jdbcLocalDeploymentCl = getDeploymentCl(urlJdbcLocal);
+ ClassLoader jdbcLocalDeploymentCl = getDeploymentClassLoader(uniqueJdbcLocalId);
for (DataSource dataSource : ds)
{
@@ -211,7 +160,7 @@
jndiName = "java:/" + jndiName;
}
- Object cf = deployDataSource(dataSource, jndiName, urlJdbcLocal, jdbcLocalDeploymentCl);
+ Object cf = deployDataSource(dataSource, jndiName, uniqueJdbcLocalId, jdbcLocalDeploymentCl);
bindConnectionFactory(deploymentName, jndiName, cf);
@@ -231,12 +180,12 @@
log.error("Deployment of datasources disabled since jdbc-local.rar couldn't be found");
}
- if (urlJdbcXA != null)
+ if (uniqueJdbcXAId != null)
{
List<XaDataSource> xads = dataSources.getXaDataSource();
if (xads != null)
{
- ClassLoader jdbcXADeploymentCl = getDeploymentCl(urlJdbcXA);
+ ClassLoader jdbcXADeploymentCl = getDeploymentClassLoader(uniqueJdbcXAId);
for (XaDataSource xaDataSource : xads)
{
@@ -250,7 +199,7 @@
jndiName = "java:/" + jndiName;
}
- Object cf = deployXADataSource(xaDataSource, jndiName, urlJdbcXA, jdbcXADeploymentCl);
+ Object cf = deployXADataSource(xaDataSource, jndiName, uniqueJdbcXAId, jdbcXADeploymentCl);
bindConnectionFactory(deploymentName, jndiName, cf);
@@ -284,18 +233,18 @@
* Deploy a datasource
* @param ds The datasource
* @param jndiName The JNDI name
- * @param ra The resource adapter
+ * @param uniqueId The unique id for 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
+ private Object deployDataSource(DataSource ds, String jndiName, String uniqueId, ClassLoader cl) throws Throwable
{
log.debug("DataSource=" + ds);
Merger merger = new Merger();
- Connector md = mdr.getResourceAdapter(ra.toExternalForm());
+ Connector md = mdr.getResourceAdapter(uniqueId);
md = merger.mergeConnectorAndDs(ds, md);
// Get the first connection definition as there is only one
@@ -349,18 +298,18 @@
* Deploy an XA datasource
* @param ds The datasource
* @param jndiName The JNDI name
- * @param ra The resource adapter
+ * @param uniqueId The unique id for 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
+ private Object deployXADataSource(XaDataSource ds, String jndiName, String uniqueId, ClassLoader cl) throws Throwable
{
log.debug("XaDataSource=" + ds);
Merger merger = new Merger();
- Connector md = mdr.getResourceAdapter(ra.toExternalForm());
+ Connector md = mdr.getResourceAdapter(uniqueId);
md = merger.mergeConnectorAndDs(ds, md);
// Get the first connection definition as there is only one
@@ -480,13 +429,11 @@
}
/**
- *
- * provide classloader of passed deployment url
- *
- * @param urlJdbcXA the url used to identify deployment
- * @return the classloader used by this deployment
+ * Provide the classloader of the deployment identified by the unique id
+ * @param uniqueId The
+ * @return The classloader used by this deployment
*/
- protected abstract ClassLoader getDeploymentCl(URL urlJdbcXA);
+ protected abstract ClassLoader getDeploymentClassLoader(String uniqueId);
/**
* Bind connection factory into JNDI
@@ -508,5 +455,4 @@
*/
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/fungal/DsXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java 2010-10-25 18:54:26 UTC (rev 108908)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java 2010-10-25 19:13:28 UTC (rev 108909)
@@ -52,6 +52,12 @@
*/
public final class DsXmlDeployer extends AbstractDsDeployer implements Deployer
{
+ /** jdbcLocal **/
+ private String jdbcLocal;
+
+ /** jdbcXA **/
+ private String jdbcXA;
+
/** The kernel */
private Kernel kernel;
@@ -62,14 +68,48 @@
{
super(Logger.getLogger(DsXmlDeployer.class));
- transactionManager = null;
- jdbcLocal = null;
- jdbcXA = null;
- mdr = null;
- kernel = null;
+ this.kernel = null;
+ this.jdbcLocal = null;
+ this.jdbcXA = null;
}
/**
+ * 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 kernel
* @param value The value
*/
@@ -119,8 +159,27 @@
String deploymentName = f.getName();
Set<String> raDeployments = mdr.getResourceAdapters();
- CommonDeployment c = createObjectsAndInjectValue(url, deploymentName, raDeployments, dataSources, parent);
+ String uniqueJdbcLocalId = null;
+ String uniqueJdbcXAId = null;
+ for (String s : raDeployments)
+ {
+ if (s.endsWith(jdbcLocal))
+ {
+ URL urlJdbcLocal = new URL(s);
+ uniqueJdbcLocalId = urlJdbcLocal.toExternalForm();
+ }
+ else if (s.endsWith(jdbcXA))
+ {
+ URL urlJdbcXA = new URL(s);
+ uniqueJdbcXAId = urlJdbcXA.toExternalForm();
+ }
+ }
+
+ CommonDeployment c = createObjectsAndInjectValue(url, deploymentName,
+ uniqueJdbcLocalId, uniqueJdbcXAId,
+ dataSources, parent);
+
return new DsXmlDeployment(c.getURL(), c.getDeploymentName(), c.getCfs(), c.getCfJndiNames(), c.getCl());
}
catch (DeployException de)
@@ -215,11 +274,25 @@
if (kernel == null)
throw new IllegalStateException("Kernel not defined");
+
+ if (jdbcLocal == null)
+ throw new IllegalStateException("JDBCLocal not defined");
+
+ if (jdbcXA == null)
+ throw new IllegalStateException("JDBCXA not defined");
}
@Override
- protected ClassLoader getDeploymentCl(URL urlJdbc)
+ protected ClassLoader getDeploymentClassLoader(String uniqueId)
{
- return kernel.getDeployment(urlJdbc).getClassLoader();
+ try
+ {
+ URL urlJdbc = new URL(uniqueId);
+ return kernel.getDeployment(urlJdbc).getClassLoader();
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException(t.getMessage(), t);
+ }
}
}
More information about the jboss-cvs-commits
mailing list