for (ModuleDescriptor aModule : app.getModules()) {
if(DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
DOLUtils.getDefaultLogger().fine("Opening sub-module " + aModule);
}
RootDeploymentDescriptor descriptor = null;
Archivist newArchivist = archivistFactory.get().getPrivateArchivistFor(aModule.getModuleType());
newArchivist.initializeContext(this);
newArchivist.setRuntimeXMLValidation(this.getRuntimeXMLValidation());
newArchivist.setRuntimeXMLValidationLevel(
this.getRuntimeXMLValidationLevel());
newArchivist.setAnnotationProcessingRequested(
annotationProcessingRequested);
ReadableArchive embeddedArchive = appArchive.getSubArchive(aModule.getArchiveUri());
if (embeddedArchive == null) {
throw new IllegalArgumentException(localStrings.getLocalString("enterprise.deployment.nosuchmodule", "Could not find sub module [{0}] as defined in application.xml", new Object[]{aModule.getArchiveUri()}));
}
embeddedArchive.setParentArchive(appArchive);
if (aModule.getAlternateDescriptor()!=null) {
// the module use alternate deployement descriptor, ignore the
// DDs in the archive.
InputStream is = appArchive.getEntry(aModule.getAlternateDescriptor());
DeploymentDescriptorFile ddFile = newArchivist.getStandardDDFile();
ddFile.setXMLValidation(newArchivist.getXMLValidation());
ddFile.setXMLValidationLevel(newArchivist.getXMLValidationLevel());
if (appArchive.getURI()!=null) {
ddFile.setErrorReportingString(appArchive.getURI().getSchemeSpecificPart());
}
descriptor = (BundleDescriptor) ddFile.read(is);
((BundleDescriptor)descriptor).setApplication(app);
is.close();
// TODO : JD need to be revisited for EAR files with Alternative descriptors, what does
// it mean for sub components.
Map<ExtensionsArchivist, RootDeploymentDescriptor> extensions =
new HashMap<ExtensionsArchivist, RootDeploymentDescriptor>();
if (extensionsArchivists!=null) {
for (ExtensionsArchivist extension : extensionsArchivists) {
if (extension.supportsModuleType(aModule.getModuleType())) {
Object rdd = extension.open(newArchivist, embeddedArchive, descriptor);
if (rdd instanceof RootDeploymentDescriptor) {
extensions.put(extension, (RootDeploymentDescriptor) rdd);
}
}
}
}
newArchivist.postStandardDDsRead(descriptor, embeddedArchive, extensions);
newArchivist.readAnnotations(embeddedArchive, descriptor, extensions);
newArchivist.postAnnotationProcess(descriptor, embeddedArchive);
newArchivist.postOpen(descriptor, embeddedArchive);
// now reads the runtime deployment descriptor...
if (isHandlingRuntimeInfo()) {
is = appArchive.getEntry("sun-" + aModule.getAlternateDescriptor());
if (is!=null) {
DeploymentDescriptorFile confDD =
newArchivist.getConfigurationDDFile();
confDD.setXMLValidation(
newArchivist.getRuntimeXMLValidation());
confDD.setXMLValidationLevel(
newArchivist.getRuntimeXMLValidationLevel());
if (appArchive.getURI()!=null) {
confDD.setErrorReportingString(
appArchive.getURI().getSchemeSpecificPart());
}
confDD.read(descriptor, is);
is.close();
newArchivist.postRuntimeDDsRead((RootDeploymentDescriptor)descriptor, embeddedArchive);
} else {
if (embeddedArchive!=null) {
newArchivist.readRuntimeDeploymentDescriptor(embeddedArchive,descriptor);
}
}
// read extensions runtime deployment descriptors if any
for (Map.Entry<ExtensionsArchivist, RootDeploymentDescriptor> extension : extensions.entrySet()) {
// after standard DD and annotations are processed
// we should have an extension descriptor now
if (extension.getValue() != null) {
extension.getKey().readRuntimeDeploymentDescriptor(newArchivist, embeddedArchive, extension.getValue());
}
}
}
} else {
// open the subarchive to get the deployment descriptor...
if (embeddedArchive!=null) {
descriptor = newArchivist.open(embeddedArchive, app);
} else {
DOLUtils.getDefaultLogger().info(localStrings.getLocalString(
"enterprise.deployment.cannotfindmodule",
"Cannot find module {0} in application bundle",
new Object[] {aModule.getArchiveUri()}));
nonexistentModules.add(aModule);
continue;
}
}
if (embeddedArchive!=null) {
embeddedArchive.close();
}
if (descriptor != null && descriptor instanceof BundleDescriptor) {
descriptor.getModuleDescriptor().setArchiveUri(
aModule.getArchiveUri());
aModule.setModuleName(
descriptor.getModuleDescriptor().getModuleName());
aModule.setDescriptor((BundleDescriptor) descriptor);
((BundleDescriptor) descriptor).setApplication(app);
aModule.setManifest(newArchivist.getManifest());
// for optional application.xml case, set the
// context root as module name for web modules