[jboss-cvs] JBossAS SVN: r61071 - trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Mar 3 08:20:06 EST 2007
Author: thomas.diesler at jboss.com
Date: 2007-03-03 08:20:05 -0500 (Sat, 03 Mar 2007)
New Revision: 61071
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java
Log:
layout code
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java 2007-03-03 11:16:35 UTC (rev 61070)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java 2007-03-03 13:20:05 UTC (rev 61071)
@@ -84,7 +84,7 @@
/**
* The name of the war level context configuration descriptor
*/
- private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml";
+ private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml";
private DeployerConfig config;
private String[] javaVMs = { " jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost" };
@@ -97,6 +97,7 @@
{
return orb;
}
+
public void setORB(ORB orb)
{
this.orb = orb;
@@ -113,8 +114,7 @@
}
@Override
- protected void performDeploy(WebApplication webApp, String warUrl)
- throws Exception
+ protected void performDeploy(WebApplication webApp, String warUrl) throws Exception
{
// Decode the URL as tomcat can't deal with paths with escape chars
warUrl = URLDecoder.decode(warUrl, "UTF-8");
@@ -137,8 +137,7 @@
}
}
- protected void performDeployInternal(String hostName,
- WebApplication webApp, String warUrl) throws Exception
+ protected void performDeployInternal(String hostName, WebApplication webApp, String warUrl) throws Exception
{
DeploymentUnit unit = webApp.getDeploymentUnit();
WebMetaData metaData = webApp.getMetaData();
@@ -150,34 +149,30 @@
metaData.setContextRoot(ctxPath);
}
- log.info("deploy, ctxPath=" + ctxPath + ", warUrl="
- + shortWarUrlFromServerHome(warUrl));
+ log.info("deploy, ctxPath=" + ctxPath + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
URL url = new URL(warUrl);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
metaData.setContextLoader(loader);
-
+
injectionContainer = new TomcatInjectionContainer(webApp, webApp.getDeploymentUnit());
Loader webLoader = webApp.getDeploymentUnit().getAttachment(Loader.class);
- if( webLoader == null )
+ if (webLoader == null)
webLoader = getWebLoader(webApp.getDeploymentUnit(), loader, url);
webApp.setName(url.getPath());
webApp.setClassLoader(loader);
webApp.setURL(url);
- String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//"
- + ((hostName == null) ? "localhost" : hostName) + ctxPath
+ String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath
+ ",J2EEApplication=none,J2EEServer=none";
ObjectName objectName = new ObjectName(objectNameS);
String contextClassName = config.getContextClassName();
- Registry.getRegistry().registerComponent(
- Class.forName(contextClassName).newInstance(), objectName,
- contextClassName);
+ Registry.getRegistry().registerComponent(Class.forName(contextClassName).newInstance(), objectName, contextClassName);
// Find and set warInfo file on the context
// If WAR is packed, expand warInfo file to temp folder
@@ -186,7 +181,8 @@
{
// TODO: this should be input metadata
ctxConfig = findConfig(url);
- } catch (IOException e)
+ }
+ catch (IOException e)
{
log.debug("No " + CONTEXT_CONFIG_FILE + " in " + url, e);
}
@@ -200,15 +196,13 @@
server.setAttribute(objectName, new Attribute("configFile", ctxConfig));
- server.setAttribute(objectName, new Attribute("defaultContextXml",
- "context.xml"));
- server.setAttribute(objectName, new Attribute("defaultWebXml",
- "conf/web.xml"));
+ server.setAttribute(objectName, new Attribute("defaultContextXml", "context.xml"));
+ server.setAttribute(objectName, new Attribute("defaultWebXml", "conf/web.xml"));
// If there is an alt-dd set it
- if( metaData.getAltDDPath() != null )
+ if (metaData.getAltDDPath() != null)
{
String altPath = metaData.getAltDDPath();
- log.debug("Setting altDDName to: "+altPath);
+ log.debug("Setting altDDName to: " + altPath);
server.setAttribute(objectName, new Attribute("altDDName", altPath));
}
@@ -216,20 +210,18 @@
server.setAttribute(objectName, new Attribute("server", serverName));
- server.setAttribute(objectName,
- new Attribute("saveConfig", Boolean.FALSE));
+ server.setAttribute(objectName, new Attribute("saveConfig", Boolean.FALSE));
if (webLoader != null)
{
server.setAttribute(objectName, new Attribute("loader", webLoader));
- } else
+ }
+ else
{
- server.setAttribute(objectName, new Attribute("parentClassLoader",
- loader));
+ server.setAttribute(objectName, new Attribute("parentClassLoader", loader));
}
- server.setAttribute(objectName, new Attribute("delegate", new Boolean(
- webApp.getJava2ClassLoadingCompliance())));
+ server.setAttribute(objectName, new Attribute("delegate", new Boolean(webApp.getJava2ClassLoadingCompliance())));
String[] jspCP = getCompileClasspath(loader);
StringBuffer classpath = new StringBuffer();
@@ -242,8 +234,7 @@
repository = repository.substring(7);
else if (repository.startsWith("file:"))
repository = repository.substring(5);
- else
- continue;
+ else continue;
if (repository == null)
continue;
// ok it is a file. Make sure that is is a directory or jar file
@@ -259,7 +250,8 @@
ZipFile zip = new ZipFile(fp);
zip.close();
- } catch (IOException e)
+ }
+ catch (IOException e)
{
continue;
}
@@ -270,32 +262,28 @@
classpath.append(repository);
}
- server.setAttribute(objectName, new Attribute("compilerClasspath",
- classpath.toString()));
+ server.setAttribute(objectName, new Attribute("compilerClasspath", classpath.toString()));
// Set the session cookies flag according to metadata
switch (metaData.getSessionCookies())
{
- case WebMetaData.SESSION_COOKIES_ENABLED:
- server.setAttribute(objectName, new Attribute("cookies", new Boolean(
- true)));
- log.debug("Enabling session cookies");
- break;
- case WebMetaData.SESSION_COOKIES_DISABLED:
- server.setAttribute(objectName, new Attribute("cookies", new Boolean(
- false)));
- log.debug("Disabling session cookies");
- break;
- default:
- log.debug("Using session cookies default setting");
+ case WebMetaData.SESSION_COOKIES_ENABLED:
+ server.setAttribute(objectName, new Attribute("cookies", new Boolean(true)));
+ log.debug("Enabling session cookies");
+ break;
+ case WebMetaData.SESSION_COOKIES_DISABLED:
+ server.setAttribute(objectName, new Attribute("cookies", new Boolean(false)));
+ log.debug("Disabling session cookies");
+ break;
+ default:
+ log.debug("Using session cookies default setting");
}
// Add a valve to estalish the JACC context before authorization valves
Certificate[] certs = null;
CodeSource cs = new CodeSource(url, certs);
JaccContextValve jaccValve = new JaccContextValve(metaData, cs);
- server.invoke(objectName, "addValve", new Object[] { jaccValve },
- new String[] { "org.apache.catalina.Valve" });
+ server.invoke(objectName, "addValve", new Object[] { jaccValve }, new String[] { "org.apache.catalina.Valve" });
// Pass the metadata to the RunAsListener via a thread local
RunAsListener.metaDataLocal.set(metaData);
@@ -311,12 +299,11 @@
// make the context class loader known to the WebMetaData, ws4ee needs it
// to instanciate service endpoint pojos that live in this webapp
- Loader ctxLoader = (Loader) server.getAttribute(objectName, "loader");
+ Loader ctxLoader = (Loader)server.getAttribute(objectName, "loader");
metaData.setContextLoader(ctxLoader.getClassLoader());
// Start it
- server.invoke(objectName, "start", new Object[]{},
- new String[]{});
+ server.invoke(objectName, "start", new Object[] {}, new String[] {});
// Build the ENC
if (injectionContainer == null)
@@ -341,13 +328,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)
{
@@ -366,7 +353,7 @@
envCtx = envCtx.createSubcontext("env");
injectionContainer.populateEnc(webLoader.getClassLoader());
-
+
// TODO: should this be handled differently?
// JAX-RPC service refs are not injectable objects
Iterator serviceRefs = metaData.getServiceRefs();
@@ -374,7 +361,7 @@
ServiceRefHandler refHandler = ServiceRefHandlerFactory.newInstance();
if (refHandler != null && serviceRefs.hasNext())
refHandler.bindServiceRefs(envCtx, serviceRefs, unit);
-
+
// TODO: this should be bindings in the metadata
currentThread.setContextClassLoader(webLoader.getClassLoader());
String securityDomain = metaData.getSecurityDomain();
@@ -396,19 +383,16 @@
{
AbstractJBossManager manager = null;
String managerClassName = config.getManagerClass();
- Class managerClass = Thread.currentThread().getContextClassLoader()
- .loadClass(managerClassName);
- manager = (AbstractJBossManager) managerClass.newInstance();
- String name = "//" + ((hostName == null) ? "localhost" : hostName)
- + ctxPath;
- manager.init(name, metaData, config.isUseJK(), config
- .isUseLocalCache());
+ Class managerClass = Thread.currentThread().getContextClassLoader().loadClass(managerClassName);
+ manager = (AbstractJBossManager)managerClass.newInstance();
+ String name = "//" + ((hostName == null) ? "localhost" : hostName) + ctxPath;
+ manager.init(name, metaData, config.isUseJK(), config.isUseLocalCache());
if (manager instanceof JBossCacheManager)
{
String snapshotMode = config.getSnapshotMode();
int snapshotInterval = config.getSnapshotInterval();
- JBossCacheManager jbcm = (JBossCacheManager) manager;
+ JBossCacheManager jbcm = (JBossCacheManager)manager;
jbcm.setSnapshotMode(snapshotMode);
jbcm.setSnapshotInterval(snapshotInterval);
}
@@ -420,15 +404,13 @@
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)
{
// JBAS-3513 Just log a WARN, not an ERROR
log.debug("Classes needed for clustered webapp unavailable", ncdf);
- log.warn("Failed to setup clustering, clustering disabled. NoClassDefFoundError: "
- + ncdf.getMessage());
+ log.warn("Failed to setup clustering, clustering disabled. NoClassDefFoundError: " + ncdf.getMessage());
}
catch (Throwable t)
{
@@ -442,19 +424,17 @@
* the authenticated user may be associated with the request
* thread/session.
*/
- SecurityAssociationValve valve = new SecurityAssociationValve(metaData,
- config.getSecurityManagerService());
+ 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) server.getAttribute(objectName, "state");
- if (state.intValue() != 1)
- {
- throw new DeploymentException("URL " + warUrl + " deployment failed");
- }
- */
+ Integer state = (Integer) server.getAttribute(objectName, "state");
+ if (state.intValue() != 1)
+ {
+ throw new DeploymentException("URL " + warUrl + " deployment failed");
+ }
+ */
webApp.setAppData(objectName);
@@ -469,8 +449,7 @@
if (metaData.getSecurityDomain() != null)
{
- String secDomain = org.jboss.security.Util
- .unprefixSecurityDomain(metaData.getSecurityDomain());
+ String secDomain = org.jboss.security.Util.unprefixSecurityDomain(metaData.getSecurityDomain());
// Associate the Context Id with the Security Domain
String contextID = metaData.getJaccContextID();
@@ -478,32 +457,30 @@
URL xacmlPolicyFile = this.config.getXacmlPolicyURL();
if (xacmlPolicyFile != null)
{
- AuthorizationManager authzmgr = org.jboss.security.Util
- .getAuthorizationManager(secDomain);
- if (authzmgr instanceof PolicyRegistration)
- {
- PolicyRegistration xam = (PolicyRegistration) authzmgr;
- xam.registerPolicy(contextID, xacmlPolicyFile);
- }
- }
+ AuthorizationManager authzmgr = org.jboss.security.Util.getAuthorizationManager(secDomain);
+ if (authzmgr instanceof PolicyRegistration)
+ {
+ PolicyRegistration xam = (PolicyRegistration)authzmgr;
+ xam.registerPolicy(contextID, xacmlPolicyFile);
+ }
+ }
}
log.debug("Initialized: " + webApp + " " + objectName);
}
- public Loader getWebLoader(DeploymentUnit unit, ClassLoader loader, URL url)
- throws MalformedURLException
+ public Loader getWebLoader(DeploymentUnit unit, ClassLoader loader, URL url) throws MalformedURLException
{
Loader webLoader = null;
-
+
/*
* If we are using the jboss class loader we need to augment its path to
* include the WEB-INF/{lib,classes} dirs or 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)
{
try
{
@@ -511,21 +488,21 @@
// Tomcat can't handle the vfs urls yet
URL vfsURL = classes.toURL();
String vfsurl = vfsURL.toString();
- if( vfsurl.startsWith("vfs") )
+ if (vfsurl.startsWith("vfs"))
vfsURL = new URL(vfsurl.substring(3));
classpath = new ArrayList<URL>();
classpath.add(classes.toURL());
}
- catch(Exception e)
+ catch (Exception e)
{
-
+
}
}
if (config.isUseJBossWebLoader())
{
WebCtxLoader jbossLoader = new WebCtxLoader(loader, injectionContainer);
- if( classpath != null )
+ if (classpath != null)
jbossLoader.setClasspath(classpath);
webLoader = jbossLoader;
}
@@ -534,7 +511,7 @@
String[] pkgs = config.getFilteredPackages();
WebAppLoader jbossLoader = new WebAppLoader(loader, pkgs, injectionContainer);
jbossLoader.setDelegate(getJava2ClassLoadingCompliance());
- if( classpath != null )
+ if (classpath != null)
jbossLoader.setClasspath(classpath);
webLoader = jbossLoader;
}
@@ -550,17 +527,15 @@
* Called as part of the undeploy() method template to ask the subclass for
* perform the web container specific undeployment steps.
*/
- protected void performUndeploy(WebApplication warInfo, String warUrl)
- throws Exception
+ protected void performUndeploy(WebApplication warInfo, String warUrl) throws Exception
{
if (warInfo == null)
{
- log.debug("performUndeploy, no WebApplication found for URL "+ warUrl);
+ log.debug("performUndeploy, no WebApplication found for URL " + warUrl);
return;
}
- log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot()
- + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
+ log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot() + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
WebMetaData metaData = warInfo.getMetaData();
String hostName = null;
@@ -578,8 +553,7 @@
}
- protected void performUndeployInternal(String hostName, String warUrl,
- WebApplication warInfo) throws Exception
+ protected void performUndeployInternal(String hostName, String warUrl, WebApplication warInfo) throws Exception
{
WebMetaData metaData = warInfo.getMetaData();
@@ -591,9 +565,7 @@
if (server == null)
return;
- ObjectName objectName = new ObjectName(config.getCatalinaDomain()
- + ":j2eeType=WebModule,name=//"
- + ((hostName == null) ? "localhost" : hostName) + ctxPath
+ ObjectName objectName = new ObjectName(config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath
+ ",J2EEApplication=none,J2EEServer=none");
if (server.isRegistered(objectName))
@@ -610,8 +582,7 @@
* @return Iterator<String> of the unique Host names
* @throws Exception
*/
- protected synchronized Iterator mapVirtualHosts(Iterator vhostNames)
- throws Exception
+ protected synchronized Iterator mapVirtualHosts(Iterator vhostNames) throws Exception
{
if (vhostToHostNames.size() == 0)
{
@@ -627,8 +598,7 @@
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++)
{
@@ -665,7 +635,8 @@
File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
if (webDD.exists() == true)
result = webDD.getAbsolutePath();
- } else
+ }
+ else
{
ZipFile zipFile = new ZipFile(warFile);
ZipEntry entry = zipFile.getEntry(CONTEXT_CONFIG_FILE);
@@ -686,6 +657,6 @@
zipFile.close();
}
return result;
- }
+ }
}
More information about the jboss-cvs-commits
mailing list