[jboss-cvs] JBossAS SVN: r72616 - in projects/jboss-deployers/trunk: deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 23 06:06:44 EDT 2008


Author: alesj
Date: 2008-04-23 06:06:43 -0400 (Wed, 23 Apr 2008)
New Revision: 72616

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/war/metainf.war/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/war/metainf.war/WEB-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/war/metainf.war/WEB-INF/classes/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/war/metainf.war/WEB-INF/classes/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/war/metainf.war/WEB-INF/classes/META-INF/persistence.xml
Modified:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/file/FileStructure.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/war/test/AbstractWARStructureTest.java
Log:
Add WEB-INF/classes/META-INF as metadata to war structure.

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/file/FileStructure.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/file/FileStructure.java	2008-04-23 09:40:56 UTC (rev 72615)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/file/FileStructure.java	2008-04-23 10:06:43 UTC (rev 72616)
@@ -199,7 +199,7 @@
             }
 
             // Create a context info for this file
-            context = createContext(file, null, metaData);
+            context = createContext(file, metaData);
             // There are no subdeployments for files
             if (trace)
                log.trace(file + " isFile: " + isFile);

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java	2008-04-23 09:40:56 UTC (rev 72615)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java	2008-04-23 10:06:43 UTC (rev 72616)
@@ -118,8 +118,9 @@
                log.trace("... ok - name ends in .war.");
             }
 
-            // Create a context for this war file with WEB-INF as the location for metadata  
-            context = createContext(file, "WEB-INF", metaData);
+            // Create a context for this war file with WEB-INF as the location for metadata
+            // Some wars also might have metadata in WEB-INF/classes/META-INF, e.g. persistence.xml
+            context = createContext(file, new String[]{"WEB-INF", "WEB-INF/classes/META-INF"}, metaData);
 
             // Add the war manifest classpath entries
             addClassPath(root, file, false, true, context);

Added: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/war/metainf.war/WEB-INF/classes/META-INF/persistence.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/war/metainf.war/WEB-INF/classes/META-INF/persistence.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structure/war/metainf.war/WEB-INF/classes/META-INF/persistence.xml	2008-04-23 10:06:43 UTC (rev 72616)
@@ -0,0 +1 @@
+<persistence name="somename"/>

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/war/test/AbstractWARStructureTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/war/test/AbstractWARStructureTest.java	2008-04-23 09:40:56 UTC (rev 72615)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structure/war/test/AbstractWARStructureTest.java	2008-04-23 10:06:43 UTC (rev 72616)
@@ -59,7 +59,14 @@
    {
       assertNotValid("/structure/war", "directorynotawar");
    }
-   
+
+   public void testMetainfMetadata() throws Throwable
+   {
+      VFSDeploymentContext war = assertDeploy("/structure/war", "metainf.war");
+      VirtualFile persistence = war.getMetaDataFile("persistence.xml");
+      assertNotNull(persistence);
+   }
+
    public void testDirectoryWithWebInf() throws Throwable
    {
       VFSDeploymentContext war = assertDeployNoChildren("/structure/war", "directorywithwebinf");

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java	2008-04-23 09:40:56 UTC (rev 72615)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java	2008-04-23 10:06:43 UTC (rev 72616)
@@ -36,6 +36,7 @@
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.VirtualFileVisitor;
 import org.jboss.virtual.VisitorAttributes;
+import org.jboss.util.collection.CollectionsFactory;
 
 /**
  * AbstractStructureDeployer.<p>
@@ -43,6 +44,7 @@
  * We don't care about the order by default.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
 public abstract class AbstractStructureDeployer implements StructureDeployer
@@ -240,6 +242,19 @@
     * Create a context
     * 
     * @param root the root context
+    * @param structureMetaData the structure metadata
+    * @return the structure metadata
+    * @throws IllegalArgumentException for a null root or structure metaData
+    */
+   protected ContextInfo createContext(VirtualFile root, StructureMetaData structureMetaData)
+   {
+      return createContext(root, (String)null, structureMetaData);
+   }
+
+   /**
+    * Create a context
+    *
+    * @param root the root context
     * @param metaDataPath the metadata path
     * @param structureMetaData the structure metadata
     * @return the structure metadata
@@ -286,6 +301,58 @@
    }
 
    /**
+    * Create a context
+    *
+    * @param root the root context
+    * @param metaDataPaths the metadata paths
+    * @param structureMetaData the structure metadata
+    * @return the structure metadata
+    * @throws IllegalArgumentException for a null root or structure metaData
+    */
+   protected ContextInfo createContext(VirtualFile root, String[] metaDataPaths, StructureMetaData structureMetaData)
+   {
+      boolean trace = log.isTraceEnabled();
+
+      if (root == null)
+         throw new IllegalArgumentException("Null root");
+      if (structureMetaData == null)
+         throw new IllegalArgumentException("Null structure metadata");
+
+      List<String> metaDataPath = CollectionsFactory.createLazyList();
+      // Determine whether the metadata paths exists
+      if (metaDataPaths != null && metaDataPaths.length > 0)
+      {
+         for(String path : metaDataPaths)
+         {
+            try
+            {
+               VirtualFile child = root.getChild(path);
+               if (child != null)
+                  metaDataPath.add(path);
+            }
+            catch (IOException e)
+            {
+               log.warn("Not using metadata path " + path + " for " + root.getName() + " reason: " + e.getMessage());
+            }
+         }
+      }
+
+      // Create and link the context
+      ContextInfo result;
+      if (metaDataPath.isEmpty())
+         result = StructureMetaDataFactory.createContextInfo("", null);
+      else
+         result = StructureMetaDataFactory.createContextInfo("", metaDataPath, null);
+
+      applyContextInfo(root, result);
+
+      structureMetaData.addContext(result);
+      if (trace)
+         log.trace("Added context " + result + " from " + root.getName());
+      return result;
+   }
+
+   /**
     * Apply context info.
     * Can be overridden for specific root.
     *




More information about the jboss-cvs-commits mailing list