[Jboss-cvs] JBossAS SVN: r56611 - in projects/microcontainer/trunk/deployers/src: main/org/jboss/deployers/plugins/deployer main/org/jboss/deployers/plugins/deployment main/org/jboss/deployers/plugins/structure main/org/jboss/deployers/plugins/structure/vfs main/org/jboss/deployers/plugins/structure/vfs/jar main/org/jboss/deployers/plugins/structure/vfs/war main/org/jboss/deployers/spi/structure main/org/jboss/deployers/spi/structure/vfs resources/tests/structure resources/tests/structure/jar resources/tests/structure/jar/notanarchive resources/tests/structure/jar/simple resources/tests/structure/jar/subdirhasmetainf resources/tests/structure/jar/subdirhasmetainf/sub resources/tests/structure/jar/subdirhasmetainf/sub/META-INF resources/tests/structure/jar/subdirisajar resources/tests/structure/jar/subdirisajar/sub.jar resources/tests/structure/jar/subdirnotajar resources/tests/structure/jar/subdirnotajar/sub resources/tests/structure/war resources/tests/structure/war/directory! .war resources/tests/structure/war/directorynotawar resources/tests/structure/war/directorywithwebinf resources/tests/structure/war/directorywithwebinf/WEB-INF resources/tests/structure/war/notanarchive resources/tests/structure/war/simple tests/org/jboss/test/deployers tests/org/jboss/test/deployers/structure tests/org/jboss/test/deployers/structure/jar/test tests/org/jboss/test/deployers/structure/war tests/org/jboss/test/deployers/structure/war/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 7 08:24:29 EDT 2006
Author: adrian at jboss.org
Date: 2006-09-07 08:24:00 -0400 (Thu, 07 Sep 2006)
New Revision: 56611
Added:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitor.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WebInfLibFilter.java
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/indirectory/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/notanarchive/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/notanarchive/NotAnArchive.jar
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/notanarchive/NotAnArchive.zip
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple1.txt
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple2.txt
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirhasmetainf/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirhasmetainf/sub/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirhasmetainf/sub/META-INF/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirhasmetainf/sub/META-INF/empty
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirisajar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirisajar/sub.jar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirisajar/sub.jar/empty
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirnotajar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirnotajar/sub/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirnotajar/sub/empty
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directory.war/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directory.war/empty
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorynotawar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorynotawar/empty
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/empty
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/notanarchive/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/notanarchive/notanarchive.war
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/simple/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/simple/simple.war
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java
Removed:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractVFSDeploymentContext.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/JARStructure.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/VFSDeploymentContext.java
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/nested/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.jar
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.zip
projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple.txt
Modified:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java
Log:
[JBMICROCONT-5] - Use org.jboss.virtual for now.
Refactored contexts such that a VFS context is just
a normal context that has a root attribute.
Finished implementations of jar and war strucuture deployments.
Needs some tests for classpath generation.
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -60,7 +60,10 @@
public ClassLoader getClassLoader()
{
- return deploymentContext.getClassLoader();
+ ClassLoader cl = deploymentContext.getClassLoader();
+ if (cl == null)
+ throw new IllegalStateException("ClassLoader has not been set");
+ return cl;
}
public URL getMetaData(String name)
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -48,7 +48,6 @@
import org.jboss.deployers.spi.deployer.DeploymentUnit;
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
-import org.jboss.deployers.spi.structure.vfs.VFSDeploymentContext;
import org.jboss.logging.Logger;
/**
@@ -305,11 +304,9 @@
if (context.getStructureDetermined() == PREDETERMINED)
return;
- if (context instanceof VFSDeploymentContext == false)
- throw new DeploymentException("Unable to determine structure for non VFSDeploymentContext " + context.getName());
+ if (context.getRoot() == null)
+ throw new DeploymentException("Unable to determine structure context has not root " + context.getName());
- VFSDeploymentContext vfsContext = (VFSDeploymentContext) context;
-
StructureDeployer[] theDeployers;
synchronized (this)
{
@@ -318,7 +315,7 @@
theDeployers = structureDeployers.toArray(new StructureDeployer[structureDeployers.size()]);
}
- determineStructure(vfsContext, theDeployers);
+ determineStructure(context, theDeployers);
}
/**
@@ -329,8 +326,12 @@
* @return true when determined
* @throws DeploymentException for any problem
*/
- private boolean determineStructure(VFSDeploymentContext context, StructureDeployer[] theDeployers) throws DeploymentException
+ private boolean determineStructure(DeploymentContext context, StructureDeployer[] theDeployers) throws DeploymentException
{
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Trying to determine structure: " + context.getName());
+
boolean result = false;
for (StructureDeployer deployer : theDeployers)
{
@@ -346,14 +347,12 @@
Set<DeploymentContext> children = context.getChildren();
for (DeploymentContext child : children)
{
- if (child instanceof VFSDeploymentContext == false)
- throw new DeploymentException("Unable to determine structure for non VFSDeploymentContext: " + context.getName());
+ if (child.getRoot() == null)
+ throw new DeploymentException("Unable to determine structure context has no root: " + context.getName());
- VFSDeploymentContext childContext = (VFSDeploymentContext) child;
-
// This must be a candidate that doesn't match
- if (determineStructure(childContext, theDeployers) == false)
- children.remove(child);
+ if (determineStructure(child, theDeployers) == false)
+ context.removeChild(child);
}
return result;
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -21,9 +21,12 @@
*/
package org.jboss.deployers.plugins.structure;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
@@ -33,7 +36,8 @@
import org.jboss.deployers.spi.structure.StructureDetermined;
import org.jboss.logging.Logger;
import org.jboss.util.UnreachableStatementException;
-import org.jboss.vfs.spi.VirtualFile;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
/**
* AbstractDeploymentContext.
@@ -57,13 +61,21 @@
/** The deployment unit */
private DeploymentUnit unit;
+ /** The root */
+ private VirtualFile root;
/** The meta data location */
private VirtualFile metaDataLocation;
+ /** The class paths */
+ private List<VirtualFile> classPath;
+
/** The class loader */
private ClassLoader classLoader;
+ /** Whether this is a candidate deployment */
+ private boolean candidate = false;
+
/** The parent context */
private DeploymentContext parent;
@@ -72,19 +84,122 @@
/** Throwable */
private Throwable problem;
+
+ /**
+ * Get the deployment name
+ *
+ * @param file the file
+ * @return the name;
+ */
+ public static String getDeploymentName(VirtualFile file)
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+ try
+ {
+ URL url = file.toURL();
+ String name = url.toString();
+ return name;
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("File does not have a valid url: " + file, e);
+ }
+ }
/**
* Create a new AbstractDeploymentContext.
*
* @param name the name
+ * @throws IllegalArgumentException if the name is null
*/
public AbstractDeploymentContext(String name)
{
+ this(name, false);
+ }
+
+ /**
+ * Create a new AbstractDeploymentContext.
+ *
+ * @param name the name
+ * @param candidate whether this is a candidate
+ * @throws IllegalArgumentException if the name is null
+ */
+ public AbstractDeploymentContext(String name, boolean candidate)
+ {
if (name == null)
throw new IllegalArgumentException("Null name");
this.name = name;
+ this.candidate = candidate;
}
+
+ /**
+ * Create a new AbstractDeploymentContext.
+ *
+ * @param name the name
+ * @param parent the parent
+ * @throws IllegalArgumentException if the name or parent is null
+ */
+ public AbstractDeploymentContext(String name, DeploymentContext parent)
+ {
+ this(name, false, parent);
+ }
+
+ /**
+ * Create a new AbstractDeploymentContext.
+ *
+ * @param name the name
+ * @param candidate whether this is a candidate
+ * @param parent the parent
+ * @throws IllegalArgumentException if the name or parent is null
+ */
+ public AbstractDeploymentContext(String name, boolean candidate, DeploymentContext parent)
+ {
+ this(name, candidate);
+ if (parent == null)
+ throw new IllegalArgumentException("Null parent");
+ setParent(parent);
+ }
+ /**
+ * Create a new AbstractDeploymentContext.
+ *
+ * @param root the root
+ * @throws IllegalArgumentException if the file/root is null
+ */
+ public AbstractDeploymentContext(VirtualFile root)
+ {
+ this(getDeploymentName(root), false);
+ setRoot(root);
+ }
+
+ /**
+ * Create a new AbstractDeploymentContext.
+ *
+ * @param root the root
+ * @param candidate whether this is a candidate
+ * @throws IllegalArgumentException if the file/root is null
+ */
+ public AbstractDeploymentContext(VirtualFile root, boolean candidate)
+ {
+ this(getDeploymentName(root), candidate);
+ setRoot(root);
+ }
+
+ /**
+ * Create a new AbstractDeploymentContext.
+ *
+ * @param root the root
+ * @param candidate whether this is a candidate
+ * @param parent the parent
+ * @throws IllegalArgumentException if the file/root or parent is null
+ */
+ public AbstractDeploymentContext(VirtualFile root, boolean candidate, DeploymentContext parent)
+ {
+ this(getDeploymentName(root), candidate, parent);
+ setRoot(root);
+ }
+
public String getName()
{
return name;
@@ -104,7 +219,7 @@
public boolean isCandidate()
{
- return false;
+ return candidate;
}
public DeploymentState getState()
@@ -129,6 +244,35 @@
this.unit = unit;
}
+ public VirtualFile getRoot()
+ {
+ return root;
+ }
+
+ /**
+ * Set the root location
+ *
+ * @param root the root
+ */
+ public void setRoot(VirtualFile root)
+ {
+ this.root = root;
+ }
+
+ public void setMetaDataPath(String path)
+ {
+ if (path == null)
+ setMetaDataLocation(null);
+ try
+ {
+ setMetaDataLocation(root.findChild(path));
+ }
+ catch (IOException e)
+ {
+ log.debug("Meta data path does not exist: root=" + root.getPathName() + " path=" + path);
+ }
+ }
+
public VirtualFile getMetaDataLocation()
{
return metaDataLocation;
@@ -137,19 +281,33 @@
public void setMetaDataLocation(VirtualFile location)
{
this.metaDataLocation = location;
+ if (log.isTraceEnabled() && location != null)
+ log.trace("MetaData locaton for " + root.getPathName() + " is " + location.getPathName());
}
public ClassLoader getClassLoader()
{
- if (classLoader == null)
- throw new IllegalStateException("Attempt to retrieve classloader when it has not been set.");
return classLoader;
}
public void setClassLoader(ClassLoader classLoader)
{
this.classLoader = classLoader;
+ if (classLoader != null)
+ log.trace("ClassLoader for " + root.getPathName() + " is " + classLoader);
}
+
+ public List<VirtualFile> getClassPath()
+ {
+ return classPath;
+ }
+
+ public void setClassPath(List<VirtualFile> paths)
+ {
+ this.classPath = paths;
+ if (log.isTraceEnabled() && paths != null)
+ log.trace("ClassPath for " + root.getPathName() + " is " + VFSUtils.getPathsString(paths));
+ }
public boolean isTopLevel()
{
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -21,10 +21,11 @@
*/
package org.jboss.deployers.plugins.structure.vfs;
+import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
-import org.jboss.deployers.spi.structure.vfs.VFSDeploymentContext;
import org.jboss.logging.Logger;
-import org.jboss.vfs.spi.VirtualFile;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VisitorAttributes;
/**
* AbstractStructureDeployer.<p>
@@ -44,25 +45,26 @@
return Integer.MAX_VALUE;
}
- public abstract boolean determineStructure(VFSDeploymentContext context);
+ public abstract boolean determineStructure(DeploymentContext context);
/**
* Add all children as candidates
*
- * @param context the context
+ * @param parent the parent context
* @param ignoreDirectories whether to ignore directories
* @throws Exception for any error
*/
- protected void addAllChildren(VFSDeploymentContext context, boolean ignoreDirectories) throws Exception
+ protected void addAllChildren(DeploymentContext parent, boolean ignoreDirectories) throws Exception
{
- VirtualFile[] childFiles = context.getRoot().getChildren();
- for (VirtualFile childFile : childFiles)
- {
- if (ignoreDirectories == false || childFile.isDirectory() == false)
- {
- AbstractVFSDeploymentContext child = new AbstractVFSDeploymentContext(childFile, true);
- context.addChild(child);
- }
- }
+ if (parent == null)
+ throw new IllegalArgumentException("Null parent");
+
+ VisitorAttributes attributes = VisitorAttributes.DEFAULT;
+ if (ignoreDirectories)
+ attributes = VisitorAttributes.NO_DIRECTORIES;
+ CandidateStructureVisitor visitor = new CandidateStructureVisitor(parent, attributes);
+
+ VirtualFile root = parent.getRoot();
+ root.visit(visitor);
}
}
Deleted: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractVFSDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractVFSDeploymentContext.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractVFSDeploymentContext.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1,111 +0,0 @@
-/*
-* 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;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
-import org.jboss.deployers.spi.structure.vfs.VFSDeploymentContext;
-import org.jboss.vfs.spi.VirtualFile;
-
-/**
- * VFSDeploymentContext.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class AbstractVFSDeploymentContext extends AbstractDeploymentContext implements VFSDeploymentContext
-{
- /** The root */
- private VirtualFile root;
-
- /** Whether this is a candidate deployment */
- private boolean candidate;
-
- /**
- * Get the deployment name
- *
- * @param file the file
- * @return the name;
- */
- public static String getDeploymentName(VirtualFile file)
- {
- if (file == null)
- throw new IllegalArgumentException("Null file");
- try
- {
- return file.toURL().toString();
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("File does not have a valid url: " + file, e);
- }
- }
-
- /**
- * Create a new AbstractDeploymentContext.
- *
- * @param root the root
- */
- public AbstractVFSDeploymentContext(VirtualFile root)
- {
- this(root, false);
- }
-
- /**
- * Create a new AbstractDeploymentContext.
- *
- * @param root the root
- * @param candidate whether this is a candidate
- */
- public AbstractVFSDeploymentContext(VirtualFile root, boolean candidate)
- {
- super(getDeploymentName(root));
- this.root = root;
- this.candidate = candidate;
- }
-
- public VirtualFile getRoot()
- {
- return root;
- }
-
- public boolean isCandidate()
- {
- return candidate;
- }
-
- public void setMetaDataPath(String path)
- {
- if (path == null)
- setMetaDataLocation(null);
- try
- {
- setMetaDataLocation(root.findChild(path));
- }
- catch (IOException e)
- {
- log.debug("Meta data path does not exist: root=" + root.getPathName() + " path=" + path);
- }
- }
-}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitor.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitor.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1,84 @@
+/*
+* 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;
+
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.vfs.helpers.AbstractVirtualFileVisitor;
+
+/**
+ * Visits the structure and creates candidates
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class CandidateStructureVisitor extends AbstractVirtualFileVisitor
+{
+ /** The parent deployment context */
+ private final DeploymentContext parent;
+
+ /**
+ * Create a new CandidateStructureVisitor.
+ *
+ * @param parent the parent
+ * @throws IllegalArgumentException for a null parent
+ */
+ public CandidateStructureVisitor(DeploymentContext parent)
+ {
+ this(parent, null);
+ }
+
+ /**
+ * Create a new CandidateStructureVisitor.
+ *
+ * @param parent the parent
+ * @param attributes the attributes
+ * @throws IllegalArgumentException for a null parent
+ */
+ public CandidateStructureVisitor(DeploymentContext parent, VisitorAttributes attributes)
+ {
+ super(attributes);
+ if (parent == null)
+ throw new IllegalArgumentException("Null parent");
+ this.parent = parent;
+ }
+
+ public void visit(VirtualFile virtualFile)
+ {
+ DeploymentContext candidate = createCandidate(virtualFile);
+ if (candidate != null)
+ parent.addChild(candidate);
+ }
+
+ /**
+ * Create a new candidate deployment context
+ *
+ * @param virtualFile the virtual file
+ * @return the candidate or null if it is not a candidate
+ */
+ protected DeploymentContext createCandidate(VirtualFile virtualFile)
+ {
+ return new AbstractDeploymentContext(virtualFile, true, parent);
+ }
+}
Deleted: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/JARStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/JARStructure.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/JARStructure.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1,83 +0,0 @@
-/*
-* 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;
-
-import java.io.IOException;
-
-import org.jboss.deployers.spi.structure.vfs.VFSDeploymentContext;
-import org.jboss.vfs.spi.VirtualFile;
-
-/**
- * JARStructure.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class JARStructure extends AbstractStructureDeployer
-{
- public boolean determineStructure(VFSDeploymentContext context)
- {
- try
- {
- VirtualFile file = context.getRoot();
- if (file.isDirectory())
- {
- if (file.isArchive() == false)
- {
- // For non top level directories we require a META-INF
- // otherwise each subdirectory would be a subdeployment
- if (context.isTopLevel() == false)
- {
- try
- {
- VirtualFile test = file.findChild("META-INF");
- if (test == null)
- return false;
- }
- catch (IOException e)
- {
- return false;
- }
- }
- }
-
- // The metadata path is META-INF
- context.setMetaDataPath("META-INF");
-
- // We tentatively try all the children as potential subdeployments
- // but ignore subdirectories if it is an archive
- addAllChildren(context, file.isArchive());
-
- return true;
- }
- else
- {
- return false;
- }
- }
- catch (Exception e)
- {
- log.warn("Error determining structure: " + context.getName(), e);
- return false;
- }
- }
-}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -21,8 +21,8 @@
*/
package org.jboss.deployers.plugins.structure.vfs;
+import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
-import org.jboss.deployers.spi.structure.vfs.VFSDeploymentContext;
import org.jboss.logging.Logger;
/**
@@ -53,7 +53,7 @@
this.deployer = deployer;
}
- public boolean determineStructure(VFSDeploymentContext context)
+ public boolean determineStructure(DeploymentContext context)
{
if (context == null)
throw new IllegalArgumentException("Null context");
Copied: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java (from rev 56542, projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/JARStructure.java)
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/JARStructure.java 2006-09-04 04:15:00 UTC (rev 56542)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1,103 @@
+/*
+* 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.jar;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * JARStructure.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JARStructure extends AbstractStructureDeployer
+{
+ public boolean determineStructure(DeploymentContext context)
+ {
+ try
+ {
+ VirtualFile root = context.getRoot();
+ if (root.isDirectory())
+ {
+ if (root.isArchive() == false)
+ {
+ // For non top level directories that don't look like jars
+ // we require a META-INF otherwise each subdirectory would be a subdeployment
+ if (context.isTopLevel() == false)
+ {
+ try
+ {
+ root.findChild("META-INF");
+ log.trace("... ok - non top level directory has a META-INF subdirectory");
+ }
+ catch (IOException e)
+ {
+ log.trace("... no - doesn't look like a jar and no META-INF subdirectory.");
+ return false;
+ }
+ }
+ else
+ {
+ log.trace("... ok - doesn't look like a jar but it is a top level directory.");
+ }
+ }
+ else
+ {
+ log.trace("... ok - its an archive or at least pretending to be.");
+ }
+
+ // The metadata path is META-INF
+ context.setMetaDataPath("META-INF");
+
+ // The classpath is the root
+ List<VirtualFile> paths = new ArrayList<VirtualFile>();
+ paths.add(root);
+ // Add the manifest locations
+ VFSUtils.addManifestLocations(root, paths);
+ context.setClassPath(paths);
+
+ // We tentatively try all the children as potential subdeployments
+ // but ignore subdirectories if it is an archive
+ addAllChildren(context, root.isArchive());
+
+ return true;
+ }
+ else
+ {
+ log.trace("... no - not a directory or an archive.");
+ return false;
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("Error determining structure: " + context.getName(), e);
+ return false;
+ }
+ }
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1,116 @@
+/*
+* 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.war;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * WARStructure.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class WARStructure extends AbstractStructureDeployer
+{
+ public boolean determineStructure(DeploymentContext context)
+ {
+ try
+ {
+ VirtualFile root = context.getRoot();
+ if (root.isDirectory())
+ {
+ // We require either a WEB-INF or the name ends in .war
+ if (root.getName().endsWith(".war") == false)
+ {
+ try
+ {
+ root.findChild("WEB-INF");
+ log.trace("... ok - directory has a WEB-INF subdirectory");
+ }
+ catch (IOException e)
+ {
+ log.trace("... no - doesn't look like a war and no WEB-INF subdirectory.");
+ return false;
+ }
+ }
+ else
+ {
+ log.trace("... ok - name ends in .war.");
+ }
+
+ // The metadata path is WEB-INF
+ context.setMetaDataPath("WEB-INF");
+
+ List<VirtualFile> paths = new ArrayList<VirtualFile>();
+ VirtualFile webinf = context.getMetaDataLocation();
+ if (webinf != null)
+ {
+ // The classpath is WEB-INF/classes
+ try
+ {
+ VirtualFile webinfClasses = webinf.findChild("classes");
+ paths.add(webinfClasses);
+ }
+ catch (IOException ignored)
+ {
+ log.trace("No WEB-INF/classes for: " + root.getPathName());
+ }
+ // and the top level jars in WEB-INF/lib
+ try
+ {
+ VirtualFile webinfLib = webinf.findChild("lib");
+ List<VirtualFile> archives = webinfLib.getChildren(WebInfLibFilter.INSTANCE);
+ for (VirtualFile archive : archives)
+ paths.add(archive);
+ }
+ catch (IOException ignored)
+ {
+ log.trace("No WEB-INF/lib for: " + root.getPathName());
+ }
+ }
+ // Add the manifest locations
+ VFSUtils.addManifestLocations(root, paths);
+ context.setClassPath(paths);
+
+ // There are no subdeployments for wars
+ return true;
+ }
+ else
+ {
+ log.trace("... no - not a directory or an archive.");
+ return false;
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("Error determining structure: " + context.getName(), e);
+ return false;
+ }
+ }
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WebInfLibFilter.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WebInfLibFilter.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WebInfLibFilter.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.war;
+
+import java.io.IOException;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilterWithAttributes;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+
+/**
+ * Filters web-inf/lib for archives
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision: 44223 $
+ */
+public class WebInfLibFilter implements VirtualFileFilterWithAttributes
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(WebInfLibFilter.class);
+
+ /** The instance */
+ public static final WebInfLibFilter INSTANCE = new WebInfLibFilter();
+
+ /**
+ * Singleton
+ */
+ private WebInfLibFilter()
+ {
+ }
+
+ public VisitorAttributes getAttributes()
+ {
+ return VisitorAttributes.DEFAULT;
+ }
+
+ public boolean accepts(VirtualFile file)
+ {
+ try
+ {
+ // We want archives
+ if (file.isArchive())
+ return true;
+
+ // Or directories pretending to be archives
+ if (file.isDirectory() && JarUtils.isArchive(file.getName()))
+ return true;
+ }
+ catch (IOException e)
+ {
+ log.warn("Ignoring " + file + " reason=" + e);
+ }
+
+ // We ignore everything else
+ return false;
+ }
+}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -23,10 +23,11 @@
import java.io.InputStream;
import java.net.URL;
+import java.util.List;
import java.util.Set;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
-import org.jboss.vfs.spi.VirtualFile;
+import org.jboss.virtual.VirtualFile;
/**
* DeploymentContext.
@@ -91,8 +92,22 @@
* @param unit the deployment unit
*/
void setDeploymentUnit(DeploymentUnit unit);
-
+
/**
+ * Get the root file
+ *
+ * @return the root
+ */
+ VirtualFile getRoot();
+
+ /**
+ * Set the meta data path relative to the root
+ *
+ * @param path the path
+ */
+ void setMetaDataPath(String path);
+
+ /**
* Get the meta data location
*
* @return the meta data location
@@ -135,6 +150,20 @@
* @param classLoader the new classloader
*/
void setClassLoader(ClassLoader classLoader);
+
+ /**
+ * Get the class path
+ *
+ * @return the class path
+ */
+ List<VirtualFile> getClassPath();
+
+ /**
+ * Set the class path
+ *
+ * @param paths the paths
+ */
+ void setClassPath(List<VirtualFile> paths);
/**
* Whether this is a top level deployment
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -23,6 +23,8 @@
import java.util.Comparator;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+
/**
* StructureDeployer.
*
@@ -37,7 +39,7 @@
* @param context the context
* @return true when it is recongnised
*/
- boolean determineStructure(VFSDeploymentContext context);
+ boolean determineStructure(DeploymentContext context);
/**
* Get the relative order
Deleted: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/VFSDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/VFSDeploymentContext.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/VFSDeploymentContext.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1,48 +0,0 @@
-/*
-* 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.spi.structure.vfs;
-
-import org.jboss.deployers.spi.structure.DeploymentContext;
-import org.jboss.vfs.spi.VirtualFile;
-
-/**
- * VFSDeploymentContext.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface VFSDeploymentContext extends DeploymentContext
-{
- /**
- * Get the root file
- *
- * @return the root
- */
- VirtualFile getRoot();
-
- /**
- * Set the meta data path relative to the root
- *
- * @param path the path
- */
- void setMetaDataPath(String path);
-}
Copied: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/indirectory (from rev 56542, projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/nested)
Copied: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/notanarchive/NotAnArchive.jar (from rev 56542, projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.jar)
Copied: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/notanarchive/NotAnArchive.zip (from rev 56542, projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.zip)
Deleted: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.jar
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.jar 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.jar 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1 +0,0 @@
-empty
Deleted: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.zip
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.zip 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/NotAnArchive.zip 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1 +0,0 @@
-empty
Deleted: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple.txt
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple.txt 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple.txt 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1 +0,0 @@
-empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple1.txt
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple1.txt 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple1.txt 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple2.txt
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple2.txt 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/simple/simple2.txt 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirhasmetainf/sub/META-INF/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirhasmetainf/sub/META-INF/empty 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirhasmetainf/sub/META-INF/empty 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirisajar/sub.jar/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirisajar/sub.jar/empty 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirisajar/sub.jar/empty 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirnotajar/sub/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirnotajar/sub/empty 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/jar/subdirnotajar/sub/empty 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directory.war/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directory.war/empty 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directory.war/empty 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorynotawar/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorynotawar/empty 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorynotawar/empty 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/empty 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/empty 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/notanarchive/notanarchive.war
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/notanarchive/notanarchive.war 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/notanarchive/notanarchive.war 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/simple/simple.war
===================================================================
(Binary files differ)
Property changes on: projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/simple/simple.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -27,10 +27,10 @@
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.test.BaseTestCase;
-import org.jboss.vfs.VFSFactory;
-import org.jboss.vfs.VFSFactoryLocator;
-import org.jboss.vfs.spi.ReadOnlyVFS;
-import org.jboss.vfs.spi.VirtualFile;
+import org.jboss.util.NotImplementedException;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
/**
* BaseDeployersTest.
@@ -45,15 +45,95 @@
super(name);
}
+ @Override
+ public URL getResource(String path)
+ {
+ URL url = super.getResource(path);
+ assertNotNull("Resource not found: " + path, url);
+ return url;
+ }
+
+ /**
+ * Get a virtual file
+ *
+ * @param root the root
+ * @param path the path
+ * @return the file
+ * @throws Exception for any error
+ */
protected VirtualFile getVirtualFile(String root, String path) throws Exception
{
URL url = getResource(root);
- assertNotNull(url);
- VFSFactory factory = VFSFactoryLocator.getFactory(url);
- ReadOnlyVFS vfs = factory.getVFS(url);
- return vfs.resolveFile(path);
+ return VFS.getVirtualFile(url, path);
}
+ /**
+ * Get a url string from a path
+ *
+ * @param path the path
+ * @return the string
+ * @throws Exception for any error
+ */
+ protected String getURL(String path) throws Exception
+ {
+ URL url = getResource(path);
+ return url.toString();
+ }
+
+ /**
+ * Get a jar url string from a path
+ *
+ * @param path the path
+ * @return the string
+ * @throws Exception for any error
+ */
+ protected String getJarURL(String path) throws Exception
+ {
+ URL url = getResource(path);
+ url = JarUtils.createJarURL(url);
+ return url.toString();
+ }
+
+ protected boolean determineStructure(DeploymentContext context) throws Exception
+ {
+ throw new NotImplementedException("Implemented in subclasses");
+ }
+
+ /**
+ * Assert non of the candidates are valid
+ *
+ * @param context the context
+ * @throws Exception for any error
+ */
+ protected void assertCandidatesNotValid(DeploymentContext context) throws Exception
+ {
+ assertNotNull(context);
+
+ for (DeploymentContext child : context.getChildren())
+ assertFalse("Should not be a valid candidate: " + child.getName(), determineStructure(child));
+ }
+
+ /**
+ * Assert the candidates are valid
+ *
+ * @param context the context
+ * @throws Exception for any error
+ */
+ protected void assertCandidatesValid(DeploymentContext context) throws Exception
+ {
+ assertNotNull(context);
+
+ for (DeploymentContext child : context.getChildren())
+ assertTrue("Should be a valid candidate: " + child.getName(), determineStructure(child));
+ }
+
+ /**
+ * Assert the contexts match the expected urls
+ *
+ * @param expected the expected
+ * @param actual the actual
+ * @throws Exception for any error
+ */
protected void assertContexts(Set<String> expected, Set<DeploymentContext> actual) throws Exception
{
assertNotNull(expected);
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.
*
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.
*
@@ -26,6 +26,7 @@
import junit.textui.TestRunner;
import org.jboss.test.deployers.structure.jar.test.JARStructureUnitTestCase;
+import org.jboss.test.deployers.structure.war.test.WARStructureUnitTestCase;
/**
* Structure Test Suite.
@@ -45,6 +46,7 @@
TestSuite suite = new TestSuite("Structure Tests");
suite.addTest(JARStructureUnitTestCase.suite());
+ suite.addTest(WARStructureUnitTestCase.suite());
return suite;
}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.
*
@@ -27,21 +27,23 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.jboss.deployers.plugins.structure.vfs.AbstractVFSDeploymentContext;
-import org.jboss.deployers.plugins.structure.vfs.JARStructure;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
import org.jboss.deployers.spi.structure.DeploymentContext;
-import org.jboss.deployers.spi.structure.vfs.VFSDeploymentContext;
import org.jboss.test.deployers.BaseDeployersTest;
-import org.jboss.vfs.spi.VirtualFile;
+import org.jboss.virtual.VirtualFile;
/**
- * A ChangeAutomaticControllerTestCase.
+ * JARStructureUnitTestCase.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 37459 $
+ * @version $Revision: 1.1 $
*/
public class JARStructureUnitTestCase extends BaseDeployersTest
{
+ /** The jar structure deployer */
+ private static final JARStructure structure = new JARStructure();
+
public static Test suite()
{
return new TestSuite(JARStructureUnitTestCase.class);
@@ -52,46 +54,129 @@
super(name);
}
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ enableTrace("org.jboss.deployers");
+ }
+
+ protected boolean determineStructure(DeploymentContext context)
+ {
+ log.debug("Determining structure: " + context.getName());
+ return structure.determineStructure(context);
+ }
+
+ protected DeploymentContext getValidContext(String root, String path) throws Exception
+ {
+ VirtualFile file = getVirtualFile(root, path);
+ DeploymentContext context = new AbstractDeploymentContext(file);
+ assertTrue("Structure should be valid: " + file, determineStructure(context));
+ return context;
+ }
+
+ protected DeploymentContext assertValidContext(String root, String path) throws Exception
+ {
+ return getValidContext(root, path);
+ }
+
+ protected DeploymentContext assertNotValidContext(String root, String path) throws Exception
+ {
+ VirtualFile file = getVirtualFile(root, path);
+ DeploymentContext context = new AbstractDeploymentContext(file);
+ assertFalse("Structure should not be valid: " + file, determineStructure(context));
+ assertEmpty(context.getChildren());
+ return context;
+ }
+
public void testSimple() throws Exception
{
- JARStructure structure = new JARStructure();
- VirtualFile file = getVirtualFile("/structure/", "jar/simple");
- AbstractVFSDeploymentContext context = new AbstractVFSDeploymentContext(file);
- assertTrue(structure.determineStructure(context));
+ DeploymentContext context = getValidContext("/structure/", "jar/simple");
// Test it got all the candidates
Set<String> expected = new HashSet<String>();
- expected.add(getResource("/structure/jar/simple/NotAnArchive.jar").toString());
- expected.add(getResource("/structure/jar/simple/NotAnArchive.zip").toString());
- expected.add(getResource("/structure/jar/simple/simple.txt").toString());
+ expected.add(getURL("/structure/jar/simple/simple1.txt"));
+ expected.add(getURL("/structure/jar/simple/simple2.txt"));
assertContexts(expected, context.getChildren());
+
+ assertCandidatesNotValid(context);
+ }
+
+ public void testRootNotAnArchive() throws Exception
+ {
+ assertNotValidContext("/structure/", "jar/notanarchive/NotAnArchive.jar");
+ assertNotValidContext("/structure/", "jar/notanarchive/NotAnArchive.zip");
+ }
+
+ public void testSubdeploymentNotAnArchive() throws Exception
+ {
+ DeploymentContext context = getValidContext("/structure/", "jar/notanarchive");
- // Test none of the candidates work
- for (DeploymentContext child : context.getChildren())
- {
- VFSDeploymentContext vfsContext = (VFSDeploymentContext) child;
- assertFalse(structure.determineStructure(vfsContext));
- }
+ // Test it got all the candidates
+ Set<String> expected = new HashSet<String>();
+ expected.add(getURL("/structure/jar/notanarchive/NotAnArchive.jar"));
+ expected.add(getURL("/structure/jar/notanarchive/NotAnArchive.zip"));
+ assertContexts(expected, context.getChildren());
+
+ assertCandidatesNotValid(context);
}
- public void testNested() throws Exception
+ public void testJarAsRoot() throws Exception
{
- JARStructure structure = new JARStructure();
- VirtualFile file = getVirtualFile("/structure/", "jar/nested");
- AbstractVFSDeploymentContext context = new AbstractVFSDeploymentContext(file);
- assertTrue(structure.determineStructure(context));
+ assertValidContext("/structure/", "jar/indirectory/archive.jar");
+ assertValidContext("/structure/", "jar/indirectory/archive.zip");
+ }
+
+ public void testJarInDirectory() throws Exception
+ {
+ DeploymentContext context = getValidContext("/structure/", "jar/indirectory");
// Test it got all the candidates
Set<String> expected = new HashSet<String>();
- expected.add(getResource("/structure/jar/nested/archive.jar").toString());
- expected.add(getResource("/structure/jar/nested/archive.zip").toString());
+ expected.add(getJarURL("/structure/jar/indirectory/archive.jar").toString());
+ expected.add(getJarURL("/structure/jar/indirectory/archive.zip").toString());
assertContexts(expected, context.getChildren());
- // Test all of the candidates work
- for (DeploymentContext child : context.getChildren())
- {
- VFSDeploymentContext vfsContext = (VFSDeploymentContext) child;
- assertTrue("Should be valid " + child.getName(), structure.determineStructure(vfsContext));
- }
+ assertCandidatesValid(context);
}
+
+ public void testSubdirectoryNotAJar() throws Exception
+ {
+ DeploymentContext context = getValidContext("/structure/", "jar/subdirnotajar");
+
+ // Test it got all the candidates
+ Set<String> expected = new HashSet<String>();
+ expected.add(getURL("/structure/jar/subdirnotajar/sub").toString());
+ assertContexts(expected, context.getChildren());
+
+ assertCandidatesNotValid(context);
+ }
+
+ public void testSubdirectoryIsAJar() throws Exception
+ {
+ DeploymentContext context = getValidContext("/structure/", "jar/subdirisajar");
+
+ // Test it got all the candidates
+ Set<String> expected = new HashSet<String>();
+ expected.add(getURL("/structure/jar/subdirisajar/sub.jar").toString());
+ assertContexts(expected, context.getChildren());
+
+ assertCandidatesValid(context);
+ }
+
+ public void testdirectoryHasMetaInf() throws Exception
+ {
+ assertValidContext("/structure/", "jar/subdirhasmetainf/sub");
+ }
+
+ public void testSubdirectoryHasMetaInf() throws Exception
+ {
+ DeploymentContext context = getValidContext("/structure/", "jar/subdirhasmetainf");
+
+ // Test it got all the candidates
+ Set<String> expected = new HashSet<String>();
+ expected.add(getURL("/structure/jar/subdirhasmetainf/sub").toString());
+ assertContexts(expected, context.getChildren());
+
+ assertCandidatesValid(context);
+ }
}
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java 2006-09-07 10:55:56 UTC (rev 56610)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java 2006-09-07 12:24:00 UTC (rev 56611)
@@ -0,0 +1,108 @@
+/*
+* 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.war.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * WARStructureUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class WARStructureUnitTestCase extends BaseDeployersTest
+{
+ /** The war structure deployer */
+ private static final WARStructure structure = new WARStructure();
+
+ public static Test suite()
+ {
+ return new TestSuite(WARStructureUnitTestCase.class);
+ }
+
+ public WARStructureUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ enableTrace("org.jboss.deployers");
+ }
+
+ protected boolean determineStructure(DeploymentContext context)
+ {
+ log.debug("Determining structure: " + context.getName());
+ return structure.determineStructure(context);
+ }
+
+ protected DeploymentContext assertValidContext(String root, String path) throws Exception
+ {
+ VirtualFile file = getVirtualFile(root, path);
+ DeploymentContext context = new AbstractDeploymentContext(file);
+ assertTrue("Structure should be valid: " + file, determineStructure(context));
+ assertEmpty(context.getChildren());
+ return context;
+ }
+
+ protected DeploymentContext assertNotValidContext(String root, String path) throws Exception
+ {
+ VirtualFile file = getVirtualFile(root, path);
+ DeploymentContext context = new AbstractDeploymentContext(file);
+ assertFalse("Structure should not be valid: " + file, determineStructure(context));
+ assertEmpty(context.getChildren());
+ return context;
+ }
+
+ public void testSimple() throws Exception
+ {
+ assertValidContext("/structure/", "war/simple/simple.war");
+ }
+
+ public void testNotAnArchive() throws Exception
+ {
+ assertNotValidContext("/structure/", "war/notanarchive/notanarchive.war");
+ }
+
+ public void testWarDirectory() throws Exception
+ {
+ assertValidContext("/structure/", "war/directory.war");
+ }
+
+ public void testDirectoryNotAWar() throws Exception
+ {
+ assertNotValidContext("/structure/", "war/directorynotawar");
+ }
+
+ public void testDirectoryWithWebInf() throws Exception
+ {
+ assertValidContext("/structure/", "war/directorywithwebinf");
+ }
+}
More information about the jboss-cvs-commits
mailing list