*@param manager The instance manager for the module
*@return The top level Descriptor object
*/
public static RootDeploymentDescriptor getDescriptor(
String appId, BaseManager manager) throws IASDeploymentException {
Application application = manager.getRegisteredDescriptor(appId);
if (application != null) {
if (application.isVirtual()) {
return application.getStandaloneBundleDescriptor();
} else {
return application;
}
}
//Now, load from disk
FileArchive in = new FileArchive();
try {
String appDir = manager.getLocation(appId);
// if is system predeployed app, load from original app dir
// else load from generated/xml dir
// print a warning if generated/xml dir is not there
// and load from original dir (upgrade scenario)
if (manager.isSystemAdmin(appId)) {
in.open(appDir);
} else {
String xmlDir = manager.getGeneratedXMLLocation(appId);
if (FileUtils.safeIsDirectory(xmlDir)) {
/*
* If default-web.xml is more recent than the generated
* directory, then the generated descriptor does not reflect
* the current contents of default-web.xml.
*/
File xmlDirFile = new File(xmlDir);
if (xmlDirFile.lastModified() < DOLLoadingContext.defaultWebXMLLastModified()) {
_logger.log(Level.INFO, "enterprise.deployment.backend.default_web_xml_more_recent",
new Object[] {appId, appDir});
in.open(appDir);
} else {
in.open(xmlDir);
}
} else {
// log a warning message in the server log
_logger.log(Level.WARNING,
"enterprise.deployment.backend.no_generated_xmldir",
new Object[]{appId, xmlDir, appDir});
in.open(appDir);
}
}
Archivist archivist = null;
if (manager instanceof AppsManager) {
archivist = new ApplicationArchivist();
} else if (manager instanceof EjbModulesManager) {
archivist = new EjbArchivist();
} else if (manager instanceof WebModulesManager) {
archivist = new WebArchivist();
} else if (manager instanceof AppclientModulesManager) {
archivist = new AppClientArchivist();
} else if (manager instanceof ConnectorModulesManager) {
archivist = new ConnectorArchivist();
}
archivist.setAnnotationProcessingRequested(false);
archivist.setXMLValidation(false);
Application desc = ApplicationArchivist.openArchive(
appId, archivist, in, true);
//note: we are not reading back the persistence information here
//we could, if ever the tools need it.
if (!desc.isVirtual()) {
archivist.setHandleRuntimeInfo(false);
((ApplicationArchivist)
archivist).readModulesDescriptors(desc, in);
// now process runtime DDs
archivist.setHandleRuntimeInfo(true);
archivist.readRuntimeDeploymentDescriptor(in, desc);
} else {
return (BundleDescriptor)
desc.getBundleDescriptors().iterator().next();
}
return desc;
} catch (Exception ex) {
_logger.log(Level.SEVERE,
"enterprise.deployment.backend.get_descriptor_failed",