Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.annotations.Annotations;
import org.jboss.jca.common.metadata.Metadata;
import org.jboss.jca.core.api.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.naming.NoopJndiStrategy;
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.PrintStream;
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.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.resource.Referenceable;
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;
import org.jboss.metadata.rar.jboss.BvGroupMetaData;
import org.jboss.metadata.rar.jboss.JBossRA20Base;
import org.jboss.metadata.rar.jboss.JBossRAMetaData;
import org.jboss.metadata.rar.spec.AdminObjectMetaData;
import org.jboss.metadata.rar.spec.ConfigPropertyMetaData;
import org.jboss.metadata.rar.spec.ConnectionDefinitionMetaData;
import org.jboss.metadata.rar.spec.ConnectorMetaData;
import org.jboss.metadata.rar.spec.JCA10DTDMetaData;
import org.jboss.metadata.rar.spec.MessageListenerMetaData;
import org.jboss.metadata.rar.spec.TransactionSupportMetaData;
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.api.util.Injection;
import com.github.fungal.api.util.JarFilter;
import com.github.fungal.spi.deployers.CloneableDeployer;
import com.github.fungal.spi.deployers.DeployException;
import com.github.fungal.spi.deployers.Deployer;
import com.github.fungal.spi.deployers.Deployment;
/**
* The RA deployer for JCA/SJC
* @author Jesper Pedersen
* @author Jeff Zhang
* @author Stefano Maestri
*/
public final class RADeployer implements CloneableDeployer
{
private static Logger log = Logger.getLogger(RADeployer.class);
private static boolean trace = log.isTraceEnabled();
/** The transaction manager */
private static TransactionManager transactionManager = null;
/** Preform bean validation */
private static AtomicBoolean beanValidation = new AtomicBoolean(true);
/** Preform archive validation */
private static AtomicBoolean archiveValidation = new AtomicBoolean(true);
/** Archive validation: Fail on Warn */
private static AtomicBoolean archiveValidationFailOnWarn = new AtomicBoolean(false);
/** Archive validation: Fail on Error */
private static AtomicBoolean archiveValidationFailOnError = new AtomicBoolean(true);
/** Print stream */
private static PrintStream printStream = null;
/** Default bootstrap context */
private static CloneableBootstrapContext defaultBootstrapContext = null;
/** Bootstrap contexts */
private static Map bootstrapContexts = null;
/** Scope deployment */
private static AtomicBoolean scopeDeployment = new AtomicBoolean(false);
/** JNDI strategy */
private static JndiStrategy jndiStrategy = null;
/**
* Constructor
*/
public RADeployer()
{
}
/**
* Set the transaction manager
* @param value The value
*/
public synchronized void setTransactionManager(TransactionManager value)
{
transactionManager = value;
}
/**
* Get the transaction manager
* @return The value
*/
public synchronized TransactionManager getTransactionManager()
{
return transactionManager;
}
/**
* Set if bean validation should be performed
* @param value The value
*/
public void setBeanValidation(boolean value)
{
beanValidation.set(value);
}
/**
* Should bean validation be performed
* @return True if validation; otherwise false
*/
public boolean getBeanValidation()
{
return beanValidation.get();
}
/**
* Set if archive validation should be performed
* @param value The value
*/
public void setArchiveValidation(boolean value)
{
archiveValidation.set(value);
}
/**
* Should archive validation be performed
* @return True if validation; otherwise false
*/
public boolean getArchiveValidation()
{
return archiveValidation.get();
}
/**
* Set if a failed warning archive validation report should fail the deployment
* @param value The value
*/
public void setArchiveValidationFailOnWarn(boolean value)
{
archiveValidationFailOnWarn.set(value);
}
/**
* Does a failed archive validation warning report fail the deployment
* @return True if failing; otherwise false
*/
public boolean getArchiveValidationFailOnWarn()
{
return archiveValidationFailOnWarn.get();
}
/**
* Set if a failed error archive validation report should fail the deployment
* @param value The value
*/
public void setArchiveValidationFailOnError(boolean value)
{
archiveValidationFailOnError.set(value);
}
/**
* Does a failed archive validation error report fail the deployment
* @return True if failing; otherwise false
*/
public boolean getArchiveValidationFailOnError()
{
return archiveValidationFailOnError.get();
}
/**
* Set the print stream
* @param value The value
*/
public synchronized void setPrintStream(PrintStream value)
{
printStream = value;
}
/**
* Get the print stream
* @return The handle
*/
public synchronized PrintStream getPrintStream()
{
return printStream;
}
/**
* Set the default bootstrap context
* @param value The value
*/
public synchronized void setDefaultBootstrapContext(CloneableBootstrapContext value)
{
defaultBootstrapContext = value;
}
/**
* Get the default bootstrap context
* @return The handle
*/
public synchronized CloneableBootstrapContext getDefaultBootstrapContext()
{
return defaultBootstrapContext;
}
/**
* Set the bootstrap context map
* @param value The value
*/
public synchronized void setBootstrapContexts(Map value)
{
bootstrapContexts = value;
}
/**
* Get the bootstrap context map
* @return The handle
*/
public synchronized Map getBootstrapContexts()
{
return bootstrapContexts;
}
/**
* Set if deployments should be scoped
* @param value The value
*/
public void setScopeDeployment(boolean value)
{
scopeDeployment.set(value);
}
/**
* Are the deployments scoped
* @return True if scoped; otherwise false
*/
public boolean getScopeDeployment()
{
return scopeDeployment.get();
}
/**
* Set the JNDI strategy
* @param value The value
*/
public synchronized void setJndiStrategy(JndiStrategy value)
{
jndiStrategy = value;
}
/**
* Get the JNDI strategy
* @return The handle
*/
public synchronized JndiStrategy getJndiStrategy()
{
return jndiStrategy;
}
/**
* Deploy
* @param url The url
* @param parent The parent classloader
* @return The deployment
* @exception DeployException Thrown if an error occurs during deployment
*/
public Deployment deploy(URL url, ClassLoader parent) throws DeployException
{
if (url == null || !(url.toExternalForm().endsWith(".rar") || url.toExternalForm().endsWith(".rar/")))
return null;
Set failures = null;
log.debug("Deploying: " + url.toExternalForm());
ClassLoader oldTCCL = SecurityActions.getThreadContextClassLoader();
try
{
File f = new File(url.toURI());
if (!f.exists())
throw new IOException("Archive " + url.toExternalForm() + " doesnt exists");
File root = null;
File destination = null;
if (f.isFile())
{
FileUtil fileUtil = new FileUtil();
destination = new File(SecurityActions.getSystemProperty("iron.jacamar.home"), "/tmp/");
root = fileUtil.extract(f, destination);
}
else
{
root = f;
}
// Create classloader
URL[] urls = getUrls(root);
KernelClassLoader cl = null;
if (scopeDeployment.get())
{
cl = ClassLoaderFactory.create(ClassLoaderFactory.TYPE_PARENT_LAST, urls, parent);
}
else
{
cl = ClassLoaderFactory.create(ClassLoaderFactory.TYPE_PARENT_FIRST, urls, parent);
}
SecurityActions.setThreadContextClassLoader(cl);
// Parse metadata
Metadata metadataHandler = new Metadata();
ConnectorMetaData cmd = metadataHandler.getStandardMetaData(root);
JBossRAMetaData jrmd = metadataHandler.getJBossMetaData(root);
// Annotation scanning
Annotations annotator = new Annotations();
cmd = annotator.scan(cmd, cl.getURLs(), cl);
// Validate metadata
metadataHandler.validate(cmd);
// Merge metadata
cmd = metadataHandler.merge(cmd, jrmd);
// Notify regarding license terms
if (cmd != null && cmd.getLicense() != null && cmd.getLicense().getRequired())
log.info("Required license terms for " + url.toExternalForm());
ResourceAdapter resourceAdapter = null;
List archiveValidationObjects = new ArrayList();
List partialFailures = null;
List