*/
public boolean loadJ2eeApplicationModule(ArchiveDescriptor descriptor)
throws Exception {
com.sun.enterprise.config.serverbeans.ExtensionModule em = null;
WebModuleConfig wmInfo = null;
Application appDesc = null;
J2eeApplication j2eeAppBean = getJ2eeAppBean();
ConfigContext eventConfigContext = j2eeAppBean.getConfigContext();
String id = j2eeAppBean.getName();
String location = j2eeAppBean.getLocation();
String resourceType = j2eeAppBean.getObjectType();
//TODO : Check if enabled and take action
// get the application descriptor
ApplicationRegistry registry = ApplicationRegistry.getInstance();
ClassLoader appLoader = registry.getClassLoaderForApplication(id);
if (appLoader != null) {
appDesc = registry.getApplication(appLoader);
}
// If the Application object is null then we should not load.
if(appDesc == null ) {
// log message
return false;
}
String j2eeApplication = appDesc.getRegistrationName();
// get the Bundle Descriptor
WebBundleDescriptor wbd = (WebBundleDescriptor)descriptor;
String moduleName = wbd.getModuleDescriptor().getArchiveUri();
StringBuffer dir = new StringBuffer(location);
dir.append(File.separator);
dir.append(FileUtils.makeFriendlyFilename(moduleName));
if (!(new File(dir.toString()).exists())) {
dir = new StringBuffer(location).append(
File.separator).append(moduleName);
}
// set the values in the ExtensionModule config bean
em = new com.sun.enterprise.config.serverbeans.ExtensionModule();
em.setLocation(dir.toString().trim());
em.setConfigContext(eventConfigContext);
em.setName(moduleName);
ElementProperty isConvergedProperty = new ElementProperty();
isConvergedProperty.setName("isConverged");
if(wbd.getContextRoot() != null) {
isConvergedProperty.setValue("true");
ElementProperty contextRootProperty = new ElementProperty();
contextRootProperty.setName("contextRoot");
contextRootProperty.setValue(wbd.getContextRoot());
em.addElementProperty(contextRootProperty);
} else {
isConvergedProperty.setValue("false");
}
em.addElementProperty(isConvergedProperty);
em.setEnabled(true);
em.setObjectType(resourceType);
// create and populate the WebModuleConfig object
wmInfo = new WebModuleConfig();
wmInfo.setBean(em);
wmInfo.setApplicationBean(j2eeAppBean);
wmInfo.setDescriptor(wbd);
wmInfo.setParentLoader(appLoader);
wmInfo.setVirtualServers(getVirtualServers(id, eventConfigContext));
// Call into the WebContainer
List<Throwable> throwables =
getWebContainer().loadWebModule(wmInfo, j2eeApplication);
setJ2eeAppBean(null);