[jboss-cvs] JBossAS SVN: r58280 - trunk/server/src/main/org/jboss/web/deployers

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Nov 12 12:07:37 EST 2006


Author: darran.lofthouse at jboss.com
Date: 2006-11-12 12:07:36 -0500 (Sun, 12 Nov 2006)
New Revision: 58280

Modified:
   trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
Log:
Use expanded war created by JBossWS if available

Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2006-11-12 03:47:28 UTC (rev 58279)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2006-11-12 17:07:36 UTC (rev 58280)
@@ -272,33 +272,33 @@
     * @param metaData - the metadata for the deployment
     */
    @Override
-   public void deploy(DeploymentUnit unit, WebMetaData metaData)
-      throws DeploymentException
+   public void deploy(DeploymentUnit unit, WebMetaData metaData) throws DeploymentException
    {
-      log.debug("Begin deploy, "+metaData);
+      log.debug("Begin deploy, " + metaData);
+
       try
       {
          /* TODO: This needs to be moved to a webservice deployer which updates the WebMetaData
-         // We need to unpack the WAR if it has webservices.xml, because we need
-         // to manipulate th web.xml before deploying to the web container 
-         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"));
-         */
+          // We need to unpack the WAR if it has webservices.xml, because we need
+          // to manipulate th web.xml before deploying to the web container 
+          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"));
+          */
          /* 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
-               // Hack for jar urls being exposed
-               || warName.endsWith("!/") == true )
+         if (warName.endsWith("/") == false
+         // Hack for jar urls being exposed
+               || warName.endsWith("!/") == true)
          {
-            if( warName.startsWith("jar:") )
+            if (warName.startsWith("jar:"))
             {
-               if( warName.endsWith("!/") )
-                  warName = warName.substring(4, warName.length()-2);
+               if (warName.endsWith("!/"))
+                  warName = warName.substring(4, warName.length() - 2);
                else
                   warName = warName.substring(4, warName.length());
             }
@@ -306,22 +306,30 @@
             ServerConfig config = ServerConfigLocator.locate();
             String prefix = warURL.getFile();
             int lastSlash = prefix.lastIndexOf('/');
-            if( lastSlash > 0 )
-               prefix = prefix.substring(lastSlash+1);
+            if (lastSlash > 0)
+               prefix = prefix.substring(lastSlash + 1);
             int dotWar = prefix.lastIndexOf(".war");
-            if( dotWar > 0 )
+            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 = unit.getDeploymentContext().getRoot();
-            InputStream is = root.openStream();
-            JarUtils.unjar(is, expWarFile);
-            is.close();
+
+            // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
+            URL expWarUrl = unit.getAttachment("jbossws.expanded.war.url", URL.class);
+            if (expWarUrl == null)
+            {
+               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 = unit.getDeploymentContext().getRoot();
+               InputStream is = root.openStream();
+               JarUtils.unjar(is, expWarFile);
+               is.close();
+               expWarUrl = expWarFile.toURL();
+            }
+            
             // Indicate that an expanded URL exists
-            unit.addAttachment("org.jboss.web.expandedWarURL", expWarFile.toURL(), URL.class);
+            unit.addAttachment("org.jboss.web.expandedWarURL", expWarUrl, URL.class);
          }
 
          metaData.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
@@ -330,11 +338,11 @@
          String webContext = metaData.getContextRoot();
          webContext = buildWebContext(webContext, warName, metaData);
          metaData.setContextRoot(webContext);
-         
+
          AbstractWarDeployment deployment = getDeployment(unit, metaData);
          deployWebModule(unit, metaData, deployment);
       }
-      catch(Exception e)
+      catch (Exception e)
       {
          throw new DeploymentException("Failed to create web module", e);
       }




More information about the jboss-cvs-commits mailing list