boolean scan = true;
Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
unmarshaller.setValidation(useValidation);
EarMetaData specMetaData = null;
JBossAppMetaData appMetaData = null;
if (applicationXml != null)
{
InputStream in = applicationXml.openStream();
try
{
specMetaData = (EarMetaData) unmarshaller.unmarshal(in, resolver);
}
finally
{
in.close();
}
scan = false;
}
if (jbossAppXml != null)
{
InputStream in = jbossAppXml.openStream();
try
{
appMetaData = (JBossAppMetaData) unmarshaller.unmarshal(in, resolver);
}
finally
{
in.close();
}
}
// Need a metadata instance and there will not be one if there are no descriptors
if (appMetaData == null)
{
appMetaData = new JBossAppMetaData();
}
// Create the merged view
appMetaData.merge(appMetaData, specMetaData);
String libDir = appMetaData.getLibraryDirectory();
if (libDir == null || libDir.length() > 0)
{
if (libDir == null)
libDir = "lib";
// Add the ear lib contents to the classpath
if(trace)
log.trace("Checking for ear lib directory: "+libDir);
try
{
lib = file.getChild(libDir);
if (lib != null)
{
if(trace)
log.trace("Found ear lib directory: "+lib);
List<VirtualFile> archives = lib.getChildren(earLibFilter);
for (VirtualFile archive : archives)
{
addClassPath(structureContext, archive, true, true, context);
try
{
// add any jars with persistence.xml as a deployment
if (archive.getChild("META-INF/persistence.xml") != null)
{
log.trace(archive.getName() + " in ear lib directory has persistence units");
if (structureContext.determineChildStructure(archive) == false)
{
throw new RuntimeException(archive.getName()
+ " in lib directory has persistence.xml but is not a recognized deployment, .ear: "
+ file.getName());
}
}
else if (trace)
log.trace(archive.getPathName() + " does not contain META-INF/persistence.xml");
}
catch(IOException e)
{
// TODO - should we throw this fwd?
log.warn("Exception searching for META-INF/persistence.xml in " + archive.getPathName() + ", " + e);
}
}
}
else if (trace)
log.trace("No lib directory in ear archive.");
}
catch (IOException e)
{
// TODO - should we throw this fwd?
log.warn("Exception while searching for lib dir: " + e);
}
}
else if (trace)
{
log.trace("Ignoring library directory, got empty library-directory element.");
}
// Add the ear manifest locations?
addClassPath(structureContext, file, includeEarRootInClasspath, true, context);
// TODO: need to scan for annotationss
if( scan )
{
scanEar(file, appMetaData);
}
// Create subdeployments for the ear modules
ModulesMetaData modules = appMetaData.getModules();
if(modules != null)
{
for (ModuleMetaData mod : modules)
{
String fileName = mod.getFileName();