if (adHocSubtrees != null) {
ctx.addAdHocSubtrees(adHocSubtrees);
}
// Object containing web.xml information
WebBundleDescriptor wbd = wmInfo.getDescriptor();
//Set the context root
String contextRoot = null;
if (wmInfo.getBean() != null) {
if( wmInfo.getBean() instanceof
com.sun.enterprise.config.serverbeans.WebModule) {
contextRoot =
((com.sun.enterprise.config.serverbeans.WebModule)wmInfo.
getBean()).getContextRoot();
} else {
if("true".equals(((ExtensionModule)wmInfo.getBean()).
getElementPropertyByName("isConverged").getValue())) {
ExtensionModule emBean = (ExtensionModule)wmInfo.getBean();
contextRoot =
emBean.getElementPropertyByName("contextRoot").
getValue();
} else {
contextRoot = wmInfo.getModuleName();
}
}
ctx.setContextRoot(contextRoot);
if (wbd != null) {
wbd.setContextRoot(contextRoot);
}
} else {
// Should never happen.
_logger.log(Level.WARNING, "Unable to set context root", wmInfo);
}
//
// Ensure that the generated directory for JSPs in the document root
// (i.e. those that are serviced by a system default-web-module)
// is different for each virtual server.
//
String wmInfoWorkDir = wmInfo.getWorkDir();
if (wmInfoWorkDir != null) {
StringBuffer workDir = new StringBuffer(wmInfo.getWorkDir());
if (wmName.equals(Constants.DEFAULT_WEB_MODULE_NAME)) {
workDir.append("-");
workDir.append(FileUtils.makeFriendlyFilename(vs.getID()));
}
ctx.setWorkDir(workDir.toString());
}
ClassLoader parentLoader = wmInfo.getParentLoader();
if (parentLoader == null) {
// Use the shared classloader as the parent for all
// standalone web-modules
parentLoader = _serverContext.getSharedClassLoader();
}
ctx.setParentClassLoader(parentLoader);
Throwable exception = null;
Switch sw = Switch.getSwitch();
try{
// Determine if an alternate DD is set for this web-module in
// the application
if (wbd != null) {
String altDDName = wbd.getModuleDescriptor().
getAlternateDescriptor();
if (altDDName != null) {
// we should load the alt dd from generated/xml directory
// first, then fall back to original app location.
// if we have alt dd, it must be an embedded web module
String appName = wmName.substring(0,
wmName.indexOf(Constants.NAME_SEPARATOR));
String appLoc =
appsManager.getGeneratedXMLLocation(appName);
if (! FileUtils.safeIsDirectory(appLoc)) {
appLoc = wmInfo.getLocation()+"/..";
}
if (altDDName.startsWith("/")) {
altDDName = appLoc+altDDName.trim();
}
else {
altDDName = appLoc+"/"+altDDName.trim();
}
Object[] objs = {altDDName, wmName};
_logger.log(Level.INFO, "webcontainer.altDDName", objs);
ctx.setAltDDName(altDDName);
}
// time to update the Web Services related information in
// our runtime jsr77 mbeans. We publish two extra properties
// hasWebServices and endpointAddresses for webservices
// enable web applications.
if (wbd.hasWebServices()) {
ctx.setHasWebServices(true);
// creates the list of endpoint addresses
String[] endpointAddresses;
WebServicesDescriptor webService = wbd.getWebServices();
Vector endpointList = new Vector();
for (Iterator endpoints = webService.getEndpoints().iterator();
endpoints.hasNext();) {
WebServiceEndpoint wse = (WebServiceEndpoint) endpoints.next();
if (wbd.getContextRoot()!=null) {
endpointList.add(wbd.getContextRoot() + "/"
+ wse.getEndpointAddressUri());
} else {
endpointList.add(wse.getEndpointAddressUri());
}
}
endpointAddresses = new String[endpointList.size()];
endpointList.copyInto(endpointAddresses);
ctx.setEndpointAddresses(endpointAddresses);
} else {
ctx.setHasWebServices(false);
}
}
// Object containing sun-web.xml information
SunWebApp iasBean = null;
// The default context is the only case when wbd == null
if (wbd != null)
iasBean = wbd.getSunDescriptor();
// set the sun-web config bean
ctx.setIasWebAppConfigBean(iasBean);
ctx.setID(wmName);
// Configure SingleThreadedServletPools, work/tmp directory etc
configureMiscSettings(ctx, iasBean, vs, displayContextPath);
// Configure alternate docroots if dummy web module
if (Constants.DEFAULT_WEB_MODULE_NAME.equals(ctx.getID())) {
ctx.setAlternateDocBases(vs.getProperties());
}
// Configure the class loader delegation model, classpath etc
Loader loader = configureLoader(ctx, iasBean, wmInfo);
// Set the class loader on the DOL object
if (wbd != null && wbd.hasWebServices())
wbd.addExtraAttribute("WEBLOADER", loader);
// Enable dynamic reloading only for Web Modules
if ( wmInfo.getBean() instanceof
com.sun.enterprise.config.serverbeans.WebModule &&
_reloadingEnabled) {
if (_reloadManager == null) {
_reloadManager = new StandaloneWebModulesManager(
_id,
_modulesRoot,
_pollInterval);
}
_reloadManager.addWebModule((com.sun.enterprise.config.serverbeans.WebModule)wmInfo.getBean());
}
// Configure the session manager and other related settings
// HERCULES:mod - take into account if app is distributable
// passing in WebBundleDescriptor which has info about whether
// app is distributable
ctx.configureSessionSettings(wbd, wmInfo);
// END HERCULES:mod
// set i18n info from locale-charset-info tag in sun-web.xml
ctx.setI18nInfo();
if (wbd != null) {
String resourceType = null;
if(wmInfo.getBean() instanceof
com.sun.enterprise.config.serverbeans.WebModule) {
resourceType =
((com.sun.enterprise.config.serverbeans.WebModule)wmInfo.
getBean()).getObjectType();
} else {
resourceType = ((ExtensionModule)wmInfo.getBean()).
getObjectType();
}
boolean isSystem = (resourceType != null &&
resourceType.startsWith("system-"));
if ("null".equals(j2eeApplication)) {
/*
* Standalone webapps inherit the realm referenced by
* the virtual server on which they are being deployed,
* unless they specify their own
*/
ctx.setRealm(getRealmAdapter(wbd, isSystem, vs.getAuthRealmName()));
} else {
ctx.setRealm(getRealmAdapter(wbd, isSystem, null));
}
configureSecurity(wbd, isSystem);
sw.setDescriptorFor(ctx, wbd);
// post processing DOL object for standalone web module
if (wbd.getApplication() != null &&
wbd.getApplication().isVirtual()) {
wbd.visit((WebBundleVisitor) new WebValidatorWithoutCL());
}
}
// Add virtual server mime mappings, if present
addMimeMappings(ctx, vs.getMimeMap());
} catch (Throwable ex){
exception = ex;
}
if (wbd != null && wbd.getApplication() != null) {
// no dummy web module
String moduleName;
// S1AS BEGIN WORKAROUND FOR 6174360
if (wbd.getApplication().isVirtual()) {
// this is a standalone module
moduleName = wbd.getApplication().getRegistrationName();
} else {
moduleName = wbd.getModuleDescriptor().getArchiveUri();
}
// S1AS END WORKAROUND FOR 6174360
ctx.setModuleName(moduleName);
} else {
ctx.setModuleName(Constants.DEFAULT_WEB_MODULE_NAME);