[jboss-cvs] JBossAS SVN: r83864 - branches/Branch_5_0/server/src/main/org/jboss/web/deployers.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 4 14:17:27 EST 2009


Author: alesj
Date: 2009-02-04 14:17:27 -0500 (Wed, 04 Feb 2009)
New Revision: 83864

Modified:
   branches/Branch_5_0/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
   branches/Branch_5_0/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
Log:
Fix copy assumption.

Modified: branches/Branch_5_0/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- branches/Branch_5_0/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2009-02-04 18:31:42 UTC (rev 83863)
+++ branches/Branch_5_0/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2009-02-04 19:17:27 UTC (rev 83864)
@@ -60,11 +60,12 @@
 import org.jboss.util.file.Files;
 import org.jboss.util.file.JarUtils;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFSUtils;
 import org.jboss.web.WebApplication;
 
 /** A template pattern class for web container integration into JBoss. This class
  * should be subclassed by web container providers wishing to integrate their
- * container into a JBoss server. The sole method to implement is: 
+ * container into a JBoss server. The sole method to implement is:
  * {@link #getDeployment(DeploymentUnit, WebMetaData)}. This is called from
  * within {@linkplain #deploy(DeploymentUnit, WebMetaData)} to translate the
  * WebMetaData into a AbstractWarDeployment bean that will be passed to the
@@ -148,7 +149,7 @@
    /** 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
     */
@@ -160,7 +161,7 @@
    /** 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
     */
@@ -194,8 +195,8 @@
    /**
     * 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 
-    *    
+    * @return the LenientEjbLink flag
+    *
     * @jmx:managed-attribute
     */
    public boolean getLenientEjbLink()
@@ -206,7 +207,7 @@
    /**
     * 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)
@@ -275,7 +276,7 @@
     * 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
@@ -288,13 +289,13 @@
     * {@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
     */
@@ -341,7 +342,7 @@
          String warName = unit.getName();
 
          /**
-          * Ignore the jacc policy service bean 
+          * Ignore the jacc policy service bean
           */
          if (warName.startsWith("jboss:") && warName.contains("id="))
             return;
@@ -349,46 +350,17 @@
          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
+            VirtualFile root = vfsUnit.getRoot();
+            URL expWarUrl = VFSUtils.getRealURL(root);
+            VirtualFile exploded = VFSUtils.explode(root);
+            // file was not exploded yet
+            if (root != exploded)
             {
-               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);
+               // get the real exploded url
+               expWarUrl = VFSUtils.getRealURL(exploded);
 
-               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
-               VirtualFile warVF = vfsUnit.getRoot();
-               String warPathName = warVF.getPathName();
+               String warPathName = root.getPathName();
                if (warPathName.endsWith("/") == false)
                   warPathName += "/";
                List<VirtualFile> classpathVFs = vfsUnit.getClassPath();
@@ -575,7 +547,7 @@
     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 - 
+    @param warName -
     */
    protected String buildWebContext(String ctxPath, String warName, JBossWebMetaData metaData, DeploymentUnit unit)
    {
@@ -667,7 +639,7 @@
     * 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

Modified: branches/Branch_5_0/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- branches/Branch_5_0/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2009-02-04 18:31:42 UTC (rev 83863)
+++ branches/Branch_5_0/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2009-02-04 19:17:27 UTC (rev 83864)
@@ -70,6 +70,7 @@
 import org.jboss.security.authorization.PolicyRegistration;
 import org.jboss.web.WebApplication;
 import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.virtual.VFSUtils;
 import org.omg.CORBA.ORB;
 
 /**
@@ -83,7 +84,7 @@
 - performUndeploy(WebApplication webApp, String warUrl) to remove the application
 corresponding to the WebApplication data. This is called when the
 AbstractWarDeployment is stopped.
- 
+
 The one thing to be aware of is the relationship between the thread context
 class loader and the JNDI ENC context. Any method that attempts to access
 the JNDI ENC context must have the ClassLoader in the WebApplication returned
@@ -346,7 +347,7 @@
 
    /**
     * Get the securityManagement.
-    * 
+    *
     * @return the securityManagement.
     */
    public String getSecurityManagementName()
@@ -356,7 +357,7 @@
 
    /**
     * Set the securityManagement.
-    * 
+    *
     * @param securityManagement the securityManagement.
     */
    public void setSecurityManagementName(String securityManagement)
@@ -366,7 +367,7 @@
 
    /**
     * Get the securityManagement.
-    * 
+    *
     * @return the securityManagement.
     */
    public ISecurityManagement getSecurityManagement()
@@ -376,7 +377,7 @@
 
    /**
     * Set the securityManagement.
-    * 
+    *
     * @param securityManagement the securityManagement.
     */
    public void setSecurityManagement(ISecurityManagement securityManagement)
@@ -431,13 +432,16 @@
          // 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();
+         {
+            VFSDeploymentUnit vdu = VFSDeploymentUnit.class.cast(unit);
+            warUrl = VFSUtils.getRealURL(vdu.getRoot());
+         }
 
          // Dynamic WebMetaData deployments might not provide an URL
          // We use the DEploymentUnit name as identifier instead.
-         // The JAXWS Endpoint API for example does this.  
+         // 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
          if (warURLString.startsWith("jar:"))
             warURLString = warURLString.substring(4, warURLString.length() - 2);




More information about the jboss-cvs-commits mailing list