[jboss-cvs] JBossAS SVN: r108364 - in projects/jboss-jca/trunk: common/src/main/java/org/jboss/jca/common/metadata/ds and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Sep 28 07:24:54 EDT 2010
Author: maeste
Date: 2010-09-28 07:24:53 -0400 (Tue, 28 Sep 2010)
New Revision: 108364
Added:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/CommonDeployment.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/Configuration.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/DeployException.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
Removed:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractResourceAdapterDeployer.java
Modified:
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonAdminObjectImpl.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonConnDefImpl.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonValidationImpl.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/StatementImpl.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/TimeOutImpl.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/ValidationImpl.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/BeanValidation.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/DsXmlDeployment.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/JCATraversableResolver.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/RAActivatorDeployment.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAConfiguration.java
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
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/RaXmlDeployment.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/SecurityActions.java
projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/deployers/fungal/RADeployerTestCase.java
Log:
refactoring of fungal deployer into common as much as possible. RaXmlDeployer missed atm in this refactoring
Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonAdminObjectImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonAdminObjectImpl.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonAdminObjectImpl.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -143,10 +143,10 @@
int result = 1;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + ((configProperties == null) ? 0 : configProperties.hashCode());
- result = prime * result + (enabled ? 1231 : 1237);
+ result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
result = prime * result + ((jndiName == null) ? 0 : jndiName.hashCode());
result = prime * result + ((poolName == null) ? 0 : poolName.hashCode());
- result = prime * result + (useJavaContext ? 1231 : 1237);
+ result = prime * result + ((useJavaContext == null) ? 0 : useJavaContext.hashCode());
return result;
}
@@ -174,7 +174,12 @@
}
else if (!configProperties.equals(other.configProperties))
return false;
- if (enabled != other.enabled)
+ if (enabled == null)
+ {
+ if (other.enabled != null)
+ return false;
+ }
+ else if (!enabled.equals(other.enabled))
return false;
if (jndiName == null)
{
@@ -190,7 +195,12 @@
}
else if (!poolName.equals(other.poolName))
return false;
- if (useJavaContext != other.useJavaContext)
+ if (useJavaContext == null)
+ {
+ if (other.useJavaContext != null)
+ return false;
+ }
+ else if (!useJavaContext.equals(other.useJavaContext))
return false;
return true;
}
Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonConnDefImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonConnDefImpl.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonConnDefImpl.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -227,13 +227,13 @@
int result = 1;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + ((configProperties == null) ? 0 : configProperties.hashCode());
- result = prime * result + (enabled ? 1231 : 1237);
+ result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
result = prime * result + ((jndiName == null) ? 0 : jndiName.hashCode());
result = prime * result + ((pool == null) ? 0 : pool.hashCode());
result = prime * result + ((poolName == null) ? 0 : poolName.hashCode());
result = prime * result + ((security == null) ? 0 : security.hashCode());
result = prime * result + ((timeOut == null) ? 0 : timeOut.hashCode());
- result = prime * result + (useJavaContext ? 1231 : 1237);
+ result = prime * result + ((useJavaContext == null) ? 0 : useJavaContext.hashCode());
result = prime * result + ((validation == null) ? 0 : validation.hashCode());
return result;
}
@@ -262,7 +262,12 @@
}
else if (!configProperties.equals(other.configProperties))
return false;
- if (enabled != other.enabled)
+ if (enabled == null)
+ {
+ if (other.enabled != null)
+ return false;
+ }
+ else if (!enabled.equals(other.enabled))
return false;
if (jndiName == null)
{
@@ -299,7 +304,12 @@
}
else if (!timeOut.equals(other.timeOut))
return false;
- if (useJavaContext != other.useJavaContext)
+ if (useJavaContext == null)
+ {
+ if (other.useJavaContext != null)
+ return false;
+ }
+ else if (!useJavaContext.equals(other.useJavaContext))
return false;
if (validation == null)
{
Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonValidationImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonValidationImpl.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonValidationImpl.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -98,10 +98,9 @@
{
final int prime = 31;
int result = 1;
- result = prime * result + (backgroundValidation ? 1231 : 1237);
- result = prime * result +
- ((backgroundValidationMinutes == null) ? 0 : backgroundValidationMinutes.hashCode());
- result = prime * result + (useFastFail ? 1231 : 1237);
+ result = prime * result + ((backgroundValidation == null) ? 0 : backgroundValidation.hashCode());
+ result = prime * result + ((backgroundValidationMinutes == null) ? 0 : backgroundValidationMinutes.hashCode());
+ result = prime * result + ((useFastFail == null) ? 0 : useFastFail.hashCode());
return result;
}
@@ -115,7 +114,12 @@
if (!(obj instanceof CommonValidationImpl))
return false;
CommonValidationImpl other = (CommonValidationImpl) obj;
- if (backgroundValidation != other.backgroundValidation)
+ if (backgroundValidation == null)
+ {
+ if (other.backgroundValidation != null)
+ return false;
+ }
+ else if (!backgroundValidation.equals(other.backgroundValidation))
return false;
if (backgroundValidationMinutes == null)
{
@@ -124,7 +128,12 @@
}
else if (!backgroundValidationMinutes.equals(other.backgroundValidationMinutes))
return false;
- if (useFastFail != other.useFastFail)
+ if (useFastFail == null)
+ {
+ if (other.useFastFail != null)
+ return false;
+ }
+ else if (!useFastFail.equals(other.useFastFail))
return false;
return true;
}
Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/StatementImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/StatementImpl.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/StatementImpl.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -97,7 +97,7 @@
final int prime = 31;
int result = 1;
result = prime * result + ((preparedStatementsCacheSize == null) ? 0 : preparedStatementsCacheSize.hashCode());
- result = prime * result + (sharePreparedStatements ? 1231 : 1237);
+ result = prime * result + ((sharePreparedStatements == null) ? 0 : sharePreparedStatements.hashCode());
result = prime * result + ((trackStatements == null) ? 0 : trackStatements.hashCode());
return result;
}
@@ -119,7 +119,12 @@
}
else if (!preparedStatementsCacheSize.equals(other.preparedStatementsCacheSize))
return false;
- if (sharePreparedStatements != other.sharePreparedStatements)
+ if (sharePreparedStatements == null)
+ {
+ if (other.sharePreparedStatements != null)
+ return false;
+ }
+ else if (!sharePreparedStatements.equals(other.sharePreparedStatements))
return false;
if (trackStatements != other.trackStatements)
return false;
Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/TimeOutImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/TimeOutImpl.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/TimeOutImpl.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -103,7 +103,7 @@
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((queryTimeout == null) ? 0 : queryTimeout.hashCode());
- result = prime * result + (setTxQuertTimeout ? 1231 : 1237);
+ result = prime * result + ((setTxQuertTimeout == null) ? 0 : setTxQuertTimeout.hashCode());
result = prime * result + ((useTryLock == null) ? 0 : useTryLock.hashCode());
return result;
}
@@ -125,7 +125,12 @@
}
else if (!queryTimeout.equals(other.queryTimeout))
return false;
- if (setTxQuertTimeout != other.setTxQuertTimeout)
+ if (setTxQuertTimeout == null)
+ {
+ if (other.setTxQuertTimeout != null)
+ return false;
+ }
+ else if (!setTxQuertTimeout.equals(other.setTxQuertTimeout))
return false;
if (useTryLock == null)
{
Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/ValidationImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/ValidationImpl.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/ValidationImpl.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -136,7 +136,7 @@
((staleConnectionCheckerClassName == null) ? 0 : staleConnectionCheckerClassName.hashCode());
result = prime * result +
((validConnectionCheckerClassName == null) ? 0 : validConnectionCheckerClassName.hashCode());
- result = prime * result + (validateOnMatch ? 1231 : 1237);
+ result = prime * result + ((validateOnMatch == null) ? 0 : validateOnMatch.hashCode());
return result;
}
@@ -178,7 +178,12 @@
}
else if (!validConnectionCheckerClassName.equals(other.validConnectionCheckerClassName))
return false;
- if (validateOnMatch != other.validateOnMatch)
+ if (validateOnMatch == null)
+ {
+ if (other.validateOnMatch != null)
+ return false;
+ }
+ else if (!validateOnMatch.equals(other.validateOnMatch))
return false;
return true;
}
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-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -22,6 +22,66 @@
package org.jboss.jca.deployers.common;
+import org.jboss.jca.common.api.metadata.common.CommonConnDef;
+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.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.ConnectionDefinition;
+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.core.api.bootstrap.CloneableBootstrapContext;
+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.AlreadyExistsException;
+import org.jboss.jca.deployers.fungal.BeanValidation;
+import org.jboss.jca.validator.Failure;
+import org.jboss.jca.validator.FailureHelper;
+import org.jboss.jca.validator.Key;
+import org.jboss.jca.validator.Severity;
+import org.jboss.jca.validator.Validate;
+import org.jboss.jca.validator.ValidateClass;
+import org.jboss.jca.validator.ValidateObject;
+import org.jboss.jca.validator.Validator;
+import org.jboss.jca.validator.ValidatorException;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.resource.Referenceable;
+import javax.resource.ResourceException;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterAssociation;
+import javax.resource.spi.TransactionSupport;
+import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
+import javax.transaction.TransactionManager;
+
import org.jboss.logging.Logger;
/**
@@ -31,14 +91,1132 @@
*/
public abstract class AbstractResourceAdapterDeployer
{
- private static Logger log = Logger.getLogger(AbstractResourceAdapterDeployer.class);
+ /** the logger **/
+ protected static final Logger log = Logger.getLogger(AbstractResourceAdapterDeployer.class);
- private static boolean trace = log.isTraceEnabled();
+ /** trace boolean check */
+ protected static final boolean trace = log.isTraceEnabled();
+ /** boolean to set if validation is needed at class level or it should be considered already valid
+ * (IOW object put in repository at previous steps have been already validated at class level**/
+ protected final boolean validateClasses;
+
+ /** The configuration */
+ private Configuration configuration = null;
+
/**
- * Constructor
+ * Create a new AbstractResourceAdapterDeployer.
+ *
+ * @param validateClasses validateClasses validateClasses boolean to express if this instance will
+ * apply validation on classes structure
*/
- public AbstractResourceAdapterDeployer()
+ public AbstractResourceAdapterDeployer(boolean validateClasses)
{
+ super();
+ this.validateClasses = validateClasses;
}
+
+ /**
+ * Set the configuration
+ * @param value value value The value
+ */
+ public void setConfiguration(Configuration value)
+ {
+ configuration = value;
+ }
+
+ /**
+ * Get the configuration
+ * @return The value
+ */
+ public Configuration getConfiguration()
+ {
+ return configuration;
+ }
+
+ /**
+ * validate archive
+ *
+ * @param url url url of the archive
+ * @param archiveValidation archiveValidation archiveValidation classes and/or to validate.
+ * @param failures failures failures original list of failures
+ * @return The list of failures gotten with all new failures added. Null in case of no failures
+ * or if validation is not run according to {@link #getArchiveValidation()} Setting. It returns null also if
+ * the concrete implementation of this class set validateClasses instance variable to flase and the list of
+ * archiveValidation contains one or more instance of {@link ValidateClass} type
+ */
+ public Set<Failure> validateArchive(URL url, List<Validate> archiveValidation, Set<Failure> failures)
+ {
+ // Archive validation
+ if (!getConfiguration().getArchiveValidation())
+ {
+ return null;
+ }
+
+ for (Validate validate : archiveValidation)
+ {
+ if (!(validate instanceof ValidateObject) && !this.validateClasses)
+ return null;
+ }
+
+ Validator validator = new Validator();
+ List<Failure> partialFailures = validator.validate(archiveValidation);
+
+ if (partialFailures != null)
+ {
+ if (failures == null)
+ {
+ failures = new HashSet<Failure>();
+ }
+ failures.addAll(partialFailures);
+ }
+
+ return failures;
+ }
+
+ /**
+ * print Failures into Log files.
+ *
+ * @param urlFileName urlFileName urlFileName filename Of deployed rar
+ * @param validator validator validator validator instance used to run validation rules
+ * @param failures failures failures the list of Failures to be printed
+ * @param reportDirectory reportDirectory reportDirectory where to put various logs
+ * @param fhInput fhInput fhInput optional parameter. Normally used only for test or in case of
+ * FailureHelper already present in context
+ * @return the error Text
+ *
+ */
+ public String printFailuresLog(String urlFileName, Validator validator, Collection<Failure> failures,
+ File reportDirectory, FailureHelper... fhInput)
+ {
+ String errorText = "";
+ FailureHelper fh = null;
+ if (fhInput.length == 0)
+ fh = new FailureHelper(failures);
+ else
+ fh = fhInput[0];
+
+ if (failures != null && failures.size() > 0)
+ {
+ if (reportDirectory == null)
+ {
+ reportDirectory = getReportDirectory();
+ }
+ if (reportDirectory.exists())
+ {
+ int lastSlashIndex = urlFileName.lastIndexOf("/");
+ int lastSepaIndex = urlFileName.lastIndexOf(File.separator);
+
+ int lastIndex = lastSlashIndex > lastSepaIndex ? lastSlashIndex : lastSepaIndex;
+ if (lastIndex != -1)
+ urlFileName = urlFileName.substring(lastIndex + 1);
+ urlFileName += ".log";
+
+ File report = new File(reportDirectory, urlFileName);
+ FileWriter fw = null;
+ BufferedWriter bw = null;
+ try
+ {
+ fw = new FileWriter(report);
+ bw = new BufferedWriter(fw, 8192);
+ bw.write(fh.asText(validator.getResourceBundle()));
+ bw.flush();
+
+ errorText = "Validation failures - see: " + report.getAbsolutePath();
+ }
+ catch (IOException ioe)
+ {
+ log.warn(ioe.getMessage(), ioe);
+ }
+ finally
+ {
+ if (bw != null)
+ {
+ try
+ {
+ bw.close();
+ }
+ catch (IOException ignore)
+ {
+ // Ignore
+ }
+ }
+ if (fw != null)
+ {
+ try
+ {
+ fw.close();
+ }
+ catch (IOException ignore)
+ {
+ // Ignore
+ }
+ }
+ }
+ }
+ else
+ {
+ errorText = fh.asText(validator.getResourceBundle());
+ }
+ }
+ return errorText;
+ }
+
+ /**
+ * Cehck for failures at a certain level
+ * @param failures failures failures The failures
+ * @param severity severity severity The level
+ * @return True if a failure is found with the specified severity; otherwise false
+ */
+ protected boolean hasFailuresLevel(Collection<Failure> failures, int severity)
+ {
+ if (failures != null)
+ {
+ for (Failure failure : failures)
+ {
+ if (failure.getSeverity() == severity)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Start the resource adapter
+ * @param resourceAdapter resourceAdapter resourceAdapter The resource adapter
+ * @param bootstrapIdentifier bootstrapIdentifier bootstrapIdentifier The bootstrap context identifier;
+ * may be <code>null</code>
+ * @throws DeployException DeployException Thrown if the resource adapter cant be started
+ */
+ @SuppressWarnings("unchecked")
+ protected void startContext(ResourceAdapter resourceAdapter, String bootstrapIdentifier) throws DeployException
+ {
+ try
+ {
+ Class clz = resourceAdapter.getClass();
+ Method start = clz.getMethod("start", new Class[]{BootstrapContext.class});
+
+ CloneableBootstrapContext cbc = null;
+
+ if (bootstrapIdentifier != null && getConfiguration().getBootstrapContexts() != null)
+ {
+ CloneableBootstrapContext bc = getConfiguration().getBootstrapContexts().get(bootstrapIdentifier);
+
+ if (bc != null)
+ cbc = bc.clone();
+ }
+
+ if (cbc == null)
+ cbc = getConfiguration().getDefaultBootstrapContext().clone();
+
+ start.invoke(resourceAdapter, new Object[]{cbc});
+ }
+ catch (InvocationTargetException ite)
+ {
+ throw new DeployException("Unable to start " + resourceAdapter.getClass().getName(),
+ ite.getTargetException());
+ }
+ catch (Throwable t)
+ {
+ throw new DeployException("Unable to start " + resourceAdapter.getClass().getName(), t);
+ }
+ }
+
+ /**
+ * Associate resource adapter with ojects if they implement ResourceAdapterAssociation
+ * @param resourceAdapter resourceAdapter resourceAdapter The resource adapter
+ * @param object object object The of possible association object
+ * @throws DeployException DeployException Thrown if the resource adapter cant be started
+ */
+ @SuppressWarnings("unchecked")
+ protected void associateResourceAdapter(ResourceAdapter resourceAdapter, Object object) throws DeployException
+ {
+ if (resourceAdapter != null && object != null)
+ {
+ if (object instanceof ResourceAdapterAssociation)
+ {
+ try
+ {
+ Class clz = object.getClass();
+
+ Method setResourceAdapter = clz.getMethod("setResourceAdapter", new Class[]{ResourceAdapter.class});
+
+ setResourceAdapter.invoke(object, new Object[]{resourceAdapter});
+ }
+ catch (Throwable t)
+ {
+ throw new DeployException("Unable to associate " + object.getClass().getName(), t);
+ }
+ }
+ }
+ }
+
+ /**
+ * Find the connection factory for a managed connection factory
+ * @param clz clz clz The fully quilified class name for the managed connection factory
+ * @param defs defs defs The connection definitions
+ * @return The connection definiton; <code>null</code> if none could be found
+ */
+ protected org.jboss.jca.common.api.metadata.common.CommonConnDef findConnectionDefinition(String clz,
+ List<org.jboss.jca.common.api.metadata.common.CommonConnDef> defs)
+ {
+ if (defs != null)
+ {
+ // If there is only one we will return that
+ if (defs.size() == 1)
+ {
+ org.jboss.jca.common.api.metadata.common.CommonConnDef cd = defs.get(0);
+
+ if (cd.getClassName() != null && !clz.equals(cd.getClassName()))
+ {
+ log.warn("Only one connection definitopn found with a mis-match in class-name: " + cd);
+ return null;
+ }
+
+ return cd;
+ }
+
+ // If there are multiple definitions the MCF class name is mandatory
+ if (clz == null)
+ throw new IllegalArgumentException("ManagedConnectionFactory must be defined in class-name");
+
+ for (org.jboss.jca.common.api.metadata.common.CommonConnDef cd : defs)
+ {
+ if (clz.equals(cd.getClassName()))
+ return cd;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Create an instance of the pool configuration based on the input
+ * @param pp pp pp The pool parameters
+ * @param tp tp tp The timeout parameters
+ * @param vp vp vp The validation parameters
+ * @return The configuration
+ */
+ protected 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;
+ }
+
+ /**
+ * Start
+ */
+ public void start()
+ {
+ if (!checkConfigurationIsValid())
+ throw new IllegalStateException("Configuration not valid or not defined");
+ }
+
+ /**
+ * init the acrtivation spec
+ *
+ * @param cl cl
+ * @param cmd cmd
+ * @param resourceAdapter resourceAdapter
+ * @param archiveValidationObjects archiveValidationObjects
+ * @param beanValidationObjects beanValidationObjects
+ * @param failures falures to be updated during implemented operations
+ * @param url url
+ * @param activateDeployment activateDeployment
+ * @return failures updated after implemented operations
+ * @throws DeployException DeployException in case of error
+ */
+ protected Set<Failure> initActivationSpec(ClassLoader cl, Connector cmd, ResourceAdapter resourceAdapter,
+ List<Validate> archiveValidationObjects, List<Object> beanValidationObjects, Set<Failure> failures, URL url,
+ boolean activateDeployment) throws DeployException
+ {
+ // 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 mlMD : mlMetas)
+ {
+ if (mlMD.getActivationspec() != null &&
+ mlMD.getActivationspec().getActivationspecClass().getValue() != null)
+ {
+ failures = validateArchive(
+ url,
+ Arrays.asList((Validate) new ValidateClass(Key.ACTIVATION_SPEC, mlMD.getActivationspec()
+ .getActivationspecClass().getValue(), cl, mlMD.getActivationspec().getConfigProperties())),
+ failures);
+ if (!(getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures,
+ Severity.ERROR)))
+ {
+ if (activateDeployment)
+ {
+ List<? extends ConfigProperty> cpm = mlMD.getActivationspec().getConfigProperties();
+
+ Object o = initAndInject(mlMD.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);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return failures;
+ }
+
+ /**
+ * init an Admin Object
+ *
+ * @param cmd cmd
+ * @param cl cl
+ * @param archiveValidationObjects archiveValidationObjects
+ * @param beanValidationObjects beanValidationObjects
+ * @param failures falures to be updated during implemented operations
+ * @param url url
+ * @param activateDeployment activateDeployment
+ * @return failures updated after implemented operations
+ * @throws DeployException DeployException in case of errors
+ */
+ protected Set<Failure> initAdminObject(Connector cmd, ClassLoader cl, List<Validate> archiveValidationObjects,
+ List<Object> beanValidationObjects, Set<Failure> failures, URL url, boolean activateDeployment)
+ throws DeployException
+ {
+ // 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)
+ {
+ failures = validateArchive(url,
+ Arrays.asList((Validate) new ValidateClass(Key.ADMIN_OBJECT, aoMeta.getAdminobjectClass()
+ .getValue(), cl, aoMeta.getConfigProperties())), failures);
+ if (!(getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures,
+ Severity.ERROR)))
+ {
+ if (activateDeployment)
+ {
+ 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);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return failures;
+ }
+
+ /**
+ * 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;
+
+ /**
+ *
+ * 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 destination destination
+ * @param cl cl
+ * @param cmd connector md
+ * @param ijmd ironjacamar md
+ * @param deployment deployment
+ * @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,
+ File destination, ClassLoader cl, Connector cmd, IronJacamar ijmd, URL deployment) throws DeployException,
+ ResourceException, ValidatorException, AlreadyExistsException, ClassNotFoundException, Throwable
+ {
+ Set<Failure> failures = null;
+ try
+ {
+ // Notify regarding license terms
+ if (cmd != null && cmd.getLicense() != null && cmd.getLicense().isLicenseRequired())
+ log.info("Required license terms for " + url.toExternalForm());
+
+ ResourceAdapter resourceAdapter = null;
+ List<Validate> archiveValidationObjects = new ArrayList<Validate>();
+ List<Object> beanValidationObjects = new ArrayList<Object>();
+ Object[] cfs = null;
+ String[] jndiNames = null;
+
+ // Check metadata for JNDI information and activate explicit
+ boolean activateDeployment = checkActivation(cmd, ijmd);
+
+ // 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)
+ {
+ failures = validateArchive(url,
+ Arrays.asList((Validate) new ValidateClass(Key.RESOURCE_ADAPTER, ra1516
+ .getResourceadapterClass(), cl, cmd.getResourceadapter().getConfigProperties())), failures);
+
+ if (!(getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures,
+ Severity.ERROR)))
+ {
+ if (activateDeployment)
+ {
+ resourceAdapter = (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)
+ {
+ ResourceAdapter10 ra10 = (ResourceAdapter10) cmd.getResourceadapter();
+
+ if (activateDeployment)
+ {
+ CommonConnDef ijCD = null;
+
+ if (ijmd != null)
+ {
+ ijCD = findConnectionDefinition(ra10.getManagedConnectionFactoryClass().getValue(),
+ ijmd.getConnectionDefinitions());
+ }
+ //
+ // if (ijmd == null || ijCD == null || ijCD.isEnabled())
+ if (ijCD == null || ijCD.isEnabled())
+ {
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(ra10
+ .getManagedConnectionFactoryClass().getValue(), ra10.getConfigProperties(), cl);
+
+ if (trace)
+ {
+ log.trace("ManagedConnectionFactory: " + mcf.getClass().getName());
+ log.trace("ManagedConnectionFactory is defined in classloader: " +
+ mcf.getClass().getClassLoader());
+ }
+
+ mcf.setLogWriter(getLogPrintWriter());
+
+ archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY, mcf, ra10
+ .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);
+ PoolFactory pf = new PoolFactory();
+
+ Boolean noTxSeparatePool = Boolean.FALSE;
+
+ 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;
+
+ TransactionSupportEnum tsmd = TransactionSupportEnum.NoTransaction;
+
+ if (ijmd != null && ijmd.getTransactionSupport() != null)
+ {
+ tsmd = ijmd.getTransactionSupport();
+ }
+ else
+ {
+ tsmd = ((ResourceAdapter10) cmd.getResourceadapter()).getTransactionSupport();
+ }
+
+ TransactionSupportLevel tsl = TransactionSupportLevel.NoTransaction;
+
+ 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 (ijCD != null && ijCD.getTimeOut() != null)
+ {
+ allocationRetry = ijCD.getTimeOut().getAllocationRetry();
+ 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 (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();
+ }
+ }
+
+ cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
+ 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)
+ {
+ if (ijCD != null)
+ {
+ String jndiName = ijCD.getJndiName();
+
+ bindConnectionFactory(url, deploymentName, cf, jndiName);
+ cfs = new Object[]{cf};
+ jndiNames = new String[]{jndiName};
+
+ cm.setJndiName(jndiName);
+ }
+ else
+ {
+ jndiNames = bindConnectionFactory(url, deploymentName, cf);
+ cfs = new Object[]{cf};
+
+ cm.setJndiName(jndiNames[0]);
+ }
+ }
+ }
+ }
+ }
+ 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)
+ {
+ // if (cdMetas.size() == 1)
+ // {
+ // ConnectionDefinition cdMeta = cdMetas.get(0);
+ cfs = new Object[cdMetas.size()];
+ jndiNames = new String[cdMetas.size()];
+
+ for (int cdIndex = 0; cdIndex < cdMetas.size(); cdIndex++)
+ {
+ ConnectionDefinition cdMeta = cdMetas.get(cdIndex);
+
+ failures = validateArchive(url,
+ Arrays.asList((Validate) new ValidateClass(Key.MANAGED_CONNECTION_FACTORY, cdMeta
+ .getManagedConnectionFactoryClass().getValue(), cl, cdMeta.getConfigProperties())),
+ failures);
+
+ if (!(getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures,
+ Severity.ERROR)))
+ {
+ if (activateDeployment)
+ {
+ org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD = null;
+
+ if (ijmd != null)
+ {
+ ijCD = findConnectionDefinition(
+ cdMeta.getManagedConnectionFactoryClass().getValue(),
+ ijmd.getConnectionDefinitions());
+ }
+
+ // if (ijmd == null || ijCD == null || ijCD.isEnabled())
+ // {
+ if (ijCD == null || ijCD.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());
+ }
+
+ mcf.setLogWriter(getLogPrintWriter());
+
+ archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY, mcf,
+ cdMeta.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);
+ PoolFactory pf = new PoolFactory();
+
+ Boolean noTxSeparatePool = Boolean.FALSE;
+
+ 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 (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 (ijCD != null && ijCD.getTimeOut() != null)
+ {
+ allocationRetry = ijCD.getTimeOut().getAllocationRetry();
+ 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 (ijCD != null && ijCD.isXa())
+ {
+ CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
+
+ interleaving = ijXaPool.isInterleaving();
+ isSameRMOverride = ijXaPool.isSameRmOverride();
+ wrapXAResource = ijXaPool.isWrapXaDataSource();
+ padXid = ijXaPool.isPadXid();
+ }
+
+ cm = cmf.createTransactional(tsl, pool, allocationRetry,
+ allocationRetryWaitMillis, 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)
+ {
+ if (ijCD != null)
+ {
+ String jndiName = ijCD.getJndiName();
+
+ bindConnectionFactory(url, deploymentName, cf, jndiName);
+ cfs[cdIndex] = cf;
+ jndiNames[cdIndex] = jndiName;
+
+ cm.setJndiName(jndiName);
+ }
+ else
+ {
+ jndiNames = bindConnectionFactory(url, deploymentName, cf);
+ cfs = new Object[]{cf};
+
+ cm.setJndiName(jndiNames[0]);
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ failures = initActivationSpec(cl, cmd, resourceAdapter, archiveValidationObjects, beanValidationObjects,
+ failures, url, activateDeployment);
+
+ failures = initAdminObject(cmd, cl, archiveValidationObjects, beanValidationObjects, failures, url,
+ activateDeployment);
+ }
+
+ // Archive validation
+ failures = validateArchive(url, archiveValidationObjects, failures);
+
+ if ((getConfiguration().getArchiveValidationFailOnWarn() && hasFailuresLevel(failures, Severity.WARNING)) ||
+ (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);
+ }
+
+ if (cmd != null)
+ {
+ try
+ {
+ // Register with MDR
+ registerResourceAdapterToMDR(url, root, cmd, ijmd);
+ }
+ catch (AlreadyExistsException e)
+ {
+ //ignore it, RA already registered
+ }
+ }
+
+ if (activateDeployment)
+ {
+ // Bean validation
+ if (getConfiguration().getBeanValidation())
+ {
+ List<Class> groupsClasses = null;
+
+ if (ijmd != null && ijmd.getBeanValidationGroups() != null &&
+ ijmd.getBeanValidationGroups().size() > 0)
+ {
+ groupsClasses = new ArrayList<Class>();
+ for (String group : ijmd.getBeanValidationGroups())
+ {
+ 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 (ijmd != null)
+ {
+ bootstrapIdentifier = ijmd.getBootstrapContext();
+ }
+
+ startContext(resourceAdapter, bootstrapIdentifier);
+ }
+ }
+
+ if (activateDeployment)
+ {
+ log.info("Deployed: " + url.toExternalForm());
+ }
+ else
+ {
+ log.debug("Activated: " + url.toExternalForm());
+ }
+
+ return new CommonDeployment(url, deploymentName, activateDeployment, resourceAdapter, cfs, destination, cl,
+ log, jndiNames, deployment, activateDeployment);
+
+ }
+ catch (DeployException de)
+ {
+ // Just rethrow
+ throw de;
+ }
+ catch (Throwable t)
+ {
+ if ((getConfiguration().getArchiveValidationFailOnWarn() && hasFailuresLevel(failures, Severity.WARNING)) ||
+ (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);
+ }
+ }
+ }
+
+ /**
+ *
+ * get The directory where write error reports
+ *
+ * @return the directory as {@link File}
+ */
+ protected abstract File getReportDirectory();
+
+ /**
+ *
+ * Register the ResourceAdapter to the MDR. Implementer should provide the implementation to get MDR and do the
+ * registration
+ *
+ * @param url url
+ * @param root root
+ * @param cmd cmd
+ * @param ijmd ijmd
+ * @throws AlreadyExistsException AlreadyExistsException
+ */
+ protected abstract void registerResourceAdapterToMDR(URL url, File root, Connector cmd, IronJacamar ijmd)
+ throws AlreadyExistsException;
+
+ /**
+ *
+ * get The transaction Manager. Implementers have to provide right implementation to find and get it
+ *
+ * @return the transaction manager to be used
+ */
+ protected abstract TransactionManager getTransactionManager();
+
+ /**
+ *
+ * get a PrintWriter where logger will put its output
+ *
+ * @return the printWriter for Logger
+ */
+ protected abstract PrintWriter getLogPrintWriter();
+
+ /**
+ * Bind connection factory into JNDI
+ * @param url The deployment URL
+ * @param deploymentName The deployment name
+ * @param cf The connection factory
+ * @return The JNDI names bound
+ * @exception Throwable Thrown if an error occurs
+ */
+ protected abstract String[] bindConnectionFactory(URL url, String deploymentName, Object cf) throws Throwable;
+
+ /**
+ * Bind connection factory into JNDI
+ * @param url The deployment URL
+ * @param deploymentName The deployment name
+ * @param cf The connection factory
+ * @param jndiName The JNDI name
+ * @return The JNDI names bound
+ * @exception Throwable Thrown if an error occurs
+ */
+ protected abstract String[] bindConnectionFactory(URL url, String deploymentName, Object cf, String jndiName)
+ throws Throwable;
+
+ /**
+ * check if the configuration for this deployer has been set to a valid value
+ *
+ * @return false if configuration is not valid
+ */
+ protected abstract boolean checkConfigurationIsValid();
+
}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/CommonDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/CommonDeployment.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/CommonDeployment.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -0,0 +1,207 @@
+/*
+ * 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 java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+
+import javax.resource.spi.ResourceAdapter;
+
+import org.jboss.logging.Logger;
+
+/**
+ *
+ * A CommonDeployment.
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public class CommonDeployment
+{
+
+ private final URL url;
+
+ private final String deploymentName;
+
+ private final boolean activateDeployment;
+
+ private final ResourceAdapter resourceAdapter;
+
+ private final Object[] cfs;
+
+ private final File destination;
+
+ private final ClassLoader cl;
+
+ private final Logger log;
+
+ private final String[] jndiNames;
+
+ private final URL deployment;
+
+ private final boolean activateDeployment2;
+
+ /**
+ * Create a new Deployment.
+ *
+ * @param url url
+ * @param deploymentName deploymentName
+ * @param activateDeployment activateDeployment
+ * @param resourceAdapter resourceAdapter
+ * @param cfs cfs
+ * @param destination destination
+ * @param cl cl
+ * @param log log
+ * @param jndiNames jndiNames
+ * @param deployment deployment
+ * @param activateDeployment2 activateDeployment2
+ */
+ public CommonDeployment(URL url, String deploymentName, boolean activateDeployment, ResourceAdapter resourceAdapter,
+ Object[] cfs, File destination, ClassLoader cl, Logger log, String[] jndiNames, URL deployment,
+ boolean activateDeployment2)
+ {
+ super();
+ this.url = url;
+ this.deploymentName = deploymentName;
+ this.activateDeployment = activateDeployment;
+ this.resourceAdapter = resourceAdapter;
+ this.cfs = Arrays.copyOf(cfs, cfs.length);
+ this.destination = destination;
+ this.cl = cl;
+ this.log = log;
+ this.jndiNames = Arrays.copyOf(jndiNames, jndiNames.length);;
+ this.deployment = deployment;
+ this.activateDeployment2 = activateDeployment2;
+ }
+
+ /**
+ * Get the url.
+ *
+ * @return the url.
+ */
+ public final URL getURL()
+ {
+ return url;
+ }
+
+ /**
+ * Get the deploymentName.
+ *
+ * @return the deploymentName.
+ */
+ public final String getDeploymentName()
+ {
+ return deploymentName;
+ }
+
+ /**
+ * Get the activateDeployment.
+ *
+ * @return the activateDeployment.
+ */
+ public final boolean isActivateDeployment()
+ {
+ return activateDeployment;
+ }
+
+ /**
+ * Get the resourceAdapter.
+ *
+ * @return the resourceAdapter.
+ */
+ public final ResourceAdapter getResourceAdapter()
+ {
+ return resourceAdapter;
+ }
+
+ /**
+ * Get the cfs.
+ *
+ * @return the cfs.
+ */
+ public final Object[] getCfs()
+ {
+ return Arrays.copyOf(cfs, cfs.length);
+ }
+
+ /**
+ * Get the destination.
+ *
+ * @return the destination.
+ */
+ public final File getDestination()
+ {
+ return destination;
+ }
+
+ /**
+ * Get the cl.
+ *
+ * @return the cl.
+ */
+ public final ClassLoader getCl()
+ {
+ return cl;
+ }
+
+ /**
+ * Get the log.
+ *
+ * @return the log.
+ */
+ public final Logger getLog()
+ {
+ return log;
+ }
+
+ /**
+ * Get the jndiNames.
+ *
+ * @return the jndiNames.
+ */
+ public final String[] getJndiNames()
+ {
+ return Arrays.copyOf(jndiNames, jndiNames.length);
+ }
+
+ /**
+ * Get the deployment.
+ *
+ * @return the deployment.
+ */
+ public final URL getDeployment()
+ {
+ return deployment;
+ }
+
+ /**
+ * Get the activateDeployment2.
+ *
+ * @return the activateDeployment2.
+ */
+ public final boolean isActivateDeployment2()
+ {
+ return activateDeployment2;
+ }
+
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/Configuration.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/Configuration.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/Configuration.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -0,0 +1,110 @@
+/*
+ * 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.core.api.bootstrap.CloneableBootstrapContext;
+
+import java.util.Map;
+
+/**
+ *
+ * Configuration interface
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public interface Configuration
+{
+
+ /**
+ * Set if bean validation should be performed
+ * @param value The value
+ */
+ public void setBeanValidation(boolean value);
+
+ /**
+ * Should bean validation be performed
+ * @return True if validation; otherwise false
+ */
+ public boolean getBeanValidation();
+
+ /**
+ * Set if archive validation should be performed
+ * @param value The value
+ */
+ public void setArchiveValidation(boolean value);
+
+ /**
+ * Should archive validation be performed
+ * @return True if validation; otherwise false
+ */
+ public boolean getArchiveValidation();
+
+ /**
+ * Set if a failed warning archive validation report should fail the deployment
+ * @param value The value
+ */
+ public void setArchiveValidationFailOnWarn(boolean value);
+
+ /**
+ * Does a failed archive validation warning report fail the deployment
+ * @return True if failing; otherwise false
+ */
+ public boolean getArchiveValidationFailOnWarn();
+
+ /**
+ * Set if a failed error archive validation report should fail the deployment
+ * @param value The value
+ */
+ public void setArchiveValidationFailOnError(boolean value);
+
+ /**
+ * Does a failed archive validation error report fail the deployment
+ * @return True if failing; otherwise false
+ */
+ public boolean getArchiveValidationFailOnError();
+
+ /**
+ * Set the default bootstrap context
+ * @param value The value
+ */
+ public void setDefaultBootstrapContext(CloneableBootstrapContext value);
+
+ /**
+ * Get the default bootstrap context
+ * @return The handle
+ */
+ public CloneableBootstrapContext getDefaultBootstrapContext();
+
+ /**
+ * Set the bootstrap context map
+ * @param value The value
+ */
+ public void setBootstrapContexts(Map<String, CloneableBootstrapContext> value);
+
+ /**
+ * Get the bootstrap context map
+ * @return The handle
+ */
+ public Map<String, CloneableBootstrapContext> getBootstrapContexts();
+
+}
Copied: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/DeployException.java (from rev 108363, 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/DeployException.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/DeployException.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+/**
+ *
+ * The deploy exception for IronJacamar
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public class DeployException extends Exception
+{
+ /** Serial version UID */
+ static final long serialVersionUID = 3820032266224196804L;
+
+ /**
+ * Constructs a new exception with the specified detail message.
+ * @param message The message
+ */
+ public DeployException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Constructs a new exception with the specified detail message and cause.
+ * @param message The message
+ * @param cause The cause
+ */
+ public DeployException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * 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.
+ *
+ * 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.fungal;
+
+import org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar;
+import org.jboss.jca.common.api.metadata.ra.ConfigProperty;
+import org.jboss.jca.common.api.metadata.ra.Connector;
+import org.jboss.jca.core.spi.mdr.AlreadyExistsException;
+import org.jboss.jca.core.spi.naming.JndiStrategy;
+import org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer;
+import org.jboss.jca.deployers.common.DeployException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.transaction.TransactionManager;
+
+import com.github.fungal.api.util.Injection;
+import com.github.fungal.api.util.JarFilter;
+
+/**
+ * An abstract resource adapter deployer which contains common functionality
+ * for all resource adapter archive based deployers.
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public abstract class AbstractFungalRADeployer extends AbstractResourceAdapterDeployer
+{
+
+
+ /**
+ * Create a new AbstractResourceAdapterDeployer.
+ *
+ * @param validateClasses boolean to express if this instance will apply validation on classes structure
+ */
+ public AbstractFungalRADeployer(boolean validateClasses)
+ {
+ super(validateClasses);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ public Object initAndInject(String className, List<? extends ConfigProperty> configs, ClassLoader cl)
+ throws DeployException
+ {
+ try
+ {
+ Class clz = Class.forName(className, true, cl);
+ Object o = clz.newInstance();
+
+ if (configs != null)
+ {
+ Injection injector = new Injection();
+ for (ConfigProperty cpmd : configs)
+ {
+ if (cpmd.isValueSet())
+ injector.inject(cpmd.getConfigPropertyType().getValue(), cpmd.getConfigPropertyName().getValue(),
+ cpmd.getConfigPropertyValue().getValue(), o);
+ }
+ }
+
+ return o;
+ }
+ catch (Throwable t)
+ {
+ throw new DeployException("Deployment " + className + " failed", t);
+ }
+ }
+
+ /**
+ * Get the URLs for the directory and all libraries located in the directory
+ * @param directory The directory
+ * @return The URLs
+ * @exception MalformedURLException MalformedURLException
+ * @exception IOException IOException
+ */
+ protected URL[] getUrls(File directory) throws MalformedURLException, IOException
+ {
+ List<URL> list = new LinkedList<URL>();
+
+ if (directory.exists() && directory.isDirectory())
+ {
+ // Add directory
+ list.add(directory.toURI().toURL());
+
+ // Add the contents of the directory too
+ File[] jars = directory.listFiles(new JarFilter());
+
+ if (jars != null)
+ {
+ for (int j = 0; j < jars.length; j++)
+ {
+ list.add(jars[j].getCanonicalFile().toURI().toURL());
+ }
+ }
+ }
+ return list.toArray(new URL[list.size()]);
+ }
+
+
+ @Override
+ public String[] bindConnectionFactory(URL url, String deployment, Object cf) throws Throwable
+ {
+ JndiStrategy js = ((RAConfiguration) getConfiguration()).getJndiStrategy().clone();
+
+ String[] result = js.bindConnectionFactories(deployment, new Object[]{cf});
+
+ ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url, cf.getClass().getName(),
+ result[0]);
+
+ return result;
+ }
+
+
+ @Override
+ public String[] bindConnectionFactory(URL url, String deployment, Object cf, String jndi) throws Throwable
+ {
+ JndiStrategy js = ((RAConfiguration) getConfiguration()).getJndiStrategy().clone();
+
+ String[] result = js.bindConnectionFactories(deployment, new Object[]{cf}, new String[]{jndi});
+
+ ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url, cf.getClass().getName(),
+ jndi);
+
+ return result;
+ }
+
+ @Override
+ protected File getReportDirectory()
+ {
+ return new File(SecurityActions.getSystemProperty("iron.jacamar.home"), "/log/");
+ }
+
+ @Override
+ protected boolean checkConfigurationIsValid()
+ {
+ return getConfiguration() != null && getConfiguration() instanceof RAConfiguration;
+ }
+
+ @Override
+ protected PrintWriter getLogPrintWriter()
+ {
+ return new PrintWriter(((RAConfiguration) getConfiguration()).getPrintStream());
+ }
+
+ @Override
+ protected TransactionManager getTransactionManager()
+ {
+ return ((RAConfiguration) getConfiguration()).getTransactionManager();
+ }
+
+ @Override
+ protected void registerResourceAdapterToMDR(URL url, File root, Connector cmd, IronJacamar ijmd)
+ throws AlreadyExistsException
+ {
+ ((RAConfiguration) getConfiguration()).getMetadataRepository().registerResourceAdapter(url, root, cmd, ijmd);
+ }
+}
Deleted: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractResourceAdapterDeployer.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractResourceAdapterDeployer.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -1,1254 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * 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.
- *
- * 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.fungal;
-
-import org.jboss.jca.common.api.metadata.common.CommonConnDef;
-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.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.ConnectionDefinition;
-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.core.api.bootstrap.CloneableBootstrapContext;
-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.AlreadyExistsException;
-import org.jboss.jca.core.spi.mdr.MetadataRepository;
-import org.jboss.jca.core.spi.naming.JndiStrategy;
-import org.jboss.jca.validator.Failure;
-import org.jboss.jca.validator.FailureHelper;
-import org.jboss.jca.validator.Key;
-import org.jboss.jca.validator.Severity;
-import org.jboss.jca.validator.Validate;
-import org.jboss.jca.validator.ValidateClass;
-import org.jboss.jca.validator.ValidateObject;
-import org.jboss.jca.validator.Validator;
-import org.jboss.jca.validator.ValidatorException;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import javax.resource.Referenceable;
-import javax.resource.ResourceException;
-import javax.resource.spi.BootstrapContext;
-import javax.resource.spi.ManagedConnectionFactory;
-import javax.resource.spi.ResourceAdapter;
-import javax.resource.spi.ResourceAdapterAssociation;
-import javax.resource.spi.TransactionSupport;
-import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
-
-import org.jboss.logging.Logger;
-
-import com.github.fungal.api.classloading.KernelClassLoader;
-import com.github.fungal.api.util.Injection;
-import com.github.fungal.api.util.JarFilter;
-import com.github.fungal.spi.deployers.DeployException;
-import com.github.fungal.spi.deployers.Deployment;
-
-/**
- * An abstract resource adapter deployer which contains common functionality
- * for all resource adapter archive based deployers.
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public abstract class AbstractResourceAdapterDeployer
-{
- private static Logger log = Logger.getLogger(AbstractResourceAdapterDeployer.class);
-
- private static boolean trace = log.isTraceEnabled();
-
- /** The configuration */
- private RAConfiguration raConfiguration = null;
-
- private final boolean validateClasses;
-
- /**
- * Create a new AbstractResourceAdapterDeployer.
- *
- * @param activateDeployment
- * @param validateClasses
- */
- public AbstractResourceAdapterDeployer(boolean validateClasses)
- {
- super();
- this.validateClasses = validateClasses;
- }
-
- /**
- * Set the configuration
- * @param value The value
- */
- public void setConfiguration(RAConfiguration value)
- {
- raConfiguration = value;
- }
-
- /**
- * Get the configuration
- * @return The value
- */
- public RAConfiguration getConfiguration()
- {
- return raConfiguration;
- }
-
- /**
- * validate archive
- *
- * @param url of the archive
- * @param archiveValidation classes and/or to validate.
- * @param failures original list of failures
- * @return The list of failures gotten with all new failures added. Null in case of no failures
- * or if validation is not run according to {@link #getArchiveValidation()} Setting. It returns null also if
- * the concrete implementation of this class set validateClasses instance variable to flase and the list of
- * archiveValidation contains one or more instance of {@link ValidateClass} type
- */
- //IT IS PACKAGE PROTECTED ONLY FOR TESTS ACCESSIBILITY
- Set<Failure> validateArchive(URL url, List<Validate> archiveValidation, Set<Failure> failures)
- {
- // Archive validation
- if (!getConfiguration().getArchiveValidation())
- {
- return null;
- }
-
- for (Validate validate : archiveValidation)
- {
- if (!(validate instanceof ValidateObject) && !this.validateClasses)
- return null;
- }
-
- Validator validator = new Validator();
- List<Failure> partialFailures = validator.validate(archiveValidation);
-
- if (partialFailures != null)
- {
- if (failures == null)
- {
- failures = new HashSet<Failure>();
- }
- failures.addAll(partialFailures);
- }
-
- return failures;
- }
-
- /**
- * print Failures into Log files.
- *
- * @param urlFileName filename Of deployed rar
- * @param validator validator instance used to run validation rules
- * @param failures the list of Failures to be printed
- * @param reportDirectory where to put various logs
- * @param fhInput optional parameter. Normally used only for test or in case of
- * FailureHelper already present in context
- * @return the error Text
- *
- */
- //IT IS PACKAGE PROTECTED ONLY FOR TESTS ACCESSIBILITY
- String printFailuresLog(String urlFileName, Validator validator, Collection<Failure> failures, File reportDirectory,
- FailureHelper... fhInput)
- {
- String errorText = "";
- FailureHelper fh = null;
- if (fhInput.length == 0)
- fh = new FailureHelper(failures);
- else
- fh = fhInput[0];
-
- if (failures != null && failures.size() > 0)
- {
- if (reportDirectory == null)
- {
- reportDirectory = new File(SecurityActions.getSystemProperty("iron.jacamar.home"), "/log/");
- }
- if (reportDirectory.exists())
- {
- int lastSlashIndex = urlFileName.lastIndexOf("/");
- int lastSepaIndex = urlFileName.lastIndexOf(File.separator);
-
- int lastIndex = lastSlashIndex > lastSepaIndex ? lastSlashIndex : lastSepaIndex;
- if (lastIndex != -1)
- urlFileName = urlFileName.substring(lastIndex + 1);
- urlFileName += ".log";
-
- File report = new File(reportDirectory, urlFileName);
- FileWriter fw = null;
- BufferedWriter bw = null;
- try
- {
- fw = new FileWriter(report);
- bw = new BufferedWriter(fw, 8192);
- bw.write(fh.asText(validator.getResourceBundle()));
- bw.flush();
-
- errorText = "Validation failures - see: " + report.getAbsolutePath();
- }
- catch (IOException ioe)
- {
- log.warn(ioe.getMessage(), ioe);
- }
- finally
- {
- if (bw != null)
- {
- try
- {
- bw.close();
- }
- catch (IOException ignore)
- {
- // Ignore
- }
- }
- if (fw != null)
- {
- try
- {
- fw.close();
- }
- catch (IOException ignore)
- {
- // Ignore
- }
- }
- }
- }
- else
- {
- errorText = fh.asText(validator.getResourceBundle());
- }
- }
- return errorText;
- }
-
- /**
- * Cehck for failures at a certain level
- * @param failures The failures
- * @param severity The level
- * @return True if a failure is found with the specified severity; otherwise false
- */
- protected boolean hasFailuresLevel(Collection<Failure> failures, int severity)
- {
- if (failures != null)
- {
- for (Failure failure : failures)
- {
- if (failure.getSeverity() == severity)
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Start the resource adapter
- * @param resourceAdapter The resource adapter
- * @param bootstrapIdentifier The bootstrap context identifier; may be <code>null</code>
- * @throws DeployException Thrown if the resource adapter cant be started
- */
- @SuppressWarnings("unchecked")
- protected void startContext(ResourceAdapter resourceAdapter, String bootstrapIdentifier) throws DeployException
- {
- try
- {
- Class clz = resourceAdapter.getClass();
- Method start = clz.getMethod("start", new Class[]
- { BootstrapContext.class });
-
- CloneableBootstrapContext cbc = null;
-
- if (bootstrapIdentifier != null && getConfiguration().getBootstrapContexts() != null)
- {
- CloneableBootstrapContext bc = getConfiguration().getBootstrapContexts().get(bootstrapIdentifier);
-
- if (bc != null)
- cbc = bc.clone();
- }
-
- if (cbc == null)
- cbc = getConfiguration().getDefaultBootstrapContext().clone();
-
- start.invoke(resourceAdapter, new Object[]
- { cbc });
- }
- catch (InvocationTargetException ite)
- {
- throw new DeployException("Unable to start " + resourceAdapter.getClass().getName(), ite.getTargetException());
- }
- catch (Throwable t)
- {
- throw new DeployException("Unable to start " + resourceAdapter.getClass().getName(), t);
- }
- }
-
- /**
- * Associate resource adapter with ojects if they implement ResourceAdapterAssociation
- * @param resourceAdapter The resource adapter
- * @param object The of possible association object
- * @throws DeployException Thrown if the resource adapter cant be started
- */
- @SuppressWarnings("unchecked")
- protected void associateResourceAdapter(ResourceAdapter resourceAdapter, Object object) throws DeployException
- {
- if (resourceAdapter != null && object != null)
- {
- if (object instanceof ResourceAdapterAssociation)
- {
- try
- {
- Class clz = object.getClass();
-
- Method setResourceAdapter = clz.getMethod("setResourceAdapter", new Class[]
- { ResourceAdapter.class });
-
- setResourceAdapter.invoke(object, new Object[]
- { resourceAdapter });
- }
- catch (Throwable t)
- {
- throw new DeployException("Unable to associate " + object.getClass().getName(), t);
- }
- }
- }
- }
-
- /**
- * 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 Object initAndInject(String className, List<? extends ConfigProperty> configs, ClassLoader cl)
- throws DeployException
- {
- try
- {
- Class clz = Class.forName(className, true, cl);
- Object o = clz.newInstance();
-
- if (configs != null)
- {
- Injection injector = new Injection();
- for (ConfigProperty cpmd : configs)
- {
- if (cpmd.isValueSet())
- injector.inject(cpmd.getConfigPropertyType().getValue(), cpmd.getConfigPropertyName().getValue(),
- cpmd.getConfigPropertyValue().getValue(), o);
- }
- }
-
- return o;
- }
- catch (Throwable t)
- {
- throw new DeployException("Deployment " + className + " failed", t);
- }
- }
-
- /**
- * Get the URLs for the directory and all libraries located in the directory
- * @param directory The directory
- * @return The URLs
- * @exception MalformedURLException MalformedURLException
- * @exception IOException IOException
- */
- protected URL[] getUrls(File directory) throws MalformedURLException, IOException
- {
- List<URL> list = new LinkedList<URL>();
-
- if (directory.exists() && directory.isDirectory())
- {
- // Add directory
- list.add(directory.toURI().toURL());
-
- // Add the contents of the directory too
- File[] jars = directory.listFiles(new JarFilter());
-
- if (jars != null)
- {
- for (int j = 0; j < jars.length; j++)
- {
- list.add(jars[j].getCanonicalFile().toURI().toURL());
- }
- }
- }
- return list.toArray(new URL[list.size()]);
- }
-
- /**
- * Bind connection factory into JNDI
- * @param url The deployment URL
- * @param deployment The deployment name
- * @param cf The connection factory
- * @return The JNDI names bound
- * @exception Throwable Thrown if an error occurs
- */
- protected String[] bindConnectionFactory(URL url, String deployment, Object cf) throws Throwable
- {
- JndiStrategy js = getConfiguration().getJndiStrategy().clone();
-
- String[] result = js.bindConnectionFactories(deployment, new Object[]
- { cf });
-
- getConfiguration().getMetadataRepository().registerJndiMapping(url, cf.getClass().getName(), result[0]);
-
- return result;
- }
-
- /**
- * Bind connection factory into JNDI
- * @param url The deployment URL
- * @param deployment The deployment name
- * @param cf The connection factory
- * @param jndi The JNDI name
- * @return The JNDI names bound
- * @exception Throwable Thrown if an error occurs
- */
- protected String[] bindConnectionFactory(URL url, String deployment, Object cf, String jndi) throws Throwable
- {
- JndiStrategy js = getConfiguration().getJndiStrategy().clone();
-
- String[] result = js.bindConnectionFactories(deployment, new Object[]
- { cf }, new String[]
- { jndi });
-
- getConfiguration().getMetadataRepository().registerJndiMapping(url, cf.getClass().getName(), jndi);
-
- return result;
- }
-
- /**
- * Find the connection factory for a managed connection factory
- * @param clz The fully quilified class name for the managed connection factory
- * @param defs The connection definitions
- * @return The connection definiton; <code>null</code> if none could be found
- */
- protected org.jboss.jca.common.api.metadata.common.CommonConnDef findConnectionDefinition(String clz,
- List<org.jboss.jca.common.api.metadata.common.CommonConnDef> defs)
- {
- if (defs != null)
- {
- // If there is only one we will return that
- if (defs.size() == 1)
- {
- org.jboss.jca.common.api.metadata.common.CommonConnDef cd = defs.get(0);
-
- if (cd.getClassName() != null && !clz.equals(cd.getClassName()))
- {
- log.warn("Only one connection definitopn found with a mis-match in class-name: " + cd);
- return null;
- }
-
- return cd;
- }
-
- // If there are multiple definitions the MCF class name is mandatory
- if (clz == null)
- throw new IllegalArgumentException("ManagedConnectionFactory must be defined in class-name");
-
- for (org.jboss.jca.common.api.metadata.common.CommonConnDef cd : defs)
- {
- if (clz.equals(cd.getClassName()))
- return cd;
- }
- }
-
- return null;
- }
-
- /**
- * 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
- */
- protected 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;
- }
-
- /**
- * Start
- */
- public void start()
- {
- if (raConfiguration == null)
- throw new IllegalStateException("Configuration not defined");
- }
-
- /**
- * init the acrtivation spec
- *
- * @param cl cl
- * @param cmd cmd
- * @param resourceAdapter resourceAdapter
- * @param archiveValidationObjects archiveValidationObjects
- * @param beanValidationObjects beanValidationObjects
- * @throws DeployException in case of error
- */
- protected Set<Failure> initActivationSpec(KernelClassLoader cl, Connector cmd, ResourceAdapter resourceAdapter,
- List<Validate> archiveValidationObjects, List<Object> beanValidationObjects, Set<Failure> failures, URL url,
- boolean activateDeployment) throws DeployException
- {
- // 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)
- {
- failures = validateArchive(
- url,
- Arrays.asList((Validate) new ValidateClass(Key.ACTIVATION_SPEC, mlMeta.getActivationspec()
- .getActivationspecClass().getValue(), cl, mlMeta.getActivationspec().getConfigProperties())),
- failures);
- if (!(getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures,
- Severity.ERROR)))
- {
- if (activateDeployment)
- {
- 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);
- }
- }
- }
- }
- }
- }
- }
- return failures;
- }
-
- /**
- * init an Admin Object
- *
- * @param cmd cmd
- * @param cl cl
- * @param archiveValidationObjects archiveValidationObjects
- * @param beanValidationObjects beanValidationObjects
- * @throws DeployException in case of errors
- */
- protected Set<Failure> initAdminObject(Connector cmd, KernelClassLoader cl, List<Validate> archiveValidationObjects,
- List<Object> beanValidationObjects, Set<Failure> failures, URL url, boolean activateDeployment)
- throws DeployException
- {
- // 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)
- {
- failures = validateArchive(url,
- Arrays.asList((Validate) new ValidateClass(Key.ADMIN_OBJECT, aoMeta.getAdminobjectClass()
- .getValue(), cl, aoMeta.getConfigProperties())), failures);
- if (!(getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures,
- Severity.ERROR)))
- {
- if (activateDeployment)
- {
- 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);
- }
- }
- }
- }
- }
- }
- }
- return failures;
- }
-
- /**
- *
- * FIXME Comment this
- *
- * @param url
- * @param f
- * @param root
- * @param destination
- * @param cl
- * @param cmd
- * @param ijmd
- * @return
- * @throws DeployException
- * @throws ResourceException
- * @throws Throwable
- * @throws ValidatorException
- * @throws AlreadyExistsException
- * @throws ClassNotFoundException
- */
- protected Deployment createObjectsAndInjectValue(URL url, String deploymentName, File root, File destination,
- KernelClassLoader cl, Connector cmd, IronJacamar ijmd, URL deployment) throws DeployException, ResourceException,
- Throwable, ValidatorException, AlreadyExistsException, ClassNotFoundException
- {
- Set<Failure> failures = null;
- try
- {
- // Notify regarding license terms
- if (cmd != null && cmd.getLicense() != null && cmd.getLicense().isLicenseRequired())
- log.info("Required license terms for " + url.toExternalForm());
-
- ResourceAdapter resourceAdapter = null;
- List<Validate> archiveValidationObjects = new ArrayList<Validate>();
- List<Object> beanValidationObjects = new ArrayList<Object>();
- Object[] cfs = null;
- String[] jndiNames = null;
-
- // Check metadata for JNDI information and activate explicit
- boolean activateDeployment = checkActivation(cmd, ijmd);
-
- // 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)
- {
- failures = validateArchive(url,
- Arrays.asList((Validate) new ValidateClass(Key.RESOURCE_ADAPTER, ra1516.getResourceadapterClass(),
- cl, cmd.getResourceadapter().getConfigProperties())),
- failures);
-
- if (!(getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures,
- Severity.ERROR)))
- {
- if (activateDeployment)
- {
- resourceAdapter = (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)
- {
- ResourceAdapter10 ra10 = (ResourceAdapter10) cmd.getResourceadapter();
-
- if (activateDeployment)
- {
- CommonConnDef ijCD = null;
-
- if (ijmd != null)
- {
- ijCD = findConnectionDefinition(ra10.getManagedConnectionFactoryClass().getValue(),
- ijmd.getConnectionDefinitions());
- }
- //
- // if (ijmd == null || ijCD == null || ijCD.isEnabled())
- if (ijCD == null || ijCD.isEnabled())
- {
- ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(ra10
- .getManagedConnectionFactoryClass().getValue(), ra10.getConfigProperties(), cl);
-
- if (trace)
- {
- log.trace("ManagedConnectionFactory: " + mcf.getClass().getName());
- log.trace("ManagedConnectionFactory defined in classloader: " + mcf.getClass().getClassLoader());
- }
-
- mcf.setLogWriter(new PrintWriter(getConfiguration().getPrintStream()));
-
- archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY, mcf, ra10
- .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);
- PoolFactory pf = new PoolFactory();
-
- Boolean noTxSeparatePool = Boolean.FALSE;
-
- 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;
-
- TransactionSupportEnum tsmd = TransactionSupportEnum.NoTransaction;
-
- if (ijmd != null && ijmd.getTransactionSupport() != null)
- {
- tsmd = ijmd.getTransactionSupport();
- }
- else
- {
- tsmd = ((ResourceAdapter10) cmd.getResourceadapter()).getTransactionSupport();
- }
-
- TransactionSupportLevel tsl = TransactionSupportLevel.NoTransaction;
-
- 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 (ijCD != null && ijCD.getTimeOut() != null)
- {
- allocationRetry = ijCD.getTimeOut().getAllocationRetry();
- 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 (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();
- }
- }
-
- cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
- 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)
- {
- if (ijCD != null)
- {
- String jndiName = ijCD.getJndiName();
-
- bindConnectionFactory(url, deploymentName, cf, jndiName);
- cfs = new Object[]
- { cf };
- jndiNames = new String[]
- { jndiName };
-
- cm.setJndiName(jndiName);
- }
- else
- {
- jndiNames = bindConnectionFactory(url, deploymentName, cf);
- cfs = new Object[]
- { cf };
-
- cm.setJndiName(jndiNames[0]);
- }
- }
- }
- }
- }
- 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)
- {
-// if (cdMetas.size() == 1)
-// {
-// ConnectionDefinition cdMeta = cdMetas.get(0);
- cfs = new Object[cdMetas.size()];
- jndiNames = new String[cdMetas.size()];
-
- for (int cdIndex = 0; cdIndex < cdMetas.size(); cdIndex++)
- {
- ConnectionDefinition cdMeta = cdMetas.get(cdIndex);
-
- failures = validateArchive(url,
- Arrays.asList((Validate) new ValidateClass(Key.MANAGED_CONNECTION_FACTORY, cdMeta
- .getManagedConnectionFactoryClass().getValue(), cl, cdMeta.getConfigProperties())),
- failures);
-
- if (!(getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures,
- Severity.ERROR)))
- {
- if (activateDeployment)
- {
- org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD = null;
-
- if (ijmd != null)
- {
- ijCD = findConnectionDefinition(cdMeta.getManagedConnectionFactoryClass().getValue(),
- ijmd.getConnectionDefinitions());
- }
-
-// if (ijmd == null || ijCD == null || ijCD.isEnabled())
-// {
- if (ijCD == null || ijCD.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());
- }
-
- mcf.setLogWriter(new PrintWriter(getConfiguration().getPrintStream()));
-
- archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY, mcf,
- cdMeta.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);
- PoolFactory pf = new PoolFactory();
-
- Boolean noTxSeparatePool = Boolean.FALSE;
-
- if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
- {
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool = (org.jboss.jca.common.api.metadata.common.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 (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 (ijCD != null && ijCD.getTimeOut() != null)
- {
- allocationRetry = ijCD.getTimeOut().getAllocationRetry();
- 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 (ijCD != null && ijCD.isXa())
- {
- CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
-
- interleaving = ijXaPool.isInterleaving();
- isSameRMOverride = ijXaPool.isSameRmOverride();
- wrapXAResource = ijXaPool.isWrapXaDataSource();
- padXid = ijXaPool.isPadXid();
- }
-
- cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
- 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)
- {
- if (ijCD != null)
- {
- String jndiName = ijCD.getJndiName();
-
- bindConnectionFactory(url, deploymentName, cf, jndiName);
- cfs[cdIndex] = cf;
- jndiNames[cdIndex] = jndiName;
-
- cm.setJndiName(jndiName);
- }
- else
- {
- jndiNames = bindConnectionFactory(url, deploymentName, cf);
- cfs = new Object[]
- { cf };
-
- cm.setJndiName(jndiNames[0]);
- }
-
- }
- }
- }
- }
- }
- }
- }
- }
-
- failures = initActivationSpec(cl, cmd, resourceAdapter, archiveValidationObjects, beanValidationObjects,
- failures, url, activateDeployment);
-
- failures = initAdminObject(cmd, cl, archiveValidationObjects, beanValidationObjects, failures, url,
- activateDeployment);
- }
-
- // Archive validation
- failures = validateArchive(url, archiveValidationObjects, failures);
-
- if ((getConfiguration().getArchiveValidationFailOnWarn() && hasFailuresLevel(failures, Severity.WARNING)) ||
- (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);
- }
-
- if (cmd != null)
- {
- try
- {
- // Register with MDR
- getConfiguration().getMetadataRepository().registerResourceAdapter(url, root, cmd, ijmd);
- }
- catch (AlreadyExistsException e)
- {
- //ignore it, RA already registered
- }
- }
-
- if (activateDeployment)
- {
- // Bean validation
- if (getConfiguration().getBeanValidation())
- {
- List<Class> groupsClasses = null;
-
- if (ijmd != null && ijmd.getBeanValidationGroups() != null && ijmd.getBeanValidationGroups().size() > 0)
- {
- groupsClasses = new ArrayList<Class>();
- for (String group : ijmd.getBeanValidationGroups())
- {
- 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 (ijmd != null)
- {
- bootstrapIdentifier = ijmd.getBootstrapContext();
- }
-
- startContext(resourceAdapter, bootstrapIdentifier);
- }
- }
-
- if (activateDeployment)
- {
- log.info("Deployed: " + url.toExternalForm());
- }
- else
- {
- log.debug("Activated: " + url.toExternalForm());
- }
-
- return createDeployment(url, deploymentName, activateDeployment, resourceAdapter, getConfiguration()
- .getJndiStrategy(), getConfiguration().getMetadataRepository(), cfs, destination, cl, log, jndiNames,
- deployment, activateDeployment);
-
- }
- catch (DeployException de)
- {
- // Just rethrow
- throw de;
- }
- catch (Throwable t)
- {
- if ((getConfiguration().getArchiveValidationFailOnWarn() && hasFailuresLevel(failures, Severity.WARNING)) ||
- (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);
- }
- }
- }
-
- /**
- * 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
- */
- protected abstract boolean checkActivation(Connector cmd, IronJacamar ijmd);
-
- public abstract Deployment createDeployment(URL deploymentUrl, String deploymentName, boolean activator,
- ResourceAdapter resourceAdapter, JndiStrategy jndiStrategy, MetadataRepository metadataRepository, Object[] cfs,
- File destination, ClassLoader cl, Logger log, String[] jndis, URL deployment, boolean activateDeployemnt);
-}
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/BeanValidation.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/BeanValidation.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/BeanValidation.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -32,7 +32,6 @@
import javax.validation.ConstraintViolationException;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
-
import javax.validation.groups.Default;
import org.jboss.logging.Logger;
@@ -46,6 +45,7 @@
public class BeanValidation
{
private static Logger log = Logger.getLogger(BeanValidation.class);
+
private static boolean trace = log.isTraceEnabled();
/**
@@ -75,7 +75,7 @@
{
context = new InitialContext();
- ValidatorFactory vf = (ValidatorFactory)context.lookup("java:/ValidatorFactory");
+ ValidatorFactory vf = (ValidatorFactory) context.lookup("java:/ValidatorFactory");
Validator v = vf.usingContext().traversableResolver(new JCATraversableResolver()).getValidator();
Set errors = null;
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-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -256,10 +256,8 @@
if (!jndiName.startsWith("java:/"))
jndiName = "java:/" + jndiName;
- Object cf = deployDataSource(dataSource,
- jndiName,
- urlJdbcLocal,
- jdbcLocalDeployment.getClassLoader());
+ Object cf = deployDataSource(dataSource, jndiName, urlJdbcLocal,
+ jdbcLocalDeployment.getClassLoader());
bindConnectionFactory(deploymentName, jndiName, cf);
@@ -295,10 +293,8 @@
if (!jndiName.startsWith("java:/"))
jndiName = "java:/" + jndiName;
- Object cf = deployXADataSource(xaDataSource,
- jndiName,
- urlJdbcXA,
- jdbcXADeployment.getClassLoader());
+ Object cf = deployXADataSource(xaDataSource, jndiName, urlJdbcXA,
+ jdbcXADeployment.getClassLoader());
bindConnectionFactory(deploymentName, jndiName, cf);
@@ -318,11 +314,8 @@
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(url, deploymentName, cfs.toArray(new Object[cfs.size()]),
+ jndis.toArray(new String[jndis.size()]), parent);
}
catch (DeployException de)
{
@@ -370,15 +363,13 @@
md = merger.mergeConnectorAndDs(ds, md);
// Get the first connection definition as there is only one
- ResourceAdapter1516 ra1516 = (ResourceAdapter1516)md.getResourceadapter();
+ 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);
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cd.getManagedConnectionFactoryClass()
+ .getValue(), cd.getConfigProperties(), cl);
// Create the pool
PoolConfiguration pc = createPoolConfiguration(ds.getPool(), ds.getTimeOut(), ds.getValidation());
@@ -398,16 +389,8 @@
// 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);
+ ConnectionManager cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
+ getTransactionManager(), null, null, null, null, null);
cm.setJndiName(jndiName);
@@ -434,15 +417,13 @@
md = merger.mergeConnectorAndDs(ds, md);
// Get the first connection definition as there is only one
- ResourceAdapter1516 ra1516 = (ResourceAdapter1516)md.getResourceadapter();
+ 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);
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cd.getManagedConnectionFactoryClass()
+ .getValue(), cd.getConfigProperties(), cl);
// Create the pool
PoolConfiguration pc = createPoolConfiguration(ds.getXaPool(), ds.getTimeOut(), ds.getValidation());
@@ -481,16 +462,8 @@
// 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);
+ ConnectionManager cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
+ getTransactionManager(), interleaving, xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
cm.setJndiName(jndiName);
@@ -505,9 +478,7 @@
* @param vp The validation parameters
* @return The configuration
*/
- private PoolConfiguration createPoolConfiguration(CommonPool pp,
- CommonTimeOut tp,
- CommonValidation vp)
+ private PoolConfiguration createPoolConfiguration(CommonPool pp, CommonTimeOut tp, CommonValidation vp)
{
PoolConfiguration pc = new PoolConfiguration();
@@ -515,13 +486,13 @@
{
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());
}
@@ -558,9 +529,7 @@
* @return The object
* @throws DeployException Thrown if the object cant be initialized
*/
- private Object initAndInject(String className,
- List<? extends ConfigProperty> configs,
- ClassLoader cl)
+ private Object initAndInject(String className, List<? extends ConfigProperty> configs, ClassLoader cl)
throws DeployException
{
try
@@ -575,7 +544,7 @@
{
if (cpmd.isValueSet())
injector.inject(cpmd.getConfigPropertyType().getValue(), cpmd.getConfigPropertyName().getValue(),
- cpmd.getConfigPropertyValue().getValue(), o);
+ cpmd.getConfigPropertyValue().getValue(), o);
}
}
@@ -599,7 +568,7 @@
{
JndiStrategy js = new ExplicitJndiStrategy();
- return js.bindConnectionFactories(deployment, new Object[] {cf}, new String[] {jndi});
+ return js.bindConnectionFactories(deployment, new Object[]{cf}, new String[]{jndi});
}
/**
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployment.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployment.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -65,11 +65,7 @@
* @param jndis The JNDI names for the factories
* @param cl The classloader
*/
- public DsXmlDeployment(URL deployment,
- String deploymentName,
- Object[] cfs,
- String[] jndis,
- ClassLoader cl)
+ public DsXmlDeployment(URL deployment, String deploymentName, Object[] cfs, String[] jndis, ClassLoader cl)
{
this.deployment = deployment;
this.deploymentName = deploymentName;
@@ -82,6 +78,7 @@
* Get the unique URL for the deployment
* @return The URL
*/
+ @Override
public URL getURL()
{
return deployment;
@@ -91,6 +88,7 @@
* Get the classloader
* @return The classloader
*/
+ @Override
public ClassLoader getClassLoader()
{
return cl;
@@ -127,7 +125,7 @@
{
try
{
- ((Closeable)cl).close();
+ ((Closeable) cl).close();
}
catch (IOException ioe)
{
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/JCATraversableResolver.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/JCATraversableResolver.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/JCATraversableResolver.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -53,9 +53,9 @@
* @return <code>true</code> if Bean Validation is allowed to reach the
* property state, <code>false</code> otherwise.
*/
- public boolean isReachable(Object traversableObject, Path.Node traversableProperty,
- Class<?> rootBeanType, Path pathToTraversableObject,
- ElementType elementType)
+ @Override
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType,
+ Path pathToTraversableObject, ElementType elementType)
{
return true;
}
@@ -82,9 +82,9 @@
* @return <code>true</code> if Bean Validation is allowed to cascade
* validation, <code>false</code> otherwise.
*/
- public boolean isCascadable(Object traversableObject,
- Path.Node traversableProperty, Class<?> rootBeanType,
- Path pathToTraversableObject, ElementType elementType)
+ @Override
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType,
+ Path pathToTraversableObject, ElementType elementType)
{
return true;
}
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-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -27,6 +27,7 @@
import org.jboss.jca.common.metadata.merge.Merger;
import org.jboss.jca.core.spi.mdr.MetadataRepository;
import org.jboss.jca.core.spi.naming.JndiStrategy;
+import org.jboss.jca.deployers.common.CommonDeployment;
import org.jboss.jca.validator.Failure;
import java.io.File;
@@ -36,8 +37,6 @@
import java.util.Map;
import java.util.Set;
-import javax.resource.spi.ResourceAdapter;
-
import org.jboss.logging.Logger;
import com.github.fungal.api.Kernel;
@@ -52,7 +51,7 @@
* The RA activator for JCA/SJC
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
*/
-public final class RAActivator extends AbstractResourceAdapterDeployer implements DeployerPhases
+public final class RAActivator extends AbstractFungalRADeployer implements DeployerPhases
{
/** The logger */
static Logger log = Logger.getLogger(RAActivator.class);
@@ -143,6 +142,7 @@
* Pre deploy
* @exception Throwable Thrown if an error occurs
*/
+ @Override
public void preDeploy() throws Throwable
{
}
@@ -151,11 +151,12 @@
* Post deploy
* @exception Throwable Thrown if an error occurs
*/
+ @Override
public void postDeploy() throws Throwable
{
if (enabled)
{
- Set<URL> rarDeployments = getConfiguration().getMetadataRepository().getResourceAdapters();
+ Set<URL> rarDeployments = ((RAConfiguration) getConfiguration()).getMetadataRepository().getResourceAdapters();
for (URL deployment : rarDeployments)
{
@@ -175,8 +176,8 @@
if (include)
{
- Map<String, List<String>> jndiMappings = getConfiguration().getMetadataRepository().getJndiMappings(
- deployment);
+ Map<String, List<String>> jndiMappings = ((RAConfiguration) getConfiguration()).getMetadataRepository()
+ .getJndiMappings(deployment);
// If there isn't any JNDI mappings then the archive isn't active
// so activate it
@@ -202,6 +203,7 @@
* Pre undeploy
* @exception Throwable Thrown if an error occurs
*/
+ @Override
public void preUndeploy() throws Throwable
{
if (deployments != null)
@@ -226,6 +228,7 @@
* Post undeploy
* @exception Throwable Thrown if an error occurs
*/
+ @Override
public void postUndeploy() throws Throwable
{
}
@@ -269,7 +272,7 @@
// Create classloader
URL[] urls = getUrls(root);
KernelClassLoader cl = null;
- if (getConfiguration().getScopeDeployment())
+ if (((RAConfiguration) getConfiguration()).getScopeDeployment())
{
cl = ClassLoaderFactory.create(ClassLoaderFactory.TYPE_PARENT_LAST, urls, parent);
}
@@ -280,20 +283,28 @@
SecurityActions.setThreadContextClassLoader(cl);
// Get metadata
- Connector cmd = getConfiguration().getMetadataRepository().getResourceAdapter(url);
- IronJacamar ijmd = getConfiguration().getMetadataRepository().getIronJacamar(url);
+ MetadataRepository metadataRepository = ((RAConfiguration) getConfiguration()).getMetadataRepository();
+ Connector cmd = metadataRepository.getResourceAdapter(url);
+ IronJacamar ijmd = metadataRepository.getIronJacamar(url);
+
cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(ijmd, cmd);
+ CommonDeployment c = createObjectsAndInjectValue(url, deploymentName, root, destination, cl, cmd, ijmd, null);
+ JndiStrategy jndiStrategy = ((RAConfiguration) getConfiguration()).getJndiStrategy();
+ return new RAActivatorDeployment(c.getURL(), c.getDeploymentName(), c.getResourceAdapter(), jndiStrategy,
+ metadataRepository, c.getCfs(), c.getJndiNames(), c.getCl(), c.getLog());
- return createObjectsAndInjectValue(url, deploymentName, root, destination, cl, cmd, ijmd, null);
-
}
catch (DeployException de)
{
//just rethrow
throw de;
}
+ catch (org.jboss.jca.deployers.common.DeployException cde)
+ {
+ throw new DeployException(cde.getMessage(), cde.getCause());
+ }
catch (Throwable t)
{
@@ -325,12 +336,4 @@
return true;
}
- @Override
- public Deployment createDeployment(URL deploymentUrl, String deploymentName, boolean activator,
- ResourceAdapter resourceAdapter, JndiStrategy jndiStrategy, MetadataRepository metadataRepository, Object[] cfs,
- File destination, ClassLoader cl, Logger log, String[] jndis, URL deployment, boolean activateDeployment)
- {
- return new RAActivatorDeployment(deploymentUrl, deploymentName, resourceAdapter, getConfiguration()
- .getJndiStrategy(), getConfiguration().getMetadataRepository(), cfs, jndis, cl, log);
- }
}
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -80,15 +80,8 @@
* @param cl The classloader for the deployment
* @param log The logger
*/
- public RAActivatorDeployment(URL deployment,
- String deploymentName,
- ResourceAdapter ra,
- JndiStrategy jndiStrategy,
- MetadataRepository metadataRepository,
- Object[] cfs,
- String[] jndis,
- ClassLoader cl,
- Logger log)
+ public RAActivatorDeployment(URL deployment, String deploymentName, ResourceAdapter ra, JndiStrategy jndiStrategy,
+ MetadataRepository metadataRepository, Object[] cfs, String[] jndis, ClassLoader cl, Logger log)
{
this.deployment = deployment;
this.deploymentName = deploymentName;
@@ -105,6 +98,7 @@
* Get the unique URL for the deployment
* @return The URL
*/
+ @Override
public URL getURL()
{
return deployment;
@@ -114,6 +108,7 @@
* Get the classloader
* @return The classloader
*/
+ @Override
public ClassLoader getClassLoader()
{
return cl;
@@ -125,7 +120,7 @@
public void stop()
{
log.debug("Undeploying: " + deployment.toExternalForm());
-
+
if (mdr != null && cfs != null && jndis != null)
{
for (int i = 0; i < cfs.length; i++)
@@ -165,7 +160,7 @@
{
try
{
- ((Closeable)cl).close();
+ ((Closeable) cl).close();
}
catch (IOException ioe)
{
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAConfiguration.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAConfiguration.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAConfiguration.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -25,6 +25,7 @@
import org.jboss.jca.core.api.bootstrap.CloneableBootstrapContext;
import org.jboss.jca.core.spi.mdr.MetadataRepository;
import org.jboss.jca.core.spi.naming.JndiStrategy;
+import org.jboss.jca.deployers.common.Configuration;
import java.io.PrintStream;
import java.util.Map;
@@ -38,7 +39,7 @@
* A configuration for the resource adapter deployer chain
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
*/
-public class RAConfiguration
+public class RAConfiguration implements Configuration
{
private static Logger log = Logger.getLogger(RAConfiguration.class);
@@ -48,16 +49,16 @@
private TransactionManager transactionManager = null;
/** Preform bean validation */
- private AtomicBoolean beanValidation = new AtomicBoolean(true);
+ private final AtomicBoolean beanValidation = new AtomicBoolean(true);
/** Preform archive validation */
- private AtomicBoolean archiveValidation = new AtomicBoolean(true);
+ private final AtomicBoolean archiveValidation = new AtomicBoolean(true);
/** Archive validation: Fail on Warn */
- private AtomicBoolean archiveValidationFailOnWarn = new AtomicBoolean(false);
+ private final AtomicBoolean archiveValidationFailOnWarn = new AtomicBoolean(false);
/** Archive validation: Fail on Error */
- private AtomicBoolean archiveValidationFailOnError = new AtomicBoolean(true);
+ private final AtomicBoolean archiveValidationFailOnError = new AtomicBoolean(true);
/** Print stream */
private PrintStream printStream = null;
@@ -69,7 +70,7 @@
private Map<String, CloneableBootstrapContext> bootstrapContexts = null;
/** Scope deployment */
- private AtomicBoolean scopeDeployment = new AtomicBoolean(false);
+ private final AtomicBoolean scopeDeployment = new AtomicBoolean(false);
/** JNDI strategy */
private JndiStrategy jndiStrategy = null;
@@ -106,6 +107,7 @@
* Set if bean validation should be performed
* @param value The value
*/
+ @Override
public void setBeanValidation(boolean value)
{
beanValidation.set(value);
@@ -115,6 +117,7 @@
* Should bean validation be performed
* @return True if validation; otherwise false
*/
+ @Override
public boolean getBeanValidation()
{
return beanValidation.get();
@@ -124,6 +127,7 @@
* Set if archive validation should be performed
* @param value The value
*/
+ @Override
public void setArchiveValidation(boolean value)
{
archiveValidation.set(value);
@@ -133,6 +137,7 @@
* Should archive validation be performed
* @return True if validation; otherwise false
*/
+ @Override
public boolean getArchiveValidation()
{
return archiveValidation.get();
@@ -142,6 +147,7 @@
* Set if a failed warning archive validation report should fail the deployment
* @param value The value
*/
+ @Override
public void setArchiveValidationFailOnWarn(boolean value)
{
archiveValidationFailOnWarn.set(value);
@@ -151,6 +157,7 @@
* Does a failed archive validation warning report fail the deployment
* @return True if failing; otherwise false
*/
+ @Override
public boolean getArchiveValidationFailOnWarn()
{
return archiveValidationFailOnWarn.get();
@@ -160,6 +167,7 @@
* Set if a failed error archive validation report should fail the deployment
* @param value The value
*/
+ @Override
public void setArchiveValidationFailOnError(boolean value)
{
archiveValidationFailOnError.set(value);
@@ -169,6 +177,7 @@
* Does a failed archive validation error report fail the deployment
* @return True if failing; otherwise false
*/
+ @Override
public boolean getArchiveValidationFailOnError()
{
return archiveValidationFailOnError.get();
@@ -196,6 +205,7 @@
* Set the default bootstrap context
* @param value The value
*/
+ @Override
public void setDefaultBootstrapContext(CloneableBootstrapContext value)
{
defaultBootstrapContext = value;
@@ -205,6 +215,7 @@
* Get the default bootstrap context
* @return The handle
*/
+ @Override
public CloneableBootstrapContext getDefaultBootstrapContext()
{
return defaultBootstrapContext;
@@ -214,6 +225,7 @@
* Set the bootstrap context map
* @param value The value
*/
+ @Override
public void setBootstrapContexts(Map<String, CloneableBootstrapContext> value)
{
bootstrapContexts = value;
@@ -223,6 +235,7 @@
* Get the bootstrap context map
* @return The handle
*/
+ @Override
public Map<String, CloneableBootstrapContext> getBootstrapContexts()
{
return bootstrapContexts;
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-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -36,6 +36,7 @@
import org.jboss.jca.common.spi.annotations.repository.AnnotationScannerFactory;
import org.jboss.jca.core.spi.mdr.MetadataRepository;
import org.jboss.jca.core.spi.naming.JndiStrategy;
+import org.jboss.jca.deployers.common.CommonDeployment;
import java.io.File;
import java.io.IOException;
@@ -44,17 +45,12 @@
import java.util.List;
import java.util.Set;
-import javax.resource.spi.ResourceAdapter;
-
-import org.jboss.logging.Logger;
-
import com.github.fungal.api.classloading.ClassLoaderFactory;
import com.github.fungal.api.classloading.KernelClassLoader;
import com.github.fungal.api.util.FileUtil;
import com.github.fungal.spi.deployers.DeployException;
import com.github.fungal.spi.deployers.Deployer;
import com.github.fungal.spi.deployers.DeployerOrder;
-import com.github.fungal.spi.deployers.Deployment;
import com.github.fungal.spi.deployers.MultiStageDeployer;
/**
@@ -63,16 +59,9 @@
* @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a>
* @author <a href="mailto:stefano.maestri at javalinux.it">Stefano Maestri</a>
*/
-public final class RADeployer extends AbstractResourceAdapterDeployer
- implements
- Deployer,
- MultiStageDeployer,
- DeployerOrder
+public final class RADeployer extends AbstractFungalRADeployer implements Deployer, MultiStageDeployer, DeployerOrder
{
- static Logger log = Logger.getLogger(RADeployer.class);
- static boolean trace = log.isTraceEnabled();
-
/**
* Constructor
*/
@@ -100,7 +89,8 @@
*/
@SuppressWarnings("rawtypes")
@Override
- public synchronized Deployment deploy(URL url, ClassLoader parent) throws DeployException
+ public synchronized com.github.fungal.spi.deployers.Deployment deploy(URL url, ClassLoader parent)
+ throws DeployException
{
if (url == null || !(url.toExternalForm().endsWith(".rar") || url.toExternalForm().endsWith(".rar/")))
return null;
@@ -130,11 +120,10 @@
}
String deploymentName = f.getName().substring(0, f.getName().indexOf(".rar"));
-
// Create classloader
URL[] urls = getUrls(root);
KernelClassLoader cl = null;
- if (getConfiguration().getScopeDeployment())
+ if (((RAConfiguration) getConfiguration()).getScopeDeployment())
{
cl = ClassLoaderFactory.create(ClassLoaderFactory.TYPE_PARENT_LAST, urls, parent);
}
@@ -161,7 +150,12 @@
// Merge metadata
cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(ijmd, cmd);
- return createObjectsAndInjectValue(url, deploymentName, root, destination, cl, cmd, ijmd, null);
+ CommonDeployment c = createObjectsAndInjectValue(url, deploymentName, root, destination, cl, cmd, ijmd, null);
+ JndiStrategy jndiStrategy = ((RAConfiguration) getConfiguration()).getJndiStrategy();
+ MetadataRepository metadataRepository = ((RAConfiguration) getConfiguration()).getMetadataRepository();
+ return new RADeployment(c.getURL(), c.getDeploymentName(), c.isActivateDeployment(), c.getResourceAdapter(),
+ jndiStrategy, metadataRepository, c.getCfs(), c.getJndiNames(), c.getDestination(),
+ c.getCl(), c.getLog());
}
catch (DeployException de)
@@ -169,6 +163,10 @@
//just rethrow
throw de;
}
+ catch (org.jboss.jca.deployers.common.DeployException cde)
+ {
+ throw new DeployException(cde.getMessage(), cde.getCause());
+ }
catch (Throwable t)
{
@@ -182,16 +180,6 @@
}
}
-
- @Override
- public Deployment createDeployment(URL deploymentUrl, String deploymentName, boolean activator,
- ResourceAdapter resourceAdapter, JndiStrategy jndiStrategy, MetadataRepository metadataRepository, Object[] cfs,
- File destination, ClassLoader cl, Logger log, String[] jndis, URL deployment, boolean activateDeployment)
- {
- return new RADeployment(deploymentUrl, deploymentName, activateDeployment, resourceAdapter, jndiStrategy,
- metadataRepository, cfs, jndis, destination, cl, log);
- }
-
/**
* Check if the resource adapter should be activated based on the ironjacamar.xml input
* @param cmd The connector metadata
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-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -90,17 +90,9 @@
* @param cl The classloader for the deployment
* @param log The logger
*/
- public RADeployment(URL deployment,
- String deploymentName,
- boolean activator,
- ResourceAdapter ra,
- JndiStrategy jndiStrategy,
- MetadataRepository metadataRepository,
- Object[] cfs,
- String[] jndis,
- File tmpDirectory,
- ClassLoader cl,
- Logger log)
+ public RADeployment(URL deployment, String deploymentName, boolean activator, ResourceAdapter ra,
+ JndiStrategy jndiStrategy, MetadataRepository metadataRepository, Object[] cfs, String[] jndis,
+ File tmpDirectory, ClassLoader cl, Logger log)
{
this.deployment = deployment;
this.deploymentName = deploymentName;
@@ -119,6 +111,7 @@
* Get the unique URL for the deployment
* @return The URL
*/
+ @Override
public URL getURL()
{
return deployment;
@@ -128,6 +121,7 @@
* Get the classloader
* @return The classloader
*/
+ @Override
public ClassLoader getClassLoader()
{
return cl;
@@ -194,7 +188,7 @@
{
try
{
- ((Closeable)cl).close();
+ ((Closeable) cl).close();
}
catch (IOException ioe)
{
@@ -214,7 +208,7 @@
// Ignore
}
}
-
+
if (activator)
{
log.info("Undeployed: " + deployment.toExternalForm());
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-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -22,6 +22,7 @@
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;
@@ -40,8 +41,6 @@
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.core.spi.naming.JndiStrategy;
import org.jboss.jca.validator.Failure;
import org.jboss.jca.validator.Key;
import org.jboss.jca.validator.Severity;
@@ -63,7 +62,6 @@
import javax.resource.Referenceable;
import javax.resource.spi.ManagedConnectionFactory;
-import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.TransactionSupport;
import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
@@ -83,10 +81,12 @@
* The -ra.xml deployer for JCA/SJC
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
*/
-public final class RaXmlDeployer extends AbstractResourceAdapterDeployer implements Deployer,
- MultiStageDeployer,
- DeployerOrder,
- DeployerPhases
+public final class RaXmlDeployer extends AbstractFungalRADeployer
+ implements
+ Deployer,
+ MultiStageDeployer,
+ DeployerOrder,
+ DeployerPhases
{
private static Logger log = Logger.getLogger(RaXmlDeployer.class);
@@ -110,6 +110,7 @@
* Deployer order
* @return The deployment
*/
+ @Override
public int getOrder()
{
return 0;
@@ -137,6 +138,7 @@
* Pre deploy
* @exception Throwable Thrown if an error occurs
*/
+ @Override
public void preDeploy() throws Throwable
{
}
@@ -145,6 +147,7 @@
* Post deploy
* @exception Throwable Thrown if an error occurs
*/
+ @Override
public void postDeploy() throws Throwable
{
}
@@ -153,6 +156,7 @@
* Pre undeploy
* @exception Throwable Thrown if an error occurs
*/
+ @Override
public void preUndeploy() throws Throwable
{
if (deployments != null)
@@ -177,6 +181,7 @@
* Post undeploy
* @exception Throwable Thrown if an error occurs
*/
+ @Override
public void postUndeploy() throws Throwable
{
}
@@ -219,8 +224,8 @@
{
deployments = new ArrayList<Deployment>(size);
- for (org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml :
- raXmlDeployment.getResourceAdapters())
+ for (org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml : raXmlDeployment
+ .getResourceAdapters())
{
Deployment raDeployment = doDeploy(url, raxml, parent);
if (raDeployment != null)
@@ -269,10 +274,8 @@
* @return The deployment
* @exception DeployException Thrown if an error occurs during deployment
*/
- private Deployment doDeploy(URL url,
- org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml,
- ClassLoader parent)
- throws DeployException
+ private Deployment doDeploy(URL url, org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml,
+ ClassLoader parent) throws DeployException
{
Set<Failure> failures = null;
@@ -282,7 +285,7 @@
// Find the archive in MDR
String archive = raxml.getArchive();
URL deployment = null;
- Set<URL> deployments = getConfiguration().getMetadataRepository().getResourceAdapters();
+ Set<URL> deployments = ((RAConfiguration) getConfiguration()).getMetadataRepository().getResourceAdapters();
for (URL u : deployments)
{
@@ -295,15 +298,16 @@
throw new DeployException("Archive " + archive + " couldn't be resolved in " + url.toExternalForm());
}
- Connector cmd = getConfiguration().getMetadataRepository().getResourceAdapter(deployment);
- IronJacamar ijmd = getConfiguration().getMetadataRepository().getIronJacamar(deployment);
- File root = getConfiguration().getMetadataRepository().getRoot(deployment);
+ Connector cmd = ((RAConfiguration) getConfiguration()).getMetadataRepository()
+ .getResourceAdapter(deployment);
+ IronJacamar ijmd = ((RAConfiguration) getConfiguration()).getMetadataRepository().getIronJacamar(deployment);
+ File root = ((RAConfiguration) getConfiguration()).getMetadataRepository().getRoot(deployment);
cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(raxml, cmd);
// Create classloader
URL[] urls = getUrls(root);
KernelClassLoader cl = null;
- if (getConfiguration().getScopeDeployment())
+ if (((RAConfiguration) getConfiguration()).getScopeDeployment())
{
cl = ClassLoaderFactory.create(ClassLoaderFactory.TYPE_PARENT_LAST, urls, parent);
}
@@ -328,12 +332,11 @@
// ResourceAdapter
if (cmd.getVersion() != Version.V_10)
{
- ResourceAdapter1516 ra1516 = (ResourceAdapter1516)cmd.getResourceadapter();
+ ResourceAdapter1516 ra1516 = (ResourceAdapter1516) cmd.getResourceadapter();
if (ra1516 != null && ra1516.getResourceadapterClass() != null)
{
- resourceAdapter =
- (javax.resource.spi.ResourceAdapter) initAndInject(
- ra1516.getResourceadapterClass(), ra1516.getConfigProperties(), cl);
+ resourceAdapter = (javax.resource.spi.ResourceAdapter) initAndInject(
+ ra1516.getResourceadapterClass(), ra1516.getConfigProperties(), cl);
if (trace)
{
@@ -342,9 +345,8 @@
resourceAdapter.getClass().getClassLoader());
}
- archiveValidationObjects.add(new ValidateObject(Key.RESOURCE_ADAPTER,
- resourceAdapter,
- ra1516.getConfigProperties()));
+ archiveValidationObjects.add(new ValidateObject(Key.RESOURCE_ADAPTER, resourceAdapter, ra1516
+ .getConfigProperties()));
beanValidationObjects.add(resourceAdapter);
}
}
@@ -353,24 +355,20 @@
if (cmd.getVersion() == Version.V_10)
{
- org.jboss.jca.common.api.metadata.common.CommonConnDef cdRaXml =
- findConnectionDefinition(((ResourceAdapter10) cmd.getResourceadapter())
- .getManagedConnectionFactoryClass().getValue(),
- raxml.getConnectionDefinitions());
+ 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);
+ 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());
+ log.trace("ManagedConnectionFactory defined in classloader: " + mcf.getClass().getClassLoader());
}
org.jboss.jca.common.api.metadata.common.CommonConnDef ijCD = null;
@@ -380,12 +378,11 @@
ijCD = findConnectionDefinition(mcf.getClass().getName(), ijmd.getConnectionDefinitions());
}
- mcf.setLogWriter(new PrintWriter(getConfiguration().getPrintStream()));
+ mcf.setLogWriter(new PrintWriter(((RAConfiguration) getConfiguration()).getPrintStream()));
- archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY,
- mcf,
+ archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY, mcf,
((ResourceAdapter10) cmd.getResourceadapter())
- .getConfigProperties()));
+ .getConfigProperties()));
beanValidationObjects.add(mcf);
associateResourceAdapter(resourceAdapter, mcf);
@@ -412,16 +409,14 @@
if (cdRaXml.getPool() != null && cdRaXml.isXa())
{
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool =
- (org.jboss.jca.common.api.metadata.common.CommonXaPool)cdRaXml.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
if (ijXaPool != null)
noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
}
else if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
{
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool =
- (org.jboss.jca.common.api.metadata.common.CommonXaPool)ijCD.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
if (ijXaPool != null)
noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
@@ -488,10 +483,7 @@
// Select the correct connection manager
if (tsl == TransactionSupportLevel.NoTransaction)
{
- cm = cmf.createNonTransactional(tsl,
- pool,
- allocationRetry,
- allocationRetryWaitMillis);
+ cm = cmf.createNonTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis);
}
else
{
@@ -503,8 +495,7 @@
if (cdRaXml.isXa())
{
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool =
- (org.jboss.jca.common.api.metadata.common.CommonXaPool)cdRaXml.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
interleaving = ijXaPool.isInterleaving();
isSameRMOverride = ijXaPool.isSameRmOverride();
@@ -514,8 +505,7 @@
if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
{
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool =
- (org.jboss.jca.common.api.metadata.common.CommonXaPool)ijCD.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
if (ijXaPool != null)
{
@@ -533,16 +523,9 @@
}
}
- cm = cmf.createTransactional(tsl,
- pool,
- allocationRetry,
- allocationRetryWaitMillis,
- getConfiguration().getTransactionManager(),
- interleaving,
- xaResourceTimeout,
- isSameRMOverride,
- wrapXAResource,
- padXid);
+ cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
+ ((RAConfiguration) getConfiguration()).getTransactionManager(), interleaving,
+ xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
}
// ConnectionFactory
@@ -557,8 +540,7 @@
if (trace)
{
log.trace("ConnectionFactory: " + cf.getClass().getName());
- log.trace("ConnectionFactory defined in classloader: "
- + cf.getClass().getClassLoader());
+ log.trace("ConnectionFactory defined in classloader: " + cf.getClass().getClassLoader());
}
}
@@ -566,14 +548,14 @@
if (cf != null && cf instanceof Serializable && cf instanceof Referenceable)
{
- org.jboss.jca.common.api.metadata.common.CommonConnDef cd =
- findConnectionDefinition(mcf.getClass().getName(), raxml.getConnectionDefinitions());
+ 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};
+ cfs = new Object[]{cf};
+ jndiNames = new String[]{jndiName};
cm.setJndiName(jndiName);
}
@@ -582,12 +564,11 @@
else
{
ResourceAdapter1516 ra = (ResourceAdapter1516) cmd.getResourceadapter();
- if (ra != null &&
- ra.getOutboundResourceadapter() != null &&
+ if (ra != null && ra.getOutboundResourceadapter() != null &&
ra.getOutboundResourceadapter().getConnectionDefinitions() != null)
{
- List<org.jboss.jca.common.api.metadata.ra.ConnectionDefinition> cdMetas =
- ra.getOutboundResourceadapter().getConnectionDefinitions();
+ List<org.jboss.jca.common.api.metadata.ra.ConnectionDefinition> cdMetas = ra
+ .getOutboundResourceadapter().getConnectionDefinitions();
if (cdMetas.size() > 0)
{
@@ -598,16 +579,13 @@
{
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());
+ 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);
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cdMeta
+ .getManagedConnectionFactoryClass().getValue(), cdMeta.getConfigProperties(), cl);
if (trace)
{
@@ -621,13 +599,12 @@
if (ijmd != null)
{
ijCD = findConnectionDefinition(mcf.getClass().getName(),
- ijmd.getConnectionDefinitions());
+ ijmd.getConnectionDefinitions());
}
- mcf.setLogWriter(new PrintWriter(getConfiguration().getPrintStream()));
+ mcf.setLogWriter(new PrintWriter(((RAConfiguration) getConfiguration()).getPrintStream()));
- archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY,
- mcf,
+ archiveValidationObjects.add(new ValidateObject(Key.MANAGED_CONNECTION_FACTORY, mcf,
cdMeta.getConfigProperties()));
beanValidationObjects.add(mcf);
associateResourceAdapter(resourceAdapter, mcf);
@@ -637,15 +614,12 @@
if (cdRaXml.getPool() != null || cdRaXml.getPool() != null || cdRaXml.getPool() != null)
{
- pc = createPoolConfiguration(cdRaXml.getPool(),
- cdRaXml.getTimeOut(),
- cdRaXml.getValidation());
+ pc = createPoolConfiguration(cdRaXml.getPool(), cdRaXml.getTimeOut(),
+ cdRaXml.getValidation());
}
else if (ijCD != null)
{
- pc = createPoolConfiguration(ijCD.getPool(),
- ijCD.getTimeOut(),
- ijCD.getValidation());
+ pc = createPoolConfiguration(ijCD.getPool(), ijCD.getTimeOut(), ijCD.getValidation());
}
else
{
@@ -659,16 +633,14 @@
if (cdRaXml.getPool() != null && cdRaXml.isXa())
{
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool =
- (org.jboss.jca.common.api.metadata.common.CommonXaPool)cdRaXml.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
if (ijXaPool != null)
noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
}
else if (ijCD != null && ijCD.getPool() != null && ijCD.isXa())
{
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool =
- (org.jboss.jca.common.api.metadata.common.CommonXaPool)ijCD.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
if (ijXaPool != null)
noTxSeparatePool = ijXaPool.isNoTxSeparatePool();
@@ -734,10 +706,7 @@
// Select the correct connection manager
if (tsl == TransactionSupportLevel.NoTransaction)
{
- cm = cmf.createNonTransactional(tsl,
- pool,
- allocationRetry,
- allocationRetryWaitMillis);
+ cm = cmf.createNonTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis);
}
else
{
@@ -749,8 +718,7 @@
if (cdRaXml.isXa())
{
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool =
- (org.jboss.jca.common.api.metadata.common.CommonXaPool)cdRaXml.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) cdRaXml.getPool();
interleaving = ijXaPool.isInterleaving();
isSameRMOverride = ijXaPool.isSameRmOverride();
@@ -760,8 +728,7 @@
if (ijCD != null && ijCD.isXa())
{
- org.jboss.jca.common.api.metadata.common.CommonXaPool ijXaPool =
- (org.jboss.jca.common.api.metadata.common.CommonXaPool)ijCD.getPool();
+ CommonXaPool ijXaPool = (CommonXaPool) ijCD.getPool();
if (interleaving == null)
interleaving = ijXaPool.isInterleaving();
@@ -776,16 +743,9 @@
padXid = ijXaPool.isPadXid();
}
- cm = cmf.createTransactional(tsl,
- pool,
- allocationRetry,
- allocationRetryWaitMillis,
- getConfiguration().getTransactionManager(),
- interleaving,
- xaResourceTimeout,
- isSameRMOverride,
- wrapXAResource,
- padXid);
+ cm = cmf.createTransactional(tsl, pool, allocationRetry, allocationRetryWaitMillis,
+ ((RAConfiguration) getConfiguration()).getTransactionManager(), interleaving,
+ xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
}
// ConnectionFactory
@@ -800,8 +760,8 @@
if (trace)
{
log.trace("ConnectionFactory: " + cf.getClass().getName());
- log.trace("ConnectionFactory defined in classloader: "
- + cf.getClass().getClassLoader());
+ log.trace("ConnectionFactory defined in classloader: " +
+ cf.getClass().getClassLoader());
}
}
@@ -827,13 +787,12 @@
if (cmd.getVersion() != Version.V_10)
{
ResourceAdapter1516 ra1516 = (ResourceAdapter1516) cmd.getResourceadapter();
- if (ra1516 != null &&
- ra1516.getInboundResourceadapter() != null &&
+ if (ra1516 != null && ra1516.getInboundResourceadapter() != null &&
ra1516.getInboundResourceadapter().getMessageadapter() != null &&
ra1516.getInboundResourceadapter().getMessageadapter().getMessagelisteners() != null)
{
- List<MessageListener> mlMetas =
- ra1516.getInboundResourceadapter().getMessageadapter().getMessagelisteners();
+ List<MessageListener> mlMetas = ra1516.getInboundResourceadapter().getMessageadapter()
+ .getMessagelisteners();
if (mlMetas.size() > 0)
{
@@ -842,11 +801,10 @@
if (mlMeta.getActivationspec() != null &&
mlMeta.getActivationspec().getActivationspecClass().getValue() != null)
{
- List<? extends ConfigProperty> cpm = mlMeta
- .getActivationspec().getConfigProperties();
+ List<? extends ConfigProperty> cpm = mlMeta.getActivationspec().getConfigProperties();
- Object o = initAndInject(mlMeta
- .getActivationspec().getActivationspecClass().getValue(), cpm, cl);
+ Object o = initAndInject(mlMeta.getActivationspec().getActivationspecClass().getValue(),
+ cpm, cl);
if (trace)
{
@@ -874,12 +832,10 @@
{
for (AdminObject aoMeta : aoMetas)
{
- if (aoMeta.getAdminobjectClass() != null &&
- aoMeta.getAdminobjectClass().getValue() != null)
+ if (aoMeta.getAdminobjectClass() != null && aoMeta.getAdminobjectClass().getValue() != null)
{
- Object o =
- initAndInject(aoMeta.getAdminobjectClass().getValue(), aoMeta.getConfigProperties(),
- cl);
+ Object o = initAndInject(aoMeta.getAdminobjectClass().getValue(),
+ aoMeta.getConfigProperties(), cl);
if (trace)
{
@@ -887,8 +843,8 @@
log.trace("AdminObject defined in classloader: " + o.getClass().getClassLoader());
}
- archiveValidationObjects
- .add(new ValidateObject(Key.ADMIN_OBJECT, o, aoMeta.getConfigProperties()));
+ archiveValidationObjects.add(new ValidateObject(Key.ADMIN_OBJECT, o, aoMeta
+ .getConfigProperties()));
beanValidationObjects.add(o);
}
}
@@ -900,8 +856,10 @@
// Archive validation
failures = validateArchive(url, archiveValidationObjects, failures);
- if ((getConfiguration().getArchiveValidationFailOnWarn() && hasFailuresLevel(failures, Severity.WARNING)) ||
- (getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures, Severity.ERROR)))
+ 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);
}
@@ -911,12 +869,11 @@
}
// Bean validation
- if (getConfiguration().getBeanValidation())
+ if (((RAConfiguration) getConfiguration()).getBeanValidation())
{
List<Class> groupsClasses = null;
- if (raxml.getBeanValidationGroups() != null &&
- raxml.getBeanValidationGroups().size() > 0)
+ if (raxml.getBeanValidationGroups() != null && raxml.getBeanValidationGroups().size() > 0)
{
List<String> groups = raxml.getBeanValidationGroups();
@@ -927,9 +884,7 @@
}
}
- if (groupsClasses == null &&
- ijmd != null &&
- ijmd.getBeanValidationGroups() != null &&
+ if (groupsClasses == null && ijmd != null && ijmd.getBeanValidationGroups() != null &&
ijmd.getBeanValidationGroups().size() > 0)
{
List<String> groups = ijmd.getBeanValidationGroups();
@@ -956,15 +911,12 @@
{
String bootstrapIdentifier = null;
- if (raxml.getBootstrapContext() != null &&
- !raxml.getBootstrapContext().trim().equals(""))
+ if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().trim().equals(""))
{
bootstrapIdentifier = raxml.getBootstrapContext();
}
- if (bootstrapIdentifier == null &&
- ijmd != null &&
- ijmd.getBootstrapContext() != null &&
+ if (bootstrapIdentifier == null && ijmd != null && ijmd.getBootstrapContext() != null &&
!ijmd.getBootstrapContext().trim().equals(""))
{
bootstrapIdentifier = ijmd.getBootstrapContext();
@@ -975,16 +927,10 @@
log.info("Deployed: " + url.toExternalForm());
- return new RaXmlDeployment(url,
- deployment,
- deploymentName,
- resourceAdapter,
- getConfiguration().getJndiStrategy(),
- getConfiguration().getMetadataRepository(),
- cfs,
- jndiNames,
- cl,
- log);
+ return new RaXmlDeployment(url, deployment, deploymentName, resourceAdapter,
+ ((RAConfiguration) getConfiguration()).getJndiStrategy(),
+ ((RAConfiguration) getConfiguration()).getMetadataRepository(), cfs, jndiNames,
+ cl, log);
}
catch (DeployException de)
{
@@ -993,10 +939,13 @@
}
catch (Throwable t)
{
- if ((getConfiguration().getArchiveValidationFailOnWarn() && hasFailuresLevel(failures, Severity.WARNING)) ||
- (getConfiguration().getArchiveValidationFailOnError() && hasFailuresLevel(failures, Severity.ERROR)))
+ 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));
+ new ValidatorException(printFailuresLog(url.getPath(), new Validator(),
+ failures, null), failures));
else
{
printFailuresLog(url.getPath(), new Validator(), failures, null);
@@ -1027,12 +976,4 @@
return true;
}
- @Override
- public Deployment createDeployment(URL deploymentUrl, String deploymentName, boolean activator,
- ResourceAdapter resourceAdapter, JndiStrategy jndiStrategy, MetadataRepository metadataRepository, Object[] cfs,
- File destination, ClassLoader cl, Logger log, String[] jndis, URL deployment, boolean activateDeployment)
- {
- //NYI
- return null;
- }
}
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -84,16 +84,9 @@
* @param cl The classloader for the deployment
* @param log The logger
*/
- public RaXmlDeployment(URL deployment,
- URL raDeployment,
- String deploymentName,
- ResourceAdapter ra,
- JndiStrategy jndiStrategy,
- MetadataRepository metadataRepository,
- Object[] cfs,
- String[] jndis,
- ClassLoader cl,
- Logger log)
+ public RaXmlDeployment(URL deployment, URL raDeployment, String deploymentName, ResourceAdapter ra,
+ JndiStrategy jndiStrategy, MetadataRepository metadataRepository, Object[] cfs, String[] jndis, ClassLoader cl,
+ Logger log)
{
this.deployment = deployment;
this.raDeployment = raDeployment;
@@ -111,6 +104,7 @@
* Get the unique URL for the deployment
* @return The URL
*/
+ @Override
public URL getURL()
{
return deployment;
@@ -120,6 +114,7 @@
* Get the classloader
* @return The classloader
*/
+ @Override
public ClassLoader getClassLoader()
{
return cl;
@@ -171,7 +166,7 @@
{
try
{
- ((Closeable)cl).close();
+ ((Closeable) cl).close();
}
catch (IOException ioe)
{
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/SecurityActions.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/SecurityActions.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -32,7 +32,7 @@
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
*/
class SecurityActions
-{
+{
/**
* Constructor
*/
@@ -46,8 +46,9 @@
*/
static ClassLoader getThreadContextClassLoader()
{
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ @Override
public ClassLoader run()
{
return Thread.currentThread().getContextClassLoader();
@@ -61,8 +62,9 @@
*/
static void setThreadContextClassLoader(final ClassLoader cl)
{
- AccessController.doPrivileged(new PrivilegedAction<Object>()
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
{
+ @Override
public Object run()
{
Thread.currentThread().setContextClassLoader(cl);
@@ -78,8 +80,9 @@
*/
static String getSystemProperty(final String name)
{
- return AccessController.doPrivileged(new PrivilegedAction<String>()
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
{
+ @Override
public String run()
{
return System.getProperty(name);
@@ -95,8 +98,9 @@
*/
static URLClassLoader createURLCLassLoader(final URL[] urls, final ClassLoader parent)
{
- return AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>()
+ return AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>()
{
+ @Override
public URLClassLoader run()
{
return new URLClassLoader(urls, parent);
Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/deployers/fungal/RADeployerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/deployers/fungal/RADeployerTestCase.java 2010-09-28 11:23:08 UTC (rev 108363)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/deployers/fungal/RADeployerTestCase.java 2010-09-28 11:24:53 UTC (rev 108364)
@@ -21,6 +21,7 @@
*/
package org.jboss.jca.deployers.fungal;
+import org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer;
import org.jboss.jca.validator.Failure;
import org.jboss.jca.validator.FailureHelper;
import org.jboss.jca.validator.Severity;
@@ -164,8 +165,8 @@
String returnValue = deployer.printFailuresLog(fileName, mock(Validator.class), failures, directory, fh);
//then
- assertThat(returnValue, is("Validation failures - see: " + directory.getAbsolutePath() + File.separator
- + "myFileName.rar.log"));
+ assertThat(returnValue, is("Validation failures - see: " + directory.getAbsolutePath() + File.separator +
+ "myFileName.rar.log"));
assertThat(directory.listFiles().length, is(1));
assertThat(directory.listFiles()[0].getName(), is("myFileName.rar.log"));
try
More information about the jboss-cvs-commits
mailing list