}
public boolean determineStructure(StructureContext structureContext) throws DeploymentException
{
ContextInfo context = null;
VirtualFile file = structureContext.getFile();
try
{
boolean trace = log.isTraceEnabled();
// the WEB-INF
VirtualFile webinf = null;
if (isLeaf(file) == false)
{
// We require either a WEB-INF or the name ends in .war
if (file.getName().endsWith(".war") == false)
{
try
{
webinf = file.getChild("WEB-INF");
if (webinf != null)
{
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;
}
}
catch (IOException e)
{
log.warn("Exception while checking if file is a war: " + e);
return false;
}
}
else if (trace)
{
log.trace("... ok - name ends in .war.");
}
List<String> metaDataLocations = new ArrayList<String>();
metaDataLocations.add("WEB-INF");
// Check for WEB-INF/classes
VirtualFile classes = null;
try
{
// The classpath contains WEB-INF/classes
classes = file.getChild("WEB-INF/classes");
// Check for a META-INF for metadata
if (classes != null)
metaDataLocations.add("WEB-INF/classes/META-INF");
}
catch(IOException e)
{
log.warn("Exception while looking for classes, " + file.getPathName() + ", " + e);
}
// Create a context for this war file and all its metadata locations
context = createContext(structureContext, metaDataLocations.toArray(new String[metaDataLocations.size()]));
// Check for jars in WEB-INF/lib
List<VirtualFile> archives = null;
try
{
VirtualFile webinfLib = file.getChild("WEB-INF/lib");
if (webinfLib != null)
{
archives = webinfLib.getChildren(webInfLibFilter);
// Add the jars' META-INF for metadata
for (VirtualFile jar : archives)
{
// either same as plain lib filter, null or accepts the jar
if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))