[jboss-cvs] JBossAS SVN: r58263 - trunk/server/src/main/org/jboss/web/deployers
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Nov 11 12:06:14 EST 2006
Author: scott.stark at jboss.org
Date: 2006-11-11 12:06:12 -0500 (Sat, 11 Nov 2006)
New Revision: 58263
Modified:
trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
Log:
Add the unpacking of wars into the server tmp deploy directory back
Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java 2006-11-11 16:08:42 UTC (rev 58262)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java 2006-11-11 17:06:12 UTC (rev 58263)
@@ -21,6 +21,8 @@
*/
package org.jboss.web.deployers;
+import java.io.File;
+import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
@@ -40,6 +42,10 @@
import org.jboss.system.metadata.ServiceConstructorMetaData;
import org.jboss.system.metadata.ServiceDependencyMetaData;
import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.server.ServerConfig;
+import org.jboss.system.server.ServerConfigLocator;
+import org.jboss.util.file.JarUtils;
+import org.jboss.virtual.VirtualFile;
import org.jboss.web.WebApplication;
/** A template pattern class for web container integration into JBoss. This class
@@ -277,40 +283,40 @@
boolean unpackWebservice = di.localCl.findResource("WEB-INF/webservices.xml") != null;
// With JSR-181 annotated JSE endpoints we need to do it as well even if there is no webservices.xml
// unpackWebservice |= server.isRegistered(ObjectNameFactory.create("jboss.ws:service=ServiceEndpointManager"));
-
- // Make sure the war is unpacked if unpackWars is true
- File warFile = new File(di.localUrl.getFile());
- if (warFile.isDirectory() == false && (unpackWars || unpackWebservice))
+ */
+ /* 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();
+ if( warName.endsWith("/") == false )
{
- // After findResource we cannot rename the WAR anymore, because
- // some systems keep an open reference to the file :(
- String prefix = warFile.getCanonicalPath();
- prefix = prefix.substring(0, prefix.lastIndexOf(".war"));
- File expWarFile = new File(prefix + "-exp.war");
+ 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 = new File(config.getServerTempDeployDir(), prefix + "-exp.war");
if( expWarFile.mkdir() == false )
throw new DeploymentException("Was unable to mkdir: "+expWarFile);
log.debug("Unpacking war to: "+expWarFile);
- FileInputStream fis = new FileInputStream(warFile);
- JarUtils.unjar(fis, expWarFile);
- fis.close();
- log.debug("Replaced war with unpacked contents");
- if (warFile.delete() == false)
- log.debug("Was unable to delete war file");
- else
- log.debug("Deleted war archive");
- // Reset the localUrl to end in a '/'
- di.localUrl = expWarFile.toURL();
- // Reset the localCl to point to the file
- URL[] localCl = new URL[]{di.localUrl};
- di.localCl = new URLClassLoader(localCl);
+ VirtualFile root = unit.getDeploymentContext().getRoot();
+ InputStream is = root.openStream();
+ JarUtils.unjar(is, expWarFile);
+ root.close();
+ // Indicate that an expanded URL exists
+ unit.addAttachment("org.jboss.web.expandedWarURL", expWarFile.toURL(), URL.class);
}
- */
metaData.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
// Build the context root if its not been set
String webContext = metaData.getContextRoot();
- String warName = unit.getName();
webContext = buildWebContext(webContext, warName, metaData);
metaData.setContextRoot(webContext);
Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java 2006-11-11 16:08:42 UTC (rev 58262)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java 2006-11-11 17:06:12 UTC (rev 58263)
@@ -42,6 +42,7 @@
import org.jboss.deployers.spi.deployer.DeploymentUnit;
import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployment.J2eeApplicationMetaData;
import org.jboss.logging.Logger;
import org.jboss.metadata.EjbLocalRefMetaData;
import org.jboss.metadata.EjbRefMetaData;
@@ -312,11 +313,13 @@
// Get the war URL
// FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
- URL warURL = (URL) di.getAttachment("jbossws.expanded.war.url");
+ URL warURL = di.getAttachment("org.jboss.web.expandedWarURL", URL.class);
+ if( warURL == null )
+ warURL = di.getAttachment("jbossws.expanded.war.url", URL.class);
if (warURL == null)
warURL = di.getDeploymentContext().getRoot().toURL();
-
- // Strip any jar: url syntax. This should be be exposed by the vfs
+
+ // Strip any jar: url syntax. This should be be handled by the vfs
String warURLString = warURL.toString();
if( warURLString.startsWith("jar:") )
warURLString = warURLString.substring(4, warURLString.length()-2);
@@ -324,19 +327,15 @@
log.debug("webContext: " + webContext);
log.debug("warURL: " + warURLString);
- /* TODO: this must come from the metadata deployers
- inherit the security setup from jboss-app.xml
- if (di.parent != null && di.parent.metaData instanceof J2eeApplicationMetaData)
+ // Merge any ear security domain info
+ J2eeApplicationMetaData appMetaData = di.getAttachment(J2eeApplicationMetaData.class);
+ if( appMetaData != null )
{
- J2eeApplicationMetaData appMetaData = (J2eeApplicationMetaData) di.parent.metaData;
-
- if (metaData.getSecurityDomain() == null)
+ if( metaData.getSecurityDomain() == null )
metaData.setSecurityDomain(appMetaData.getSecurityDomain());
-
metaData.mergeSecurityRoles(appMetaData.getSecurityRoles());
}
- */
-
+
// Register the permissions with the JACC layer
String contextID = metaData.getJaccContextID();
if( contextID == null )
More information about the jboss-cvs-commits
mailing list