[jboss-cvs] JBossAS SVN: r57656 - in projects/microcontainer/trunk/deployers/src: main/org/jboss/deployers/plugins/structure/vfs main/org/jboss/deployers/plugins/structure/vfs/explicit resources/tests/structure resources/tests/structure/explicit resources/tests/structure/explicit/complex.deployer resources/tests/structure/explicit/complex.deployer/META-INF resources/tests/structure/explicit/complex.deployer/cp-mf.jar resources/tests/structure/explicit/complex.deployer/lib-dir resources/tests/structure/explicit/complex.deployer/lib-dir/jar2.jar resources/tests/structure/explicit/complex.deployer/lib-dir/jar2.jar/META-INF resources/tests/structure/explicit/complex.deployer/sub.jar resources/tests/structure/explicit/complex.deployer/sub.jar/META-INF resources/tests/structure/explicit/complex.deployer/x.war resources/tests/structure/explicit/complex.deployer/x.war/WEB-INF resources/tests/structure/explicit/complex.deployer/x.war/WEB-INF/lib tests/org/jboss/test/deployers/structure! tests/org/jboss/test/deployers/structure/explicit tests/org/jboss/test/deployers/structure/explicit/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 13 02:51:54 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-10-13 02:51:45 -0400 (Fri, 13 Oct 2006)
New Revision: 57656

