[jboss-cvs] JBossAS SVN: r99561 - in branches/vfs3-int/server/src/main/java/org/jboss: web/deployers and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 18 19:13:49 EST 2010
Author: johnbailey
Date: 2010-01-18 19:13:49 -0500 (Mon, 18 Jan 2010)
New Revision: 99561
Modified:
branches/vfs3-int/server/src/main/java/org/jboss/deployment/EARStructure.java
branches/vfs3-int/server/src/main/java/org/jboss/web/deployers/WARStructure.java
Log:
[JBAS-7350] - Updated to structure deployers
Modified: branches/vfs3-int/server/src/main/java/org/jboss/deployment/EARStructure.java
===================================================================
--- branches/vfs3-int/server/src/main/java/org/jboss/deployment/EARStructure.java 2010-01-18 23:30:08 UTC (rev 99560)
+++ branches/vfs3-int/server/src/main/java/org/jboss/deployment/EARStructure.java 2010-01-19 00:13:49 UTC (rev 99561)
@@ -29,6 +29,7 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSArchiveStructureDeployer;
import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
import org.jboss.deployers.vfs.spi.structure.StructureContext;
import org.jboss.metadata.ear.jboss.JBossAppMetaData;
@@ -45,6 +46,7 @@
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
import org.jboss.vfs.util.SuffixMatchFilter;
+import org.jboss.vfs.util.automount.Automounter;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
@@ -58,7 +60,7 @@
* @author adrian at jboss.org
* @version $Revision$
*/
-public class EARStructure extends AbstractVFSStructureDeployer
+public class EARStructure extends AbstractVFSArchiveStructureDeployer
{
/**
* The default ear/lib filter
@@ -127,16 +129,24 @@
{
this.resolver = resolver;
}
+
+
- public boolean determineStructure(StructureContext structureContext) throws DeploymentException
+ @Override
+ protected boolean hasValidSuffix(String name)
{
+ return name.endsWith(".ear");
+ }
+
+ public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException
+ {
ContextInfo context;
boolean valid;
boolean trace = log.isTraceEnabled();
VirtualFile file = structureContext.getFile();
try
{
- if (file.isLeaf() == true || file.getName().endsWith(".ear") == false)
+ if (hasValidName(file) == false)
return false;
context = createContext(structureContext, "META-INF");
@@ -197,16 +207,17 @@
try
{
lib = file.getChild(libDir);
- if (lib != null)
+ if (lib.exists())
{
if(trace)
log.trace("Found ear lib directory: "+lib);
List<VirtualFile> archives = lib.getChildren(earLibFilter);
for (VirtualFile archive : archives)
{
+ Automounter.mount(file, archive);
addClassPath(structureContext, archive, true, true, context);
// add any jars with persistence.xml as a deployment
- if (archive.getChild("META-INF/persistence.xml") != null)
+ if (archive.getChild("META-INF/persistence.xml").exists())
{
log.trace(archive.getName() + " in ear lib directory has persistence units");
if (structureContext.determineChildStructure(archive) == false)
@@ -256,7 +267,7 @@
log.trace("Checking application.xml module: " + fileName);
VirtualFile module = file.getChild(fileName);
- if (module == null)
+ if (module.exists() == false)
{
throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + file.toURI());
}
@@ -413,7 +424,7 @@
{
VirtualFile metaFile = null;
metaFile = file.getChild(path);
- return metaFile;
+ return metaFile.exists() ? metaFile : null;
}
public void setIncludeEarRootInClasspath(boolean includeEarRootInClasspath)
Modified: branches/vfs3-int/server/src/main/java/org/jboss/web/deployers/WARStructure.java
===================================================================
--- branches/vfs3-int/server/src/main/java/org/jboss/web/deployers/WARStructure.java 2010-01-18 23:30:08 UTC (rev 99560)
+++ branches/vfs3-int/server/src/main/java/org/jboss/web/deployers/WARStructure.java 2010-01-19 00:13:49 UTC (rev 99561)
@@ -27,12 +27,14 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.structure.ContextInfo;
import org.jboss.deployers.spi.structure.MetaDataType;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSArchiveStructureDeployer;
import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
import org.jboss.deployers.vfs.spi.structure.StructureContext;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
import org.jboss.vfs.VisitorAttributes;
import org.jboss.vfs.util.SuffixMatchFilter;
+import org.jboss.vfs.util.automount.Automounter;
/**
* WARStructure.
@@ -41,7 +43,7 @@
* @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @version $Revision$
*/
-public class WARStructure extends AbstractVFSStructureDeployer
+public class WARStructure extends AbstractVFSArchiveStructureDeployer
{
/** The default filter which allows jars/jar directories */
public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER = new SuffixMatchFilter(".jar", VisitorAttributes.DEFAULT);
@@ -117,7 +119,7 @@
this.includeWebInfInClasspath = includeWebInfInClasspath;
}
- public boolean determineStructure(StructureContext structureContext) throws DeploymentException
+ public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException
{
ContextInfo context = null;
VirtualFile file = structureContext.getFile();
@@ -126,126 +128,118 @@
boolean trace = log.isTraceEnabled();
// the WEB-INF
- VirtualFile webinf;
-
- if (isLeaf(file) == false)
+ VirtualFile webinf = null;
+
+ // We require either a WEB-INF or the name ends in .war
+ if (hasValidSuffix(file.getName()) == false)
{
- // We require either a WEB-INF or the name ends in .war
- if (file.getName().endsWith(".war") == false)
- {
- webinf = file.getChild("WEB-INF");
- if (webinf.exists())
- {
- if (trace)
- log.trace("... ok - directory has a WEB-INF subdirectory");
- }
- else
- {
- if (trace)
- log.trace("... no - doesn't look like a war and no WEB-INF subdirectory.");
- return false;
- }
- }
- else if (trace)
- {
- log.trace("... ok - name ends in .war.");
- }
+ webinf = file.getChild("WEB-INF");
+ if (webinf.exists())
+ {
+ if (trace)
+ log.trace("... ok - directory has a WEB-INF subdirectory");
+ }
+ else
+ {
+ if (trace)
+ log.trace("... no - doesn't look like a war and no WEB-INF subdirectory.");
+ return false;
+ }
+ }
+ else if (trace)
+ {
+ log.trace("... ok - name ends in .war.");
+ }
- // Check for a META-INF for metadata
- // FIXME: This is not spec legal, descriptors could be loaded from this location
- String[] metaDataLocations = new String[]{"WEB-INF", "WEB-INF/classes/META-INF"};
- // Create a context for this war file and all its metadata locations
- context = createContext(structureContext, metaDataLocations);
+ // Check for a META-INF for metadata
+ // FIXME: This is not spec legal, descriptors could be loaded from this location
+ String[] metaDataLocations = new String[]{"WEB-INF", "WEB-INF/classes/META-INF"};
+ // Create a context for this war file and all its metadata locations
+ context = createContext(structureContext, metaDataLocations);
- // Add all children as locations for TLDs (except classes and lib), recursively
- webinf = file.getChild("WEB-INF");
- if (webinf.exists())
+ // Add all children as locations for TLDs (except classes and lib), recursively
+ webinf = file.getChild("WEB-INF");
+ if (webinf.exists())
+ {
+ List<VirtualFile> children = webinf.getChildren();
+ for (VirtualFile child : children)
{
- List<VirtualFile> children = webinf.getChildren();
- for (VirtualFile child : children)
+ if (!isLeaf(child) && (!"lib".equals(child.getName())) && (!"classes".equals(child.getName())))
{
- if (!isLeaf(child) && (!"lib".equals(child.getName())) && (!"classes".equals(child.getName())))
- {
- addMetaDataPath(structureContext, context, "WEB-INF/" + child.getName(), MetaDataType.ALTERNATIVE);
- addPathsRecursively(structureContext, context, child, "WEB-INF/" + child.getName());
- }
+ addMetaDataPath(structureContext, context, "WEB-INF/" + child.getName(), MetaDataType.ALTERNATIVE);
+ addPathsRecursively(structureContext, context, child, "WEB-INF/" + child.getName());
}
}
+ }
- // Check for jars in WEB-INF/lib
- List<VirtualFile> archives = null;
- try
+ // Check for jars in WEB-INF/lib
+ List<VirtualFile> archives = null;
+ try
+ {
+ VirtualFile webinfLib = file.getChild("WEB-INF/lib");
+ if (webinfLib.exists())
{
- VirtualFile webinfLib = file.getChild("WEB-INF/lib");
- if (webinfLib.exists())
+ archives = webinfLib.getChildren(webInfLibFilter);
+ // Add the jars' META-INF for metadata
+ for (VirtualFile jar : archives)
{
- archives = webinfLib.getChildren(webInfLibFilter);
- // Add the jars' META-INF for metadata
- for (VirtualFile jar : archives)
+ Automounter.mount(file, jar);
+ // either same as plain lib filter, null or accepts the jar
+ if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
{
- // either same as plain lib filter, null or accepts the jar
- if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
+ VirtualFile metaInf = jar.getChild("META-INF");
+ if (metaInf.exists() && !isLeaf(metaInf))
{
- VirtualFile metaInf = jar.getChild("META-INF");
- if (metaInf.exists() && !isLeaf(metaInf))
+ addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF", MetaDataType.ALTERNATIVE);
+ List<VirtualFile> children = metaInf.getChildren();
+ for (VirtualFile child : children)
{
- addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF", MetaDataType.ALTERNATIVE);
- List<VirtualFile> children = metaInf.getChildren();
- for (VirtualFile child : children)
+ if (!isLeaf(child) && (!"resources".equals(child.getName())))
{
- if (!isLeaf(child) && (!"resources".equals(child.getName())))
- {
- addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName(), MetaDataType.ALTERNATIVE);
- addPathsRecursively(structureContext, context, child, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName());
- }
+ addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName(), MetaDataType.ALTERNATIVE);
+ addPathsRecursively(structureContext, context, child, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName());
}
}
}
}
}
}
- catch (IOException e)
- {
- log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e);
- }
-
- // Add the war manifest classpath entries
- addClassPath(structureContext, file, false, true, context);
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e);
+ }
+
+ // Add the war manifest classpath entries
+ addClassPath(structureContext, file, false, true, context);
- // Check for WEB-INF/classes
- VirtualFile classes = file.getChild("WEB-INF/classes");
- // Add WEB-INF/classes if present
- if (classes.exists())
- addClassPath(structureContext, classes, true, false, context);
- else if (trace)
- log.trace("No WEB-INF/classes for: " + file.getPathName());
+ // Check for WEB-INF/classes
+ VirtualFile classes = file.getChild("WEB-INF/classes");
+ // Add WEB-INF/classes if present
+ if (classes.exists())
+ addClassPath(structureContext, classes, true, false, context);
+ else if (trace)
+ log.trace("No WEB-INF/classes for: " + file.getPathName());
- // and the top level jars in WEB-INF/lib
- if (archives != null)
- {
- for (VirtualFile jar : archives)
- addClassPath(structureContext, jar, true, true, context);
- }
- else if (trace)
- {
- log.trace("No WEB-INF/lib for: " + file.getPathName());
- }
-
- // do we include WEB-INF in classpath
- if (includeWebInfInClasspath && webinf != null)
- {
- addClassPath(structureContext, webinf, true, false, context);
- }
-
- // There are no subdeployments for wars
- return true;
+ // and the top level jars in WEB-INF/lib
+ if (archives != null)
+ {
+ for (VirtualFile jar : archives)
+ addClassPath(structureContext, jar, true, true, context);
}
- else
+ else if (trace)
{
- if (trace)
- log.trace("... no - not a directory or an archive.");
- return false;
+ log.trace("No WEB-INF/lib for: " + file.getPathName());
}
+
+ // do we include WEB-INF in classpath
+ if (includeWebInfInClasspath && webinf != null)
+ {
+ addClassPath(structureContext, webinf, true, false, context);
+ }
+
+ // There are no subdeployments for wars
+ return true;
}
catch (Exception e)
{
@@ -256,7 +250,21 @@
throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
}
}
+
+ @Override
+ protected boolean hasValidSuffix(String name)
+ {
+ return name.endsWith(".war");
+ }
+
+
+ @Override
+ protected void performMount(VirtualFile file) throws IOException
+ {
+ Automounter.mountExpanded(file);
+ }
+
protected void addPathsRecursively(StructureContext context, ContextInfo info, VirtualFile parent, String path) throws IOException
{
List<VirtualFile> children = parent.getChildren();
More information about the jboss-cvs-commits
mailing list