Methods Summary |
---|
private com.sun.enterprise.web.WebContainer | getWebContainer()
if (webContainer == null) {
this.webContainer = WebContainer.getInstance();
}
return this.webContainer;
|
private synchronized com.sun.enterprise.config.serverbeans.WebModule | getWebModuleAndUpdateCache(com.sun.enterprise.config.ConfigContext config, java.lang.String moduleName, boolean isAddToCache)
WebModule webModule = (WebModule)cachedWebModules.get(moduleName);
if ( webModule == null ) {
try {
webModule = (WebModule) ApplicationHelper.findApplication(
config, moduleName);
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce);
}
if (webModule == null) {
String msg = localStrings.getString(
"webmodule.module_not_found",
moduleName);
throw new AdminEventListenerException(msg);
}
if (isAddToCache) {
cachedWebModules.put(moduleName, webModule);
}
} else {
if (!isAddToCache) {
cachedWebModules.remove(moduleName);
}
}
return webModule;
|
private com.sun.enterprise.instance.WebModulesManager | getWebModulesManager()
return (WebModulesManager) this.configManager;
|
protected boolean | isEnabled(com.sun.enterprise.config.ConfigContext config, java.lang.String moduleName)Whether or not a web module should be
enabled is defined by the "enable" attribute on both the
module element and the application-ref element.
try {
ConfigBean app = ApplicationHelper.findApplication(config, moduleName);
Server server = ServerBeansFactory.getServerBean(config);
ApplicationRef appRef = server.getApplicationRefByRef(moduleName);
return ((app != null && app.isEnabled()) &&
(appRef != null && appRef.isEnabled()));
} catch (ConfigException e) {
AdminEventListenerException ex = new AdminEventListenerException();
ex.initCause(e);
_logger.log(Level.FINE, "Error in finding " + moduleName, e);
//If there is anything wrong, do not enable the module
return false;
}
|
private com.sun.enterprise.web.WebModuleConfig | loadWebModuleConfig(com.sun.enterprise.config.serverbeans.WebModule wm, com.sun.enterprise.config.ConfigContext config)Creates and returns an object that contains information about
the web module's configuration such as the information specified
in server.xml, the deployment descriptor objects etc.
// --------------------------------------------------------- Private Methods
WebModuleConfig wmInfo = new WebModuleConfig();
wmInfo.setBean(wm);
String wmID = wm.getName();
String location = wm.getLocation();
try {
Application app = getWebModulesManager().getDescriptor(wmID,
location);
WebBundleDescriptor wbd = (WebBundleDescriptor) app.getStandaloneBundleDescriptor();
wmInfo.setDescriptor(wbd);
String vs = ServerBeansFactory.getVirtualServersByAppName(
config, wmID);
wmInfo.setVirtualServers(vs);
} catch (ConfigException ce) {
wmInfo = null;
}
return wmInfo;
|
private void | moduleDeployed(com.sun.enterprise.config.ConfigContext config, java.lang.String moduleName)
WebModule webModule = getWebModuleAndUpdateCache(
config, moduleName, true);
//Do not deploy if enable is false
if (!isEnabled(config, moduleName)) {
return;
}
String location = webModule.getLocation();
// If module root is relative then prefix it with the
// location of where all the standalone modules for
// this server instance are deployed
File moduleBase = new File(location);
String modulesRoot = getWebContainer().getModulesRoot();
if (!moduleBase.isAbsolute()) {
location = modulesRoot+File.separator+location;
webModule.setLocation(location);
}
WebModuleConfig wmInfo = loadWebModuleConfig(webModule, config);
List<Throwable> throwables =
getWebContainer().loadWebModule(wmInfo, "null");
if (throwables != null && !throwables.isEmpty()) {
//we don't have the ability to return all errors. so return the
//first one, enough to signal the problem.
String msg = throwables.get(0).getMessage();
AdminEventListenerException ex =
new AdminEventListenerException(msg);
ex.initCause(throwables.get(0));
throw ex;
}
|
public synchronized void | moduleDeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is deployed.
if (event.getModuleType().equals(ModuleDeployEvent.TYPE_WEBMODULE)) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"[WebModuleDeployEventListener] Handling event " + event.toString());
}
DeployEventListenerHelper.getDeployEventListenerHelper().synchronize(event);
ConfigContext config = event.getConfigContext();
String moduleName = event.getModuleName();
// refreshes the config context with the context from this event
try {
getWebModulesManager().refreshConfigContext(config);
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce.getMessage());
}
// The only job of dummyLoader is to inform the ondemand framework
// about this module. It does not actually load the app.
AbstractLoader dummyLoader = getLoader(moduleName);
if (dummyLoader.load(false)) {
moduleDeployed(config, moduleName);
}
}
|
public synchronized void | moduleDisabled(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is disabled.
if (event.getModuleType().equals(ModuleDeployEvent.TYPE_WEBMODULE)) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"[WebModuleDeployEventListener] Handling event " + event.toString());
}
ConfigContext config = event.getConfigContext();
String moduleName = event.getModuleName();
WebModule webModule = getWebModuleAndUpdateCache(
config, moduleName, true);
String appName = null;
WebBundleDescriptor wbd;
try {
Application app = getWebModulesManager().getDescriptor(
webModule.getName(), webModule.getLocation());
wbd =
(WebBundleDescriptor) app.getStandaloneBundleDescriptor();
appName = app.getRegistrationName();
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce);
}
String contextRoot = webModule.getContextRoot();
String virtualServers = null;
try {
virtualServers = ServerBeansFactory
.getVirtualServersByAppName(config,moduleName);
} catch(ConfigException ce) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"Exception getting virtual servers by app name "
+ moduleName, ce);
}
}
getWebContainer().disableWebModule(contextRoot,appName,
virtualServers);
}
|
public synchronized void | moduleEnabled(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is enabled.
if (event.getModuleType().equals(ModuleDeployEvent.TYPE_WEBMODULE)) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"[WebModuleDeployEventListener] Handling event " + event.toString());
}
ConfigContext config = event.getConfigContext();
String moduleName = event.getModuleName();
WebModule webModule = getWebModuleAndUpdateCache(
config, moduleName, true);
//Do not deploy if enable is false
if (!isEnabled(event.getConfigContext(), moduleName)) {
return;
}
String location = webModule.getLocation();
// If module root is relative then prefix it with the
// location of where all the standalone modules for
// this server instance are deployed
File moduleBase = new File(location);
String modulesRoot = getWebContainer().getModulesRoot();
if (!moduleBase.isAbsolute()) {
location = modulesRoot+File.separator+location;
webModule.setLocation(location);
}
WebModuleConfig wmInfo = loadWebModuleConfig(webModule, config);
getWebContainer().enableWebModule(wmInfo, "null");
}
|
public synchronized void | moduleRedeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is redeployed.
if (event.getModuleType().equals(ModuleDeployEvent.TYPE_WEBMODULE)) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"[WebModuleDeployEventListener] Handling event " + event.toString());
}
String moduleName = event.getModuleName();
// unload from old location
ConfigContext oldConfig = event.getOldConfigContext();
moduleUndeployed(oldConfig, moduleName);
// load to new location
ConfigContext config = event.getConfigContext();
moduleDeployed(config, moduleName);
}
|
public void | moduleReferenceAdded(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a reference is created from a
server instance (or cluster) to a particular module.
|
public void | moduleReferenceRemoved(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a reference is removed from a
server instance (or cluster) to a particular module.
|
private void | moduleUndeployed(com.sun.enterprise.config.ConfigContext config, java.lang.String moduleName)
WebModule webModule = getWebModuleAndUpdateCache(
config, moduleName, false);
String appName = null;
WebBundleDescriptor wbd;
try {
Application app = getWebModulesManager().getDescriptor(
webModule.getName(), webModule.getLocation());
RoleMapper.removeRoleMapper(app.getRoleMapper().getName());
wbd = (WebBundleDescriptor) app.getStandaloneBundleDescriptor();
appName = app.getRegistrationName();
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce);
}
String contextRoot = webModule.getContextRoot();
String virtualServers = null;
try {
virtualServers = ServerBeansFactory
.getVirtualServersByAppName(config,moduleName);
} catch(ConfigException ce) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"Exception getting virtual servers by app name "
+ moduleName, ce);
}
}
try {
getWebContainer().unloadWebModule(contextRoot, appName,
virtualServers, wbd);
} finally {
try {
Switch.getSwitch().getNamingManager().unbindObjects(wbd);
} catch (javax.naming.NamingException nameEx) {
_logger.log(Level.FINEST, "[WebModuleDeployEventListener] "
+ " Exception during namingManager.unbindObject",
nameEx);
}
}
|
public synchronized void | moduleUndeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is undeployed.
if (event.getModuleType().equals(ModuleDeployEvent.TYPE_WEBMODULE)) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"[WebModuleDeployEventListener] Handling event " + event.toString());
}
ConfigContext config = event.getOldConfigContext();
String moduleName = event.getModuleName();
// refreshes the config context with the context from this event
try {
getWebModulesManager().refreshConfigContext(config);
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce.getMessage());
}
AbstractLoader dummyLoader = getLoader(moduleName);
dummyLoader.unload(false);
moduleUndeployed(config, moduleName);
}
|