[jboss-cvs] JBossAS SVN: r57836 - 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/explicit main/org/jboss/deployers/plugins/structure/vfs/file main/org/jboss/deployers/plugins/structure/vfs/jar main/org/jboss/deployers/plugins/structure/vfs/war main/org/jboss/deployers/spi main/org/jboss/deployers/spi/deployer main/org/jboss/deployers/spi/structure/vfs resources/tests/structure/explicit resources/tests/structure/explicit/complex.jar resources/tests/structure/explicit/complex.jar/META-INF resources/tests/structure/explicit/complex.jar/lib-dir resources/tests/structure/explicit/complex.jar/sub.jar resources/tests/structure/explicit/complex.jar/x.war resources/tests/structure/explicit/complex.jar/x.war/WEB-INF resources/tests/structure/explicit/complex.jar/x.wa! r/WEB-INF/lib resources/tests/structure/war/directorywithwebinf/WEB-INF resources/tests/structure/war/directorywithwebinf/WEB-INF/lib tests/org/jboss/test/deployers tests/org/jboss/test/deployers/structure/explicit/test tests/org/jboss/test/deployers/structure/file/test tests/org/jboss/test/deployers/structure/jar/test tests/org/jboss/test/deployers/structure/main/support tests/org/jboss/test/deployers/structure/main/test tests/org/jboss/test/deployers/structure/war/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 25 19:12:45 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-10-25 19:12:12 -0400 (Wed, 25 Oct 2006)
New Revision: 57836
Added:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/BasicStructuredDeployers.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ClassPathInfoImpl.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ContextInfoImpl.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilder.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilderFactory.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataFilter.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataImpl.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/OrderedDeployer.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ClassPathInfo.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ContextInfo.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilder.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilderFactory.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureMetaData.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructuredDeployers.java
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/META-INF/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/META-INF/jboss-structure.xml
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/jar1.jar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/lib-dir/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/lib-dir/j0.jar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/sub.jar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/sub.jar/empty
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/x.war/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/x.war/WEB-INF/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/x.war/WEB-INF/lib/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/x.war/WEB-INF/lib/w0.jar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/classes/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/lib/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/lib/j0.jar/
projects/microcontainer/trunk/deployers/src/resources/tests/structure/war/directorywithwebinf/WEB-INF/lib/j1.jar/
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/StructureMetaDataUnitTestCase.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/StructureUnitTestCase.java
Removed:
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/StructureMetaData.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataFileVisitor.java
Modified:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.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/vfs/AbstractCandidateStructureVisitor.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/CandidateStructureVisitorFactory.java
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/explicit/DeclaredStructure.java
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/file/FileStructure.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitor.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitorFactory.java
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/WARStructure.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.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/structure/explicit/test/DeclaredStructureUnitTestCase.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/FileStructureUnitTestCase.java
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/main/support/TestStructureDeployer.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureOrdering.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java
Log:
Break out the structure deployer into a phase that creates StructureMetaData rather than DeploymentContexts
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -35,7 +35,8 @@
{
/** The log */
protected Logger log = Logger.getLogger(this.getClass());
-
+ private int relativeOrder = Integer.MAX_VALUE;
+
public boolean isRelevant(DeploymentUnit unit)
{
return true;
@@ -43,6 +44,10 @@
public int getRelativeOrder()
{
- return Integer.MAX_VALUE;
+ return relativeOrder;
}
+ public void setRelativeOrder(int order)
+ {
+ this.relativeOrder = order;
+ }
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -176,6 +176,10 @@
{
return deployer.getRelativeOrder();
}
+ public void setRelativeOrder(int order)
+ {
+ deployer.setRelativeOrder(order);
+ }
@Override
public boolean equals(Object obj)
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-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -45,13 +45,17 @@
import org.jboss.deployers.plugins.deployer.AbstractDeploymentUnit;
import org.jboss.deployers.plugins.deployer.DeployerWrapper;
-import org.jboss.deployers.plugins.structure.vfs.StructureDeployerWrapper;
+import org.jboss.deployers.plugins.structure.BasicStructuredDeployers;
+import org.jboss.deployers.plugins.structure.DefaultStructureBuilder;
+import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.Deployer;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
import org.jboss.deployers.spi.deployment.MainDeployer;
import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureBuilder;
import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
import org.jboss.logging.Logger;
import org.jboss.virtual.VirtualFile;
@@ -72,8 +76,11 @@
private AtomicBoolean shutdown = new AtomicBoolean(false);
/** The structure deployers */
- private SortedSet<StructureDeployer> structureDeployers = new TreeSet<StructureDeployer>(StructureDeployer.COMPARATOR);
+ private BasicStructuredDeployers structureDeployers = new BasicStructuredDeployers();
+ /** The structure builder that translates structure metadata to deployments */
+ private StructureBuilder structureBuilder = new DefaultStructureBuilder();
+
/** The deployers */
private SortedSet<Deployer> deployers = new TreeSet<Deployer>(Deployer.COMPARATOR);
@@ -102,9 +109,10 @@
*/
public synchronized Set<StructureDeployer> getStructureDeployers()
{
- return new TreeSet<StructureDeployer>(structureDeployers);
+ SortedSet<StructureDeployer> sdeployers = structureDeployers.getDeployers();
+ return sdeployers;
}
-
+
/**
* Set the structure deployers
*
@@ -115,18 +123,7 @@
{
if (deployers == null)
throw new IllegalArgumentException("Null deployers");
-
- // Remove all the old deployers that are not in the new set
- HashSet<StructureDeployer> oldDeployers = new HashSet<StructureDeployer>(structureDeployers);
- oldDeployers.removeAll(deployers);
- for (StructureDeployer deployer : oldDeployers)
- removeStructureDeployer(deployer);
-
- // Add all the new deployers that were not already present
- HashSet<StructureDeployer> newDeployers = new HashSet<StructureDeployer>(deployers);
- newDeployers.removeAll(structureDeployers);
- for (StructureDeployer deployer : newDeployers)
- addStructureDeployer(deployer);
+ structureDeployers.setDeployers(deployers);
}
/**
@@ -138,8 +135,7 @@
{
if (deployer == null)
throw new IllegalArgumentException("Null deployer");
- StructureDeployerWrapper wrapper = new StructureDeployerWrapper(deployer);
- structureDeployers.add(wrapper);
+ structureDeployers.addDeployer(deployer);
// TODO recheck failed deployments
log.debug("Added structure deployer: " + deployer);
}
@@ -153,7 +149,7 @@
{
if (deployer == null)
throw new IllegalArgumentException("Null deployer");
- structureDeployers.remove(deployer);
+ structureDeployers.removeDeployer(deployer);
log.debug("Remove structure deployer: " + deployer);
// TODO remove deployments for this structure?
}
@@ -227,7 +223,16 @@
throw new IllegalArgumentException("Null name");
return allDeployments.get(name);
}
-
+
+ public StructureBuilder getStructureBuilder()
+ {
+ return structureBuilder;
+ }
+ public void setStructureBuilder(StructureBuilder builder)
+ {
+ this.structureBuilder = builder;
+ }
+
public synchronized void addDeploymentContext(DeploymentContext context) throws DeploymentException
{
if (context == null)
@@ -502,7 +507,8 @@
*
* @param context the context
*/
- private void determineStructure(DeploymentContext context) throws DeploymentException
+ private void determineStructure(DeploymentContext context)
+ throws DeploymentException
{
if (context.getStructureDetermined() == PREDETERMINED)
return;
@@ -510,17 +516,22 @@
if (context.getRoot() == null)
throw new DeploymentException("Unable to determine structure context has not root " + context.getName());
- StructureDeployer[] theDeployers;
synchronized (this)
{
if (structureDeployers.isEmpty())
throw new IllegalStateException("No structure deployers");
- theDeployers = structureDeployers.toArray(new StructureDeployer[structureDeployers.size()]);
}
+ VirtualFile root = context.getRoot();
- determineStructure(context, theDeployers);
+ // TODO: does the StructureMetaData impl need to be externalized?
+ StructureMetaData metaData = new StructureMetaDataImpl();
+ boolean result = structureDeployers.determineStructure(root, metaData);
+ if (result == false)
+ throw new DeploymentException("No structural deployer recognised the deployment. " + context.getName());
+ // Build the deployment context from the structure metadata
+ structureBuilder.populateContext(context, metaData);
}
-
+
/**
* Determine the structure
*
@@ -528,17 +539,16 @@
* @param theDeployers the deployers
* @return true when determined
* @throws DeploymentException for any problem
- */
- private boolean determineStructure(DeploymentContext context, StructureDeployer[] theDeployers) throws DeploymentException
+ private boolean determineStructure(DeploymentContext context) throws DeploymentException
{
boolean trace = log.isTraceEnabled();
if (trace)
log.trace("Trying to determine structure: " + context.getName());
- boolean result = false;
+ boolean result = this.structureDeployers.determineStructure(context);
for (StructureDeployer deployer : theDeployers)
{
- if (deployer.determineStructure(context))
+ if (deployer.determineStructure(context, deployers))
{
result = true;
break;
@@ -560,6 +570,7 @@
return result;
}
+ */
/**
* Add a context
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/BasicStructuredDeployers.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/BasicStructuredDeployers.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/BasicStructuredDeployers.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,131 @@
+/*
+ * 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;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A basic StructuredDeployers implementation.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BasicStructuredDeployers
+ implements StructuredDeployers
+{
+
+ private SortedSet<StructureDeployer> structureDeployers;
+
+ public BasicStructuredDeployers()
+ {
+ this(new TreeSet<StructureDeployer>(StructureDeployer.COMPARATOR));
+ }
+ public BasicStructuredDeployers(SortedSet<StructureDeployer> structureDeployers)
+ {
+ this.structureDeployers = structureDeployers;
+ }
+
+ public boolean isEmpty()
+ {
+ return structureDeployers == null ? true : structureDeployers.isEmpty();
+ }
+
+ public boolean determineStructure(VirtualFile file, StructureMetaData metaData)
+ throws DeploymentException
+ {
+ StructureDeployer[] theDeployers;
+ synchronized (this)
+ {
+ if (structureDeployers.isEmpty())
+ throw new IllegalStateException("No structure deployers");
+
+ theDeployers = structureDeployers.toArray(new StructureDeployer[structureDeployers.size()]);
+ }
+
+ boolean result = false;
+ for (StructureDeployer deployer : theDeployers)
+ {
+ if (deployer.determineStructure(file, metaData, this))
+ {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get the
+ */
+ public SortedSet<StructureDeployer> getDeployers()
+ {
+ return structureDeployers;
+ }
+ public void setDeployers(Set<StructureDeployer> deployers)
+ {
+ // Remove all the old deployers that are not in the new set
+ HashSet<StructureDeployer> oldDeployers = new HashSet<StructureDeployer>(structureDeployers);
+ oldDeployers.removeAll(deployers);
+ for (StructureDeployer deployer : oldDeployers)
+ removeDeployer(deployer);
+
+ // Add all the new deployers that were not already present
+ HashSet<StructureDeployer> newDeployers = new HashSet<StructureDeployer>(deployers);
+ newDeployers.removeAll(structureDeployers);
+ for (StructureDeployer deployer : newDeployers)
+ addDeployer(deployer);
+ }
+
+ /**
+ * Add a structure deployer
+ *
+ * @param deployer the deployer
+ */
+ public synchronized void addDeployer(StructureDeployer deployer)
+ {
+ if (deployer == null)
+ throw new IllegalArgumentException("Null deployer");
+ structureDeployers.add(deployer);
+ }
+
+ /**
+ * Remove a structure deployer
+ *
+ * @param deployer the deployer
+ */
+ public synchronized void removeDeployer(StructureDeployer deployer)
+ {
+ if (deployer == null)
+ throw new IllegalArgumentException("Null deployer");
+ structureDeployers.remove(deployer);
+ }
+
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ClassPathInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ClassPathInfoImpl.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ClassPathInfoImpl.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,88 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.structure.vfs.ClassPathInfo;
+
+/**
+ * A representation of a classpath element. This is a vfs relative path to
+ * the root of the deployment its associated with.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ClassPathInfoImpl implements ClassPathInfo
+{
+ private String path;
+ private HashMap options = new HashMap();
+
+ public ClassPathInfoImpl()
+ {
+ this(null);
+ }
+ public ClassPathInfoImpl(String path)
+ {
+ this.path = path;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+
+ public Object getOption(Object key)
+ {
+ return options.get(key);
+ }
+
+ public Map getOptions()
+ {
+ return options;
+ }
+
+ public void setOption(Object key, Object value)
+ {
+ options.put(key, value);
+ }
+
+ public void setOptions(Map options)
+ {
+ this.options.clear();
+ this.options.putAll(options);
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder();
+ tmp.append("ClassPathInfo(");
+ tmp.append(path);
+ tmp.append(')');
+ return tmp.toString();
+ }
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ContextInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ContextInfoImpl.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ContextInfoImpl.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,106 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.structure.vfs.ClassPathInfo;
+import org.jboss.deployers.spi.structure.vfs.ContextInfo;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ContextInfoImpl
+ implements ContextInfo
+{
+ private String vfsPath;
+ private String metaDataPath;
+ private ContextInfo parent;
+ private ArrayList<ClassPathInfo> classpath = new ArrayList<ClassPathInfo>();
+
+ public ContextInfoImpl()
+ {
+ this(null);
+ }
+ public ContextInfoImpl(String vfsPath)
+ {
+ setVfsPath(vfsPath);
+ }
+ public ContextInfoImpl(String vfsPath, ContextInfo parent)
+ {
+ setVfsPath(vfsPath);
+ setParent(parent);
+ }
+
+ public ContextInfo getParent()
+ {
+ return parent;
+ }
+ public void setParent(ContextInfo parent)
+ {
+ this.parent = parent;
+ }
+
+ public String getVfsPath()
+ {
+ return vfsPath;
+ }
+ public void setVfsPath(String path)
+ {
+ this.vfsPath = path;
+ }
+
+ public String getMetaDataPath()
+ {
+ return metaDataPath;
+ }
+ public void setMetaDataPath(String metaDataPath)
+ {
+ this.metaDataPath = metaDataPath;
+ }
+
+ public List<ClassPathInfo> getClassPath()
+ {
+ return classpath;
+ }
+ public void setClassPath(List<ClassPathInfo> classpath)
+ {
+ this.classpath.clear();
+ this.classpath.addAll(classpath);
+ }
+ public void addClassPathInfo(ClassPathInfo info)
+ {
+ classpath.add(info);
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder(super.toString());
+ tmp.append('(');
+ tmp.append(this.getVfsPath());
+ tmp.append(')');
+ return tmp.toString();
+ }
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilder.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilder.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,168 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.ClassPathInfo;
+import org.jboss.deployers.spi.structure.vfs.ContextInfo;
+import org.jboss.deployers.spi.structure.vfs.StructureBuilder;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
+
+/**
+ * The default StructureBuilder. It translates a
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DefaultStructureBuilder
+ implements StructureBuilder
+{
+ private static Logger log = Logger.getLogger(DefaultStructureBuilder.class);
+ private HashMap<String, DeploymentContext> contextMap = new HashMap<String, DeploymentContext>();
+
+ public void populateContext(DeploymentContext context, StructureMetaData metaData)
+ throws DeploymentException
+ {
+ // Validate that the root file has a valid ContextInfo
+ VirtualFile root = context.getRoot();
+ ContextInfo rootInfo = metaData.getContext(root.getPathName());
+ if( rootInfo == null )
+ throw new DeploymentException("Failed to find ContextInfo for context root: "+root);
+
+ // Process the context from the root down
+ VFS vfs = root.getVFS();
+ contextMap.put(root.getPathName(), context);
+ try
+ {
+ for(ContextInfo info : metaData.getContexts())
+ {
+ String vfsPath = info.getVfsPath();
+ VirtualFile vf = vfs.findChild(vfsPath);
+ ContextInfo parentInfo = info.getParent();
+ String parentPath = parentInfo != null ? parentInfo.getVfsPath() : "";
+ DeploymentContext ctx = contextMap.get(vfsPath);
+ DeploymentContext parent = contextMap.get(parentPath);
+ if( ctx == null )
+ {
+ if( parent != null )
+ {
+ ctx = new AbstractDeploymentContext(vf, true, parent);
+ parent.addChild(ctx);
+ }
+ else
+ ctx = new AbstractDeploymentContext(vf);
+ }
+ processContext(ctx, vf, info);
+ }
+ }
+ catch(Exception e)
+ {
+ throw new DeploymentException("Failed to process context: "+context.getName(), e);
+ }
+ }
+
+ protected void processContext(DeploymentContext context, VirtualFile virtualFile, ContextInfo info)
+ {
+ boolean trace = log.isTraceEnabled();
+ if( trace )
+ log.trace("Processing context: "+context+", info: "+info);
+ String metaDataPath = info.getMetaDataPath();
+ if( metaDataPath != null && metaDataPath.length() > 0 )
+ context.setMetaDataPath(metaDataPath);
+ ArrayList<VirtualFile> paths = new ArrayList<VirtualFile>();
+ List<ClassPathInfo> classPath = info.getClassPath();
+ if( classPath != null )
+ {
+ for(ClassPathInfo cp : classPath)
+ {
+ try
+ {
+ VirtualFile child = virtualFile.findChild(cp.getPath());
+ String suffixesOpt = (String) cp.getOption("suffixes");
+ String[] suffixes = null;
+ if( suffixesOpt != null )
+ suffixes = suffixesOpt.split(",");
+ // 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
+ if( virtualFile.isLeaf() == false )
+ VFSUtils.addManifestLocations(virtualFile, paths);
+ }
+ catch(IOException ignore)
+ {
+ }
+ // Set the classpath
+ if( paths.size() > 0 )
+ context.setClassPath(paths);
+ // Add the context to the vfs path to context map
+ contextMap.put(virtualFile.getPathName(), context);
+ }
+
+}
Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilder.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilderFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilderFactory.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/DefaultStructureBuilderFactory.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import org.jboss.deployers.spi.structure.vfs.StructureBuilder;
+import org.jboss.deployers.spi.structure.vfs.StructureBuilderFactory;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DefaultStructureBuilderFactory
+ implements StructureBuilderFactory
+{
+
+ public StructureBuilder createBuilder(StructureMetaData metaData)
+ {
+ return new DefaultStructureBuilder();
+ }
+
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataFilter.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataFilter.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataFilter.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+import org.jboss.deployers.spi.structure.vfs.ContextInfo;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StructureMetaDataFilter implements VirtualFileFilter
+{
+ private StructureMetaData metaData;
+
+ public StructureMetaDataFilter(StructureMetaData metaData)
+ {
+ this.metaData = metaData;
+ }
+
+ /**
+ * Accept a file for which the StructureMetaData
+ * @return true if the file has a ContextInfo
+ */
+ public boolean accepts(VirtualFile file)
+ {
+ ContextInfo info = metaData.getContext(file.getPathName());
+ return info != null;
+ }
+
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataImpl.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataImpl.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -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;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.jboss.deployers.spi.structure.vfs.ContextInfo;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+
+/**
+ * Metadata describing the structure of a deployment.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StructureMetaDataImpl implements StructureMetaData
+{
+ private HashMap<String, ContextInfo> contextMap =
+ new HashMap<String, ContextInfo>();
+ private TreeSet<ContextInfo> contextSet = new TreeSet<ContextInfo>(new ContextComparator());
+
+ public void addContext(ContextInfo context)
+ {
+ String key = context.getVfsPath();
+ contextMap.put(key, context);
+ ContextInfo parent = context.getParent();
+ // If the parent has not been set try to find it
+ if( parent == null )
+ {
+ String[] keys = key.split("/");
+ StringBuilder parentKey = new StringBuilder();
+ for(int n = 0; n < keys.length-1; n ++)
+ {
+ key = keys[n];
+ parentKey.append(key);
+ parent = contextMap.get(parentKey.toString());
+ if( parent != null )
+ context.setParent(parent);
+ parentKey.append('/');
+ }
+ }
+ contextSet.add(context);
+ }
+
+ public ContextInfo getContext(String vfsPath)
+ {
+ return contextMap.get(vfsPath);
+ }
+
+ public ContextInfo removeContext(String vfsPath)
+ {
+ return contextMap.remove(vfsPath);
+ }
+
+ public SortedSet<ContextInfo> getContexts()
+ {
+ return contextSet;
+ }
+
+ private class ContextComparator implements Comparator<ContextInfo>
+ {
+ public int compare(ContextInfo o1, ContextInfo o2)
+ {
+ int compare = 0;
+ if( o1 == null && o2 != null )
+ compare = -1;
+ else if( o1 != null && o2 == null )
+ compare = 1;
+ else
+ {
+ // Sort by depth and then name
+ ContextInfo p1 = o1.getParent();
+ ContextInfo p2 = o2.getParent();
+ if( p1 != p2 )
+ {
+ compare = compare(p1, p2);
+ }
+ else if( p1 != null )
+ {
+ compare = o1.getVfsPath().compareTo(o2.getVfsPath());
+ }
+ }
+ return compare;
+ }
+ }
+}
Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/StructureMetaDataImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractCandidateStructureVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractCandidateStructureVisitor.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractCandidateStructureVisitor.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -23,9 +23,9 @@
import java.io.IOException;
-import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
-import org.jboss.deployers.plugins.structure.vfs.jar.JARCandidateStructureVisitor;
-import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.ContextInfo;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
import org.jboss.logging.Logger;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
@@ -43,11 +43,12 @@
/** The log */
private static final Logger log = Logger.getLogger(AbstractCandidateStructureVisitor.class);
- /** The parent deployment context */
- private final DeploymentContext parent;
+ /** The parent deployment file */
+ private final VirtualFile parent;
/** The meta data location */
- private final String metaDataPath;
+ private final StructureMetaData metaData;
+ private final StructuredDeployers deployers;
/** Ignore directories */
private boolean ignoreDirectories;
@@ -61,9 +62,9 @@
* @param parent the parent
* @throws IllegalArgumentException for a null parent
*/
- public AbstractCandidateStructureVisitor(DeploymentContext parent)
+ public AbstractCandidateStructureVisitor(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers)
{
- this(parent, null);
+ this(parent, metaData, deployers, null);
}
/**
@@ -73,25 +74,22 @@
* @param attributes the attributes
* @throws IllegalArgumentException for a null parent
*/
- public AbstractCandidateStructureVisitor(DeploymentContext parent, VisitorAttributes attributes)
+ public AbstractCandidateStructureVisitor(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers, VisitorAttributes attributes)
{
super(attributes);
if (parent == null)
throw new IllegalArgumentException("Null parent");
this.parent = parent;
- VirtualFile metaDataLocation = parent.getMetaDataLocation();
- if (metaDataLocation != null)
- metaDataPath = metaDataLocation.getPathName();
- else
- metaDataPath = null;
+ this.metaData = metaData;
+ this.deployers = deployers;
}
-
+
/**
* Get the parent deployment context
*
* @return the parent.
*/
- public DeploymentContext getParent()
+ public VirtualFile getParent()
{
return parent;
}
@@ -136,41 +134,37 @@
this.ignoreDirectories = ignoreDirectories;
}
- public void visit(VirtualFile virtualFile)
+ public void visit(VirtualFile file)
{
- 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)
- {
- // Exclude the meta data location
- if (metaDataPath != null && virtualFile.getPathName().startsWith(metaDataPath))
- return null;
-
- // Ignore directories when asked
- try
+ ContextInfo context = metaData.getContext(file.getPathName());
+ if (context == null)
{
- if (ignoreDirectories && virtualFile.isLeaf() == false)
- return null;
+ // Ignore directories when asked
+ try
+ {
+ if (ignoreDirectories && file.isLeaf() == false)
+ return;
+ }
+ catch (IOException e)
+ {
+ log.debug("Ignoring " + file + " reason=" + e);
+ return;
+ }
+
+ // Apply any filter
+ if (filter != null && filter.accepts(file) == false)
+ return;
+
+ try
+ {
+ // Ask the deployers to process this file
+ deployers.determineStructure(file, metaData);
+ }
+ catch (Exception e)
+ {
+ log.debug("Ignoring " + file + " reason=" + e);
+ return;
+ }
}
- catch (IOException e)
- {
- log.debug("Ignoring " + virtualFile + " reason=" + e);
- return null;
- }
-
- // Apply any filter
- if (filter != null && filter.accepts(virtualFile) == false)
- return null;
-
- return new AbstractDeploymentContext(virtualFile, true, parent);
}
}
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-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -21,10 +21,19 @@
*/
package org.jboss.deployers.plugins.structure.vfs;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.plugins.structure.ClassPathInfoImpl;
import org.jboss.deployers.plugins.structure.vfs.jar.JARCandidateStructureVisitorFactory;
-import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.ClassPathInfo;
+import org.jboss.deployers.spi.structure.vfs.ContextInfo;
import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
import org.jboss.logging.Logger;
+import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileVisitor;
import org.jboss.virtual.VisitorAttributes;
@@ -41,14 +50,20 @@
{
/** The log */
protected Logger log = Logger.getLogger(getClass());
-
+ private int relativeOrder = Integer.MAX_VALUE;
+
/** The candidate structure visitor factory */
private CandidateStructureVisitorFactory candidateStructureVisitorFactory = JARCandidateStructureVisitorFactory.INSTANCE;
-
+
public int getRelativeOrder()
{
- return Integer.MAX_VALUE;
+ return relativeOrder;
}
+ public void setRelativeOrder(int order)
+ {
+ this.relativeOrder = order;
+ }
+
/**
* Get the candidateStructureVisitorFactory.
@@ -73,19 +88,86 @@
this.candidateStructureVisitorFactory = candidateStructureVisitorFactory;
}
- public abstract boolean determineStructure(DeploymentContext context);
-
+ public abstract boolean determineStructure(VirtualFile root,
+ StructureMetaData metaData, StructuredDeployers deployers);
+
/**
+ * See if a file corresponds to a top-level deployment.
+ *
+ * @param root
+ * @param metaData
+ * @return
+ */
+ public boolean isTopLevel(VirtualFile file, StructureMetaData metaData)
+ throws IOException
+ {
+ // See if this is a top-level by checking the parent
+ VirtualFile parent = file.getParent();
+ String parentPath = parent != null ? parent.getPathName() : null;
+ boolean isTopLevel = parentPath == null || metaData.getContext(parentPath) == null;
+ return isTopLevel;
+ }
+
+ /**
+ * Add an entry to the context classpath.
+ *
+ * @param root - the root file the classpath entry should be relative to
+ * @param entry - the candidate file to add as a classpath entry
+ * @param includeEntry - a flag indicating if the entry should be added to
+ * the classpath
+ * @param includeRootManifestCP - a flag indicating if the entry metainf
+ * manifest classpath should be included.
+ * @param context - the context to populate
+ * @throws IOException
+ */
+ protected void addClassPath(VirtualFile root, VirtualFile entry,
+ boolean includeEntry, boolean includeRootManifestCP,
+ ContextInfo context)
+ throws IOException
+ {
+ // Add the manifest locations
+ List<VirtualFile> paths = new ArrayList<VirtualFile>();
+ if( includeEntry )
+ paths.add(entry);
+ String rootPath = root.getPathName();
+ if( includeRootManifestCP )
+ {
+ VFSUtils.addManifestLocations(entry, paths);
+ }
+ // Add to any existing classpath
+ List<ClassPathInfo> pathInfo = new ArrayList<ClassPathInfo>();
+ if( context.getClassPath() != null )
+ pathInfo.addAll(context.getClassPath());
+ // Translate from VirtualFile to root relative paths
+ for(VirtualFile vf : paths)
+ {
+ // Set the path relative to the root
+ String cp = vf.getPathName();
+ if( cp.startsWith(rootPath) )
+ {
+ if( cp.length() == rootPath.length() )
+ cp = "";
+ else
+ cp = cp.substring(rootPath.length()+1);
+ }
+ ClassPathInfoImpl cpi = new ClassPathInfoImpl(cp);
+ pathInfo.add(cpi);
+ }
+ context.setClassPath(pathInfo);
+ }
+
+ /**
* Add all children as candidates
*
* @param parent the parent context
* @throws Exception for any error
*/
- protected void addAllChildren(DeploymentContext parent) throws Exception
+ protected void addAllChildren(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers)
+ throws Exception
{
- addChildren(parent, null);
+ addChildren(parent, metaData, deployers, null);
}
-
+
/**
* Add all children as candidates
*
@@ -93,13 +175,13 @@
* @param attributes the visitor attributes uses {@link VisitorAttributes#DEFAULT} when null
* @throws Exception for any error
*/
- protected void addChildren(DeploymentContext parent, VisitorAttributes attributes) throws Exception
+ protected void addChildren(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers,
+ VisitorAttributes attributes) throws Exception
{
if (parent == null)
throw new IllegalArgumentException("Null parent");
- VirtualFileVisitor visitor = candidateStructureVisitorFactory.createVisitor(parent, attributes);
- VirtualFile root = parent.getRoot();
- root.visit(visitor);
+ VirtualFileVisitor visitor = candidateStructureVisitorFactory.createVisitor(parent, metaData, deployers, attributes);
+ parent.visit(visitor);
}
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitorFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitorFactory.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitorFactory.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -21,7 +21,9 @@
*/
package org.jboss.deployers.plugins.structure.vfs;
-import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileVisitor;
import org.jboss.virtual.VisitorAttributes;
@@ -41,5 +43,6 @@
* @return the visitor
* @throws Exception for any error
*/
- VirtualFileVisitor createVisitor(DeploymentContext context, VisitorAttributes attributes) throws Exception;
+ VirtualFileVisitor createVisitor(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers,
+ VisitorAttributes attributes) throws Exception;
}
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-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -23,7 +23,10 @@
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
/**
* StructureDeployerWrapper.
@@ -54,26 +57,27 @@
log = Logger.getLogger(deployer.getClass());
}
- public boolean determineStructure(DeploymentContext context)
+ public boolean determineStructure(VirtualFile root,
+ StructureMetaData metaData, StructuredDeployers deployers)
{
- if (context == null)
- throw new IllegalArgumentException("Null context");
+ if (root == null)
+ throw new IllegalArgumentException("Null root");
try
{
- boolean result = deployer.determineStructure(context);
+ boolean result = deployers.determineStructure(root, metaData);
if (log.isTraceEnabled())
{
if (result == false)
- log.trace("Not recognised: " + context.getName());
+ log.trace("Not recognised: " + root.getName());
else
- log.trace("Recognised: " + context.getName());
+ log.trace("Recognised: " + root.getName());
}
return result;
}
catch (Throwable t)
{
- log.warn("Error during determineStructure: " + context.getName(), t);
+ log.warn("Error during determineStructure: " + root.getName(), t);
return false;
}
}
@@ -82,6 +86,10 @@
{
return deployer.getRelativeOrder();
}
+ public void setRelativeOrder(int order)
+ {
+ deployer.setRelativeOrder(order);
+ }
@Override
public boolean equals(Object obj)
Deleted: 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-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/ContextInfo.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.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;
- }
-}
Modified: 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-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/DeclaredStructure.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -1,100 +1,90 @@
-/*
-* 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;
- }
- }
-}
+/*
+* 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.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
+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
+{
+ private static ThreadLocal<StructureMetaData> activeMetaData
+ = new ThreadLocal<StructureMetaData>();
+
+ public DeclaredStructure()
+ {
+ }
+
+ /**
+ * Overriden to be the highest priority deployer
+ */
+ @Override
+ public int getRelativeOrder()
+ {
+ return 0;
+ }
+
+ public boolean determineStructure(VirtualFile root, StructureMetaData metaData, StructuredDeployers deployers)
+ {
+ try
+ {
+ if( root.isLeaf() == false )
+ {
+ 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();
+ unmarshaller.unmarshal(url.toString(), ofactory, metaData);
+ activeMetaData.set(metaData);
+ }
+ catch (IOException e)
+ {
+ log.trace("... no META-INF subdirectory.");
+ return false;
+ }
+ return true;
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("Error determining structure: " + root.getName(), e);
+ }
+ return false;
+ }
+}
Deleted: 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-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaData.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.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);
- }
-}
Deleted: 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-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataFileVisitor.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -1,117 +0,0 @@
-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);
- }
-}
Modified: 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-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/explicit/StructureMetaDataObjectFactory.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -23,6 +23,10 @@
import java.util.ArrayList;
+import org.jboss.deployers.plugins.structure.ClassPathInfoImpl;
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
+import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
+import org.jboss.deployers.spi.structure.vfs.ClassPathInfo;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
import org.xml.sax.Attributes;
@@ -35,14 +39,14 @@
*/
public class StructureMetaDataObjectFactory implements ObjectModelFactory
{
- public StructureMetaData newRoot(Object root, UnmarshallingContext navigator,
+ public StructureMetaDataImpl newRoot(Object root, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
{
- StructureMetaData metaData = null;
+ StructureMetaDataImpl metaData = null;
if (root != null)
- metaData = (StructureMetaData) root;
+ metaData = (StructureMetaDataImpl) root;
else
- metaData = new StructureMetaData();
+ metaData = new StructureMetaDataImpl();
return metaData;
}
@@ -53,22 +57,22 @@
return root;
}
- public Object newChild(StructureMetaData parent, UnmarshallingContext navigator,
+ public Object newChild(StructureMetaDataImpl parent, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
{
Object child = null;
if(localName.equals("context"))
{
- child = new ContextInfo();
+ child = new ContextInfoImpl();
}
return child;
}
- public Object newChild(ContextInfo parent, UnmarshallingContext navigator,
+ public Object newChild(ContextInfoImpl parent, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
{
Object child = null;
if (localName.equals("classpath"))
- child = new ArrayList<ContextInfo.Path>();
+ child = new ArrayList<ClassPathInfoImpl>();
else if( localName.equals("path") )
{
String path = attrs.getValue("name");
@@ -81,7 +85,7 @@
}
return child;
}
- public Object newChild(ArrayList<ContextInfo.Path> parent, UnmarshallingContext navigator,
+ public Object newChild(ArrayList<ClassPathInfo> parent, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
{
Object child = null;
@@ -89,18 +93,19 @@
{
String name = attrs.getValue("name");
String suffixes = attrs.getValue("suffixes");
- ContextInfo.Path path = new ContextInfo.Path(name, suffixes);
+ ClassPathInfoImpl path = new ClassPathInfoImpl(name);
+ path.setOption("suffixes", suffixes);
parent.add(path);
}
return child;
}
- public void addChild(StructureMetaData parent, ContextInfo context,
+ public void addChild(StructureMetaDataImpl parent, ContextInfoImpl context,
UnmarshallingContext navigator, String namespaceURI, String localName)
{
parent.addContext(context);
}
- public void addChild(ContextInfo context, ArrayList<ContextInfo.Path> classpath,
+ public void addChild(ContextInfoImpl context, ArrayList<ClassPathInfo> classpath,
UnmarshallingContext navigator, String namespaceURI, String localName)
{
context.setClassPath(classpath);
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -24,8 +24,10 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
-import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
import org.jboss.virtual.VirtualFile;
/**
@@ -46,7 +48,7 @@
fileSuffixes.add("-beans.xml");
fileSuffixes.add("-ds.xml");
fileSuffixes.add("-aop.xml");
- }
+ }
public FileStructure()
{
@@ -55,9 +57,10 @@
public FileStructure(Set<String> suffixes)
{
- this.fileSuffixes = suffixes;
+ fileSuffixes.clear();
+ fileSuffixes.addAll(suffixes);
}
-
+
/**
* Gets the list of suffixes recognised as files
*
@@ -116,15 +119,14 @@
return fileSuffixes.contains(suffix);
}
- public boolean determineStructure(DeploymentContext context)
+ public boolean determineStructure(VirtualFile root, StructureMetaData metaData, StructuredDeployers deployers)
{
try
{
- VirtualFile root = context.getRoot();
if (root.isLeaf())
{
- // It must be top level
- if (context.isTopLevel() == false)
+ // See if this is a top-level by checking the parent
+ if (isTopLevel(root, metaData) == false)
{
if (isKnownFile(root.getName()) == false)
{
@@ -141,6 +143,9 @@
log.trace("... ok - it is a top level file");
}
+ // Create a context info for this file
+ ContextInfoImpl context = new ContextInfoImpl(root.getPathName());
+ metaData.addContext(context);
// There are no subdeployments for files
return true;
}
@@ -152,7 +157,7 @@
}
catch (Exception e)
{
- log.warn("Error determining structure: " + context.getName(), e);
+ log.warn("Error determining structure: " + root.getName(), e);
return false;
}
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitor.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitor.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -22,7 +22,9 @@
package org.jboss.deployers.plugins.structure.vfs.jar;
import org.jboss.deployers.plugins.structure.vfs.AbstractCandidateStructureVisitor;
-import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VisitorAttributes;
/**
@@ -41,8 +43,9 @@
* @throws IllegalArgumentException for a null parent
* @throws Exception for any error
*/
- public JARCandidateStructureVisitor(DeploymentContext parent, VisitorAttributes attributes) throws Exception
+ public JARCandidateStructureVisitor(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers,
+ VisitorAttributes attributes) throws Exception
{
- super(parent, attributes);
+ super(parent, metaData, deployers, attributes);
}
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitorFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitorFactory.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitorFactory.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -22,7 +22,9 @@
package org.jboss.deployers.plugins.structure.vfs.jar;
import org.jboss.deployers.plugins.structure.vfs.CandidateStructureVisitorFactory;
-import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
import org.jboss.virtual.VirtualFileVisitor;
import org.jboss.virtual.VisitorAttributes;
@@ -61,10 +63,10 @@
this.filter = filter;
}
- public VirtualFileVisitor createVisitor(DeploymentContext context, VisitorAttributes attributes) throws Exception
+ public VirtualFileVisitor createVisitor(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers,
+ VisitorAttributes attributes) throws Exception
{
-
- JARCandidateStructureVisitor visitor = new JARCandidateStructureVisitor(context, attributes);
+ JARCandidateStructureVisitor visitor = new JARCandidateStructureVisitor(parent, metaData, deployers, attributes);
if (filter != null)
visitor.setFilter(filter);
return visitor;
Modified: 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/jar/JARStructure.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -22,13 +22,12 @@
package org.jboss.deployers.plugins.structure.vfs.jar;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Set;
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
-import org.jboss.deployers.spi.structure.DeploymentContext;
-import org.jboss.virtual.VFSUtils;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.plugins.context.jar.JarUtils;
@@ -67,18 +66,17 @@
return 10000;
}
- public boolean determineStructure(DeploymentContext context)
+ public boolean determineStructure(VirtualFile root, StructureMetaData metaData, StructuredDeployers deployers)
{
try
{
- VirtualFile root = context.getRoot();
if (root.isLeaf() == 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 (JarUtils.isArchive(root.getName()) == false)
{
- if (context.isTopLevel() == false)
+ if (isTopLevel(root, metaData) == false)
{
try
{
@@ -96,31 +94,33 @@
log.trace("... ok - doesn't look like a jar but it is a top level directory.");
}
}
-
- // 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
- addAllChildren(context);
-
- return true;
}
+ else if(JarUtils.isArchive(root.getName()))
+ {
+ log.trace("... ok - its an archive or at least pretending to be.");
+ }
else
{
log.trace("... no - not a directory or an archive.");
return false;
}
+
+ // Create a context for this jar file
+ ContextInfoImpl context = new ContextInfoImpl(root.getPathName());
+ // The metadata path is META-INF
+ context.setMetaDataPath("META-INF");
+
+ // The classpath is the root
+ super.addClassPath(root, root, true, true, context);
+ metaData.addContext(context);
+
+ // We tentatively try all the children as potential subdeployments
+ addAllChildren(root, metaData, deployers);
+ return true;
}
catch (Exception e)
{
- log.warn("Error determining structure: " + context.getName(), e);
+ log.warn("Error determining structure: " + root.getName(), e);
return false;
}
}
Modified: 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-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -1,35 +1,36 @@
/*
-* 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.
-*/
+ * 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.war;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
-import org.jboss.deployers.spi.structure.DeploymentContext;
-import org.jboss.virtual.VFSUtils;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VisitorAttributes;
import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
/**
@@ -40,8 +41,9 @@
*/
public class WARStructure extends AbstractStructureDeployer
{
- /** The default filter */
- public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER = new SuffixMatchFilter(".jar");
+ /** The default filter which allows jars/jar directories */
+ public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER =
+ new SuffixMatchFilter(".jar", VisitorAttributes.DEFAULT);
/** The web-inf/lib filter */
private VirtualFileFilter webInfLibFilter = DEFAULT_WEB_INF_LIB_FILTER;
@@ -75,11 +77,10 @@
this.webInfLibFilter = webInfLibFilter;
}
- public boolean determineStructure(DeploymentContext context)
+ public boolean determineStructure(VirtualFile root, StructureMetaData metaData, StructuredDeployers deployers)
{
try
{
- VirtualFile root = context.getRoot();
if (root.isLeaf() == false)
{
// We require either a WEB-INF or the name ends in .war
@@ -101,39 +102,38 @@
log.trace("... ok - name ends in .war.");
}
+ ContextInfoImpl context = new ContextInfoImpl(root.getPathName());
// The metadata path is WEB-INF
context.setMetaDataPath("WEB-INF");
- List<VirtualFile> paths = new ArrayList<VirtualFile>();
- VirtualFile webinf = context.getMetaDataLocation();
- if (webinf != null)
+ // Add the war manifest classpath entries
+ addClassPath(root, root, false, true, context);
+ try
{
// The classpath is WEB-INF/classes
- try
+ VirtualFile classes = root.findChild("WEB-INF/classes");
+ // Add the war manifest classpath entries
+ addClassPath(root, classes, true, false, context);
+ }
+ catch(IOException e)
+ {
+ log.trace("No WEB-INF/classes for: " + root.getPathName());
+ }
+ // and the top level jars in WEB-INF/lib
+ try
+ {
+ VirtualFile webinfLib = root.findChild("WEB-INF/lib");
+ List<VirtualFile> archives = webinfLib.getChildren(webInfLibFilter);
+ for (VirtualFile jar : archives)
{
- VirtualFile webinfClasses = webinf.findChild("classes");
- paths.add(webinfClasses);
+ addClassPath(root, jar, true, true, context);
}
- 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);
- 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);
+ catch (IOException ignored)
+ {
+ log.trace("No WEB-INF/lib for: " + root.getPathName());
+ }
+ metaData.addContext(context);
// There are no subdeployments for wars
return true;
@@ -146,7 +146,7 @@
}
catch (Exception e)
{
- log.warn("Error determining structure: " + context.getName(), e);
+ log.warn("Error determining structure: " + root.getName(), e);
return false;
}
}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/OrderedDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/OrderedDeployer.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/OrderedDeployer.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,64 @@
+/*
+ * 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.spi;
+
+import java.util.Comparator;
+
+/**
+ * A base interface for deployers that defines the ordering contract
+ * and comparator.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface OrderedDeployer
+{
+ /**
+ * Get the relative order
+ *
+ * @return the relative order
+ */
+ int getRelativeOrder();
+ /**
+ * Set the deployer relative order.
+ * @param order - the order of the deployer in a deployer chain.
+ */
+ public void setRelativeOrder(int order);
+
+ /** The comparator for relative ordering of deployers */
+ Comparator<OrderedDeployer> COMPARATOR = new DeployerComparator();
+
+ /**
+ * The comparator for relative ordering of deployers
+ */
+ public class DeployerComparator implements Comparator<OrderedDeployer>
+ {
+ public int compare(OrderedDeployer o1, OrderedDeployer o2)
+ {
+ int relative = o1.getRelativeOrder() - o2.getRelativeOrder();
+ if (relative != 0)
+ return relative;
+ return o1.toString().compareTo(o2.toString());
+ }
+ }
+
+}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -24,6 +24,7 @@
import java.util.Comparator;
import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.OrderedDeployer;
/**
* Deployer.
@@ -33,7 +34,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public interface Deployer
+public interface Deployer extends OrderedDeployer
{
/** The parser order */
public static final int PARSER_DEPLOYER = 2000;
@@ -97,27 +98,4 @@
*/
void commitUndeploy(DeploymentUnit unit);
- /**
- * Get the relative order
- *
- * @return the relative order
- */
- int getRelativeOrder();
-
- /** The comparator for relative ordering of deployers */
- Comparator<Deployer> COMPARATOR = new DeployerComparator();
-
- /**
- * The comparator for relative ordering of deployers
- */
- public class DeployerComparator implements Comparator<Deployer>
- {
- public int compare(Deployer o1, Deployer o2)
- {
- int relative = o1.getRelativeOrder() - o2.getRelativeOrder();
- if (relative != 0)
- return relative;
- return o1.toString().compareTo(o2.toString());
- }
- }
}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ClassPathInfo.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ClassPathInfo.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ClassPathInfo.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,62 @@
+/*
+ * 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.spi.structure.vfs;
+
+import java.util.Map;
+
+/**
+ * A classpath entry.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ClassPathInfo
+{
+ /**
+ * path relative to the context virtual file.
+ */
+ public String getPath();
+ public void setPath(String path);
+ /**
+ * Get the options associated with the classpath entry.
+ * @return A map of entry options.
+ */
+ public Map getOptions();
+ /**
+ * Set the options associated with the classpath entry.
+ * @param options - A map of entry options.
+ */
+ public void setOptions(Map options);
+
+ /**
+ * Get a classpath entry option
+ * @param key - the option key
+ * @return the option if it exists, null otherwise
+ */
+ public Object getOption(Object key);
+ /**
+ * Set a classpath entry option
+ * @param key - the option key
+ * @param value - the option value
+ */
+ public void setOption(Object key, Object value);
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ContextInfo.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ContextInfo.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ContextInfo.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,76 @@
+/*
+ * 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.spi.structure.vfs;
+
+import java.util.List;
+
+/**
+ * An encapsulation of deployment context information
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ContextInfo
+{
+ /**
+ * Get the context parent parent.
+ * @return the parent if one exists, null otherwise
+ */
+ public ContextInfo getParent();
+ /**
+ *
+ * @param parent
+ */
+ public void setParent(ContextInfo parent);
+
+ /**
+ * Get the VFS path of the context
+ * @return the VFS path of the context
+ */
+ public String getVfsPath();
+ /**
+ * Set the VFS path of the context
+ * @param path - VFS path of the context
+ */
+ public void setVfsPath(String path);
+
+ /**
+ * Get the path of the metdata location.
+ * @return the path of the metdata location.
+ */
+ public String getMetaDataPath();
+ /**
+ * Set the metadata path of the context.
+ * @param metaDataPath - the path relative to root of the context
+ */
+ public void setMetaDataPath(String metaDataPath);
+
+ /**
+ * Get the deployment context classpath
+ * @return the possibly null context classpath
+ */
+ public List<ClassPathInfo> getClassPath();
+ /**
+ * Set the deployment context classpath
+ * @param classPath - the context classpath
+ */
+ public void setClassPath(List<ClassPathInfo> classPath);
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilder.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilder.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,47 @@
+/*
+ * 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.spi.structure.vfs;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+
+/**
+ * A StructureBuilder transforms the StructureMetaData for a deployment info
+ * a DeploymentContext tree.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface StructureBuilder
+{
+ /**
+ * Create the visitor
+ *
+ * @param context - the root deployment context to populate
+ * @param metaData - the metadata from a structural parse of the context
+ * root VirtualFile
+ * @throws Exception for any error
+ */
+ public void populateContext(DeploymentContext context, StructureMetaData metaData)
+ throws DeploymentException;
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilderFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilderFactory.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilderFactory.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,33 @@
+/*
+ * 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.spi.structure.vfs;
+
+/**
+ * A factory interface for creating StructureBuilders
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface StructureBuilderFactory
+{
+ StructureBuilder createBuilder(StructureMetaData metaData);
+}
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-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -1,67 +1,46 @@
/*
-* 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.
-*/
+ * 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.spi.structure.vfs;
-import java.util.Comparator;
+import org.jboss.deployers.spi.OrderedDeployer;
+import org.jboss.virtual.VirtualFile;
-import org.jboss.deployers.spi.structure.DeploymentContext;
-
/**
- * StructureDeployer.
+ * A StructureDeployer translates a deployment virtual file root into
+ * StructureMetaData representing the deployment contexts.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public interface StructureDeployer
+public interface StructureDeployer extends OrderedDeployer
{
/**
* Determine the structure of a deployment
*
- * @param context the context
+ * @param file - the candidate root file of the deployment
+ * @param metaData - the structure metadata to build
+ * @param deployers - the available structure deployers
* @return true when it is recongnised
*/
- boolean determineStructure(DeploymentContext context);
+ boolean determineStructure(VirtualFile file, StructureMetaData metaData, StructuredDeployers deployers);
- /**
- * Get the relative order
- *
- * @return the relative order
- */
- int getRelativeOrder();
-
- /** The comparator for relative ordering of deployers */
- Comparator<StructureDeployer> COMPARATOR = new StructureComparator();
-
- /**
- * The comparator for relative ordering of deployers
- */
- public class StructureComparator implements Comparator<StructureDeployer>
- {
- public int compare(StructureDeployer o1, StructureDeployer o2)
- {
- int relative = o1.getRelativeOrder() - o2.getRelativeOrder();
- if (relative != 0)
- return relative;
- return o1.toString().compareTo(o2.toString());
- }
- }
}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureMetaData.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureMetaData.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureMetaData.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,59 @@
+/*
+ * 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.spi.structure.vfs;
+
+import java.util.SortedSet;
+
+/**
+ * A map of vfs paths to deployment context information.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface StructureMetaData
+{
+ /**
+ * Add a deployment context info. The context must have a vfs path, and its
+ * parent must already have been added if it has not been set on the context.
+ *
+ * @param context - the context info
+ */
+ public void addContext(ContextInfo context);
+ /**
+ * Get a context based on its vfs path.
+ * @param vfsPath - the VFS path name
+ * @return the ContextInfo if one exists for vfsPath.
+ */
+ public ContextInfo getContext(String vfsPath);
+ /**
+ * Remove a context based on its vfs path.
+ * @param vfsPath - the VFS path name
+ * @return the ContextInfo if one exists for vfsPath.
+ */
+ public ContextInfo removeContext(String vfsPath);
+ /**
+ * Get the deployment context info ordered from parent to child. This must
+ * order parent contexts before their children.
+ * @return deployment context info ordered from parent to child.
+ */
+ public SortedSet<ContextInfo> getContexts();
+}
Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructuredDeployers.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructuredDeployers.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructuredDeployers.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,57 @@
+/*
+ * 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.spi.structure.vfs;
+
+import java.util.SortedSet;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * An encapsulation of the avaialble StructureDeployer
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface StructuredDeployers
+{
+ /**
+ *
+ * @param file - root of the deployment in the VFS
+ * @param metaData - the existing metadata to use/populate with structure metadata
+ * @return true if the deployment was recognized, false if it was not
+ * @throws DeploymentException - thrown on failure to parse the deployment
+ */
+ public boolean determineStructure(VirtualFile file, StructureMetaData metaData)
+ throws DeploymentException;
+
+ /**
+ * Get the ordered set of deployers.
+ * @return the ordered set of deployers.
+ */
+ public SortedSet<StructureDeployer> getDeployers();
+ /**
+ * Are there any deployers
+ * @return
+ */
+ public boolean isEmpty();
+}
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/META-INF/jboss-structure.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/META-INF/jboss-structure.xml 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/META-INF/jboss-structure.xml 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,18 @@
+<structure>
+ <context>
+ <path>complex.jar</path>
+ <metaDataPath>META-INF</metaDataPath>
+ <classpath>
+ <path>jar1.jar</path>
+ <path>lib-dir/*.jar</path>
+ </classpath>
+ </context>
+ <context>
+ <path>complex.jar/sub.jar</path>
+ <metaDataPath>META-INF</metaDataPath>
+ </context>
+ <context>
+ <path>complex.jar/sub.jar</path>
+ <metaDataPath>META-INF</metaDataPath>
+ </context>
+</structure>
\ No newline at end of file
Property changes on: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/META-INF/jboss-structure.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/sub.jar/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/sub.jar/empty 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/sub.jar/empty 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Property changes on: projects/microcontainer/trunk/deployers/src/resources/tests/structure/explicit/complex.jar/sub.jar/empty
___________________________________________________________________
Name: svn:executable
+ *
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-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -27,9 +27,17 @@
import java.util.Set;
import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.plugins.structure.BasicStructuredDeployers;
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
+import org.jboss.deployers.plugins.structure.DefaultStructureBuilderFactory;
+import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.deployers.spi.structure.StructureDetermined;
+import org.jboss.deployers.spi.structure.vfs.StructureBuilder;
+import org.jboss.deployers.spi.structure.vfs.StructureBuilderFactory;
import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
import org.jboss.test.BaseTestCase;
import org.jboss.util.NotImplementedException;
import org.jboss.virtual.VFS;
@@ -107,6 +115,20 @@
{
throw new NotImplementedException("Implemented in subclasses");
}
+ protected StructuredDeployers getStrucuturedDeployers()
+ {
+ BasicStructuredDeployers deployers = new BasicStructuredDeployers();
+ deployers.addDeployer(getStrucutureDeployer());
+ return deployers;
+ }
+ /**
+ * Get the StructureVisitorFactory that translates the StructureMetaData into a DeploymentContext tree.
+ * @return
+ */
+ protected StructureBuilderFactory getStructureBuilderFactory()
+ {
+ return new DefaultStructureBuilderFactory();
+ }
/**
* Determine the structure
@@ -114,9 +136,12 @@
* @param context the context
* @return the result
*/
- protected boolean determineStructure(DeploymentContext context)
+ protected boolean determineStructure(DeploymentContext context, boolean addTopLevelInfo)
+ throws Exception
{
- return determineStructure(getStrucutureDeployer(), context);
+ StructureDeployer deployer = getStrucutureDeployer();
+ StructuredDeployers deployers = getStrucuturedDeployers();
+ return determineStructure(deployer, deployers, context, addTopLevelInfo);
}
/**
@@ -126,15 +151,65 @@
* @param context the context
* @return the result
*/
- protected boolean determineStructure(StructureDeployer structure, DeploymentContext context)
+ protected boolean determineStructure(StructureDeployer deployer,
+ DeploymentContext context)
+ throws Exception
{
- assertNotNull(structure);
+ return determineStructure(deployer, getStrucuturedDeployers(), context, false);
+ }
+ /**
+ * Determine the structure
+ *
+ * @param structure the structural deployer
+ * @param context the context
+ * @return the result
+ */
+ protected boolean determineStructure(StructureDeployer deployer,
+ DeploymentContext context, boolean addTopLevelInfo)
+ throws Exception
+ {
+ return determineStructure(deployer, getStrucuturedDeployers(), context, addTopLevelInfo);
+ }
+ /**
+ *
+ * @param deployer
+ * @param deployers
+ * @param context
+ * @param addTopLevelInfo - should a ContextInfo be created for the
+ * context root
+ * @return
+ * @throws Exception
+ */
+ protected boolean determineStructure(StructureDeployer deployer,
+ StructuredDeployers deployers, DeploymentContext context,
+ boolean addTopLevelInfo)
+ throws Exception
+ {
+ assertNotNull(deployer);
assertNotNull(context);
log.debug("Determining structure: " + context.getName());
- return structure.determineStructure(context);
+ StructureMetaData metaData = new StructureMetaDataImpl();
+ VirtualFile root = context.getRoot();
+ String rootPath = root.getPathName();
+ if( addTopLevelInfo && metaData.getContext(rootPath) == null )
+ {
+ /* For backward compatibility with the top-level context notion, we need
+ to add an entry for the
+ */
+ ContextInfoImpl rootContextInfo = new ContextInfoImpl(rootPath);
+ metaData.addContext(rootContextInfo);
+ }
+ boolean result = deployer.determineStructure(root, metaData, deployers);
+ if( result )
+ {
+ StructureBuilderFactory factory = getStructureBuilderFactory();
+ StructureBuilder builder = factory.createBuilder(metaData);
+ builder.populateContext(context, metaData);
+ }
+ return result;
}
-
+
/**
* Assert non of the candidates are valid
*
@@ -156,9 +231,11 @@
protected void assertCandidatesNotValid(StructureDeployer structure, DeploymentContext context) throws Exception
{
assertNotNull(context);
-
for (DeploymentContext child : context.getChildren())
- assertFalse("Should not be a valid candidate: " + child.getName(), determineStructure(structure, child));
+ {
+ boolean recognized = determineStructure(structure, child);
+ assertFalse("Should not be a valid candidate: " + child.getName(), recognized);
+ }
}
/**
@@ -254,4 +331,4 @@
context.setStructureDetermined(StructureDetermined.PREDETERMINED);
return context;
}
-}
+}
\ No newline at end of file
Modified: 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-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/explicit/test/DeclaredStructureUnitTestCase.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -70,22 +70,21 @@
return structure;
}
- protected DeploymentContext getValidContext(String root, String path) throws Exception
+ protected DeploymentContext getValidContext(String root, String path)
+ throws Exception
{
DeploymentContext context = createDeploymentContext(root, path);
- assertTrue("Structure should be valid: " + context.getName(), determineStructure(context));
+ boolean recognized = determineStructure(context, false);
+ assertTrue("Structure should be valid: " + context.getName(), recognized);
return context;
}
- protected DeploymentContext assertValidContext(String root, String path) throws Exception
+ protected DeploymentContext assertNotValidContext(String root, String path, boolean addTopLevelInfo)
+ 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));
+ boolean recognized = determineStructure(context, addTopLevelInfo);
+ assertFalse("Structure should not be valid: " + context.getName(), recognized);
assertEmpty(context.getChildren());
return context;
}
@@ -172,4 +171,5 @@
}
return pathMap;
}
+
}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/FileStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/FileStructureUnitTestCase.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/FileStructureUnitTestCase.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -66,36 +66,41 @@
return structure;
}
- protected DeploymentContext assertValidContext(String root, String path) throws Exception
+ protected DeploymentContext assertValidContext(String root, String path, boolean addTopLevelInfo)
+ throws Exception
{
DeploymentContext context = createDeploymentContext(root, path);
- assertTrue("Structure should be valid: " + context.getName(), determineStructure(context));
+ boolean recoginized = determineStructure(context, addTopLevelInfo);
+ assertTrue("Structure should be valid: " + context.getName(), recoginized);
assertEmpty(context.getChildren());
return context;
}
- protected DeploymentContext assertNotValidContext(String root, String path, boolean isDirectory) throws Exception
+ protected DeploymentContext assertNotValidContext(String root, String path,
+ boolean isDirectory, boolean addTopLevelInfo)
+ throws Exception
{
DeploymentContext context = createDeploymentContext(root, path);
- assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
+ boolean recoginized = determineStructure(context, addTopLevelInfo);
+ assertFalse("Structure should not be valid: " + context.getName(), recoginized);
assertEmpty(context.getChildren());
return context;
}
public void testSimple() throws Exception
{
- assertValidContext("/structure/", "file/simple/simple-service.xml");
+ assertValidContext("/structure/", "file/simple/simple-service.xml", false);
}
public void testNotKnownButTopLevel() throws Exception
{
- assertValidContext("/structure/", "file/notknown/test-unknown.xml");
- assertValidContext("/structure/", "file/notknown/unknown.xml");
+ assertValidContext("/structure/", "file/notknown/test-unknown.xml", true);
+ assertValidContext("/structure/", "file/notknown/unknown.xml", true);
}
-
+
public void testDirectory() throws Exception
{
- assertNotValidContext("/structure/", "file/directory", true);
+ assertNotValidContext("/structure/", "file/directory", false, false);
}
protected void assertContexts(Map<String, Boolean> expected, Set<DeploymentContext> actual) throws Exception
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-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -67,22 +67,37 @@
return structure;
}
- protected DeploymentContext getValidContext(String root, String path) throws Exception
+ protected DeploymentContext getValidContext(String root, String path)
+ throws Exception
{
+ return getValidContext(root, path, false);
+ }
+ protected DeploymentContext getValidContext(String root, String path, boolean addTopLevelInfo)
+ throws Exception
+ {
DeploymentContext context = createDeploymentContext(root, path);
- assertTrue("Structure should be valid: " + context.getName(), determineStructure(context));
+ boolean recognized = determineStructure(context, addTopLevelInfo);
+ assertTrue("Structure should be valid: " + context.getName(), recognized);
return context;
}
- protected DeploymentContext assertValidContext(String root, String path) throws Exception
+ protected DeploymentContext assertValidContext(String root, String path)
+ throws Exception
{
- return getValidContext(root, path);
+ return getValidContext(root, path, false);
}
+ protected DeploymentContext assertValidContext(String root, String path, boolean addTopLevelInfo)
+ throws Exception
+ {
+ return getValidContext(root, path, addTopLevelInfo);
+ }
- protected DeploymentContext assertNotValidContext(String root, String path, boolean other) throws Exception
+ protected DeploymentContext assertNotValidContext(String root, String path, boolean addTopLevelInfo)
+ throws Exception
{
DeploymentContext context = createDeploymentContext(root, path);
- assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
+ boolean recognized = determineStructure(context, addTopLevelInfo);
+ assertFalse("Structure should not be valid: " + context.getName(), recognized);
assertEmpty(context.getChildren());
return context;
}
@@ -91,11 +106,12 @@
{
DeploymentContext context = getValidContext("/structure/", "jar/simple");
- // Test it got all the candidates
+ /* Test it got all the candidates
Map<String, Boolean> expected = new HashMap<String, Boolean>();
expected.put(getURL("/structure/jar/simple/simple1.txt"), false);
expected.put(getURL("/structure/jar/simple/simple2.txt"), false);
assertContexts(expected, context.getChildren());
+ */
assertCandidatesNotValid(context);
}
@@ -110,11 +126,12 @@
{
DeploymentContext context = getValidContext("/structure/", "jar/notanarchive");
- // Test it got all the candidates
+ /* Test it got all the candidates
Map<String, Boolean> expected = new HashMap<String, Boolean>();
expected.put(getURL("/structure/jar/notanarchive/NotAnArchive.jar"), false);
expected.put(getURL("/structure/jar/notanarchive/NotAnArchive.zip"), false);
assertContexts(expected, context.getChildren());
+ */
assertCandidatesNotValid(context);
}
@@ -142,10 +159,11 @@
{
DeploymentContext context = getValidContext("/structure/", "jar/subdirnotajar");
- // Test it got all the candidates
+ /* Test it got all the candidates
Map<String, Boolean> expected = new HashMap<String, Boolean>();
expected.put(getURL("/structure/jar/subdirnotajar/sub/"), false);
assertContexts(expected, context.getChildren());
+ */
assertCandidatesNotValid(context);
}
@@ -164,43 +182,47 @@
public void testdirectoryHasMetaInf() throws Exception
{
- assertValidContext("/structure/", "jar/subdirhasmetainf/sub");
+ assertValidContext("/structure/", "jar/subdirhasmetainf/sub", true);
}
public void testSubdirectoryHasMetaInf() throws Exception
{
- DeploymentContext context = getValidContext("/structure/", "jar/subdirhasmetainf");
+ DeploymentContext context = getValidContext("/structure/", "jar/subdirhasmetainf", true);
- // Test it got all the candidates
+ /* Test it got all the candidates
Map<String, Boolean> expected = new HashMap<String, Boolean>();
expected.put(getURL("/structure/jar/subdirhasmetainf/sub/"), true);
assertContexts(expected, context.getChildren());
+ */
assertCandidatesValid(context);
}
public void testSubdeploymentIsKnownFile() throws Exception
{
- DeploymentContext context = getValidContext("/structure/file", "simple");
+ DeploymentContext context = getValidContext("/structure/file", "simple", true);
- // Test it got all the candidates
+ /* Test it got all the candidates
Map<String, Boolean> expected = new HashMap<String, Boolean>();
expected.put(getURL("/structure/file/simple/simple-service.xml"), true);
assertContexts(expected, context.getChildren());
+ */
assertCandidatesNotValid(context);
}
public void testSubdeploymentIsUnknownFile() throws Exception
{
- DeploymentContext context = getValidContext("/structure/file", "notknown");
+ DeploymentContext context = getValidContext("/structure/file", "notknown", true);
- // Test it got all the candidates
- Map<String, Boolean> expected = new HashMap<String, Boolean>();
- expected.put(getURL("/structure/file/notknown/test-unknown.xml"), false);
- expected.put(getURL("/structure/file/notknown/unknown.xml"), false);
- assertContexts(expected, context.getChildren());
-
+ /* This is not valid as the output of the structure deployers does not
+ include unknown candidate
+ Test it got all the candidates
+ Map<String, Boolean> expected = new HashMap<String, Boolean>();
+ expected.put(getURL("/structure/file/notknown/test-unknown.xml"), false);
+ expected.put(getURL("/structure/file/notknown/unknown.xml"), false);
+ assertContexts(expected, context.getChildren());
+ */
assertCandidatesNotValid(context);
}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureDeployer.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureDeployer.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -24,8 +24,11 @@
import java.util.HashSet;
import java.util.Set;
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
-import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
/**
* TestStructureDeployer.
@@ -35,24 +38,27 @@
*/
public class TestStructureDeployer extends AbstractStructureDeployer
{
- /** The contexts with which we have been invoked */
- private Set<DeploymentContext> invoked = new HashSet<DeploymentContext>();
+ /** The files with which we have been invoked */
+ private Set<VirtualFile> invoked = new HashSet<VirtualFile>();
/**
* Get the contexts with which we were invoked and clear it
*
* @return the set of contexts
*/
- public Set<DeploymentContext> getInvoked()
+ public Set<VirtualFile> getInvoked()
{
- HashSet<DeploymentContext> result = new HashSet<DeploymentContext>(invoked);
+ HashSet<VirtualFile> result = new HashSet<VirtualFile>(invoked);
invoked.clear();
return result;
}
- public boolean determineStructure(DeploymentContext context)
+ public boolean determineStructure(VirtualFile root,
+ StructureMetaData metaData, StructuredDeployers deployers)
{
- invoked.add(context);
+ invoked.add(root);
+ ContextInfoImpl context = new ContextInfoImpl(root.getPathName());
+ metaData.addContext(context);
return true;
}
}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureOrdering.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureOrdering.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureOrdering.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -22,7 +22,9 @@
package org.jboss.test.deployers.structure.main.support;
import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
-import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
/**
* TestStructureOrdering.
@@ -58,7 +60,8 @@
return relativeOrder;
}
- public boolean determineStructure(DeploymentContext context)
+ public boolean determineStructure(VirtualFile root,
+ StructureMetaData metaData, StructuredDeployers deployers)
{
structureOrder = ++order;
return false;
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -23,7 +23,10 @@
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
@@ -31,6 +34,10 @@
import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.plugins.structure.BasicStructuredDeployers;
+import org.jboss.deployers.plugins.structure.vfs.StructureDeployerWrapper;
+import org.jboss.deployers.plugins.structure.vfs.explicit.DeclaredStructure;
+import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
import org.jboss.deployers.spi.structure.DeploymentContext;
@@ -39,6 +46,7 @@
import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
import org.jboss.test.deployers.BaseDeployersTest;
import org.jboss.test.deployers.structure.main.support.TestStructureDeployer;
+import org.jboss.virtual.VirtualFile;
/**
* MainDeployerStructureUnitTestCase.
@@ -168,7 +176,7 @@
checkThrowable(IllegalArgumentException.class, t);
}
}
-
+
public void testSetStructuralDeployers() throws Exception
{
MainDeployerImpl main = new MainDeployerImpl();
@@ -226,8 +234,8 @@
DeploymentContext context = createDeploymentContext("/structure/", "jar/simple");
main.addDeploymentContext(context);
- Set<DeploymentContext> expected = new HashSet<DeploymentContext>();
- expected.add(context);
- assertEquals(expected, deployer.getInvoked());
+ Set<VirtualFile> files = deployer.getInvoked();
+ VirtualFile root = files.iterator().next();
+ assertEquals("jar/simple", root.getPathName());
}
}
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/StructureMetaDataUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/StructureMetaDataUnitTestCase.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/StructureMetaDataUnitTestCase.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,266 @@
+/*
+* 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.main.test;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.TreeSet;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
+import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
+import org.jboss.deployers.spi.structure.vfs.ContextInfo;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * Tests of the default StructureMetaData implementation
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class StructureMetaDataUnitTestCase extends BaseTestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(StructureMetaDataUnitTestCase.class);
+ }
+
+ public StructureMetaDataUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ enableTrace("org.jboss.deployers");
+ }
+
+ protected StructureMetaData getStructureMetaData()
+ {
+ StructureMetaData metaData = new StructureMetaDataImpl();
+ return metaData;
+ }
+ protected ContextInfo getContextInfo(String vfsPath)
+ {
+ ContextInfo context = new ContextInfoImpl(vfsPath);
+ return context;
+ }
+
+ public void testStructureMetaDataParentChild()
+ {
+ StructureMetaData metaData = getStructureMetaData();
+ ContextInfo context = getContextInfo("/top/root");
+ metaData.addContext(context);
+ context = getContextInfo("/top/root/sub1");
+ metaData.addContext(context);
+ context = getContextInfo("/top/root/sub2");
+ metaData.addContext(context);
+ context = getContextInfo("/top/root/sub2/sub21");
+ metaData.addContext(context);
+ context = getContextInfo("/top/root/sub2/sub21.war");
+ metaData.addContext(context);
+ context = getContextInfo("/top/root/sub2/sub21.jar");
+ metaData.addContext(context);
+ context = getContextInfo("/top/root/subdir/sub3.jar");
+ metaData.addContext(context);
+
+ // Validate the parent/child structure
+ ContextInfo root = metaData.getContext("/top/root");
+ assertNotNull("/top/root", root);
+ ContextInfo sub1 = metaData.getContext("/top/root/sub1");
+ assertNotNull("/top/root/sub1", sub1);
+ ContextInfo sub2 = metaData.getContext("/top/root/sub2");
+ assertNotNull("/top/root/sub2", sub2);
+ assertSame(root, sub2.getParent());
+ ContextInfo sub3 = metaData.getContext("/top/root/subdir/sub3.jar");
+ assertNotNull("/top/root/subdir/sub3.jar", sub3);
+ assertSame(root, sub3.getParent());
+
+ ContextInfo sub21 = metaData.getContext("/top/root/sub2/sub21");
+ assertNotNull("/top/root/sub2/sub21", sub21);
+ assertSame(sub2, sub21.getParent());
+ ContextInfo sub21War = metaData.getContext("/top/root/sub2/sub21.war");
+ assertNotNull("/top/root/sub2/sub21", sub21War);
+ assertSame(sub2, sub21War.getParent());
+ ContextInfo sub21Jar = metaData.getContext("/top/root/sub2/sub21.jar");
+ assertNotNull("/top/root/sub2/sub21", sub21Jar);
+ assertSame(sub2, sub21Jar.getParent());
+
+ }
+
+ public void testStructureMetaDataParentChildRelative()
+ {
+ StructureMetaData metaData = new StructureMetaDataImpl();
+ ContextInfo context = getContextInfo("top/root");
+ metaData.addContext(context);
+ context = getContextInfo("top/root/sub1");
+ metaData.addContext(context);
+ context = getContextInfo("top/root/sub2");
+ metaData.addContext(context);
+ context = getContextInfo("top/root/sub2/sub21");
+ metaData.addContext(context);
+ context = getContextInfo("top/root/sub2/sub21.war");
+ metaData.addContext(context);
+ context = getContextInfo("top/root/sub2/sub21.jar");
+ metaData.addContext(context);
+ context = getContextInfo("top/root/subdir/sub3.jar");
+ metaData.addContext(context);
+
+ // Validate the parent/child structure
+ ContextInfo root = metaData.getContext("top/root");
+ assertNotNull("top/root", root);
+ ContextInfo sub1 = metaData.getContext("top/root/sub1");
+ assertNotNull("top/root/sub1", sub1);
+ ContextInfo sub2 = metaData.getContext("top/root/sub2");
+ assertNotNull("top/root/sub2", sub2);
+ assertSame(root, sub2.getParent());
+ ContextInfo sub3 = metaData.getContext("top/root/subdir/sub3.jar");
+ assertNotNull("top/root/subdir/sub3.jar", sub3);
+ assertSame(root, sub3.getParent());
+
+ ContextInfo sub21 = metaData.getContext("top/root/sub2/sub21");
+ assertNotNull("top/root/sub2/sub21", sub21);
+ assertSame(sub2, sub21.getParent());
+ ContextInfo sub21War = metaData.getContext("top/root/sub2/sub21.war");
+ assertNotNull("top/root/sub2/sub21", sub21War);
+ assertSame(sub2, sub21War.getParent());
+ ContextInfo sub21Jar = metaData.getContext("top/root/sub2/sub21.jar");
+ assertNotNull("top/root/sub2/sub21", sub21Jar);
+ assertSame(sub2, sub21Jar.getParent());
+ }
+
+ public void testSortedSet()
+ {
+ Comparator<ContextInfo> c = new Comparator<ContextInfo>()
+ {
+ public int compare(ContextInfo o1, ContextInfo o2)
+ {
+ int compare = 0;
+ if( o1 == null && o2 != null )
+ compare = -1;
+ else if( o1 != null && o2 == null )
+ compare = 1;
+ else
+ {
+ // Sort by depth and then name
+ ContextInfo p1 = o1.getParent();
+ ContextInfo p2 = o2.getParent();
+ if( p1 != p2 )
+ {
+ compare = compare(p1, p2);
+ }
+ else if( p1 != null )
+ {
+ compare = o1.getVfsPath().compareTo(o2.getVfsPath());
+ }
+ }
+ return compare;
+ }
+ };
+ TreeSet<ContextInfo> info = new TreeSet<ContextInfo>(c);
+
+ ArrayList<ContextInfo> order = new ArrayList<ContextInfo>();
+ StructureMetaData metaData = new StructureMetaDataImpl();
+ ContextInfo context = getContextInfo("top/root");
+ metaData.addContext(context);
+ info.add(context);
+ order.add(context);
+ context = getContextInfo("top/root/sub1");
+ metaData.addContext(context);
+ info.add(context);
+ order.add(context);
+ context = getContextInfo("top/root/sub2");
+ metaData.addContext(context);
+ info.add(context);
+ order.add(context);
+ context = getContextInfo("top/root/subdir/sub3.jar");
+ metaData.addContext(context);
+ info.add(context);
+ order.add(context);
+
+ context = getContextInfo("top/root/sub2/sub21");
+ metaData.addContext(context);
+ info.add(context);
+ order.add(context);
+ context = getContextInfo("top/root/sub2/sub21.jar");
+ metaData.addContext(context);
+ info.add(context);
+ order.add(context);
+ metaData.addContext(context);
+ context = getContextInfo("top/root/sub2/sub21.war");
+ metaData.addContext(context);
+ info.add(context);
+ order.add(context);
+
+ int count = 0;
+ for(ContextInfo ci : info)
+ {
+ ContextInfo expected = order.get(count);
+ assertSame("At: "+count, ci, expected);
+ count ++;
+ }
+ }
+
+ public void testGetContextsOrder()
+ {
+ StructureMetaData metaData = new StructureMetaDataImpl();
+ ContextInfo context = getContextInfo("top/root");
+ ArrayList<ContextInfo> order = new ArrayList<ContextInfo>();
+ metaData.addContext(context);
+ order.add(context);
+
+ // top/root children
+ context = getContextInfo("top/root/sub1");
+ metaData.addContext(context);
+ order.add(context);
+ context = getContextInfo("top/root/sub2");
+ metaData.addContext(context);
+ order.add(context);
+ context = getContextInfo("top/root/subdir/sub3.jar");
+ metaData.addContext(context);
+ order.add(context);
+
+ // top/root/sub2 children
+ context = getContextInfo("top/root/sub2/sub21");
+ metaData.addContext(context);
+ order.add(context);
+ context = getContextInfo("top/root/sub2/sub21.jar");
+ metaData.addContext(context);
+ order.add(context);
+ context = getContextInfo("top/root/sub2/sub21.war");
+ metaData.addContext(context);
+ order.add(context);
+
+ int count = 0;
+ for(ContextInfo ci : metaData.getContexts())
+ {
+ ContextInfo expected = order.get(count);
+ assertSame("At: "+count, ci, expected);
+ count ++;
+ }
+ }
+}
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/StructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/StructureUnitTestCase.java 2006-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/StructureUnitTestCase.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -0,0 +1,94 @@
+/*
+* 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.main.test;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.BasicStructuredDeployers;
+import org.jboss.deployers.plugins.structure.vfs.explicit.DeclaredStructure;
+import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.test.deployers.BaseDeployersTest;
+
+/**
+ * MainDeployerStructureUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class StructureUnitTestCase extends BaseDeployersTest
+{
+ public static Test suite()
+ {
+ return new TestSuite(MainDeployerStructureUnitTestCase.class);
+ }
+
+ public StructureUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ enableTrace("org.jboss.deployers");
+ }
+
+ public void testSetStructuredDeployers() throws Exception
+ {
+ BasicStructuredDeployers main = new BasicStructuredDeployers();
+ assertEmpty(main.getDeployers());
+
+ StructureDeployer declaredDeployer = new DeclaredStructure();
+ Set<StructureDeployer> expected = new HashSet<StructureDeployer>();
+ expected.add(declaredDeployer);
+ main.setDeployers(expected);
+ assertEquals(expected, main.getDeployers());
+ Set<StructureDeployer> sdset = new TreeSet<StructureDeployer>(main.getDeployers());
+ assertEquals(expected, sdset);
+
+ SortedSet<StructureDeployer> deployers = main.getDeployers();
+ Iterator<StructureDeployer> iter = deployers.iterator();
+ StructureDeployer[] order = new StructureDeployer[4];
+ int count = 0;
+ while( iter.hasNext() )
+ {
+ order[count ++] = iter.next();
+ }
+ boolean equals = declaredDeployer.equals(order[0]);
+ log.debug(declaredDeployer+", order[0]="+order[0]+", equals="+equals);
+ assertEquals("deployers[0]", declaredDeployer, order[0]);
+
+ expected = Collections.emptySet();
+ main.setDeployers(expected);
+ assertEquals(expected, main.getDeployers());
+ }
+
+}
Modified: 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-10-25 21:43:10 UTC (rev 57835)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java 2006-10-25 23:12:12 UTC (rev 57836)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.deployers.structure.war.test;
+import java.util.List;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -28,6 +30,7 @@
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;
/**
* WARStructureUnitTestCase.
@@ -63,18 +66,27 @@
return structure;
}
- protected DeploymentContext assertValidContext(String root, String path) throws Exception
+ protected DeploymentContext assertValidContext(String root, String path)
+ throws Exception
{
+ return assertValidContext(root, path, false);
+ }
+ protected DeploymentContext assertValidContext(String root, String path, boolean addTopLevelInfo)
+ throws Exception
+ {
DeploymentContext context = createDeploymentContext(root, path);
- assertTrue("Structure should be valid: " + context.getName(), determineStructure(context));
+ boolean recognized = determineStructure(context, addTopLevelInfo);
+ assertTrue("Structure should be valid: " + context.getName(), recognized);
assertEmpty(context.getChildren());
return context;
}
- protected DeploymentContext assertNotValidContext(String root, String path, boolean other) throws Exception
+ protected DeploymentContext assertNotValidContext(String root, String path, boolean addTopLevelInfo)
+ throws Exception
{
DeploymentContext context = createDeploymentContext(root, path);
- assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
+ boolean recognized = determineStructure(context, addTopLevelInfo);
+ assertFalse("Structure should not be valid: " + context.getName(), recognized);
assertEmpty(context.getChildren());
return context;
}
@@ -83,7 +95,7 @@
{
assertValidContext("/structure/", "war/simple/simple.war");
}
-
+
public void testNotAnArchive() throws Exception
{
assertNotValidContext("/structure/", "war/notanarchive/notanarchive.war", true);
@@ -101,6 +113,16 @@
public void testDirectoryWithWebInf() throws Exception
{
- assertValidContext("/structure/", "war/directorywithwebinf");
+ DeploymentContext war = assertValidContext("/structure/", "war/directorywithwebinf");
+ List<VirtualFile> classpath = war.getClassPath();
+ assertNotNull("classpath", classpath);
+ assertEquals("classpath.size = 3", 3, classpath.size());
+ VirtualFile warFile = war.getRoot();
+ VirtualFile classes = warFile.findChild("WEB-INF/classes");
+ assertTrue("WEB-INF/classes in classpath", classpath.contains(classes));
+ VirtualFile j0 = warFile.findChild("WEB-INF/lib/j0.jar");
+ assertTrue("WEB-INF/lib/j0.jar in classpath", classpath.contains(j0));
+ VirtualFile j1 = warFile.findChild("WEB-INF/lib/j1.jar");
+ assertTrue("WEB-INF/lib/j1.jar in classpath", classpath.contains(j1));
}
}
More information about the jboss-cvs-commits
mailing list