[jboss-cvs] JBossAS SVN: r83773 - in branches/tdiesler: server/src/main/org/jboss/web/deployers and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 2 06:29:15 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-02-02 06:29:14 -0500 (Mon, 02 Feb 2009)
New Revision: 83773
Modified:
branches/tdiesler/server/src/main/org/jboss/web/WebApplication.java
branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
branches/tdiesler/server/src/main/org/jboss/web/deployers/WebModule.java
branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
Log:
All good
Modified: branches/tdiesler/server/src/main/org/jboss/web/WebApplication.java
===================================================================
--- branches/tdiesler/server/src/main/org/jboss/web/WebApplication.java 2009-02-02 10:47:55 UTC (rev 83772)
+++ branches/tdiesler/server/src/main/org/jboss/web/WebApplication.java 2009-02-02 11:29:14 UTC (rev 83773)
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
/** A WebApplication represents the information for a war deployment.
@@ -39,7 +39,7 @@
public class WebApplication
{
/** */
- private VFSDeploymentUnit unit;
+ private DeploymentUnit unit;
/** Class loader of this application */
protected ClassLoader classLoader = null;
/** name of this application */
@@ -102,11 +102,12 @@
this.classLoader = classLoader;
}
- public VFSDeploymentUnit getDeploymentUnit()
+ public DeploymentUnit getDeploymentUnit()
{
return unit;
}
- public void setDeploymentUnit(VFSDeploymentUnit unit)
+
+ public void setDeploymentUnit(DeploymentUnit unit)
{
this.unit = unit;
}
Modified: branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java 2009-02-02 10:47:55 UTC (rev 83772)
+++ branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java 2009-02-02 11:29:14 UTC (rev 83773)
@@ -30,6 +30,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -40,7 +41,6 @@
import org.jboss.deployers.spi.deployer.helpers.AttachmentLocator;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
@@ -112,7 +112,7 @@
/** Legacy support for MBeanServer */
private MBeanServer server;
private MainDeployerStructure mainDeployer;
-
+
private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
/**
@@ -120,7 +120,7 @@
*/
public AbstractWarDeployer()
{
- super(JBossWebMetaData.class);
+ super(JBossWebMetaData.class);
setOutput(ServiceMetaData.class);
setOutput(WarDeployment.class);
}
@@ -242,7 +242,7 @@
{
this.persistenceUnitDependencyResolver = resolver;
}
-
+
/** Get the session attribute number under which the caller Subject is stored
* @jmx:managed-attribute
*/
@@ -285,15 +285,15 @@
/**
* Deploy a web app based on the WebMetaData. This calls
- * {@link #getDeployment(VFSDeploymentUnit, WebMetaData)} to obtain an
+ * {@link #getDeployment(DeploymentUnit, WebMetaData)} to obtain an
* AbstractWarDeployment bean that is wrapped in a ServiceMetaData by
* deployWebModule.
*
* This will set the WebMetaData.contextRoot if it has not been set based
* on the war deployment name.
*
- * @see #deployWebModule(VFSDeploymentUnit, WebMetaData, AbstractWarDeployment)
- * @see #buildWebContext(VFSDeploymentUnit, String, String, WebMetaData)
+ * @see #deployWebModule(DeploymentUnit, WebMetaData, AbstractWarDeployment)
+ * @see #buildWebContext(DeploymentUnit, String, String, WebMetaData)
*
* @param unit - the war for the deployment
* @param metaData - the metadata for the deployment
@@ -348,109 +348,108 @@
if (unit instanceof VFSDeploymentUnit)
{
- VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit;
- URL expWarUrl = vfsUnit.getRoot().toURL();
- if (warName.endsWith("/") == false
- || warName.endsWith("!/") == true) // Hack for jar urls being exposed
- {
- if (warName.startsWith("jar:"))
- {
- if (warName.endsWith("!/"))
- warName = warName.substring(4, warName.length() - 2);
- else
- warName = warName.substring(4, warName.length());
- }
- URL warURL = new URL(warName);
- ServerConfig config = ServerConfigLocator.locate();
- String prefix = warURL.getFile();
- int lastSlash = prefix.lastIndexOf('/');
- if (lastSlash > 0)
- prefix = prefix.substring(lastSlash + 1);
- int dotWar = prefix.lastIndexOf(".war");
- if (dotWar > 0)
- prefix = prefix.substring(0, dotWar);
+ VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
+ URL expWarUrl = vfsUnit.getRoot().toURL();
+ if (warName.endsWith("/") == false || warName.endsWith("!/") == true) // Hack for jar urls being exposed
+ {
+ if (warName.startsWith("jar:"))
+ {
+ if (warName.endsWith("!/"))
+ warName = warName.substring(4, warName.length() - 2);
+ else
+ warName = warName.substring(4, warName.length());
+ }
+ URL warURL = new URL(warName);
+ ServerConfig config = ServerConfigLocator.locate();
+ String prefix = warURL.getFile();
+ int lastSlash = prefix.lastIndexOf('/');
+ if (lastSlash > 0)
+ prefix = prefix.substring(lastSlash + 1);
+ int dotWar = prefix.lastIndexOf(".war");
+ if (dotWar > 0)
+ prefix = prefix.substring(0, dotWar);
- File expWarFile = File.createTempFile(prefix, "-exp.war", config.getServerTempDeployDir());
- expWarFile.delete();
- if (expWarFile.mkdir() == false)
- throw new DeploymentException("Was unable to mkdir: " + expWarFile);
- log.debug("Unpacking war to: " + expWarFile);
- VirtualFile root = vfsUnit.getRoot();
- InputStream is = root.openStream();
- try
- {
- JarUtils.unjar(is, expWarFile);
- }
- finally
- {
- is.close();
- }
- expWarUrl = expWarFile.toURL();
+ File expWarFile = File.createTempFile(prefix, "-exp.war", config.getServerTempDeployDir());
+ expWarFile.delete();
+ if (expWarFile.mkdir() == false)
+ throw new DeploymentException("Was unable to mkdir: " + expWarFile);
+ log.debug("Unpacking war to: " + expWarFile);
+ VirtualFile root = vfsUnit.getRoot();
+ InputStream is = root.openStream();
+ try
+ {
+ JarUtils.unjar(is, expWarFile);
+ }
+ finally
+ {
+ is.close();
+ }
+ expWarUrl = expWarFile.toURL();
- // Map
- VirtualFile warVF = vfsUnit.getRoot();
- String warPathName = warVF.getPathName();
- if (warPathName.endsWith("/") == false)
- warPathName += "/";
- List<VirtualFile> classpathVFs = vfsUnit.getClassPath();
- if (classpathVFs != null)
- {
- ArrayList<URL> classpath = new ArrayList<URL>();
- for (VirtualFile vf : classpathVFs)
- {
- try
- {
- String path = vf.getPathName();
- if (path.startsWith(warPathName))
- {
- path = path.substring(warPathName.length());
- URL pathURL = new URL(expWarUrl, path);
- classpath.add(pathURL);
- }
- else
- {
- log.debug("Ignoring path element: " + vf);
- }
- }
- catch (Exception e)
- {
- log.debug("Ignoring path element: " + vf, e);
- }
- }
- unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath);
- }
+ // Map
+ VirtualFile warVF = vfsUnit.getRoot();
+ String warPathName = warVF.getPathName();
+ if (warPathName.endsWith("/") == false)
+ warPathName += "/";
+ List<VirtualFile> classpathVFs = vfsUnit.getClassPath();
+ if (classpathVFs != null)
+ {
+ ArrayList<URL> classpath = new ArrayList<URL>();
+ for (VirtualFile vf : classpathVFs)
+ {
+ try
+ {
+ String path = vf.getPathName();
+ if (path.startsWith(warPathName))
+ {
+ path = path.substring(warPathName.length());
+ URL pathURL = new URL(expWarUrl, path);
+ classpath.add(pathURL);
+ }
+ else
+ {
+ log.debug("Ignoring path element: " + vf);
+ }
+ }
+ catch (Exception e)
+ {
+ log.debug("Ignoring path element: " + vf, e);
+ }
+ }
+ unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath);
+ }
- // Indicate that an expanded URL exists
- unit.addAttachment("org.jboss.web.expandedWarURL", expWarUrl, URL.class);
- }
+ // Indicate that an expanded URL exists
+ unit.addAttachment("org.jboss.web.expandedWarURL", expWarUrl, URL.class);
+ }
- // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file
- String altDDPath = metaData.getAlternativeDD();
- if (altDDPath != null)
- {
- // First see if this is already a war local dd
- VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath);
- if (altDD == null)
- {
- // Pass absolute paths through
- File file = new File(altDDPath);
- if (!file.exists() || !file.isAbsolute())
- {
- // Should be an relative to the top deployment
- VFSDeploymentUnit topUnit = vfsUnit.getTopLevel();
- if (topUnit == unit)
- throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path");
- altDD = topUnit.getFile(altDDPath);
- if (altDD == null)
- throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path");
- File webInf = new File(expWarUrl.toURI());
- File altDDFile = new File(webInf, "WEB-INF/" + altDD.getName());
- log.debug("Copying the altDD to: " + altDDFile);
- Files.copy(altDD.toURL(), altDDFile);
- metaData.setAlternativeDD(altDDFile.getAbsolutePath());
- }
- }
- }
+ // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file
+ String altDDPath = metaData.getAlternativeDD();
+ if (altDDPath != null)
+ {
+ // First see if this is already a war local dd
+ VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath);
+ if (altDD == null)
+ {
+ // Pass absolute paths through
+ File file = new File(altDDPath);
+ if (!file.exists() || !file.isAbsolute())
+ {
+ // Should be an relative to the top deployment
+ VFSDeploymentUnit topUnit = vfsUnit.getTopLevel();
+ if (topUnit == unit)
+ throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path");
+ altDD = topUnit.getFile(altDDPath);
+ if (altDD == null)
+ throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path");
+ File webInf = new File(expWarUrl.toURI());
+ File altDDFile = new File(webInf, "WEB-INF/" + altDD.getName());
+ log.debug("Copying the altDD to: " + altDDFile);
+ Files.copy(altDD.toURL(), altDDFile);
+ metaData.setAlternativeDD(altDDFile.getAbsolutePath());
+ }
+ }
+ }
}
ClassLoadingMetaData classLoading = metaData.getClassLoading();
@@ -651,7 +650,7 @@
// Obtain the war virtual host and context root to define a unique war name
String virtualHost = "";
List<String> hosts = metaData.getVirtualHosts();
- if(hosts != null && hosts.size() > 0)
+ if (hosts != null && hosts.size() > 0)
{
virtualHost = hosts.get(0);
}
@@ -686,7 +685,7 @@
webModule.setCode(WebModule.class.getName());
// WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
- constructor.setSignature(new String[] { VFSDeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
+ constructor.setSignature(new String[] { DeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
constructor.setParameters(new Object[] { unit, this, deployment });
webModule.setConstructor(constructor);
@@ -697,13 +696,13 @@
ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName());
attr.setValue(injectionValue);
attrs.add(attr);
-
+
ServiceAttributeMetaData attrPR = new ServiceAttributeMetaData();
attrPR.setName("PolicyRegistration");
ServiceInjectionValueMetaData injectionValuePR = new ServiceInjectionValueMetaData(deployment.getPolicyRegistrationName());
attrPR.setValue(injectionValuePR);
attrs.add(attrPR);
-
+
ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData();
attrKernel.setName("Kernel");
ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME);
@@ -732,7 +731,7 @@
// Here's where a bit of magic happens. By attaching the ServiceMetaData
// to the deployment, we now make the deployment "relevant" to
// deployers that use ServiceMetaData as an input (e.g. the
- // org.jboss.system.deployers.ServiceDeployer). Those deployers
+ // org.jboss.system.deployers.ServiceDeployer). Those deployers
// can now take over deploying the web module.
unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class);
Modified: branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java 2009-02-02 10:47:55 UTC (rev 83772)
+++ branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java 2009-02-02 11:29:14 UTC (rev 83773)
@@ -28,6 +28,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
+
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.naming.Context;
@@ -126,22 +127,22 @@
/**
* The default security-domain name to use
*/
- protected String defaultSecurityDomain;
-
+ protected String defaultSecurityDomain;
+
/** The Security PolicyRegistration Name **/
protected String policyRegistrationName;
-
+
/** The Security PolicyRegistration **/
protected PolicyRegistration policyRegistration;
/** The security management name */
protected String securityManagementName;
-
+
/** The security management */
protected ISecurityManagement securityManagement;
-
+
private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
-
+
public AbstractWarDeployment()
{
log = Logger.getLogger(getClass());
@@ -166,16 +167,16 @@
*/
public static String shortWarUrlFromServerHome(String warUrl)
{
- String serverHomeUrl = System.getProperty(org.jboss.bootstrap.spi.ServerConfig.SERVER_HOME_URL);
+ String serverHomeUrl = System.getProperty(org.jboss.bootstrap.spi.ServerConfig.SERVER_HOME_URL);
- if (warUrl == null || serverHomeUrl == null)
- return warUrl;
+ if (warUrl == null || serverHomeUrl == null)
+ return warUrl;
- if (warUrl.startsWith(serverHomeUrl))
+ if (warUrl.startsWith(serverHomeUrl))
return ".../" + warUrl.substring(serverHomeUrl.length());
- else
+ else
return warUrl;
- }
+ }
/**
* Initialize the deployment using an instance specific configuration object.
@@ -279,8 +280,8 @@
*/
public String getDefaultSecurityDomain()
{
- if(defaultSecurityDomain == null)
- throw new IllegalStateException("Default Security Domain is null");
+ if (defaultSecurityDomain == null)
+ throw new IllegalStateException("Default Security Domain is null");
return defaultSecurityDomain;
}
@@ -294,19 +295,19 @@
public void setDefaultSecurityDomain(String defaultSecurityDomain)
{
this.defaultSecurityDomain = defaultSecurityDomain;
- }
+ }
protected PersistenceUnitDependencyResolver getPersistenceUnitDependencyResolver()
{
return persistenceUnitDependencyResolver;
}
-
+
@Inject
public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
{
this.persistenceUnitDependencyResolver = resolver;
}
-
+
/**
* Get the Policy Registration Name
* @return
@@ -361,7 +362,7 @@
public void setSecurityManagementName(String securityManagement)
{
this.securityManagementName = securityManagement;
- }
+ }
/**
* Get the securityManagement.
@@ -415,8 +416,7 @@
* be null if war was is not being deployed as part of an enterprise
* application. It also contains the URL of the web application war.
*/
- public synchronized WebApplication start(VFSDeploymentUnit unit, JBossWebMetaData metaData)
- throws Exception
+ public synchronized WebApplication start(DeploymentUnit unit, JBossWebMetaData metaData) throws Exception
{
Thread thread = Thread.currentThread();
ClassLoader appClassLoader = thread.getContextClassLoader();
@@ -424,36 +424,33 @@
try
{
// Create a classloader for the war to ensure a unique ENC
- // TODO: this should be handled by the WarClassLoaderDeployer
- /*
- VirtualFile root = unit.getRoot();
- URL[] empty = {root.toURL()};
- URLClassLoader warLoader = URLClassLoader.newInstance(empty, unit.getClassLoader());
- */
ClassLoader warLoader = unit.getClassLoader();
thread.setContextClassLoader(warLoader);
String webContext = metaData.getContextRoot();
-
+
// Get the war URL
- // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
- URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
- if (warURL == null)
- warURL = unit.getRoot().toURL();
+ URL warUrl = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
+ if (warUrl == null && unit instanceof VFSDeploymentUnit)
+ warUrl = ((VFSDeploymentUnit)unit).getRoot().toURL();
- // Strip any jar: url syntax. This should be be handled by the vfs
- String warURLString = warURL.toString();
- if( warURLString.startsWith("jar:") )
- warURLString = warURLString.substring(4, warURLString.length()-2);
+ // Dynamic WebMetaData deployments might not provide an URL
+ // We use the DEploymentUnit name as identifier instead.
+ // The JAXWS Endpoint API for example does this.
+ String warURLString = (warUrl != null ? warUrl.toExternalForm() : unit.getName());
+ // Strip any jar: url syntax. This should be be handled by the vfs
+ if (warURLString.startsWith("jar:"))
+ warURLString = warURLString.substring(4, warURLString.length() - 2);
+
log.debug("webContext: " + webContext);
log.debug("warURL: " + warURLString);
-
+
// Register the permissions with the JACC layer
String contextID = metaData.getJaccContextID();
- if( contextID == null )
+ if (contextID == null)
contextID = unit.getSimpleName();
- metaData.setJaccContextID(contextID);
-
+ metaData.setJaccContextID(contextID);
+
webApp = new WebApplication(metaData);
webApp.setClassLoader(warLoader);
webApp.setDeploymentUnit(unit);
@@ -472,12 +469,11 @@
* performUndeploy()} method to perform the container specific undeployment
* steps and unregisters the the warUrl from the deployment map.
*/
- public synchronized void stop(DeploymentUnit di, WebApplication webApp)
- throws Exception
+ public synchronized void stop(DeploymentUnit di, WebApplication webApp) throws Exception
{
URL warURL = webApp.getURL();
String warUrl = warURL.toString();
- performUndeploy(webApp, warUrl);
+ performUndeploy(webApp, warUrl);
}
/**
@@ -487,19 +483,19 @@
* @param webApp The web application information context. This contains the
* metadata such as the context-root element value from the J2EE
* application/module/web application.xml descriptor and virtual-host.
- * @param warUrl The string for the URL of the web application war.
+ * @param warUrlStr The string for the URL of the web application war.
*/
- protected abstract void performDeploy(WebApplication webApp, String warUrl) throws Exception;
+ protected abstract void performDeploy(WebApplication webApp, String warUrlStr) throws Exception;
+
/**
* Called as part of the stop() method template to ask the subclass for
* perform the web container specific undeployment steps.
* @param webApp The web application information context. This contains the
* metadata such as the context-root element value from the J2EE
* application/module/web application.xml descriptor and virtual-host.
- * @param warUrl The string for the URL of the web application war.
+ * @param warUrlStr The string for the URL of the web application war.
*/
- protected abstract void performUndeploy(WebApplication webApp, String warUrl)
- throws Exception;
+ protected abstract void performUndeploy(WebApplication webApp, String warUrlStr) throws Exception;
/**
* This method is invoked from within subclass performDeploy() method
@@ -508,11 +504,10 @@
* @param metaData the WebMetaData from the WebApplication object passed to
* the performDeploy method.
*/
- protected void processEnc(ClassLoader loader, WebApplication webApp)
- throws Exception
+ protected void processEnc(ClassLoader loader, WebApplication webApp) throws Exception
{
- if(loader == null)
- throw new IllegalArgumentException("Classloader passed to process ENC refs is null");
+ if (loader == null)
+ throw new IllegalArgumentException("Classloader passed to process ENC refs is null");
log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
InitialContext iniCtx = new InitialContext();
Context envCtx = null;
@@ -531,15 +526,15 @@
}
// TODO: The enc should be an input?
currentThread.setContextClassLoader(loader);
- //webApp.setENCLoader(loader);
- envCtx = (Context) iniCtx.lookup("java:comp");
+ // webApp.setENCLoader(loader);
+ envCtx = (Context)iniCtx.lookup("java:comp");
// TODO: inject the ORB
ORB orb = null;
try
{
ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB");
- orb = (ORB) server.getAttribute(ORB_NAME, "ORB");
+ orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
// Bind the orb
if (orb != null)
{
@@ -569,10 +564,9 @@
log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
}
- protected void processEncReferences(WebApplication webApp, Context envCtx)
- throws ClassNotFoundException, NamingException
+ protected void processEncReferences(WebApplication webApp, Context envCtx) throws ClassNotFoundException, NamingException
{
- VFSDeploymentUnit unit = webApp.getDeploymentUnit();
+ DeploymentUnit unit = webApp.getDeploymentUnit();
JBossWebMetaData metaData = webApp.getMetaData();
EnvironmentEntriesMetaData envEntries = metaData.getEnvironmentEntries();
log.debug("addEnvEntries");
@@ -597,32 +591,33 @@
linkServiceRefs(unit, serviceRefs, envCtx);
}
- private void linkServiceRefs(VFSDeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException
+ private void linkServiceRefs(DeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException
{
- ClassLoader loader = unit.getClassLoader();
- UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot());
- for(ServiceReferenceMetaData sref : serviceRefs)
+ if (unit instanceof VFSDeploymentUnit)
{
- String refName = sref.getServiceRefName();
- new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
+ VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
+ ClassLoader loader = unit.getClassLoader();
+ UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(vfsUnit.getRoot());
+ for (ServiceReferenceMetaData sref : serviceRefs)
+ {
+ String refName = sref.getServiceRefName();
+ new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
+ }
}
}
- protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx)
- throws ClassNotFoundException, NamingException
+ protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx) throws ClassNotFoundException, NamingException
{
for (EnvironmentEntryMetaData entry : envEntries)
{
- log.debug("Binding env-entry: " + entry.getName() + " of type: " +
- entry.getType() + " to value:" + entry.getValue());
+ log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue());
bindEnvEntry(envCtx, entry);
}
}
- protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx)
- throws NamingException
+ protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx) throws NamingException
{
- for(ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs)
+ for (ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs)
{
String resourceName = ref.getJndiName();
String refName = ref.getResourceEnvRefName();
@@ -646,16 +641,14 @@
}
else
{
- throw new NamingException("resource-env-ref: " + refName
- + " has no valid JNDI binding. Check the jboss-web/resource-env-ref.");
+ throw new NamingException("resource-env-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-env-ref.");
}
}
}
- protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx)
- throws NamingException
+ protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx) throws NamingException
{
- for(ResourceReferenceMetaData ref : resourceRefs)
+ for (ResourceReferenceMetaData ref : resourceRefs)
{
String jndiName = ref.getJndiName();
String refName = ref.getResourceName();
@@ -689,16 +682,14 @@
}
else
{
- throw new NamingException("resource-ref: " + refName
- + " has no valid JNDI binding. Check the jboss-web/resource-ref.");
+ throw new NamingException("resource-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-ref.");
}
}
}
- protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx)
- throws NamingException
+ protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx) throws NamingException
{
- for(MessageDestinationReferenceMetaData ref : msgRefs)
+ for (MessageDestinationReferenceMetaData ref : msgRefs)
{
String refName = ref.getName();
String jndiName = ref.getJndiName();
@@ -709,8 +700,8 @@
{
MessageDestinationMetaData messageDestination = EjbUtil50.findMessageDestination(mainDeployer, unit, link);
if (messageDestination == null)
- throw new NamingException("message-destination-ref '" + refName +
- "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml");
+ throw new NamingException("message-destination-ref '" + refName + "' message-destination-link '" + link
+ + "' not found and no jndi-name in jboss-web.xml");
else
{
String linkJNDIName = messageDestination.getJndiName();
@@ -721,37 +712,33 @@
}
}
else
- log.warn("message-destination-ref '" + refName +
- "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml");
+ log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml");
}
else if (jndiName == null)
- throw new NamingException("message-destination-ref '" + refName +
- "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml");
+ throw new NamingException("message-destination-ref '" + refName + "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml");
Util.bind(envCtx, refName, new LinkRef(jndiName));
}
}
- protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx)
- throws NamingException
+ protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx) throws NamingException
{
- for(EJBReferenceMetaData ejb : ejbRefs)
+ for (EJBReferenceMetaData ejb : ejbRefs)
{
String name = ejb.getName();
String linkName = ejb.getLink();
String jndiName = null;
-
- //use ejb-link if it is specified
+
+ // use ejb-link if it is specified
if (linkName != null)
{
jndiName = EjbUtil50.findEjbLink(mainDeployer, unit, linkName);
-
- //if flag does not allow misconfigured ejb-links, it is an error
+
+ // if flag does not allow misconfigured ejb-links, it is an error
if ((jndiName == null) && !(getLenientEjbLink()))
throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
}
-
- //fall through to the jndiName
+ // fall through to the jndiName
if (jndiName == null)
{
jndiName = ejb.getJndiName();
@@ -764,26 +751,24 @@
}
}
- protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx)
- throws NamingException
+ protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx) throws NamingException
{
- for(EJBLocalReferenceMetaData ejb : ejbLocalRefs)
+ for (EJBLocalReferenceMetaData ejb : ejbLocalRefs)
{
String name = ejb.getName();
String linkName = ejb.getLink();
String jndiName = null;
- //use the ejb-link field if it is specified
+ // use the ejb-link field if it is specified
if (linkName != null)
{
jndiName = EjbUtil50.findLocalEjbLink(mainDeployer, unit, linkName);
-
- //if flag does not allow misconfigured ejb-links, it is an error
+
+ // if flag does not allow misconfigured ejb-links, it is an error
if ((jndiName == null) && !(getLenientEjbLink()))
throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
}
-
if (jndiName == null)
{
jndiName = ejb.getJndiName();
@@ -792,13 +777,11 @@
String msg = null;
if (linkName == null)
{
- msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and "
- + "no local-jndi-name in jboss-web.xml";
+ msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and " + "no local-jndi-name in jboss-web.xml";
}
else
{
- msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '"
- + linkName + "' failed to resolve to an ejb with a LocalHome";
+ msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '" + linkName + "' failed to resolve to an ejb with a LocalHome";
}
throw new NamingException(msg);
}
@@ -818,23 +801,22 @@
* element. If there was no security-domain element then the bindings are to
* NullSecurityManager instance which simply allows all access.
*/
- protected void linkSecurityDomain(String securityDomain, Context envCtx)
- throws NamingException
+ protected void linkSecurityDomain(String securityDomain, Context envCtx) throws NamingException
{
if (securityDomain == null)
{
securityDomain = getDefaultSecurityDomain();
log.debug("No security-domain given, using default: " + securityDomain);
}
-
- //JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix
- if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false)
+
+ // JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix
+ if (securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false)
securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain;
-
+
log.debug("Linking security/securityMgr to JNDI name: " + securityDomain);
Util.bind(envCtx, "security/securityMgr", new LinkRef(securityDomain));
- Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain+"/realmMapping"));
- Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain+"/authorizationMgr"));
+ Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain + "/realmMapping"));
+ Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr"));
Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain));
Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject"));
}
@@ -848,11 +830,7 @@
*/
public String[] getStandardCompileClasspath(ClassLoader loader)
{
- String[] jspResources = {
- "javax/servlet/resources/web-app_2_3.dtd",
- "org/apache/jasper/resources/jsp12.dtd",
- "javax/ejb/EJBHome.class"
- };
+ String[] jspResources = { "javax/servlet/resources/web-app_2_3.dtd", "org/apache/jasper/resources/jsp12.dtd", "javax/ejb/EJBHome.class" };
ArrayList tmp = new ArrayList();
for (int j = 0; j < jspResources.length; j++)
{
@@ -897,8 +875,7 @@
}
try
{
- URL[] globalUrls = (URL[]) server.getAttribute(LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY,
- "URLs");
+ URL[] globalUrls = (URL[])server.getAttribute(LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY, "URLs");
addURLs(tmp, globalUrls);
}
catch (Exception e)
@@ -918,10 +895,9 @@
URL url = urls[u];
urlSet.add(url.toExternalForm());
}
- }
+ }
- public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry)
- throws ClassNotFoundException, NamingException
+ public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry) throws ClassNotFoundException, NamingException
{
ClassLoader loader = EnvironmentEntryMetaData.class.getClassLoader();
Class type = loader.loadClass(entry.getType());
@@ -955,7 +931,7 @@
String input = entry.getValue();
if (input == null || input.length() == 0)
{
- value = new Character((char) 0);
+ value = new Character((char)0);
}
else
{
@@ -978,4 +954,3 @@
}
}
}
-
Modified: branches/tdiesler/server/src/main/org/jboss/web/deployers/WebModule.java
===================================================================
--- branches/tdiesler/server/src/main/org/jboss/web/deployers/WebModule.java 2009-02-02 10:47:55 UTC (rev 83772)
+++ branches/tdiesler/server/src/main/org/jboss/web/deployers/WebModule.java 2009-02-02 11:29:14 UTC (rev 83773)
@@ -21,7 +21,7 @@
*/
package org.jboss.web.deployers;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployment.DeploymentException;
import org.jboss.kernel.Kernel;
import org.jboss.logging.Logger;
@@ -49,18 +49,18 @@
{
private static Logger log = Logger.getLogger(WebModule.class);
- private VFSDeploymentUnit di;
+ private DeploymentUnit unit;
private AbstractWarDeployer container;
- private AbstractWarDeployment deployment;
+ private AbstractWarDeployment deployment;
private ISecurityManagement securityManagement;
-
- public WebModule(VFSDeploymentUnit di, AbstractWarDeployer container, AbstractWarDeployment deployment)
+
+ public WebModule(DeploymentUnit unit, AbstractWarDeployer container, AbstractWarDeployment deployment)
{
- this.di = di;
+ this.unit = unit;
this.container = container;
this.deployment = deployment;
- this.deployment.setDeploymentUnit(di);
+ this.deployment.setDeploymentUnit(unit);
}
public void setKernel(Kernel kernel)
@@ -74,9 +74,9 @@
*/
public void setPolicyRegistration(PolicyRegistration policyRegistration)
{
- deployment.setPolicyRegistration(policyRegistration);
+ deployment.setPolicyRegistration(policyRegistration);
}
-
+
/**
* Set the securityManagement.
*
@@ -89,8 +89,9 @@
public void create()
{
-
+
}
+
public void start() throws Exception
{
startModule();
@@ -103,39 +104,37 @@
public void destroy()
{
- this.di = null;
+ this.unit = null;
this.container = null;
- this.deployment = null;
+ this.deployment = null;
}
/** Invokes the deployer start
*/
- public synchronized void startModule()
- throws Exception
+ public synchronized void startModule() throws Exception
{
// Get the war URL
- JBossWebMetaData metaData = di.getAttachment(JBossWebMetaData.class);
- WebApplication webApp = deployment.start(di, metaData);
- String warURL = di.getName();
+ JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
+ WebApplication webApp = deployment.start(unit, metaData);
+ String warURL = unit.getName();
container.addDeployedApp(warURL, webApp);
}
/** Invokes the deployer stop
*/
- public synchronized void stopModule()
- throws DeploymentException
+ public synchronized void stopModule() throws DeploymentException
{
- String warURL = di.getName();
+ String warURL = unit.getName();
try
{
WebApplication webApp = container.removeDeployedApp(warURL);
- if( deployment != null && webApp != null )
+ if (deployment != null && webApp != null)
{
- deployment.stop(di, webApp);
+ deployment.stop(unit, webApp);
}
else
{
- log.debug("Failed to find deployer/deployment for war: "+warURL);
+ log.debug("Failed to find deployer/deployment for war: " + warURL);
}
}
catch (Exception e)
Modified: branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
===================================================================
--- branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java 2009-02-02 10:47:55 UTC (rev 83772)
+++ branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java 2009-02-02 11:29:14 UTC (rev 83773)
@@ -45,6 +45,7 @@
import javax.servlet.Servlet;
import org.apache.InstanceManager;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
import org.jboss.deployment.dependency.ContainerDependencyMetaData;
@@ -127,7 +128,7 @@
protected DependencyPolicy dependencyPolicy = new JBoss5DependencyPolicy(this);
protected Collection<InjectionHandler<Environment>> handlers;
- protected VFSDeploymentUnit unit;
+ protected DeploymentUnit unit;
protected ClassLoader webLoader;
protected WebApplication appInfo;
protected JBossWebMetaData webDD;
@@ -140,83 +141,99 @@
private static final Properties restrictedListeners = new Properties();
private static final Properties restrictedServlets = new Properties();
- static {
- try {
- InputStream is =
- TomcatInjectionContainer.class.getClassLoader().getResourceAsStream
- ("org/apache/catalina/core/RestrictedServlets.properties");
- if (is != null) {
- restrictedServlets.load(is);
- } else {
- log.error("Could not load org/apache/catalina/core/RestrictedServlets.properties");
- }
- } catch (IOException e) {
- log.error("Error reading org/apache/catalina/core/RestrictedServlets.properties", e);
- }
+ static
+ {
+ try
+ {
+ InputStream is = TomcatInjectionContainer.class.getClassLoader().getResourceAsStream("org/apache/catalina/core/RestrictedServlets.properties");
+ if (is != null)
+ {
+ restrictedServlets.load(is);
+ }
+ else
+ {
+ log.error("Could not load org/apache/catalina/core/RestrictedServlets.properties");
+ }
+ }
+ catch (IOException e)
+ {
+ log.error("Error reading org/apache/catalina/core/RestrictedServlets.properties", e);
+ }
- try {
- InputStream is =
- TomcatInjectionContainer.class.getClassLoader().getResourceAsStream
- ("org/apache/catalina/core/RestrictedListeners.properties");
- if (is != null) {
- restrictedListeners.load(is);
- } else {
- log.error("Could not load org/apache/catalina/core/RestrictedListeners.properties");
- }
- } catch (IOException e) {
- log.error("Error reading org/apache/catalina/core/RestrictedListeners.properties", e);
- }
- try {
- InputStream is =
- TomcatInjectionContainer.class.getClassLoader().getResourceAsStream
- ("org/apache/catalina/core/RestrictedFilters.properties");
- if (is != null) {
- restrictedFilters.load(is);
- } else {
- log.error("Could not load org/apache/catalina/core/RestrictedFilters.properties");
- }
- } catch (IOException e) {
- log.error("Error reading org/apache/catalina/core/RestrictedFilters.properties", e);
- }
-
- //
- dynamicClassLoaders.add("org.apache.jasper.servlet.JasperLoader");
+ try
+ {
+ InputStream is = TomcatInjectionContainer.class.getClassLoader().getResourceAsStream("org/apache/catalina/core/RestrictedListeners.properties");
+ if (is != null)
+ {
+ restrictedListeners.load(is);
+ }
+ else
+ {
+ log.error("Could not load org/apache/catalina/core/RestrictedListeners.properties");
+ }
+ }
+ catch (IOException e)
+ {
+ log.error("Error reading org/apache/catalina/core/RestrictedListeners.properties", e);
+ }
+ try
+ {
+ InputStream is = TomcatInjectionContainer.class.getClassLoader().getResourceAsStream("org/apache/catalina/core/RestrictedFilters.properties");
+ if (is != null)
+ {
+ restrictedFilters.load(is);
+ }
+ else
+ {
+ log.error("Could not load org/apache/catalina/core/RestrictedFilters.properties");
+ }
+ }
+ catch (IOException e)
+ {
+ log.error("Error reading org/apache/catalina/core/RestrictedFilters.properties", e);
+ }
+
+ //
+ dynamicClassLoaders.add("org.apache.jasper.servlet.JasperLoader");
}
-
- public TomcatInjectionContainer(WebApplication appInfo, VFSDeploymentUnit unit, org.apache.catalina.Context catalinaContext, PersistenceUnitDependencyResolver resolver)
+
+ public TomcatInjectionContainer(WebApplication appInfo, DeploymentUnit unit, org.apache.catalina.Context catalinaContext,
+ PersistenceUnitDependencyResolver resolver)
{
super(new SimpleJavaEEModule(appInfo.getName()));
-
+
this.unit = unit;
this.appInfo = appInfo;
this.catalinaContext = catalinaContext;
this.persistenceUnitDependencyResolver = resolver;
this.deploymentEndpointResolver = unit.getAttachment(DeploymentEndpointResolver.class);
this.endpointMap = unit.getTopLevel().getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY, Map.class);
-
+
this.webDD = unit.getAttachment(JBossWebMetaData.class);
assert this.webDD != null : "webDD is null (no JBossWebMetaData attachment in VFSDeploymentUnit)";
-
+
}
private void checkAccess(Class<?> clazz)
{
- if (catalinaContext.getPrivileged()) return;
- if (Filter.class.isAssignableFrom(clazz))
- {
+ if (catalinaContext.getPrivileged())
+ return;
+ if (Filter.class.isAssignableFrom(clazz))
+ {
checkAccess(clazz, restrictedFilters);
- }
- else if (Servlet.class.isAssignableFrom(clazz))
- {
+ }
+ else if (Servlet.class.isAssignableFrom(clazz))
+ {
checkAccess(clazz, restrictedServlets);
- }
- else
- {
+ }
+ else
+ {
checkAccess(clazz, restrictedListeners);
- }
+ }
}
- private void checkAccess(Class<?> clazz, Properties restricted) {
+ private void checkAccess(Class<?> clazz, Properties restricted)
+ {
while (clazz != null)
{
if ("restricted".equals(restricted.getProperty(clazz.getName())))
@@ -232,52 +249,53 @@
return webDD.getJndiEnvironmentRefsGroup();
}
- public Object newInstance(String className)
- throws IllegalAccessException, InvocationTargetException, NamingException,
- InstantiationException, ClassNotFoundException
+ public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException,
+ ClassNotFoundException
{
ClassLoader loader = catalinaContext.getLoader().getClassLoader();
Class<?> clazz = loader.loadClass(className);
checkAccess(clazz);
Object instance = clazz.newInstance();
processInjectors(instance);
- if (!catalinaContext.getIgnoreAnnotations())
- {
- processDynamicBeanAnnotations(instance);
- postConstruct(instance);
- }
+ if (!catalinaContext.getIgnoreAnnotations())
+ {
+ processDynamicBeanAnnotations(instance);
+ postConstruct(instance);
+ }
return instance;
}
- public Object newInstance(String className, ClassLoader classLoader) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException
+ public Object newInstance(String className, ClassLoader classLoader) throws IllegalAccessException, InvocationTargetException, NamingException,
+ InstantiationException, ClassNotFoundException
{
- Class<?> clazz = classLoader.loadClass(className);
- checkAccess(clazz);
- Object instance = clazz.newInstance();
- processInjectors(instance);
- if (!catalinaContext.getIgnoreAnnotations())
- {
- processDynamicBeanAnnotations(instance);
- postConstruct(instance);
- }
- return instance;
+ Class<?> clazz = classLoader.loadClass(className);
+ checkAccess(clazz);
+ Object instance = clazz.newInstance();
+ processInjectors(instance);
+ if (!catalinaContext.getIgnoreAnnotations())
+ {
+ processDynamicBeanAnnotations(instance);
+ postConstruct(instance);
+ }
+ return instance;
}
- public void newInstance(Object instance) throws IllegalAccessException, InvocationTargetException, NamingException
+ public void newInstance(Object instance) throws IllegalAccessException, InvocationTargetException, NamingException
{
processInjectors(instance);
- if (!catalinaContext.getIgnoreAnnotations())
- {
- processDynamicBeanAnnotations(instance);
- postConstruct(instance);
- }
+ if (!catalinaContext.getIgnoreAnnotations())
+ {
+ processDynamicBeanAnnotations(instance);
+ postConstruct(instance);
+ }
}
- public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException {
- if (!catalinaContext.getIgnoreAnnotations())
- {
- preDestroy(instance);
- }
+ public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException
+ {
+ if (!catalinaContext.getIgnoreAnnotations())
+ {
+ preDestroy(instance);
+ }
}
/**
@@ -289,7 +307,8 @@
*/
public void postConstruct(Object object) throws IllegalAccessException, InvocationTargetException
{
- if (webDD.getPostConstructs() == null) return;
+ if (webDD.getPostConstructs() == null)
+ return;
for (LifecycleCallbackMetaData metaData : webDD.getPostConstructs())
{
try
@@ -317,7 +336,8 @@
*/
public void preDestroy(Object object) throws IllegalAccessException, InvocationTargetException
{
- if (webDD.getPreDestroys() == null) return;
+ if (webDD.getPreDestroys() == null)
+ return;
for (LifecycleCallbackMetaData metaData : webDD.getPreDestroys())
{
try
@@ -360,7 +380,7 @@
injector.inject(object);
}
}
-
+
/**
* Process annotations for dynamic beans only.
*
@@ -369,14 +389,13 @@
* @throws InvocationTargetException
* @throws NamingException
*/
- protected void processDynamicBeanAnnotations(Object object)
- throws IllegalAccessException, InvocationTargetException, NamingException
+ protected void processDynamicBeanAnnotations(Object object) throws IllegalAccessException, InvocationTargetException, NamingException
{
// Only process annotation on dynamic beans
- if(isDynamicBean(object))
+ if (isDynamicBean(object))
processAnnotations(object);
}
-
+
/**
* When we get here, we are assuming that any XML defined injection has been already done.
* We will set up more here if the class being processed is a dynamic class.
@@ -386,11 +405,10 @@
* @throws InvocationTargetException
* @throws NamingException
*/
- public void processAnnotations(Object object)
- throws IllegalAccessException, InvocationTargetException, NamingException
+ public void processAnnotations(Object object) throws IllegalAccessException, InvocationTargetException, NamingException
{
final boolean trace = log.isTraceEnabled();
-
+
Map<AccessibleObject, Injector> injectors = getEncInjectionsForClass(object.getClass(), true);
if (injectors == null)
{
@@ -398,7 +416,7 @@
log.trace("**************** Processing annotations for: " + object.getClass().getName());
encInjectors.recordAdded();
-
+
// Populate the encInjections
TomcatInjectionUtils.processDynamicBeanAnnotations(this, handlers, object.getClass());
@@ -411,12 +429,12 @@
}
encInjectors.clearAdded();
}
-
+
// Process the injectors
processInjectors(object);
}
}
-
+
/**
* Get the the Injectors for a object and it's superclass.
*
@@ -425,29 +443,30 @@
*/
private Map<AccessibleObject, Injector> getEncInjectionsForObject(Object object)
{
- if(object == null || object.getClass() == Object.class)
+ if (object == null || object.getClass() == Object.class)
return null;
-
+
return getEncInjectionsForClass(object.getClass(), isDynamicBean(object));
}
-
+
private Map<AccessibleObject, Injector> getEncInjectionsForClass(Class<?> clazz, boolean isDynamic)
{
- if(clazz == null || clazz == Object.class) return null;
-
+ if (clazz == null || clazz == Object.class)
+ return null;
+
Map<AccessibleObject, Injector> injectors = encInjections.get(clazz.getName());
Map<AccessibleObject, Injector> additionalInjectors = null;
- if(clazz.getSuperclass() != null && ! isDynamic)
+ if (clazz.getSuperclass() != null && !isDynamic)
additionalInjectors = getEncInjectionsForClass(clazz.getSuperclass(), isDynamic);
- if(injectors == null)
+ if (injectors == null)
return additionalInjectors;
- else if(additionalInjectors != null)
+ else if (additionalInjectors != null)
injectors.putAll(additionalInjectors);
-
+
return injectors;
}
-
+
/**
* Check if the class is a dynamic bean.
*
@@ -456,17 +475,17 @@
*/
private boolean isDynamicBean(Object object)
{
- if(object == null)
+ if (object == null)
throw new IllegalArgumentException("null class");
ClassLoader loader = object.getClass().getClassLoader();
- if(loader == null)
+ if (loader == null)
return false;
// Check if the object was loaded by a dynamic class loader (e.g. Jasper)
String classLoaderName = loader.getClass().getName();
- if(dynamicClassLoaders.contains(classLoaderName))
+ if (dynamicClassLoaders.contains(classLoaderName))
return true;
-
+
return false;
}
@@ -477,29 +496,30 @@
injector.inject(this);
}
}
-
- private void processesLifecycleCallbackMetaData(Object object, LifecycleCallbackMetaData lifeCycleMetaData) throws IllegalAccessException, InvocationTargetException
+
+ private void processesLifecycleCallbackMetaData(Object object, LifecycleCallbackMetaData lifeCycleMetaData) throws IllegalAccessException,
+ InvocationTargetException
{
final Object args[] = null;
Class<?> clazz = object.getClass();
Method method = null;
// Also check superClasses for private members
- while(clazz != null)
+ while (clazz != null)
{
- for(Method m : clazz.getDeclaredMethods())
+ for (Method m : clazz.getDeclaredMethods())
{
- if(m.getName().equals(lifeCycleMetaData.getMethodName()))
+ if (m.getName().equals(lifeCycleMetaData.getMethodName()))
{
method = m;
}
}
- if(method != null)
+ if (method != null)
break;
clazz = clazz.getSuperclass();
}
- if(method == null)
- throw new IllegalStateException("Method: "+ lifeCycleMetaData.getMethodName() + " not found.");
-
+ if (method == null)
+ throw new IllegalStateException("Method: " + lifeCycleMetaData.getMethodName() + " not found.");
+
boolean accessible = method.isAccessible();
try
{
@@ -512,7 +532,7 @@
method.setAccessible(accessible);
}
}
-
+
/**
* Process the meta data. There is no introspection needed, as the annotations
* were already processed. The handlers add the EjbEncInjectors to encInjectors.
@@ -525,7 +545,7 @@
{
//
InjectionHandler<Environment> webEjbHandler = new WebEJBHandler<Environment>(webDD, deploymentEndpointResolver, endpointMap, unit.getRelativePath());
-
+
// todo injection handlers should be pluggable from XML
handlers = new ArrayList<InjectionHandler<Environment>>();
handlers.add(webEjbHandler);
@@ -548,7 +568,7 @@
Thread.currentThread().setContextClassLoader(old);
}
}
-
+
public Map<String, EncInjector> getEncInjectors()
{
return encInjectors;
@@ -567,7 +587,10 @@
public VirtualFile getRootFile()
{
- return unit.getRoot();
+ if (unit instanceof VFSDeploymentUnit)
+ return ((VFSDeploymentUnit)unit).getRoot();
+ else
+ return null;
}
public String getIdentifier()
@@ -615,7 +638,7 @@
{
return false;
}
-
+
public Container resolveEjbContainer(String link, Class<?> businessIntf)
{
return null;
Modified: branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
===================================================================
--- branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-02-02 10:47:55 UTC (rev 83772)
+++ branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-02-02 11:29:14 UTC (rev 83773)
@@ -21,6 +21,8 @@
*/
package org.jboss.web.tomcat.service.deployers;
+// $Id: $
+
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -99,7 +101,7 @@
private static Logger log = Logger.getLogger(JBossContextConfig.class);
private boolean runDestroy = false;
-
+
/**
* <p>
* Creates a new instance of {@code JBossContextConfig}.
@@ -145,7 +147,7 @@
{
if (context instanceof StandardContext)
{
- ((StandardContext) context).setReplaceWelcomeFiles(true);
+ ((StandardContext)context).setReplaceWelcomeFiles(true);
}
// Metadata complete
@@ -161,7 +163,7 @@
else
context.setPublicId(org.apache.catalina.startup.Constants.WebDtdPublicId_22);
- // processContextParameters() provides a merged view of the context params
+ // processContextParameters() provides a merged view of the context params
// Display name
DescriptionGroupMetaData dg = metaData.getDescriptionGroup();
@@ -459,8 +461,8 @@
Iterator iter = keys != null ? keys.iterator() : null;
while (iter != null && iter.hasNext())
{
- String key = (String) iter.next();
- String authenticatorStr = (String) authProps.get(key);
+ String key = (String)iter.next();
+ String authenticatorStr = (String)authProps.get(key);
Class authClass = tcl.loadClass(authenticatorStr);
authenticators.put(key, authClass.newInstance());
}
@@ -480,9 +482,9 @@
*/
private Properties getAuthenticatorsFromJndi() throws NamingException
{
- return (Properties) new InitialContext().lookup("TomcatAuthenticators");
+ return (Properties)new InitialContext().lookup("TomcatAuthenticators");
}
-
+
/**
* Process the context parameters. Let a user application
* override the sharedMetaData values.
@@ -491,9 +493,9 @@
{
JBossWebMetaData local = metaDataLocal.get();
JBossWebMetaData shared = metaDataShared.get();
-
+
Map<String, String> overrideParams = new HashMap<String, String>();
-
+
List<ParamValueMetaData> params = local.getContextParams();
if (params != null)
{
@@ -507,92 +509,110 @@
{
for (ParamValueMetaData param : params)
{
- if(overrideParams.get(param.getParamName()) == null)
+ if (overrideParams.get(param.getParamName()) == null)
{
overrideParams.put(param.getParamName(), param.getParamValue());
}
}
- }
-
- for(String key : overrideParams.keySet())
+ }
+
+ for (String key : overrideParams.keySet())
{
context.addParameter(key, overrideParams.get(key));
}
-
+
}
/**
* Process a "init" event for this Context.
*/
- protected void init() {
-
- if (TomcatService.OLD_CODE) {
+ protected void init()
+ {
+
+ if (TomcatService.OLD_CODE)
+ {
super.init();
return;
}
-
+
context.setConfigured(false);
ok = true;
-
- if (!context.getOverride()) {
- processContextConfig("context.xml", false);
- processContextConfig(getHostConfigPath(org.apache.catalina.startup.Constants.HostContextXml), false);
+
+ if (!context.getOverride())
+ {
+ processContextConfig("context.xml", false);
+ processContextConfig(getHostConfigPath(org.apache.catalina.startup.Constants.HostContextXml), false);
}
// This should come from the deployment unit
processContextConfig(context.getConfigFile(), true);
-
+
}
-
-
+
protected void processContextConfig(String resourceName, boolean local)
{
ContextMetaData contextMetaData = null;
- try {
+ try
+ {
SchemaBinding schema = JBossXBBuilder.build(ContextMetaData.class);
Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
u.setSchemaValidation(false);
u.setValidation(false);
u.setEntityResolver(new JBossEntityResolver());
+
InputStream is = null;
- try {
+ try
+ {
if (local)
{
- VirtualFile vf = ((VFSDeploymentUnit) deploymentUnitLocal.get()).getFile(resourceName);
- if (vf != null)
- is = vf.openStream();
+ DeploymentUnit localUnit = deploymentUnitLocal.get();
+ if (localUnit instanceof VFSDeploymentUnit)
+ {
+ VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)localUnit;
+ VirtualFile vf = vfsUnit.getFile(resourceName);
+ if (vf != null)
+ is = vf.openStream();
+ }
}
- else
+
+ if (is == null)
+ is = getClass().getClassLoader().getResourceAsStream(resourceName);
+
+ if (is != null)
+ contextMetaData = ContextMetaData.class.cast(u.unmarshal(is, schema));
+ }
+ finally
+ {
+ if (is != null)
{
- is = getClass().getClassLoader().getResourceAsStream(resourceName);
- }
- if (is == null) {
- return;
- }
- contextMetaData = ContextMetaData.class.cast(u.unmarshal(is, schema));
- } finally {
- if (is != null) {
- try {
+ try
+ {
is.close();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
// Ignore
}
}
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error("XML error parsing: " + resourceName, e);
ok = false;
return;
}
-
- try {
- if (contextMetaData != null)
+
+ if (contextMetaData != null)
+ {
+ try
{
-
- if (contextMetaData.getAttributes() != null) {
+ if (contextMetaData.getAttributes() != null)
+ {
Iterator<QName> names = contextMetaData.getAttributes().keySet().iterator();
- while (names.hasNext()) {
+ while (names.hasNext())
+ {
QName name = names.next();
- String value = (String) contextMetaData.getAttributes().get(name);
+ String value = (String)contextMetaData.getAttributes().get(name);
// FIXME: This should be done by XB
value = StringPropertyReplacer.replaceProperties(value);
IntrospectionUtils.setProperty(context, name.getLocalPart(), value);
@@ -602,53 +622,59 @@
TomcatService.addLifecycleListeners(context, contextMetaData.getListeners());
// Context/Realm
- if (contextMetaData.getRealm() != null) {
- context.setRealm((org.apache.catalina.Realm) TomcatService.getInstance(contextMetaData.getRealm(), null));
+ if (contextMetaData.getRealm() != null)
+ {
+ context.setRealm((org.apache.catalina.Realm)TomcatService.getInstance(contextMetaData.getRealm(), null));
}
-
+
// Context/Valve
TomcatService.addValves(context, contextMetaData.getValves());
-
+
// Context/InstanceListener
- if (contextMetaData.getInstanceListeners() != null) {
+ if (contextMetaData.getInstanceListeners() != null)
+ {
Iterator<String> listeners = contextMetaData.getInstanceListeners().iterator();
while (listeners.hasNext())
{
context.addInstanceListener(listeners.next());
}
}
-
+
// Context/Loader
- if (contextMetaData.getLoader() != null) {
+ if (contextMetaData.getLoader() != null)
+ {
// This probably won't work very well in JBoss
- context.setLoader((org.apache.catalina.Loader) TomcatService.getInstance(contextMetaData.getLoader(),
- "org.apache.catalina.loader.WebappLoader"));
+ context.setLoader((org.apache.catalina.Loader)TomcatService.getInstance(contextMetaData.getLoader(), "org.apache.catalina.loader.WebappLoader"));
}
-
+
// Context/Manager
- if (contextMetaData.getManager() != null) {
- context.setManager((org.apache.catalina.Manager) TomcatService.getInstance(contextMetaData.getManager(),
+ if (contextMetaData.getManager() != null)
+ {
+ context.setManager((org.apache.catalina.Manager)TomcatService.getInstance(contextMetaData.getManager(),
"org.apache.catalina.session.StandardManager"));
}
-
+
// Context/Parameter
- if (contextMetaData.getParameters() != null) {
+ if (contextMetaData.getParameters() != null)
+ {
Iterator<ParameterMetaData> parameterMetaDatas = contextMetaData.getParameters().iterator();
while (parameterMetaDatas.hasNext())
{
ParameterMetaData parameterMetaData = parameterMetaDatas.next();
- context.addApplicationParameter((org.apache.catalina.deploy.ApplicationParameter) TomcatService.getInstance(parameterMetaData, null));
+ context.addApplicationParameter((org.apache.catalina.deploy.ApplicationParameter)TomcatService.getInstance(parameterMetaData, null));
}
}
// Context/Resources
- if (contextMetaData.getResources() != null) {
- context.setResources((javax.naming.directory.DirContext) TomcatService.getInstance(contextMetaData.getResources(),
+ if (contextMetaData.getResources() != null)
+ {
+ context.setResources((javax.naming.directory.DirContext)TomcatService.getInstance(contextMetaData.getResources(),
"org.apache.naming.resources.FileDirContext"));
}
-
+
// Context/SessionCookie
- if (contextMetaData.getSessionCookie() != null) {
+ if (contextMetaData.getSessionCookie() != null)
+ {
SessionCookie sessionCookie = new SessionCookie();
sessionCookie.setComment(contextMetaData.getSessionCookie().getComment());
sessionCookie.setDomain(contextMetaData.getSessionCookie().getDomain());
@@ -657,21 +683,22 @@
sessionCookie.setSecure(contextMetaData.getSessionCookie().getSecure());
context.setSessionCookie(sessionCookie);
}
-
+
}
+ catch (Exception e)
+ {
+ log.error("Error processing: " + resourceName, e);
+ ok = false;
+ }
}
- catch (Exception e)
+ }
+
+ protected void destroy()
+ {
+ if (runDestroy)
{
- log.error("Error processing: " + resourceName, e);
- ok = false;
+ super.destroy();
}
-
}
-
- protected void destroy() {
- if (runDestroy) {
- super.destroy();
- }
- }
-
+
}
Modified: branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2009-02-02 10:47:55 UTC (rev 83772)
+++ branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2009-02-02 11:29:14 UTC (rev 83773)
@@ -51,6 +51,7 @@
import org.apache.catalina.core.StandardContext;
import org.apache.tomcat.util.modeler.Registry;
import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
@@ -89,7 +90,7 @@
private DeployerConfig config;
- private final String[] javaVMs = {" jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost"};
+ private final String[] javaVMs = { " jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost" };
private final String serverName = "jboss";
@@ -112,7 +113,7 @@
@Override
public void init(Object containerConfig) throws Exception
{
- this.config = (DeployerConfig) containerConfig;
+ this.config = (DeployerConfig)containerConfig;
super.setJava2ClassLoadingCompliance(config.isJava2ClassLoadingCompliance());
super.setUnpackWars(config.isUnpackWars());
super.setLenientEjbLink(config.isLenientEjbLink());
@@ -143,17 +144,16 @@
hostName = hostNames.next().toString();
}
}
- performDeployInternal(hostName, webApp, warUrl);
+ performDeployInternal(webApp, hostName, warUrl);
while (hostNames.hasNext())
{
String additionalHostName = hostNames.next().toString();
- performDeployInternal(additionalHostName, webApp, warUrl);
+ performDeployInternal(webApp, additionalHostName, warUrl);
}
}
- protected void performDeployInternal(String hostName, WebApplication webApp, String warUrl) throws Exception
+ protected void performDeployInternal(WebApplication webApp, String hostName, String warUrlStr) throws Exception
{
-
JBossWebMetaData metaData = webApp.getMetaData();
String ctxPath = metaData.getContextRoot();
if (ctxPath.equals("/") || ctxPath.equals("/ROOT") || ctxPath.equals(""))
@@ -163,99 +163,48 @@
metaData.setContextRoot(ctxPath);
}
- log.info("deploy, ctxPath=" + ctxPath + ", vfsUrl=" + webApp.getDeploymentUnit().getFile("").getPathName());
+ log.info("deploy, ctxPath=" + ctxPath);
- URL url = new URL(warUrl);
+ URL warUrl = new URL(warUrlStr);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
metaData.setContextLoader(loader);
- StandardContext context = (StandardContext) Class.forName(config.getContextClassName()).newInstance();
+ StandardContext context = (StandardContext)Class.forName(config.getContextClassName()).newInstance();
- injectionContainer = new TomcatInjectionContainer(webApp, webApp.getDeploymentUnit(), context,
- getPersistenceUnitDependencyResolver());
+ DeploymentUnit depUnit = webApp.getDeploymentUnit();
+ injectionContainer = new TomcatInjectionContainer(webApp, depUnit, context, getPersistenceUnitDependencyResolver());
- Loader webLoader = webApp.getDeploymentUnit().getAttachment(Loader.class);
+ Loader webLoader = depUnit.getAttachment(Loader.class);
if (webLoader == null)
- webLoader = getWebLoader(webApp.getDeploymentUnit(), metaData, loader, url);
+ webLoader = getWebLoader(depUnit, metaData, loader, warUrl);
- webApp.setName(url.getPath());
+ webApp.setName(warUrl.getPath());
webApp.setClassLoader(loader);
- webApp.setURL(url);
+ webApp.setURL(warUrl);
- String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//"
- + ((hostName == null) ? "localhost" : hostName) + ctxPath + ",J2EEApplication=none,J2EEServer=none";
+ String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath
+ + ",J2EEApplication=none,J2EEServer=none";
ObjectName objectName = new ObjectName(objectNameS);
if (Registry.getRegistry(null, null).getMBeanServer().isRegistered(objectName))
- throw new DeploymentException("Web mapping already exists for deployment URL " + warUrl);
+ throw new DeploymentException("Web mapping already exists for deployment URL " + warUrlStr);
Registry.getRegistry(null, null).registerComponent(context, objectName, config.getContextClassName());
- if (TomcatService.OLD_CODE)
- {
- String ctxConfig = null;
- File warFile = new File(url.getFile());
- if (warFile.isDirectory() == false)
- {
- // Using VFS access
- VFSDirContext resources = new VFSDirContext();
- resources.setVirtualFile(webApp.getDeploymentUnit().getFile(""));
- context.setResources(resources);
- // Find META-INF/context.xml
- VirtualFile file = webApp.getDeploymentUnit().getFile(CONTEXT_CONFIG_FILE);
- if (file != null)
- {
- // Copy the META-INF/context.xml from the VFS to the temp folder
- InputStream is = file.openStream();
- FileOutputStream fos = null;
- try
- {
- byte[] buffer = new byte[512];
- int bytes;
- // FIXME: use JBoss'temp folder instead
- File tempFile = File.createTempFile("context-", ".xml");
- tempFile.deleteOnExit();
- fos = new FileOutputStream(tempFile);
- while ((bytes = is.read(buffer)) > 0)
- {
- fos.write(buffer, 0, bytes);
- }
- ctxConfig = tempFile.getAbsolutePath();
- }
- finally
- {
- is.close();
- if (fos != null)
- {
- fos.close();
- }
- }
- }
- }
- else
- {
- // Using direct filesystem access: no operation needed
- // Find META-INF/context.xml
- File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
- if (webDD.exists() == true)
- {
- ctxConfig = webDD.getAbsolutePath();
- }
- }
-
- context.setConfigFile(ctxConfig);
- }
- else
- {
- context.setConfigFile(CONTEXT_CONFIG_FILE);
- }
+ context.setConfigFile(CONTEXT_CONFIG_FILE);
context.setInstanceManager(injectionContainer);
- context.setDocBase(url.getFile());
context.setDefaultContextXml("context.xml");
context.setDefaultWebXml("conf/web.xml");
context.setPublicId(metaData.getPublicID());
+
+ String docBase = depUnit.getAttachment("org.jboss.web.explicitDocBase", String.class);
+ if (docBase == null)
+ docBase = warUrl.getFile();
+
+ context.setDocBase(docBase);
+
// If there is an alt-dd set it
if (metaData.getAlternativeDD() != null)
{
@@ -321,31 +270,30 @@
// Set the session cookies flag according to metadata
switch (metaData.getSessionCookies())
{
- case JBossWebMetaData.SESSION_COOKIES_ENABLED :
+ case JBossWebMetaData.SESSION_COOKIES_ENABLED:
context.setCookies(true);
log.debug("Enabling session cookies");
break;
- case JBossWebMetaData.SESSION_COOKIES_DISABLED :
+ case JBossWebMetaData.SESSION_COOKIES_DISABLED:
context.setCookies(false);
log.debug("Disabling session cookies");
break;
- default :
+ default:
log.debug("Using session cookies default setting");
}
String metaDataSecurityDomain = metaData.getSecurityDomain();
if (metaDataSecurityDomain != null)
metaDataSecurityDomain = metaDataSecurityDomain.trim();
-
+
// Add a valve to establish security context
- SecurityContextEstablishmentValve scevalve = new SecurityContextEstablishmentValve(metaDataSecurityDomain,
- SecurityUtil.unprefixSecurityDomain(config.getDefaultSecurityDomain()),
- SecurityActions.loadClass(config.getSecurityContextClassName()), getSecurityManagement());
+ SecurityContextEstablishmentValve scevalve = new SecurityContextEstablishmentValve(metaDataSecurityDomain, SecurityUtil.unprefixSecurityDomain(config
+ .getDefaultSecurityDomain()), SecurityActions.loadClass(config.getSecurityContextClassName()), getSecurityManagement());
context.addValve(scevalve);
// Add a valve to estalish the JACC context before authorization valves
Certificate[] certs = null;
- CodeSource cs = new CodeSource(url, certs);
+ CodeSource cs = new CodeSource(warUrl, certs);
JaccContextValve jaccValve = new JaccContextValve(metaData, cs);
context.addValve(jaccValve);
@@ -370,7 +318,7 @@
catch (Exception e)
{
context.destroy();
- DeploymentException.rethrowAsDeploymentException("URL " + warUrl + " deployment failed", e);
+ DeploymentException.rethrowAsDeploymentException("URL " + warUrlStr + " deployment failed", e);
}
finally
{
@@ -385,7 +333,7 @@
if (context.getState() != 1)
{
context.destroy();
- throw new DeploymentException("URL " + warUrl + " deployment failed");
+ throw new DeploymentException("URL " + warUrlStr + " deployment failed");
}
// Clustering
@@ -398,7 +346,7 @@
AbstractJBossManager manager = null;
String managerClassName = config.getManagerClass();
Class managerClass = Thread.currentThread().getContextClassLoader().loadClass(managerClassName);
- manager = (AbstractJBossManager) managerClass.newInstance();
+ manager = (AbstractJBossManager)managerClass.newInstance();
String name = "//" + ((hostName == null) ? "localhost" : hostName) + ctxPath;
manager.init(name, metaData);
@@ -409,8 +357,7 @@
catch (ClusteringNotSupportedException e)
{
// JBAS-3513 Just log a WARN, not an ERROR
- log.warn("Failed to setup clustering, clustering disabled. ClusteringNotSupportedException: "
- + e.getMessage());
+ log.warn("Failed to setup clustering, clustering disabled. ClusteringNotSupportedException: " + e.getMessage());
}
catch (NoClassDefFoundError ncdf)
{
@@ -431,7 +378,7 @@
*/
SecurityAssociationValve valve = new SecurityAssociationValve(metaData, config.getSecurityManagerService());
valve.setSubjectAttributeName(config.getSubjectAttributeName());
- server.invoke(objectName, "addValve", new Object[]{valve}, new String[]{"org.apache.catalina.Valve"});
+ server.invoke(objectName, "addValve", new Object[] { valve }, new String[] { "org.apache.catalina.Valve" });
/*
* TODO: Retrieve the state, and throw an exception in case of a failure Integer state = (Integer)
@@ -461,7 +408,7 @@
protected JBossWebMetaData metaData;
- protected VFSDeploymentUnit unit;
+ protected DeploymentUnit unit;
public EncListener(ClassLoader loader, Loader webLoader, WebApplication webApp)
{
@@ -498,13 +445,13 @@
currentThread.setContextClassLoader(webLoader.getClassLoader());
metaData.setENCLoader(webLoader.getClassLoader());
InitialContext iniCtx = new InitialContext();
- Context envCtx = (Context) iniCtx.lookup("java:comp");
+ Context envCtx = (Context)iniCtx.lookup("java:comp");
// Add ORB/UserTransaction
ORB orb = null;
try
{
ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB");
- orb = (ORB) server.getAttribute(ORB_NAME, "ORB");
+ orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
// Bind the orb
if (orb != null)
{
@@ -518,10 +465,8 @@
}
// JTA links
- envCtx
- .bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry"));
- log
- .debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry");
+ envCtx.bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry"));
+ log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry");
envCtx.bind("UserTransaction", new LinkRef("UserTransaction"));
log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction");
envCtx = envCtx.createSubcontext("env");
@@ -554,8 +499,7 @@
}
- public Loader getWebLoader(VFSDeploymentUnit unit, JBossWebMetaData metaData, ClassLoader loader, URL url)
- throws MalformedURLException
+ public Loader getWebLoader(DeploymentUnit unit, JBossWebMetaData metaData, ClassLoader loader, URL rl) throws MalformedURLException
{
Loader webLoader = null;
@@ -564,12 +508,13 @@
* else scoped class loading does not see the war level overrides. The call to setWarURL adds these paths to the
* deployment UCL.
*/
- ArrayList<URL> classpath = (ArrayList<URL>) unit.getAttachment("org.jboss.web.expandedWarClasspath");
- if (classpath == null)
+ ArrayList<URL> classpath = (ArrayList<URL>)unit.getAttachment("org.jboss.web.expandedWarClasspath");
+ if (classpath == null && unit instanceof VFSDeploymentUnit)
{
+ VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
try
{
- VirtualFile classes = unit.getFile("WEB-INF/classes");
+ VirtualFile classes = vfsUnit.getFile("WEB-INF/classes");
// Tomcat can't handle the vfs urls yet
URL vfsURL = classes.toURL();
String vfsurl = vfsURL.toString();
@@ -587,14 +532,8 @@
WebCtxLoader jbossLoader = new WebCtxLoader(loader, injectionContainer);
if (classpath != null)
jbossLoader.setClasspath(classpath);
+
webLoader = jbossLoader;
- /*
- * if (classLoading != null && classLoading.isJava2ClassLoadingCompliance()) { WebCtxLoader jbossLoader = new
- * WebCtxLoader(loader, injectionContainer); if (classpath != null) jbossLoader.setClasspath(classpath); webLoader =
- * jbossLoader; } else { String[] pkgs = config.getFilteredPackages(); WebAppLoader jbossLoader = new
- * WebAppLoader(loader, pkgs, injectionContainer); jbossLoader.setDelegate(getJava2ClassLoadingCompliance()); if
- * (classpath != null) jbossLoader.setClasspath(classpath); webLoader = jbossLoader; }
- */
return webLoader;
}
@@ -616,8 +555,7 @@
return;
}
- log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot() + ", vfsUrl="
- + warInfo.getDeploymentUnit().getFile("").getPathName());
+ log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot());
JBossWebMetaData metaData = warInfo.getMetaData();
String hostName = null;
@@ -637,18 +575,17 @@
hostName = hostNames.next().toString();
}
}
- performUndeployInternal(hostName, warUrl, warInfo);
+ performUndeployInternal(warInfo, hostName, warUrl);
while (hostNames.hasNext())
{
String additionalHostName = hostNames.next().toString();
- performUndeployInternal(additionalHostName, warUrl, warInfo);
+ performUndeployInternal(warInfo, additionalHostName, warUrl);
}
}
- protected void performUndeployInternal(String hostName, String warUrl, WebApplication warInfo) throws Exception
+ protected void performUndeployInternal(WebApplication warInfo, String hostName, String warUrlStr) throws Exception
{
-
JBossWebMetaData metaData = warInfo.getMetaData();
String ctxPath = metaData.getContextRoot();
@@ -658,13 +595,13 @@
if (server == null)
return;
- ObjectName objectName = new ObjectName(config.getCatalinaDomain() + ":j2eeType=WebModule,name=//"
- + ((hostName == null) ? "localhost" : hostName) + ctxPath + ",J2EEApplication=none,J2EEServer=none");
+ ObjectName objectName = new ObjectName(config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath
+ + ",J2EEApplication=none,J2EEServer=none");
if (server.isRegistered(objectName))
{
// Contexts should be stopped by the host already
- server.invoke(objectName, "destroy", new Object[]{}, new String[]{});
+ server.invoke(objectName, "destroy", new Object[] {}, new String[] {});
}
}
@@ -686,12 +623,12 @@
Iterator iter = hosts.iterator();
while (iter.hasNext())
{
- ObjectName host = (ObjectName) iter.next();
+ ObjectName host = (ObjectName)iter.next();
String name = host.getKeyProperty("host");
if (name != null)
{
vhostToHostNames.put(name, name);
- String[] aliases = (String[]) server.invoke(host, "findAliases", null, null);
+ String[] aliases = (String[])server.invoke(host, "findAliases", null, null);
int count = aliases != null ? aliases.length : 0;
for (int n = 0; n < count; n++)
{
@@ -707,7 +644,7 @@
{
for (String vhost : vhostNames)
{
- String host = (String) vhostToHostNames.get(vhost);
+ String host = (String)vhostToHostNames.get(vhost);
if (host == null)
{
log.warn("Failed to map vhost: " + vhost);
@@ -734,9 +671,9 @@
Iterator iter = engines.iterator();
while (iter.hasNext())
{
- ObjectName engine = (ObjectName) iter.next();
+ ObjectName engine = (ObjectName)iter.next();
- String defaultHost = (String) server.getAttribute(engine, "defaultHost");
+ String defaultHost = (String)server.getAttribute(engine, "defaultHost");
if (defaultHost != null)
{
defaultHosts.add(defaultHost);
More information about the jboss-cvs-commits
mailing list