[jboss-cvs] JBossAS SVN: r95153 - projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 19 21:16:45 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-10-19 21:16:44 -0400 (Mon, 19 Oct 2009)
New Revision: 95153

Removed:
   projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
Log:
This is being moved to AS server module

Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java	2009-10-19 23:31:57 UTC (rev 95152)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java	2009-10-20 01:16:44 UTC (rev 95153)
@@ -1,262 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.vfs.plugins.structure.war;
-
-import java.io.IOException;
-import java.io.Closeable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
-import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.VirtualFileFilter;
-import org.jboss.vfs.VisitorAttributes;
-import org.jboss.vfs.VFS;
-import org.jboss.vfs.TempFileProvider;
-import org.jboss.vfs.VFSUtils;
-import org.jboss.vfs.util.SuffixMatchFilter;
-import org.jboss.logging.Logger;
-
-/**
- * WARStructure.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- * @version $Revision: 83811 $
- */
-public class WARStructure extends AbstractVFSStructureDeployer
-{
-   /** The default filter which allows jars/jar directories */
-   public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER = new SuffixMatchFilter(".jar", VisitorAttributes.DEFAULT);
-
-   /** The web-inf/lib filter */
-   private VirtualFileFilter webInfLibFilter = DEFAULT_WEB_INF_LIB_FILTER;
-
-   /** The web-inf/lib/[some-archive]/META-INF filter */
-   private VirtualFileFilter webInfLibMetaDataFilter;
-
-   /** Whether to include web-inf in the classpath */
-   private boolean includeWebInfInClasspath;
-   private ScheduledExecutorService scheduledExecutorService;
-
-   /**
-    * Sets the default relative order 1000.
-    *
-    */
-   public WARStructure()
-   {
-      setRelativeOrder(1000);
-   }
-
-   /**
-    * Get the scheduled executor service.
-    *
-    * @return the scheduled executor service
-    */
-   public ScheduledExecutorService getScheduledExecutorService()
-   {
-      return scheduledExecutorService;
-   }
-
-   /**
-    * Set the scheduled executor service.
-    *
-    * @param scheduledExecutorService the scheduled executor service
-    */
-   public void setScheduledExecutorService(final ScheduledExecutorService scheduledExecutorService)
-   {
-      this.scheduledExecutorService = scheduledExecutorService;
-   }
-
-   /**
-    * Get the webInfLibFilter.
-    *
-    * @return the webInfLibFilter.
-    */
-   public VirtualFileFilter getWebInfLibFilter()
-   {
-      return webInfLibFilter;
-   }
-
-   /**
-    * Set the webInfLibFilter.
-    *
-    * @param webInfLibFilter the webInfLibFilter.
-    * @throws IllegalArgumentException for a null filter
-    */
-   public void setWebInfLibFilter(VirtualFileFilter webInfLibFilter)
-   {
-      if (webInfLibFilter == null)
-         throw new IllegalArgumentException("Null filter");
-      this.webInfLibFilter = webInfLibFilter;
-   }
-
-   /**
-    * Get webInfLibMetaDataFilter
-    *
-    * @return the webInfLibMetaDataFilter
-    */
-   public VirtualFileFilter getWebInfLibMetaDataFilter()
-   {
-      return webInfLibMetaDataFilter;
-   }
-
-   /**
-    * Set the webInfLibMetaDataFilter.
-    *
-    * @param webInfLibMetaDataFilter the webInfLibFilter.
-    */
-   public void setWebInfLibMetaDataFilter(VirtualFileFilter webInfLibMetaDataFilter)
-   {
-      this.webInfLibMetaDataFilter = webInfLibMetaDataFilter;
-   }
-
-   /**
-    * Should we include web-inf in classpath.
-    *
-    * @param includeWebInfInClasspath the include web-inf flag
-    */
-   public void setIncludeWebInfInClasspath(boolean includeWebInfInClasspath)
-   {
-      this.includeWebInfInClasspath = includeWebInfInClasspath;
-   }
-
-   public boolean determineStructure(StructureContext structureContext) throws DeploymentException
-   {
-      boolean ok = false;
-      VirtualFile file = structureContext.getFile();
-      final Logger log = WARStructure.log;
-      boolean trace = log.isTraceEnabled();
-
-      // the WEB-INF
-      final List<Closeable> handles = new ArrayList<Closeable>();
-      if (! file.isDirectory()) try {
-         handles.add(VFS.mountZipExpanded(file, file, TempFileProvider.create(file.getName(), scheduledExecutorService)));
-      } catch (IOException e) {
-         DeploymentException.rethrowAsDeploymentException("Failed to mount WAR archive", e);
-      }
-      try {
-         final VirtualFile webinf = file.getChild("WEB-INF");
-         if (file.getName().endsWith(".war") == false)
-         {
-            if (webinf.exists())
-            {
-               if (trace)
-                  log.trace("... ok - directory has a WEB-INF subdirectory");
-            }
-            else
-            {
-               if (trace)
-                  log.trace("... no - doesn't look like a war and no WEB-INF subdirectory.");
-               return false;
-            }
-         }
-         else if (trace)
-         {
-            log.trace("... ok - name ends in .war.");
-         }
-         List<String> metaDataLocations = new ArrayList<String>();
-         metaDataLocations.add("WEB-INF");
-         // Check for WEB-INF/classes
-         final VirtualFile classes = file.getChild("WEB-INF/classes");
-         // Check for a META-INF for metadata
-         if (classes.isDirectory())
-         {
-            metaDataLocations.add("WEB-INF/classes/META-INF");
-         }
-         // Check for jars in WEB-INF/lib
-         List<VirtualFile> archives = null;
-         final VirtualFile webinfLib = file.getChild("WEB-INF/lib");
-         if (webinfLib.isDirectory())
-         {
-            try
-            {
-               archives = webinfLib.getChildren(webInfLibFilter);
-               // Add the jars' META-INF for metadata
-               for (VirtualFile jar : archives)
-               {
-                  // mount up the JAR if it is an archive
-                  // todo - is it a fatal error if the mount fails, or should we just skip the entry?
-                  if (! jar.isDirectory()) {
-                     try {
-                        handles.add(VFS.mountZip(jar, jar, TempFileProvider.create(jar.getName(), scheduledExecutorService)));
-                     } catch (IOException e) {
-                        log.warn("Failed to mount file " + jar.getName() + ": " + e);
-                        // try the next one
-                        continue;
-                     }
-                  }
-                  // either same as plain lib filter, null or accepts the jar
-                  if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
-                     metaDataLocations.add("WEB-INF/lib/" + jar.getName() + "/META-INF");
-               }
-            }
-            catch (IOException e)
-            {
-               log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e);
-            }
-         }
-         // Create a context for this war file and all its metadata locations
-         final ContextInfo context = createContext(structureContext, metaDataLocations.toArray(new String[metaDataLocations.size()]));
-         try {
-            // Add the war manifest classpath entries
-            addClassPath(structureContext, file, false, true, context);
-            // Add WEB-INF/classes if present
-            if (classes != null)
-               addClassPath(structureContext, classes, true, false, context);
-            else if (trace)
-               log.trace("No WEB-INF/classes for: " + file.getPathName());
-            // and the top level jars in WEB-INF/lib
-            if (archives != null)
-            {
-               for (VirtualFile jar : archives)
-                  addClassPath(structureContext, jar, true, true, context);
-            }
-            else if (trace)
-            {
-               log.trace("No WEB-INF/lib for: " + file.getPathName());
-            }
-            // do we include WEB-INF in classpath
-            if (includeWebInfInClasspath && webinf != null)
-            {
-               addClassPath(structureContext, webinf, true, false, context);
-            }
-            // There are no subdeployments for wars
-            return ok = true;
-         } finally {
-            if (! ok) {
-               // Remove the invalid context
-               structureContext.removeChild(context);
-            }
-         }
-      } finally {
-         if (! ok) {
-            // Undo all mounts
-            VFSUtils.safeClose(handles);
-         }
-      }
-   }
-}




More information about the jboss-cvs-commits mailing list