Added:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/ContextInfo.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/DeclaredStructure.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaData.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataFileVisitor.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataObjectFactory.java
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/META-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/META-INF/jboss-structure.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/cp-mf.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/cp-mf.jar/info
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/jar1.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/lib-dir/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/lib-dir/jar0.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/lib-dir/jar2.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/lib-dir/jar2.jar/META-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/lib-dir/jar2.jar/META-INF/MANIFEST.MF
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/META-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/META-INF/MANIFEST.MF
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/empty
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/x.war/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/x.war/WEB-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/x.war/WEB-INF/classes/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/x.war/WEB-INF/lib/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/x.war/WEB-INF/lib/w0.jar/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/explicit/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/explicit/test/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/explicit/test/DeclaredStructureUnitTestCase.java
Log:
Initial commit of the DeclaredStructure deployer.

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/ContextInfo.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/ContextInfo.java	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/ContextInfo.java	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1,89 @@
+/*
+ * 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.plugins.structure.vfs.explicit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Structure info for a DeploymentContext.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ContextInfo
+{
+   static class Path
+   {
+      private String name;
+      private String[] suffixes = {};
+      Path(String name, String suffixes)
+      {
+         this.name = name;
+         if( suffixes != null )
+            this.suffixes = suffixes.split(",");
+      }
+      public String getName()
+      {
+         return name;
+      }
+      public String[] getSuffixes()
+      {
+         return suffixes;
+      }
+   }
+
+   /** The relative VFS path */
+   private String vfsPath;
+   /** The optional context classpath */
+   private ArrayList<Path> classPath;
+   /** The optional context metadata path */
+   private String metaDataPath;
+
+   public List<Path> getClassPath()
+   {
+      return classPath;
+   }
+   public void setClassPath(List<Path> classPath)
+   {
+      if( this.classPath == null )
+         this.classPath = new ArrayList<Path>();
+      this.classPath.clear();
+      this.classPath.addAll(classPath);
+   }
+   public String getMetaDataPath()
+   {
+      return metaDataPath;
+   }
+   public void setMetaDataPath(String metaDataPath)
+   {
+      this.metaDataPath = metaDataPath;
+   }
+   public String getVfsPath()
+   {
+      return vfsPath;
+   }
+   public void setVfsPath(String path)
+   {
+      this.vfsPath = path;
+   }
+}


Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/ContextInfo.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/DeclaredStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/DeclaredStructure.java	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/DeclaredStructure.java	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.plugins.structure.vfs.explicit;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.plugins.structure.vfs.CandidateStructureVisitorFactory;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileVisitor;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+/**
+ * A structural deployer that looks for a jboss-structure.xml descriptor as
+ * the defining structure.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class DeclaredStructure extends AbstractStructureDeployer
+   implements CandidateStructureVisitorFactory
+{
+   private static ThreadLocal<StructureMetaData> activeMetaData = new ThreadLocal<StructureMetaData>();
+
+   public DeclaredStructure()
+   {
+      super.setCandidateStructureVisitorFactory(this);
+   }
+
+   public VirtualFileVisitor createVisitor(DeploymentContext context, VisitorAttributes attributes)
+      throws Exception
+   {
+      StructureMetaData metaData = activeMetaData.get();
+      return new StructureMetaDataFileVisitor(metaData, context, attributes);
+   }
+
+   /**
+    * Overriden to be the highest priority deployer
+    */
+   @Override
+   public int getRelativeOrder()
+   {
+      return 0;
+   }
+
+   public boolean determineStructure(DeploymentContext context)
+   {
+      try
+      {
+         VirtualFile root = context.getRoot();
+         try
+         {
+            VirtualFile jbossStructure = root.findChild("META-INF/jboss-structure.xml");
+            log.trace("... context has a META-INF subdirectory");
+            URL url = jbossStructure.toURL();
+            UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
+            Unmarshaller unmarshaller = factory.newUnmarshaller();
+            StructureMetaDataObjectFactory ofactory = new StructureMetaDataObjectFactory();
+            StructureMetaData metaData = (StructureMetaData) unmarshaller.unmarshal(url.toString(), ofactory, null);
+            activeMetaData.set(metaData);
+         }
+         catch (IOException e)
+         {
+            log.trace("... no META-INF subdirectory.");
+            return false;
+         }
+
+         super.addAllChildren(context);
+         return true;
+      }
+      catch (Exception e)
+      {
+         log.warn("Error determining structure: " + context.getName(), e);
+         return false;
+      }
+   }
+}


Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/DeclaredStructure.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaData.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaData.java	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaData.java	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1,44 @@
+/*
+ * 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.plugins.structure.vfs.explicit;
+
+import java.util.HashMap;
+
+/**
+ * Metadata describing the structure of a DeploymentContext.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StructureMetaData
+{
+   private HashMap<String, ContextInfo> contexts = new HashMap<String, ContextInfo>();
+
+   public void addContext(ContextInfo context)
+   {
+      contexts.put(context.getVfsPath(), context);
+   }
+   public ContextInfo getContext(String vfsPath)
+   {
+      return contexts.get(vfsPath);
+   }
+}


Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaData.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataFileVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataFileVisitor.java	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataFileVisitor.java	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1,117 @@
+package org.jboss.deployers.plugins.structure.vfs.explicit;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.plugins.structure.vfs.AbstractCandidateStructureVisitor;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
+
+/**
+ * A CandidateStructureVisitor that uses the explicit
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StructureMetaDataFileVisitor extends AbstractCandidateStructureVisitor
+{
+   private static Logger log = Logger.getLogger(StructureMetaDataFileVisitor.class);
+   private StructureMetaData metaData;
+   private String parentPath;
+
+   public StructureMetaDataFileVisitor(StructureMetaData metaData, DeploymentContext parent, VisitorAttributes attributes)
+   {
+      super(parent, attributes);
+      this.metaData = metaData;
+      VirtualFile parentFile = parent.getRoot();
+      this.parentPath = parentFile.getPathName();
+      ContextInfo info = metaData.getContext(parentPath);
+      processContext(parent, info, parentFile);
+   }
+
+   protected DeploymentContext createCandidate(VirtualFile virtualFile)
+   {
+      DeploymentContext context = null;
+      String path = virtualFile.getPathName();
+      ContextInfo info = metaData.getContext(path);
+      if( info != null && path.equals(parentPath) == false )
+      {
+         context = new AbstractDeploymentContext(virtualFile, true, getParent());
+         processContext(context, info, virtualFile);
+      }      
+      
+      return context;
+   }
+
+   protected void processContext(DeploymentContext context, ContextInfo info, VirtualFile virtualFile)
+   {
+      if( info == null )
+         return;
+
+      boolean trace = log.isTraceEnabled();
+      if( trace )
+         log.trace("Processing context: "+context+", info: "+info);
+      context.setMetaDataPath(info.getMetaDataPath());
+      ArrayList<VirtualFile> paths = new ArrayList<VirtualFile>();
+      List<ContextInfo.Path> classPath = info.getClassPath();
+      if( classPath != null )
+      {
+         for(ContextInfo.Path cp : classPath)
+         {
+            try
+            {
+               VirtualFile child = virtualFile.findChild(cp.getName());
+               String[] suffixes = cp.getSuffixes();
+               // Add the path if there is no suffix
+               if( suffixes == null || suffixes.length == 0 )
+               {
+                  paths.add(child);
+                  if( trace )
+                     log.trace("Added simple classpath entry: "+child);
+                  // Process any Manifest Class-Path refs
+                  VFSUtils.addManifestLocations(child, paths);
+               }
+               // Filter the immeadiate children against the suffixes
+               else
+               {
+                  SuffixMatchFilter filter = new SuffixMatchFilter(Arrays.asList(suffixes), VisitorAttributes.DEFAULT);
+                  List<VirtualFile> matches = child.getChildren(filter);
+                  if( matches != null )
+                  {
+                     paths.addAll(matches);
+                     if( trace )
+                        log.trace("Added classpath matches: "+matches);
+                     // Process any Manifest Class-Path refs
+                     for(VirtualFile file : matches)
+                     {
+                        VFSUtils.addManifestLocations(file, paths);
+                     }
+                  }
+               }
+            }
+            catch(IOException e)
+            {
+               log.debug("Failed to find cp element: "+cp+", "+e.getMessage());
+            }
+         }
+      }
+
+      try
+      {
+         // Process any Manifest Class-Path refs on the context itself
+         VFSUtils.addManifestLocations(virtualFile, paths);
+      }
+      catch(IOException ignore)
+      {
+      }
+      // Set the classpath
+      if( paths.size() > 0 )
+         context.setClassPath(paths);
+   }
+}


Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataFileVisitor.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataObjectFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataObjectFactory.java	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataObjectFactory.java	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1,108 @@
+/*
+ * 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.plugins.structure.vfs.explicit;
+
+import java.util.ArrayList;
+
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * An ObjectModelFactory for the jboss-structure.xml descriptor.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StructureMetaDataObjectFactory implements ObjectModelFactory
+{
+   public StructureMetaData newRoot(Object root, UnmarshallingContext navigator,
+         String namespaceURI, String localName, Attributes attrs)
+   {
+      StructureMetaData metaData = null;
+      if (root != null)
+         metaData = (StructureMetaData) root;
+      else
+         metaData = new StructureMetaData();
+
+      return metaData;
+   }
+
+   public Object completeRoot(Object root, UnmarshallingContext ctx,
+         String uri, String name)
+   {
+      return root;
+   }
+
+   public Object newChild(StructureMetaData parent, UnmarshallingContext navigator,
+         String namespaceURI, String localName, Attributes attrs)
+   {
+      Object child = null;
+      if(localName.equals("context"))
+      {
+         child = new ContextInfo();
+      }
+      return child;
+   }
+   public Object newChild(ContextInfo parent, UnmarshallingContext navigator,
+         String namespaceURI, String localName, Attributes attrs)
+   {
+      Object child = null;
+      if (localName.equals("classpath"))
+         child = new ArrayList<ContextInfo.Path>();
+      else if( localName.equals("path") )
+      {
+         String path = attrs.getValue("name");
+         parent.setVfsPath(path);
+      }
+      else if( localName.equals("metaDataPath") )
+      {
+         String path = attrs.getValue("name");
+         parent.setMetaDataPath(path);
+      }
+      return child;
+   }
+   public Object newChild(ArrayList<ContextInfo.Path> parent, UnmarshallingContext navigator,
+         String namespaceURI, String localName, Attributes attrs)
+   {
+      Object child = null;
+      if( localName.equals("path") )
+      {
+         String name = attrs.getValue("name");
+         String suffixes = attrs.getValue("suffixes");
+         ContextInfo.Path path = new ContextInfo.Path(name, suffixes);
+         parent.add(path);
+      }
+      return child;
+   }
+
+   public void addChild(StructureMetaData parent, ContextInfo context,
+         UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      parent.addContext(context);
+   }
+   public void addChild(ContextInfo context, ArrayList<ContextInfo.Path> classpath,
+         UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      context.setClassPath(classpath);
+   }
+}


Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataObjectFactory.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/META-INF/jboss-structure.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/META-INF/jboss-structure.xml	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/META-INF/jboss-structure.xml	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1,22 @@
+<structure>
+	<context>
+		<path name="complex.deployer" />
+		<metaDataPath name="META-INF" />
+		<classpath>
+			<path name="jar1.jar" />
+			<path name="lib-dir" suffixes=".jar" />
+		</classpath>
+	</context>
+	<context>
+		<path name="complex.deployer/sub.jar" />
+		<metaDataPath name="META-INF" />
+	</context>
+	<context>
+		<path name="complex.deployer/x.war" />
+		<metaDataPath name="WEB-INF" />
+		<classpath>
+			<path name="WEB-INF/classes" />
+			<path name="WEB-INF/lib" suffixes=".jar" />
+		</classpath>
+	</context>
+</structure>


Property changes on: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/META-INF/jboss-structure.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/cp-mf.jar/info
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/cp-mf.jar/info	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/cp-mf.jar/info	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1 @@
+A jar referenced via Class-Path manifest entries.
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/lib-dir/jar2.jar/META-INF/MANIFEST.MF
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/lib-dir/jar2.jar/META-INF/MANIFEST.MF	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/lib-dir/jar2.jar/META-INF/MANIFEST.MF	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1 @@
+Class-Path: bad.jar ../cp-mf.jar

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/META-INF/MANIFEST.MF
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/META-INF/MANIFEST.MF	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/META-INF/MANIFEST.MF	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1 @@
+Class-Path: cp-mf.jar

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/empty	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/empty	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1 @@
+empty
\ No newline at end of file


Property changes on: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.deployer/sub.jar/empty
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/explicit/test/DeclaredStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/explicit/test/DeclaredStructureUnitTestCase.java	2006-10-13 06:35:07 UTC (rev 57655)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/explicit/test/DeclaredStructureUnitTestCase.java	2006-10-13 06:51:45 UTC (rev 57656)
@@ -0,0 +1,175 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.test.deployers.structure.explicit.test;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.vfs.explicit.DeclaredStructure;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * DeclaredStructure deployer unit tests.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class DeclaredStructureUnitTestCase extends BaseDeployersTest
+{
+   /** The jar structure deployer */
+   private static final DeclaredStructure structure = new DeclaredStructure();
+   
+   public static Test suite()
+   {
+      return new TestSuite(DeclaredStructureUnitTestCase.class);
+   }
+   
+   public DeclaredStructureUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      enableTrace("org.jboss.deployers");
+   }
+
+   @Override
+   protected StructureDeployer getStrucutureDeployer()
+   {
+      return structure;
+   }
+   
+   protected DeploymentContext getValidContext(String root, String path) throws Exception
+   {
+      DeploymentContext context = createDeploymentContext(root, path);
+      assertTrue("Structure should be valid: " + context.getName(), determineStructure(context));
+      return context;
+   }
+
+   protected DeploymentContext assertValidContext(String root, String path) throws Exception
+   {
+      return getValidContext(root, path);
+   }
+   
+   protected DeploymentContext assertNotValidContext(String root, String path, boolean other) throws Exception
+   {
+      DeploymentContext context = createDeploymentContext(root, path);
+      assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
+      assertEmpty(context.getChildren());
+      return context;
+   }
+   
+   public void testComplex() throws Exception
+   {
+      DeploymentContext root = getValidContext("/structure/explicit/", "complex.deployer");
+      
+      // Test it got all the candidates
+      Map<String, Boolean> expected = new HashMap<String, Boolean>();
+      expected.put(getURL("/structure/explicit/complex.deployer/sub.jar/"), false);
+      expected.put(getURL("/structure/explicit/complex.deployer/x.war/"), false);
+      assertContexts(expected, root.getChildren());
+      // None of the complex.deployer children should be valid
+      assertCandidatesNotValid(root);
+
+      // Validate the root context info
+      assertEquals("complex.deployer/META-INF", "complex.deployer/META-INF",
+         root.getMetaDataLocation().getPathName());
+      List<VirtualFile> rootCP = root.getClassPath();
+      assertEquals("classpath.size = 4", 4, rootCP.size());
+      HashSet<String> rootCPSet = new HashSet<String>();
+      rootCPSet.add(getURL("/structure/explicit/complex.deployer/cp-mf.jar/"));
+      rootCPSet.add(getURL("/structure/explicit/complex.deployer/jar1.jar/"));
+      rootCPSet.add(getURL("/structure/explicit/complex.deployer/lib-dir/jar0.jar/"));
+      rootCPSet.add(getURL("/structure/explicit/complex.deployer/lib-dir/jar2.jar/"));
+      for(VirtualFile file : rootCP)
+      {
+         String url = file.toURL().toString();
+         assertTrue(url, rootCPSet.contains(url));
+      }
+
+      Map<String, DeploymentContext> pathMap = buildPathMap(root);
+      // Validate the sub.jar context info
+      DeploymentContext subJar = pathMap.get("complex.deployer/sub.jar");
+      assertNotNull("complex.deployer/sub.jar", subJar);
+      assertEquals("complex.deployer/sub.jar/META-INF", "complex.deployer/sub.jar/META-INF",
+            subJar.getMetaDataLocation().getPathName());
+      List<VirtualFile> subJarCP = subJar.getClassPath();
+      assertEquals("classpath.size = 1", 1, subJarCP.size());
+      HashSet<String> subJarCPSet = new HashSet<String>();
+      subJarCPSet.add(getURL("/structure/explicit/complex.deployer/cp-mf.jar/"));
+      for(VirtualFile file : subJarCP)
+      {
+         String url = file.toURL().toString();
+         assertTrue(url, subJarCPSet.contains(url));
+      }
+
+      // Validate the x.war context info
+      DeploymentContext xwar = pathMap.get("complex.deployer/x.war");
+      assertNotNull("complex.deployer/x.war", xwar);
+      assertEquals("complex.deployer/x.war/WEB-INF", "complex.deployer/x.war/WEB-INF",
+            xwar.getMetaDataLocation().getPathName());
+      List<VirtualFile> xWarCP = xwar.getClassPath();
+      assertEquals("classpath.size = 2", 2, xWarCP.size());
+      HashSet<String> xWarCPSet = new HashSet<String>();
+      xWarCPSet.add(getURL("/structure/explicit/complex.deployer/x.war/WEB-INF/classes/"));
+      xWarCPSet.add(getURL("/structure/explicit/complex.deployer/x.war/WEB-INF/lib/w0.jar/"));
+      for(VirtualFile file : xWarCP)
+      {
+         String url = file.toURL().toString();
+         assertTrue(url, xWarCPSet.contains(url));
+      }
+   }
+
+   protected void assertContexts(Map<String, Boolean> expected, Set<DeploymentContext> actual) throws Exception
+   {
+      assertCandidateContexts(expected, actual);
+   }
+
+   /**
+    * Create a map of vfs relative paths to the child DeploymentContexts.
+    * @param root
+    * @return
+    */
+   protected Map<String, DeploymentContext> buildPathMap(DeploymentContext root)
+   {
+      HashMap<String, DeploymentContext> pathMap = new HashMap<String, DeploymentContext>();
+      Set<DeploymentContext> children = root.getChildren();
+      for(DeploymentContext ctx : children)
+      {
+         String path = ctx.getRoot().getPathName();
+         pathMap.put(path, ctx);
+      }
+      return pathMap;
+   }
+}


Property changes on: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/explicit/test/DeclaredStructureUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-cvs-commits mailing list