[jboss-cvs] JBossAS SVN: r60901 - in trunk: tomcat/src/main/org/jboss/web/tomcat/tc6/deployers and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 26 05:24:13 EST 2007
Author: thomas.diesler at jboss.com
Date: 2007-02-26 05:24:12 -0500 (Mon, 26 Feb 2007)
New Revision: 60901
Modified:
trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefMetaData.java
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment2.java
Log:
Add <service-ref> handling to TomcatDEployment2
Modified: trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefMetaData.java 2007-02-26 09:59:42 UTC (rev 60900)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefMetaData.java 2007-02-26 10:24:12 UTC (rev 60901)
@@ -113,6 +113,8 @@
addPortComponentRef(pcSourceRef);
pcTargetRef = pcSourceRef;
}
+
+ pcTargetRef.setCallProperties(pcSourceRef.getCallProperties());
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment2.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment2.java 2007-02-26 09:59:42 UTC (rev 60900)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment2.java 2007-02-26 10:24:12 UTC (rev 60901)
@@ -34,7 +34,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -46,16 +45,16 @@
import javax.naming.InitialContext;
import javax.naming.LinkRef;
-import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Loader;
import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.startup.ContextConfig;
import org.apache.tomcat.util.modeler.Registry;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.metadata.WebMetaData;
+import org.jboss.metadata.serviceref.ServiceRefHandler;
+import org.jboss.metadata.serviceref.ServiceRefHandlerFactory;
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.naming.NonSerializableFactory;
import org.jboss.security.AuthorizationManager;
@@ -65,7 +64,7 @@
import org.jboss.web.deployers.AbstractWarDeployment;
import org.jboss.web.tomcat.security.JaccContextValve;
import org.jboss.web.tomcat.security.RunAsListener;
-import org.jboss.web.tomcat.security.SecurityAssociationValve;
+import org.jboss.web.tomcat.security.SecurityAssociationValve;
import org.jboss.web.tomcat.tc6.TomcatInjectionContainer;
import org.jboss.web.tomcat.tc6.WebAppLoader;
import org.jboss.web.tomcat.tc6.WebCtxLoader;
@@ -88,7 +87,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" };
@@ -101,6 +100,7 @@
{
return orb;
}
+
public void setORB(ORB orb)
{
this.orb = orb;
@@ -117,8 +117,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");
@@ -141,8 +140,7 @@
}
}
- protected void performDeployInternal(String hostName,
- WebApplication webApp, String warUrl) throws Exception
+ protected void performDeployInternal(String hostName, WebApplication webApp, String warUrl) throws Exception
{
WebMetaData metaData = webApp.getMetaData();
@@ -154,34 +152,31 @@
metaData.setContextRoot(ctxPath);
}
- log.info("deploy, ctxPath=" + ctxPath + ", vfsUrl="
- + webApp.getDeploymentUnit().getFile("").getPathName());
+ log.info("deploy, ctxPath=" + ctxPath + ", vfsUrl=" + webApp.getDeploymentUnit().getFile("").getPathName());
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);
- StandardContext context = (StandardContext) Class.forName(config.getContextClassName()).newInstance();
- Registry.getRegistry().registerComponent(context, objectName,
- config.getContextClassName());
-
+ StandardContext context = (StandardContext)Class.forName(config.getContextClassName()).newInstance();
+ Registry.getRegistry().registerComponent(context, objectName, config.getContextClassName());
+
// Find and set warInfo file on the context
// If WAR is packed, expand warInfo file to temp folder
String ctxConfig = null;
@@ -189,24 +184,25 @@
{
// TODO: this should be input metadata
ctxConfig = findConfig(url);
- } catch (IOException e)
+ }
+ catch (IOException e)
{
log.debug("No " + CONTEXT_CONFIG_FILE + " in " + url, e);
}
-
+
VFSDirContext resources = new VFSDirContext();
resources.setVirtualFile(webApp.getDeploymentUnit().getFile(""));
context.setResources(resources);
-
+
context.setAnnotationProcessor(injectionContainer);
context.setDocBase(url.getFile());
context.setConfigFile(ctxConfig);
context.setDefaultContextXml("context.xml");
context.setDefaultWebXml("conf/web.xml");
// If there is an alt-dd set it
- if( metaData.getAltDDPath() != null )
+ if (metaData.getAltDDPath() != null)
{
- log.debug("Setting altDDName to: "+metaData.getAltDDPath());
+ log.debug("Setting altDDName to: " + metaData.getAltDDPath());
context.setAltDDName(metaData.getAltDDPath());
}
context.setJavaVMs(javaVMs);
@@ -215,10 +211,11 @@
if (webLoader != null)
{
- context.setLoader(webLoader);
- } else
+ context.setLoader(webLoader);
+ }
+ else
{
- context.setParentClassLoader(loader);
+ context.setParentClassLoader(loader);
}
context.setDelegate(webApp.getJava2ClassLoadingCompliance());
@@ -233,8 +230,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
@@ -250,7 +246,8 @@
ZipFile zip = new ZipFile(fp);
zip.close();
- } catch (IOException e)
+ }
+ catch (IOException e)
{
continue;
}
@@ -266,16 +263,16 @@
// Set the session cookies flag according to metadata
switch (metaData.getSessionCookies())
{
- case WebMetaData.SESSION_COOKIES_ENABLED:
- context.setCookies(true);
- log.debug("Enabling session cookies");
- break;
- case WebMetaData.SESSION_COOKIES_DISABLED:
- context.setCookies(false);
- log.debug("Disabling session cookies");
- break;
- default:
- log.debug("Using session cookies default setting");
+ case WebMetaData.SESSION_COOKIES_ENABLED:
+ context.setCookies(true);
+ log.debug("Enabling session cookies");
+ break;
+ case WebMetaData.SESSION_COOKIES_DISABLED:
+ context.setCookies(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
@@ -286,19 +283,19 @@
// Set listener
context.setConfigClass("org.jboss.web.tomcat.tc6.deployers.JBossContextConfig");
- context.addLifecycleListener(new EncListener(loader, webLoader, metaData));
-
+ context.addLifecycleListener(new EncListener(loader, webLoader, webApp));
+
// Pass the metadata to the RunAsListener via a thread local
RunAsListener.metaDataLocal.set(metaData);
JBossContextConfig.metaDataLocal.set(metaData);
JBossContextConfig.metaDataShared.set(config.getSharedMetaData());
try
{
- // Init the container; this will also start it
- context.init();
- // Start it
- context.start();
- // Build the ENC
+ // Init the container; this will also start it
+ context.init();
+ // Start it
+ context.start();
+ // Build the ENC
}
finally
{
@@ -316,19 +313,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);
}
@@ -340,15 +334,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)
{
@@ -362,19 +354,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);
@@ -389,8 +379,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();
@@ -398,34 +387,41 @@
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 class EncListener implements LifecycleListener {
-
- protected ClassLoader loader = null;
- protected Loader webLoader = null;
- protected WebMetaData metaData = null;
- public EncListener(ClassLoader loader, Loader webLoader, WebMetaData metaData) {
+
+ public class EncListener implements LifecycleListener
+ {
+ protected ClassLoader loader;
+ protected Loader webLoader;
+ protected WebApplication webApp;
+ protected WebMetaData metaData;
+ protected DeploymentUnit unit;
+
+ public EncListener(ClassLoader loader, Loader webLoader, WebApplication webApp)
+ {
this.loader = loader;
this.webLoader = webLoader;
- this.metaData = metaData;
+ this.webApp = webApp;
+ this.metaData = webApp.getMetaData();
+ this.unit = webApp.getDeploymentUnit();
}
-
- public void lifecycleEvent(LifecycleEvent event) {
- if (event.getType().equals(StandardContext.AFTER_START_EVENT)) {
+ public void lifecycleEvent(LifecycleEvent event)
+ {
+ if (event.getType().equals(StandardContext.AFTER_START_EVENT))
+ {
+
// make the context class loader known to the WebMetaData, ws4ee needs it
// to instanciate service endpoint pojos that live in this webapp
metaData.setContextLoader(webLoader.getClassLoader());
@@ -446,13 +442,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)
{
@@ -475,6 +471,15 @@
String securityDomain = metaData.getSecurityDomain();
log.debug("linkSecurityDomain");
linkSecurityDomain(securityDomain, envCtx);
+
+ // TODO: should this be handled differently?
+ // JAX-RPC service refs are not injectable objects
+ Iterator serviceRefs = metaData.getServiceRefs();
+ log.debug("linkServiceRefs");
+ ServiceRefHandler refHandler = ServiceRefHandlerFactory.newInstance();
+ if (refHandler != null && serviceRefs.hasNext())
+ refHandler.bindServiceRefs(envCtx, serviceRefs, unit);
+
}
catch (Throwable t)
{
@@ -493,22 +498,21 @@
}
}
-
+
}
- 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
{
@@ -516,21 +520,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;
}
@@ -539,7 +543,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;
}
@@ -555,17 +559,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()
- + ", vfsUrl=" + warInfo.getDeploymentUnit().getFile("").getPathName());
+ log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot() + ", vfsUrl=" + warInfo.getDeploymentUnit().getFile("").getPathName());
WebMetaData metaData = warInfo.getMetaData();
String hostName = null;
@@ -583,8 +585,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();
@@ -596,9 +597,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))
@@ -615,8 +614,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)
{
@@ -632,8 +630,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++)
{
@@ -670,7 +667,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);
@@ -691,6 +689,6 @@
zipFile.close();
}
return result;
- }
+ }
}
More information about the jboss-cvs-commits
mailing list