[jboss-cvs] JBossAS SVN: r83776 - in trunk: 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 07:36:14 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-02-02 07:36:14 -0500 (Mon, 02 Feb 2009)
New Revision: 83776
Modified:
trunk/server/src/main/org/jboss/web/WebApplication.java
trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
trunk/server/src/main/org/jboss/web/deployers/WebModule.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
Log:
[JBAS-6436] In-Memory webapp deployment. Fix testsuite regression
Modified: trunk/server/src/main/org/jboss/web/WebApplication.java
===================================================================
--- trunk/server/src/main/org/jboss/web/WebApplication.java 2009-02-02 12:18:19 UTC (rev 83775)
+++ trunk/server/src/main/org/jboss/web/WebApplication.java 2009-02-02 12:36:14 UTC (rev 83776)
@@ -106,6 +106,7 @@
{
return unit;
}
+
public void setDeploymentUnit(DeploymentUnit unit)
{
this.unit = unit;
@@ -168,6 +169,8 @@
*/
public void setURL(URL url)
{
+ if (url == null)
+ throw new IllegalArgumentException("Null URL");
this.url = url;
}
Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java 2009-02-02 12:18:19 UTC (rev 83775)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java 2009-02-02 12:36:14 UTC (rev 83776)
@@ -87,668 +87,658 @@
*/
public abstract class AbstractWarDeployer extends AbstractSimpleRealDeployer<JBossWebMetaData>
{
- public static final String DEPLOYER = "org.jboss.web.AbstractWebContainer.deployer";
- public static final String WEB_APP = "org.jboss.web.AbstractWebContainer.webApp";
- public static final String WEB_MODULE = "org.jboss.web.AbstractWebContainer.webModule";
- public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
+ public static final String DEPLOYER = "org.jboss.web.AbstractWebContainer.deployer";
+ public static final String WEB_APP = "org.jboss.web.AbstractWebContainer.webApp";
+ public static final String WEB_MODULE = "org.jboss.web.AbstractWebContainer.webModule";
+ public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
- /** A mapping of deployed warUrl strings to the WebApplication object */
- protected HashMap deploymentMap = new HashMap();
- /** The parent class loader first model flag */
- protected boolean java2ClassLoadingCompliance = false;
- /** A flag indicating if war archives should be unpacked */
- protected boolean unpackWars = true;
- /** A flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
- */
- protected boolean acceptNonWarDirs = false;
+ /** A mapping of deployed warUrl strings to the WebApplication object */
+ protected HashMap deploymentMap = new HashMap();
+ /** The parent class loader first model flag */
+ protected boolean java2ClassLoadingCompliance = false;
+ /** A flag indicating if war archives should be unpacked */
+ protected boolean unpackWars = true;
+ /** A flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
+ */
+ protected boolean acceptNonWarDirs = false;
- /** If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name) */
- protected boolean lenientEjbLink = false;
+ /** If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name) */
+ protected boolean lenientEjbLink = false;
- /** The default security-domain name to use */
- protected String defaultSecurityDomain = "java:/jaas/other";
- /** The request attribute name under which the JAAS Subject is store */
- private String subjectAttributeName = null;
- /** Legacy support for MBeanServer */
- private MBeanServer server;
- private MainDeployerStructure mainDeployer;
+ /** The default security-domain name to use */
+ protected String defaultSecurityDomain = "java:/jaas/other";
+ /** The request attribute name under which the JAAS Subject is store */
+ private String subjectAttributeName = null;
+ /** Legacy support for MBeanServer */
+ private MBeanServer server;
+ private MainDeployerStructure mainDeployer;
- private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+ private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
- /**
- * Create a new AbstractWarDeployer.
- */
- public AbstractWarDeployer()
- {
- super(JBossWebMetaData.class);
- setOutput(ServiceMetaData.class);
- setOutput(WarDeployment.class);
- }
+ /**
+ * Create a new AbstractWarDeployer.
+ */
+ public AbstractWarDeployer()
+ {
+ super(JBossWebMetaData.class);
+ setOutput(ServiceMetaData.class);
+ setOutput(WarDeployment.class);
+ }
- /** Get the flag indicating if the normal Java2 parent first class loading
- * model should be used over the servlet 2.3 web container first model.
- * @return true for parent first, false for the servlet 2.3 model
- * @jmx:managed-attribute
- */
- public boolean getJava2ClassLoadingCompliance()
- {
- return java2ClassLoadingCompliance;
- }
+ /** Get the flag indicating if the normal Java2 parent first class loading
+ * model should be used over the servlet 2.3 web container first model.
+ * @return true for parent first, false for the servlet 2.3 model
+ * @jmx:managed-attribute
+ */
+ public boolean getJava2ClassLoadingCompliance()
+ {
+ return java2ClassLoadingCompliance;
+ }
- /** Set the flag indicating if the normal Java2 parent first class loading
- * model should be used over the servlet 2.3 web container first model.
- * @param flag true for parent first, false for the servlet 2.3 model
- * @jmx:managed-attribute
- */
- public void setJava2ClassLoadingCompliance(boolean flag)
- {
- java2ClassLoadingCompliance = flag;
- }
+ /** Set the flag indicating if the normal Java2 parent first class loading
+ * model should be used over the servlet 2.3 web container first model.
+ * @param flag true for parent first, false for the servlet 2.3 model
+ * @jmx:managed-attribute
+ */
+ public void setJava2ClassLoadingCompliance(boolean flag)
+ {
+ java2ClassLoadingCompliance = flag;
+ }
- /** Set the flag indicating if war archives should be unpacked. This may
- * need to be set to false as long extraction paths under deploy can
- * show up as deployment failures on some platforms.
- *
- * @jmx:managed-attribute
- * @return true is war archives should be unpacked
- */
- public boolean getUnpackWars()
- {
- return unpackWars;
- }
+ /** Set the flag indicating if war archives should be unpacked. This may
+ * need to be set to false as long extraction paths under deploy can
+ * show up as deployment failures on some platforms.
+ *
+ * @jmx:managed-attribute
+ * @return true is war archives should be unpacked
+ */
+ public boolean getUnpackWars()
+ {
+ return unpackWars;
+ }
- /** Get the flag indicating if war archives should be unpacked. This may
- * need to be set to false as long extraction paths under deploy can
- * show up as deployment failures on some platforms.
- *
- * @jmx:managed-attribute
- * @param flag , true is war archives should be unpacked
- */
- public void setUnpackWars(boolean flag)
- {
- this.unpackWars = flag;
- }
+ /** Get the flag indicating if war archives should be unpacked. This may
+ * need to be set to false as long extraction paths under deploy can
+ * show up as deployment failures on some platforms.
+ *
+ * @jmx:managed-attribute
+ * @param flag , true is war archives should be unpacked
+ */
+ public void setUnpackWars(boolean flag)
+ {
+ this.unpackWars = flag;
+ }
- /**
- * Get the flag indicating if local dirs with WEB-INF/web.xml should be
- * treated as wars
- * @return true if local dirs with WEB-INF/web.xml should be treated as wars
- * @jmx.managed-attribute
- */
- public boolean getAcceptNonWarDirs()
- {
- return acceptNonWarDirs;
- }
+ /**
+ * Get the flag indicating if local dirs with WEB-INF/web.xml should be
+ * treated as wars
+ * @return true if local dirs with WEB-INF/web.xml should be treated as wars
+ * @jmx.managed-attribute
+ */
+ public boolean getAcceptNonWarDirs()
+ {
+ return acceptNonWarDirs;
+ }
- /**
- * Set the flag indicating if local dirs with WEB-INF/web.xml should be
- * treated as wars
- * @param flag - true if local dirs with WEB-INF/web.xml should be treated as wars
- * @jmx.managed-attribute
- */
- public void setAcceptNonWarDirs(boolean flag)
- {
- this.acceptNonWarDirs = flag;
- }
+ /**
+ * Set the flag indicating if local dirs with WEB-INF/web.xml should be
+ * treated as wars
+ * @param flag - true if local dirs with WEB-INF/web.xml should be treated as wars
+ * @jmx.managed-attribute
+ */
+ public void setAcceptNonWarDirs(boolean flag)
+ {
+ this.acceptNonWarDirs = flag;
+ }
- /**
- * Get the flag indicating if ejb-link errors should be ignored
- * in favour of trying the jndi-name in jboss-web.xml
- * @return the LenientEjbLink flag
- *
- * @jmx:managed-attribute
- */
- public boolean getLenientEjbLink()
- {
- return lenientEjbLink;
- }
+ /**
+ * Get the flag indicating if ejb-link errors should be ignored
+ * in favour of trying the jndi-name in jboss-web.xml
+ * @return the LenientEjbLink flag
+ *
+ * @jmx:managed-attribute
+ */
+ public boolean getLenientEjbLink()
+ {
+ return lenientEjbLink;
+ }
- /**
- * Set the flag indicating if ejb-link errors should be ignored
- * in favour of trying the jndi-name in jboss-web.xml
- *
- * @jmx:managed-attribute
- */
- public void setLenientEjbLink(boolean flag)
- {
- lenientEjbLink = flag;
- }
+ /**
+ * Set the flag indicating if ejb-link errors should be ignored
+ * in favour of trying the jndi-name in jboss-web.xml
+ *
+ * @jmx:managed-attribute
+ */
+ public void setLenientEjbLink(boolean flag)
+ {
+ lenientEjbLink = flag;
+ }
- /** Get the default security domain implementation to use if a war
- * does not declare a security-domain.
- *
- * @return jndi name of the security domain binding to use.
- * @jmx:managed-attribute
- */
- public String getDefaultSecurityDomain()
- {
- return defaultSecurityDomain;
- }
+ /** Get the default security domain implementation to use if a war
+ * does not declare a security-domain.
+ *
+ * @return jndi name of the security domain binding to use.
+ * @jmx:managed-attribute
+ */
+ public String getDefaultSecurityDomain()
+ {
+ return defaultSecurityDomain;
+ }
- /** Set the default security domain implementation to use if a war
- * does not declare a security-domain.
- *
- * @param defaultSecurityDomain - jndi name of the security domain binding
- * to use.
- * @jmx:managed-attribute
- */
- public void setDefaultSecurityDomain(String defaultSecurityDomain)
- {
- this.defaultSecurityDomain = defaultSecurityDomain;
- }
+ /** Set the default security domain implementation to use if a war
+ * does not declare a security-domain.
+ *
+ * @param defaultSecurityDomain - jndi name of the security domain binding
+ * to use.
+ * @jmx:managed-attribute
+ */
+ public void setDefaultSecurityDomain(String defaultSecurityDomain)
+ {
+ this.defaultSecurityDomain = defaultSecurityDomain;
+ }
- @Inject
- public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
- {
- this.persistenceUnitDependencyResolver = resolver;
- }
+ @Inject
+ public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
+ {
+ this.persistenceUnitDependencyResolver = resolver;
+ }
- /** Get the session attribute number under which the caller Subject is stored
- * @jmx:managed-attribute
- */
- public String getSubjectAttributeName()
- {
- return subjectAttributeName;
- }
+ /** Get the session attribute number under which the caller Subject is stored
+ * @jmx:managed-attribute
+ */
+ public String getSubjectAttributeName()
+ {
+ return subjectAttributeName;
+ }
- /** Set the session attribute number under which the caller Subject is stored
- * @jmx:managed-attribute
- */
- public void setSubjectAttributeName(String subjectAttributeName)
- {
- this.subjectAttributeName = subjectAttributeName;
- }
+ /** Set the session attribute number under which the caller Subject is stored
+ * @jmx:managed-attribute
+ */
+ public void setSubjectAttributeName(String subjectAttributeName)
+ {
+ this.subjectAttributeName = subjectAttributeName;
+ }
- public void start() throws Exception
- {
- // TODO: remove dependency on jmx
- this.server = MBeanServerLocator.locateJBoss();
- }
+ public void start() throws Exception
+ {
+ // TODO: remove dependency on jmx
+ this.server = MBeanServerLocator.locateJBoss();
+ }
- public void stop() throws Exception
- {
+ public void stop() throws Exception
+ {
- }
+ }
- /**
- * Get the AbstractWarDeployment bean for the deployment metadata. Subclasses
- * override this method to provide a AbstractWarDeployment bean whose
- * start/stop will control the deployment/undeployment of the web
- * application.
- *
- * @param unit - the deployment unit
- * @param metaData - the input web application metadata
- * @return the AbstractWarDeployment for the input WebMetaData
- * @throws Exception - thrown on any failure
- */
- public abstract AbstractWarDeployment getDeployment(DeploymentUnit unit, JBossWebMetaData metaData) throws Exception;
+ /**
+ * Get the AbstractWarDeployment bean for the deployment metadata. Subclasses
+ * override this method to provide a AbstractWarDeployment bean whose
+ * start/stop will control the deployment/undeployment of the web
+ * application.
+ *
+ * @param unit - the deployment unit
+ * @param metaData - the input web application metadata
+ * @return the AbstractWarDeployment for the input WebMetaData
+ * @throws Exception - thrown on any failure
+ */
+ public abstract AbstractWarDeployment getDeployment(DeploymentUnit unit, JBossWebMetaData metaData) throws Exception;
- /**
- * Deploy a web app based on the WebMetaData. This calls
- * {@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(DeploymentUnit, WebMetaData, AbstractWarDeployment)
- * @see #buildWebContext(WebMetaData, DeploymentUnit, String, String)
- *
- * @param unit - the war for the deployment
- * @param metaData - the metadata for the deployment
- */
- @Override
- public void deploy(DeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException
- {
- log.debug("Begin deploy, " + metaData);
+ /**
+ * Deploy a web app based on the WebMetaData. This calls
+ * {@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(DeploymentUnit, WebMetaData, AbstractWarDeployment)
+ * @see #buildWebContext(DeploymentUnit, String, String, WebMetaData)
+ *
+ * @param unit - the war for the deployment
+ * @param metaData - the metadata for the deployment
+ */
+ @Override
+ public void deploy(DeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException
+ {
+ log.debug("Begin deploy, " + metaData);
- // Merge any settings from the ear level
- JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class);
- if (earMetaData != null)
- {
- String path = unit.getRelativePath();
- ModuleMetaData webModule = earMetaData.getModule(path);
- if (webModule != null)
+ // Merge any settings from the ear level
+ JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class);
+ if (earMetaData != null)
{
- // Check for a context-root setting
- String contextRoot = metaData.getContextRoot();
- if (contextRoot == null)
- {
- WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue();
- contextRoot = wmodule.getContextRoot();
- metaData.setContextRoot(contextRoot);
- }
+ String path = unit.getRelativePath();
+ ModuleMetaData webModule = earMetaData.getModule(path);
+ if (webModule != null)
+ {
+ // Check for a context-root setting
+ String contextRoot = metaData.getContextRoot();
+ if (contextRoot == null)
+ {
+ WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue();
+ contextRoot = wmodule.getContextRoot();
+ metaData.setContextRoot(contextRoot);
+ }
- // Add any alt-dd setting
- metaData.setAlternativeDD(webModule.getAlternativeDD());
+ // Add any alt-dd setting
+ metaData.setAlternativeDD(webModule.getAlternativeDD());
+ }
+
+ // Merge security domain/roles
+ if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null)
+ metaData.setSecurityDomain(earMetaData.getSecurityDomain());
+ // TODO
+ metaData.mergeSecurityRoles(earMetaData.getSecurityRoles());
}
- // Merge security domain/roles
- if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null)
- metaData.setSecurityDomain(earMetaData.getSecurityDomain());
- // TODO
- metaData.mergeSecurityRoles(earMetaData.getSecurityRoles());
- }
-
- try
- {
- /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since
- * the vfs deals with the distinction between a true directory, the only way we can tell from
- * this level of the api is to look for a url that ends in '/'. Here we assume that the name is
- * the root url.
- */
- String warName = unit.getName();
-
- /**
- * Ignore the jacc policy service bean
- */
- if (warName.startsWith("jboss:") && warName.contains("id="))
- return;
-
- if (unit instanceof VFSDeploymentUnit)
+ try
{
- VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
- VirtualFile vfsRoot = vfsUnit.getRoot();
+ /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since
+ * the vfs deals with the distinction between a true directory, the only way we can tell from
+ * this level of the api is to look for a url that ends in '/'. Here we assume that the name is
+ * the root url.
+ */
+ String warName = unit.getName();
- URL expWarUrl = vfsRoot.toURL();
+ /**
+ * Ignore the jacc policy service bean
+ */
+ if (warName.startsWith("jboss:") && warName.contains("id="))
+ return;
- // Hack for jar urls being exposed
- if (warName.endsWith("/") == false || warName.endsWith("!/") == true)
- {
- 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);
+ 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);
- 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 = vfsRoot;
- 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
- String warPathName = vfsRoot.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);
- }
+ // 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);
}
- unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath);
- }
- // 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())
+ // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file
+ String altDDPath = metaData.getAlternativeDD();
+ if (altDDPath != null)
{
- // 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());
+ // 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();
- if (classLoading == null)
- classLoading = new ClassLoadingMetaData();
-
- // Pass in the java2ClassLoadingCompliance if it was not set at the war level
- if (classLoading.wasJava2ClassLoadingComplianceSet() == false)
- classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
-
- metaData.setClassLoading(classLoading);
+ ClassLoadingMetaData classLoading = metaData.getClassLoading();
+ if (classLoading == null)
+ classLoading = new ClassLoadingMetaData();
+ // pass in the java2ClassLoadingCompliance if it was not set at the war level
+ if (classLoading.wasJava2ClassLoadingComplianceSet() == false)
+ classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
+ metaData.setClassLoading(classLoading);
- // Build the context root if its not been set or is specified at the ear
- String webContext = metaData.getContextRoot();
- webContext = buildWebContext(unit, webContext, warName, metaData);
- metaData.setContextRoot(webContext);
+ // Build the context root if its not been set or is specified at the ear
+ String webContext = metaData.getContextRoot();
+ webContext = buildWebContext(webContext, warName, metaData, unit);
+ metaData.setContextRoot(webContext);
- AbstractWarDeployment deployment = getDeployment(unit, metaData);
- deployment.setMainDeployer(mainDeployer);
-
- // TODO: until deployment is a MC bean
- deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver);
- deployWebModule(unit, metaData, deployment);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Failed to create web module", e);
- }
- }
+ AbstractWarDeployment deployment = getDeployment(unit, metaData);
+ deployment.setMainDeployer(mainDeployer);
+ // TODO: until deployment is a MC bean
+ deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver);
+ deployWebModule(unit, metaData, deployment);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Failed to create web module", e);
+ }
+ }
- /**
- * Cleanup war deployer specifics.
- */
- @Override
- public void undeploy(DeploymentUnit unit, JBossWebMetaData metaData)
- {
- try
- {
- // Delete any expanded war
- URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
- if (warURL != null)
+ /**
+ * Cleanup war deployer specifics.
+ */
+ @Override
+ public void undeploy(DeploymentUnit unit, JBossWebMetaData metaData)
+ {
+ try
{
- File war = new File(warURL.toURI());
- Files.delete(war);
+ // Delete any expanded war
+ URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
+ if (warURL != null)
+ {
+ File war = new File(warURL.toURI());
+ Files.delete(war);
+ }
}
- }
- catch (Exception e)
- {
- log.debug("Failed to remove expanded war", e);
- }
- }
+ catch (Exception e)
+ {
+ log.debug("Failed to remove expanded war", e);
+ }
+ /* Clear class loader refs
+ metaData.setContextLoader(null);
+ metaData.setResourceClassLoader(null);
+ metaData.setENCLoader(null);
+ */
+ }
- public void addDeployedApp(String warURL, WebApplication webApp)
- {
- deploymentMap.put(warURL, webApp);
- }
+ public void addDeployedApp(String warURL, WebApplication webApp)
+ {
+ deploymentMap.put(warURL, webApp);
+ }
- /** Get the WebApplication object for a deployed war.
- @param warUrl the war url string as originally passed to deploy().
- @return The WebApplication created during the deploy step if the
- warUrl is valid, null if no such deployment exists.
- */
- public WebApplication getDeployedApp(String warUrl)
- {
- WebApplication appInfo = (WebApplication)deploymentMap.get(warUrl);
- return appInfo;
- }
+ /** Get the WebApplication object for a deployed war.
+ @param warUrl the war url string as originally passed to deploy().
+ @return The WebApplication created during the deploy step if the
+ warUrl is valid, null if no such deployment exists.
+ */
+ public WebApplication getDeployedApp(String warUrl)
+ {
+ WebApplication appInfo = (WebApplication)deploymentMap.get(warUrl);
+ return appInfo;
+ }
- public WebApplication removeDeployedApp(String warURL)
- {
- WebApplication appInfo = (WebApplication)deploymentMap.remove(warURL);
- return appInfo;
- }
+ public WebApplication removeDeployedApp(String warURL)
+ {
+ WebApplication appInfo = (WebApplication)deploymentMap.remove(warURL);
+ return appInfo;
+ }
- /** Returns the applications deployed by the web container subclasses.
- @jmx:managed-attribute
- @return An Iterator of WebApplication objects for the deployed wars.
- */
- public Iterator getDeployedApplications()
- {
- return deploymentMap.values().iterator();
- }
+ /** Returns the applications deployed by the web container subclasses.
+ @jmx:managed-attribute
+ @return An Iterator of WebApplication objects for the deployed wars.
+ */
+ public Iterator getDeployedApplications()
+ {
+ return deploymentMap.values().iterator();
+ }
- /** A utility method that uses reflection to access a URL[] getURLs method
- * so that non-URLClassLoader class loaders that support this method can
- * provide info.
- */
- public static URL[] getClassLoaderURLs(ClassLoader cl)
- {
- URL[] urls = {};
- try
- {
- Class returnType = urls.getClass();
- Class[] parameterTypes = {};
- Method getURLs = cl.getClass().getMethod("getURLs", parameterTypes);
- if (returnType.isAssignableFrom(getURLs.getReturnType()))
+ /** A utility method that uses reflection to access a URL[] getURLs method
+ * so that non-URLClassLoader class loaders that support this method can
+ * provide info.
+ */
+ public static URL[] getClassLoaderURLs(ClassLoader cl)
+ {
+ URL[] urls = {};
+ try
{
- Object[] args = {};
- urls = (URL[])getURLs.invoke(cl, args);
+ Class returnType = urls.getClass();
+ Class[] parameterTypes = {};
+ Method getURLs = cl.getClass().getMethod("getURLs", parameterTypes);
+ if (returnType.isAssignableFrom(getURLs.getReturnType()))
+ {
+ Object[] args = {};
+ urls = (URL[])getURLs.invoke(cl, args);
+ }
+ if (urls == null || urls.length == 0)
+ {
+ getURLs = cl.getClass().getMethod("getAllURLs", parameterTypes);
+ if (returnType.isAssignableFrom(getURLs.getReturnType()))
+ {
+ Object[] args = {};
+ urls = (URL[])getURLs.invoke(cl, args);
+ }
+ }
}
- if (urls == null || urls.length == 0)
+ catch (Exception ignore)
{
- getURLs = cl.getClass().getMethod("getAllURLs", parameterTypes);
- if (returnType.isAssignableFrom(getURLs.getReturnType()))
- {
- Object[] args = {};
- urls = (URL[])getURLs.invoke(cl, args);
- }
}
- }
- catch (Exception ignore)
- {
- }
- return urls;
- }
+ return urls;
+ }
- /** This method creates a context-root string from either the
- WEB-INF/jboss-web.xml context-root element is one exists, or the
- filename portion of the warURL. It is called if the deployment
- webContext value is null which indicates a standalone war deployment.
- A war name of ROOT.war is handled as a special case of a war that
- should be installed as the default web context.
- * @param ctxPath - war level context-root
- * @param warName -
- */
- protected String buildWebContext(DeploymentUnit unit, String ctxPath, String warName, JBossWebMetaData metaData)
- {
- // Build a war root context from the war name if one was not specified
- String webContext = ctxPath;
+ /** This method creates a context-root string from either the
+ WEB-INF/jboss-web.xml context-root element is one exists, or the
+ filename portion of the warURL. It is called if the deployment
+ webContext value is null which indicates a standalone war deployment.
+ A war name of ROOT.war is handled as a special case of a war that
+ should be installed as the default web context.
+ @param ctxPath - war level context-root
+ @param warName -
+ */
+ protected String buildWebContext(String ctxPath, String warName, JBossWebMetaData metaData, DeploymentUnit unit)
+ {
+ // Build a war root context from the war name if one was not specified
+ String webContext = ctxPath;
- // Build the context from the deployment name
- if (webContext == null)
- {
- // Build the context from the war name, strip the .war suffix
- webContext = warName;
- webContext = webContext.replace('\\', '/');
- if (webContext.endsWith("/"))
- webContext = webContext.substring(0, webContext.length() - 1);
- int prefix = webContext.lastIndexOf('/');
- if (prefix > 0)
- webContext = webContext.substring(prefix + 1);
- int suffix = webContext.lastIndexOf(".war");
- if (suffix > 0)
- webContext = webContext.substring(0, suffix);
- // Strip any '<int-value>.' prefix
- int index = 0;
- for (; index < webContext.length(); index++)
+ // Build the context from the deployment name
+ if (webContext == null)
{
- char c = webContext.charAt(index);
- if (Character.isDigit(c) == false && c != '.')
- break;
+ // Build the context from the war name, strip the .war suffix
+ webContext = warName;
+ webContext = webContext.replace('\\', '/');
+ if (webContext.endsWith("/"))
+ webContext = webContext.substring(0, webContext.length() - 1);
+ int prefix = webContext.lastIndexOf('/');
+ if (prefix > 0)
+ webContext = webContext.substring(prefix + 1);
+ int suffix = webContext.lastIndexOf(".war");
+ if (suffix > 0)
+ webContext = webContext.substring(0, suffix);
+ // Strip any '<int-value>.' prefix
+ int index = 0;
+ for (; index < webContext.length(); index++)
+ {
+ char c = webContext.charAt(index);
+ if (Character.isDigit(c) == false && c != '.')
+ break;
+ }
+ webContext = webContext.substring(index);
}
- webContext = webContext.substring(index);
- }
- // Servlet containers are anal about the web context starting with '/'
- if (webContext.length() > 0 && webContext.charAt(0) != '/')
- webContext = "/" + webContext;
-
- // And also the default root context must be an empty string, not '/'
- else if (webContext.equals("/"))
- webContext = "";
-
- return webContext;
- }
+ // Servlet containers are anal about the web context starting with '/'
+ if (webContext.length() > 0 && webContext.charAt(0) != '/')
+ webContext = "/" + webContext;
+ // And also the default root context must be an empty string, not '/'
+ else if (webContext.equals("/"))
+ webContext = "";
+ return webContext;
+ }
- /**
- * TODO: The use of an MBeanServer needs to be removed
- * @return
- */
- @Deprecated
- protected MBeanServer getServer()
- {
- return server;
- }
+ /**
+ * TODO: The use of an MBeanServer needs to be removed
+ * @return
+ */
+ @Deprecated
+ protected MBeanServer getServer()
+ {
+ return server;
+ }
- public MainDeployerStructure getMainDeployer()
- {
- return mainDeployer;
- }
+ public MainDeployerStructure getMainDeployer()
+ {
+ return mainDeployer;
+ }
- public void setMainDeployer(MainDeployerStructure mainDeployer)
- {
- this.mainDeployer = mainDeployer;
- }
+ public void setMainDeployer(MainDeployerStructure mainDeployer)
+ {
+ this.mainDeployer = mainDeployer;
+ }
- /**
- * Get the object name of the ServiceMetaData instance associated with
- * the WebMetaData. This uses the pattern:
- * "jboss.web.deployment:war="+metaData.getContextRoot()
- * if there are no virtual hosts, otherwise
- * "jboss.web.deployment:war="+metaData.getVirtualHosts()[0]+metaData.getContextRoot()
- * @param metaData - the web app metaData
- * @return the war object name
- */
- protected String getObjectName(JBossWebMetaData metaData)
- {
- // 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)
- {
- virtualHost = hosts.get(0);
- }
- String ctxPath = metaData.getContextRoot();
-
- // The ctx path value cannot be empty in the object name
- if (ctxPath == null || ctxPath.length() == 0)
- ctxPath = "/";
-
- String objectName = "jboss.web.deployment:war=" + virtualHost + ctxPath;
- return objectName;
- }
+ /**
+ * Get the object name of the ServiceMetaData instance associated with
+ * the WebMetaData. This uses the pattern:
+ * "jboss.web.deployment:war="+metaData.getContextRoot()
+ * if there are no virtual hosts, otherwise
+ * "jboss.web.deployment:war="+metaData.getVirtualHosts()[0]+metaData.getContextRoot()
+ * @param metaData - the web app metaData
+ * @return the war object name
+ */
+ protected String getObjectName(JBossWebMetaData metaData)
+ {
+ // 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)
+ {
+ virtualHost = hosts.get(0);
+ }
+ String ctxPath = metaData.getContextRoot();
+ // The ctx path value cannot be empty in the object name
+ if (ctxPath == null || ctxPath.length() == 0)
+ ctxPath = "/";
+ String objectName = "jboss.web.deployment:war=" + virtualHost + ctxPath;
+ return objectName;
+ }
- /**
- * Called by deploy first to create a ServiceMetaData instance that wraps the
- * AbstractWarDeployment bean and then attach it to the deployment unit. The
- * presence of the ServiceMetaData attachment makes the deployment unit
- * "relevant" to the deployers that handle mbean services.
- *
- * @param unit - the deployment unit
- * @param metaData - the web app metadata passed to deploy
- * @param deployment - the web app deployment bean created by getDeployment
- * @throws Exception
- */
- protected void deployWebModule(DeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception
- {
- log.debug("deployWebModule: " + unit.getName());
- try
- {
- ServiceMetaData webModule = new ServiceMetaData();
- String name = getObjectName(metaData);
- ObjectName objectName = new ObjectName(name);
- webModule.setObjectName(objectName);
- webModule.setCode(WebModule.class.getName());
-
- // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
- ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
- constructor.setSignature(new String[] { DeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
- constructor.setParameters(new Object[] { unit, this, deployment });
- webModule.setConstructor(constructor);
+ /**
+ * Called by deploy first to create a ServiceMetaData instance that wraps the
+ * AbstractWarDeployment bean and then attach it to the deployment unit. The
+ * presence of the ServiceMetaData attachment makes the deployment unit
+ * "relevant" to the deployers that handle mbean services.
+ *
+ * @param unit - the deployment unit
+ * @param metaData - the web app metadata passed to deploy
+ * @param deployment - the web app deployment bean created by getDeployment
+ * @throws Exception
+ */
+ protected void deployWebModule(DeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception
+ {
+ log.debug("deployWebModule: " + unit.getName());
+ try
+ {
+ ServiceMetaData webModule = new ServiceMetaData();
+ String name = getObjectName(metaData);
+ ObjectName objectName = new ObjectName(name);
+ webModule.setObjectName(objectName);
+ webModule.setCode(WebModule.class.getName());
+ // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
+ ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
+ constructor.setSignature(new String[] { DeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
+ constructor.setParameters(new Object[] { unit, this, deployment });
+ webModule.setConstructor(constructor);
- List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
+ List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
- ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
- attr.setName("SecurityManagement");
- ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName());
- attr.setValue(injectionValue);
- attrs.add(attr);
+ ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
+ attr.setName("SecurityManagement");
+ 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 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);
- attrKernel.setValue(injectionValueKernel);
- attrs.add(attrKernel);
+ ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData();
+ attrKernel.setName("Kernel");
+ ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME);
+ attrKernel.setValue(injectionValueKernel);
+ attrs.add(attrKernel);
- webModule.setAttributes(attrs);
+ webModule.setAttributes(attrs);
- // Dependencies...Still have old jmx names here
- Collection<String> depends = metaData.getDepends();
- List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
- if (depends != null && depends.isEmpty() == false)
- {
- if (log.isTraceEnabled())
- log.trace(name + " has dependencies: " + depends);
+ // Dependencies...Still have old jmx names here
+ Collection<String> depends = metaData.getDepends();
+ List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
+ if (depends != null && depends.isEmpty() == false)
+ {
+ if (log.isTraceEnabled())
+ log.trace(name + " has dependencies: " + depends);
- for (String iDependOn : depends)
- {
- ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
- sdmd.setIDependOn(iDependOn);
- dependencies.add(sdmd);
- }
- }
- webModule.setDependencies(dependencies);
+ for (String iDependOn : depends)
+ {
+ ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
+ sdmd.setIDependOn(iDependOn);
+ dependencies.add(sdmd);
+ }
+ }
+ webModule.setDependencies(dependencies);
- // 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
- // can now take over deploying the web module.
+ // 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
+ // can now take over deploying the web module.
- unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class);
- }
- catch (Exception e)
- {
- throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
- }
- }
+ unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class);
+ }
+ catch (Exception e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
+ }
+ }
}
Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java 2009-02-02 12:18:19 UTC (rev 83775)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java 2009-02-02 12:36:14 UTC (rev 83776)
@@ -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;
@@ -36,7 +37,6 @@
import javax.naming.NamingException;
import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.bootstrap.spi.ServerConfig;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
@@ -167,7 +167,7 @@
*/
public static String shortWarUrlFromServerHome(String warUrl)
{
- String serverHomeUrl = System.getProperty(ServerConfig.SERVER_HOME_URL);
+ String serverHomeUrl = System.getProperty(org.jboss.bootstrap.spi.ServerConfig.SERVER_HOME_URL);
if (warUrl == null || serverHomeUrl == null)
return warUrl;
@@ -424,40 +424,37 @@
try
{
// Create a classloader for the war to ensure a unique ENC
- // TODO: this should be handled by the WarClassLoaderDeployer
ClassLoader warLoader = unit.getClassLoader();
thread.setContextClassLoader(warLoader);
String webContext = metaData.getContextRoot();
// Get the war URL
- URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
- if (warURL == null && unit instanceof VFSDeploymentUnit)
- warURL = ((VFSDeploymentUnit)unit).getRoot().toURL();
+ URL warUrl = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
+ if (warUrl == null && unit instanceof VFSDeploymentUnit)
+ warUrl = ((VFSDeploymentUnit)unit).getRoot().toURL();
- // For in-memory WebMetaData deployments we use the deployment name as the warURL
- // The WS Endpoint API uses this approach
- if (warURL == null)
- warURL = new URL(unit.getName());
-
+ // 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
- String warURLStr = warURL.toString();
- if (warURLStr.startsWith("jar:"))
- warURLStr = warURLStr.substring(4, warURLStr.length() - 2);
+ if (warURLString.startsWith("jar:"))
+ warURLString = warURLString.substring(4, warURLString.length() - 2);
log.debug("webContext: " + webContext);
- log.debug("warURL: " + warURLStr);
+ log.debug("warURL: " + warURLString);
// Register the permissions with the JACC layer
String contextID = metaData.getJaccContextID();
if (contextID == null)
contextID = unit.getSimpleName();
-
metaData.setJaccContextID(contextID);
webApp = new WebApplication(metaData);
webApp.setClassLoader(warLoader);
webApp.setDeploymentUnit(unit);
- performDeploy(webApp, warURLStr);
+ performDeploy(webApp, warURLString);
}
finally
{
@@ -486,9 +483,9 @@
* @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
@@ -496,9 +493,9 @@
* @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
@@ -596,10 +593,10 @@
private void linkServiceRefs(DeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException
{
- ClassLoader loader = unit.getClassLoader();
if (unit instanceof VFSDeploymentUnit)
{
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
+ ClassLoader loader = unit.getClassLoader();
UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(vfsUnit.getRoot());
for (ServiceReferenceMetaData sref : serviceRefs)
{
Modified: trunk/server/src/main/org/jboss/web/deployers/WebModule.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/WebModule.java 2009-02-02 12:18:19 UTC (rev 83775)
+++ trunk/server/src/main/org/jboss/web/deployers/WebModule.java 2009-02-02 12:36:14 UTC (rev 83776)
@@ -22,7 +22,6 @@
package org.jboss.web.deployers;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.deployment.DeploymentException;
import org.jboss.kernel.Kernel;
import org.jboss.logging.Logger;
@@ -52,10 +51,10 @@
private DeploymentUnit unit;
private AbstractWarDeployer container;
- private AbstractWarDeployment deployment;
+ private AbstractWarDeployment deployment;
private ISecurityManagement securityManagement;
-
+
public WebModule(DeploymentUnit unit, AbstractWarDeployer container, AbstractWarDeployment deployment)
{
this.unit = unit;
@@ -75,9 +74,9 @@
*/
public void setPolicyRegistration(PolicyRegistration policyRegistration)
{
- deployment.setPolicyRegistration(policyRegistration);
+ deployment.setPolicyRegistration(policyRegistration);
}
-
+
/**
* Set the securityManagement.
*
@@ -90,8 +89,9 @@
public void create()
{
-
+
}
+
public void start() throws Exception
{
startModule();
@@ -106,37 +106,35 @@
{
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 = unit.getAttachment(JBossWebMetaData.class);
+ JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
WebApplication webApp = deployment.start(unit, metaData);
- String depName = unit.getName();
- container.addDeployedApp(depName, webApp);
+ 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 depName = unit.getName();
+ String warURL = unit.getName();
try
{
- WebApplication webApp = container.removeDeployedApp(depName);
- if( deployment != null && webApp != null )
+ WebApplication webApp = container.removeDeployedApp(warURL);
+ if (deployment != null && webApp != null)
{
deployment.stop(unit, webApp);
}
else
{
- log.debug("Failed to find deployer/deployment for war: "+depName);
+ log.debug("Failed to find deployer/deployment for war: " + warURL);
}
}
catch (Exception e)
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java 2009-02-02 12:18:19 UTC (rev 83775)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java 2009-02-02 12:36:14 UTC (rev 83776)
@@ -141,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, DeploymentUnit 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())))
@@ -233,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);
+ }
}
/**
@@ -290,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
@@ -318,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
@@ -361,7 +380,7 @@
injector.inject(object);
}
}
-
+
/**
* Process annotations for dynamic beans only.
*
@@ -370,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.
@@ -387,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)
{
@@ -399,7 +416,7 @@
log.trace("**************** Processing annotations for: " + object.getClass().getName());
encInjectors.recordAdded();
-
+
// Populate the encInjections
TomcatInjectionUtils.processDynamicBeanAnnotations(this, handlers, object.getClass());
@@ -412,12 +429,12 @@
}
encInjectors.clearAdded();
}
-
+
// Process the injectors
processInjectors(object);
}
}
-
+
/**
* Get the the Injectors for a object and it's superclass.
*
@@ -426,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.
*
@@ -457,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;
}
@@ -478,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
{
@@ -513,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.
@@ -526,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);
@@ -549,7 +568,7 @@
Thread.currentThread().setContextClassLoader(old);
}
}
-
+
public Map<String, EncInjector> getEncInjectors()
{
return encInjectors;
@@ -619,7 +638,7 @@
{
return false;
}
-
+
public Container resolveEjbContainer(String link, Class<?> businessIntf)
{
return null;
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-02-02 12:18:19 UTC (rev 83775)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java 2009-02-02 12:36:14 UTC (rev 83776)
@@ -21,6 +21,8 @@
*/
package org.jboss.web.tomcat.service.deployers;
+// $Id$
+
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -548,24 +550,27 @@
u.setSchemaValidation(false);
u.setValidation(false);
u.setEntityResolver(new JBossEntityResolver());
+
InputStream is = null;
try
{
- if (local && deploymentUnitLocal instanceof VFSDeploymentUnit)
+ 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)
- {
- return;
- }
- contextMetaData = ContextMetaData.class.cast(u.unmarshal(is, schema));
+
+ if (is != null)
+ contextMetaData = ContextMetaData.class.cast(u.unmarshal(is, schema));
}
finally
{
@@ -589,11 +594,10 @@
return;
}
- try
+ if (contextMetaData != null)
{
- if (contextMetaData != null)
+ try
{
-
if (contextMetaData.getAttributes() != null)
{
Iterator<QName> names = contextMetaData.getAttributes().keySet().iterator();
@@ -673,13 +677,12 @@
}
}
+ catch (Exception e)
+ {
+ log.error("Error processing: " + resourceName, e);
+ ok = false;
+ }
}
- catch (Exception e)
- {
- log.error("Error processing: " + resourceName, e);
- ok = false;
- }
-
}
protected void destroy()
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2009-02-02 12:18:19 UTC (rev 83775)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2009-02-02 12:36:14 UTC (rev 83776)
@@ -22,7 +22,9 @@
package org.jboss.web.tomcat.service.deployers;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
@@ -38,7 +40,6 @@
import javax.management.Attribute;
import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -120,11 +121,10 @@
}
@Override
- protected void performDeploy(WebApplication webApp, String warUrlStr) throws Exception
+ protected void performDeploy(WebApplication webApp, String warUrl) throws Exception
{
// Decode the URL as tomcat can't deal with paths with escape chars
- warUrlStr = URLDecoder.decode(warUrlStr, "UTF-8");
-
+ warUrl = URLDecoder.decode(warUrl, "UTF-8");
webApp.setDomain(config.getCatalinaDomain());
JBossWebMetaData metaData = webApp.getMetaData();
String hostName = null;
@@ -144,20 +144,17 @@
hostName = hostNames.next().toString();
}
}
-
- performDeployInternal(webApp, hostName, warUrlStr);
+ performDeployInternal(webApp, hostName, warUrl);
while (hostNames.hasNext())
{
String additionalHostName = hostNames.next().toString();
- performDeployInternal(webApp, additionalHostName, warUrlStr);
+ performDeployInternal(webApp, additionalHostName, warUrl);
}
}
protected void performDeployInternal(WebApplication webApp, String hostName, String warUrlStr) throws Exception
{
JBossWebMetaData metaData = webApp.getMetaData();
- DeploymentUnit unit = webApp.getDeploymentUnit();
-
String ctxPath = metaData.getContextRoot();
if (ctxPath.equals("/") || ctxPath.equals("/ROOT") || ctxPath.equals(""))
{
@@ -168,25 +165,31 @@
log.info("deploy, ctxPath=" + ctxPath);
+ URL warUrl = new URL(warUrlStr);
+
ClassLoader loader = Thread.currentThread().getContextClassLoader();
metaData.setContextLoader(loader);
StandardContext context = (StandardContext)Class.forName(config.getContextClassName()).newInstance();
- injectionContainer = new TomcatInjectionContainer(webApp, unit, context, getPersistenceUnitDependencyResolver());
- Loader webLoader = unit.getAttachment(Loader.class);
+ DeploymentUnit depUnit = webApp.getDeploymentUnit();
+ injectionContainer = new TomcatInjectionContainer(webApp, depUnit, context, getPersistenceUnitDependencyResolver());
+
+ Loader webLoader = depUnit.getAttachment(Loader.class);
if (webLoader == null)
- webLoader = getWebLoader(unit, metaData, loader);
+ webLoader = getWebLoader(depUnit, metaData, loader, warUrl);
- URL warUrl = new URL(warUrlStr);
-
- webApp.setName(ctxPath);
+ webApp.setName(warUrl.getPath());
webApp.setClassLoader(loader);
webApp.setURL(warUrl);
- ObjectName objectName = getObjectName(hostName, ctxPath);
+ 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: " + objectName);
+ throw new DeploymentException("Web mapping already exists for deployment URL " + warUrlStr);
Registry.getRegistry(null, null).registerComponent(context, objectName, config.getContextClassName());
@@ -196,19 +199,18 @@
context.setDefaultWebXml("conf/web.xml");
context.setPublicId(metaData.getPublicID());
- String docbase = unit.getAttachment("org.jboss.web.explicitDocBase", String.class);
- if (docbase == null)
- docbase = warUrl.getFile();
-
- context.setDocBase(docbase);
+ 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)
{
log.debug("Setting altDDName to: " + metaData.getAlternativeDD());
context.setAltDDName(metaData.getAlternativeDD());
}
-
context.setJavaVMs(javaVMs);
context.setServer(serverName);
context.setSaveConfig(false);
@@ -497,7 +499,7 @@
}
- public Loader getWebLoader(DeploymentUnit unit, JBossWebMetaData metaData, ClassLoader loader) throws MalformedURLException
+ public Loader getWebLoader(DeploymentUnit unit, JBossWebMetaData metaData, ClassLoader loader, URL rl) throws MalformedURLException
{
Loader webLoader = null;
@@ -509,9 +511,10 @@
ArrayList<URL> classpath = (ArrayList<URL>)unit.getAttachment("org.jboss.web.expandedWarClasspath");
if (classpath == null && unit instanceof VFSDeploymentUnit)
{
+ VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
try
{
- VirtualFile classes = ((VFSDeploymentUnit)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();
@@ -544,17 +547,17 @@
* undeployment steps.
*/
@Override
- protected void performUndeploy(WebApplication webApp, String warUrl) throws Exception
+ protected void performUndeploy(WebApplication warInfo, String warUrl) throws Exception
{
- if (webApp == null)
+ if (warInfo == null)
{
log.debug("performUndeploy, no WebApplication found for URL " + warUrl);
return;
}
- log.info("undeploy, ctxPath=" + webApp.getMetaData().getContextRoot());
+ log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot());
- JBossWebMetaData metaData = webApp.getMetaData();
+ JBossWebMetaData metaData = warInfo.getMetaData();
String hostName = null;
// Get any jboss-web/virtual-hosts
List<String> vhostNames = metaData.getVirtualHosts();
@@ -572,41 +575,36 @@
hostName = hostNames.next().toString();
}
}
- performUndeployInternal(webApp, hostName, warUrl);
+ performUndeployInternal(warInfo, hostName, warUrl);
while (hostNames.hasNext())
{
String additionalHostName = hostNames.next().toString();
- performUndeployInternal(webApp, additionalHostName, warUrl);
+ performUndeployInternal(warInfo, additionalHostName, warUrl);
}
}
- protected void performUndeployInternal(WebApplication webApp, String hostName, String warUrl) throws Exception
+ protected void performUndeployInternal(WebApplication warInfo, String hostName, String warUrlStr) throws Exception
{
- JBossWebMetaData metaData = webApp.getMetaData();
+ JBossWebMetaData metaData = warInfo.getMetaData();
String ctxPath = metaData.getContextRoot();
- ObjectName objectName = getObjectName(hostName, ctxPath);
-
// TODO: Need to remove the dependency on MBeanServer
MBeanServer server = MBeanServerLocator.locateJBoss();
-
// If the server is gone, all apps were stopped already
- if (server != null)
+ if (server == null)
+ return;
+
+ 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
- if (server.isRegistered(objectName))
- server.invoke(objectName, "destroy", new Object[] {}, new String[] {});
+ server.invoke(objectName, "destroy", new Object[] {}, new String[] {});
}
}
- private ObjectName getObjectName(String hostName, String ctxPath) throws MalformedObjectNameException
- {
- hostName = (hostName == null ? "localhost" : hostName);
- String onamestr = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + hostName + ctxPath + ",J2EEApplication=none,J2EEServer=none";
- return new ObjectName(onamestr);
- }
-
/**
* Resolve the input virtual host names to the names of the configured Hosts
*
More information about the jboss-cvs-commits
mailing list