StandAloneEJBModulesManagerpublic class StandAloneEJBModulesManager extends AbstractManager implements com.sun.enterprise.admin.event.ModuleDeployEventListenerManages all stand alone EJB modules. It also acts as an listener for
the deployment events. |
Fields Summary |
---|
static Logger | _loggerlogger to log core messages | private static com.sun.enterprise.util.i18n.StringManager | localStringslocal string manager |
Constructors Summary |
---|
StandAloneEJBModulesManager(com.sun.enterprise.instance.EjbModulesManager ejbManager, ClassLoader parentClassLoader)This manager is responsible for loading all stand alone ejb modules
in an instance. It creates EJBModuleLoader for each deployed ejb module.
EJBModuleLoader is responsible for further loading ejb containers for
each module.
It is assumed that the next two params are set by the startup Code.
super(parentClassLoader, ejbManager);
AdminEventListenerRegistry.addModuleDeployEventListener(this);
|
Methods Summary |
---|
protected AbstractLoader | getLoader(java.lang.String moduleId)Returns a loader for stand alone ejb module.
return new EJBModuleLoader(moduleId, this.parentClassLoader,
(EjbModulesManager)this.configManager);
| private void | holdRequest()
| private void | holdRequest(java.lang.String appID)
| public synchronized void | moduleDeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is deployed.
boolean jsr77 = false;
if (event.getModuleTypeCode() == event.TYPE_EJBMODULE_CODE) {
DeployEventListenerHelper.getDeployEventListenerHelper().synchronize(event);
String modID = event.getModuleName();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"Deploying EJB Module: " + modID);
}
try {
// refreshes the config context with the context from this event
this.configManager.refreshConfigContext(
event.getConfigContext() );
// set jsr77 flag
String action = event.getAction();
if ((action.equals(BaseDeployEvent.DEPLOY)) ||
(action.equals(BaseDeployEvent.REDEPLOY))) {
jsr77 = true;
}
if (isEnabled(event.getConfigContext(), modID) &&
!moduleDeployed(jsr77, modID, event.getConfigContext())) {
String msg = localStrings.getString(
"standaloneejbmodulesmgr.ejbmodule_deployed_failed",
modID);
registerException(event, msg);
}
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce.getMessage());
}
}
| private boolean | moduleDeployed(boolean jsr77, java.lang.String moduleName, com.sun.enterprise.config.ConfigContext dynamicConfigContext)
return moduleDeployed(jsr77, moduleName, true, dynamicConfigContext);
| private boolean | moduleDeployed(boolean jsr77, java.lang.String moduleName, boolean addToRM, com.sun.enterprise.config.ConfigContext dynamicConfigContext)
boolean result = false;
boolean loadJSR77 = jsr77 || loadJSR77(moduleName, DeployableObjectType.EJB);
AbstractLoader modLoader = null;
try {
modLoader = getLoader(moduleName);
modLoader.setConfigContext(dynamicConfigContext);
// create root mBean for this module
if (loadJSR77) {
try {
modLoader.createRootMBean();
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_creating_jsr77_root_mbean",mbe);
}
}
if (isEnabled(dynamicConfigContext, moduleName)) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"Loading enabled ejb module: " + moduleName);
}
//Check to see if the app is already loaded. If yes, do not reload.
if (id2loader.get(moduleName) != null) {
return true;
}
// set jsr77 state STARTING
try {
modLoader.setState(StateManageable.STARTING_STATE);
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_setting_jsr77_state",mbe);
}
boolean retSts = modLoader.load(jsr77);
if (retSts) {
this.id2loader.put(moduleName, modLoader);
// adds the ejb module to be monitored if ON
if (addToRM) {
addToReloadMonitor(moduleName);
}
// set jsr77 state to RUNNING
try {
modLoader.setState(StateManageable.RUNNING_STATE);
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_setting_jsr77_state",mbe);
}
result = true;
} else {
if (loadJSR77) {
// delete root and leaf mBeans for this module
try {
modLoader.deleteLeafAndRootMBeans();
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_deleting_jsr77_root_and_leaf_mbeans",mbe);
}
} else {
// set jsr77 state FAILED
try {
modLoader.setState(StateManageable.FAILED_STATE);
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_setting_jsr77_state",mbe);
}
}
_logger.log(Level.WARNING,
"core.error_while_loading_ejb_module");
}
} else {
_logger.log(Level.INFO, "core.ejb_module_disabled", moduleName);
//setting result to false since module was disabled
result = false;
}
} catch (ConfigException ce) {
_logger.log(Level.WARNING,"core.error_while_loading_ejb_module",ce);
result = false;
} finally {
//To ensure that the config context is not reused...
if (modLoader != null) {
modLoader.setConfigContext(null);
}
}
return result;
| public synchronized void | moduleDisabled(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is disabled.
if (event.getModuleTypeCode() == event.TYPE_EJBMODULE_CODE) {
String modID = event.getModuleName();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"Disabling EJB Module: " + modID);
}
moduleUndeployed(event);
}
| public synchronized void | moduleEnabled(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is enabled.
if (event.getModuleTypeCode() == event.TYPE_EJBMODULE_CODE) {
String modID = event.getModuleName();
if (!isEnabled(event.getConfigContext(), modID)) {
return;
}
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "Enabling EJB Module: " + modID);
}
moduleDeployed(event);
}
| public synchronized void | moduleRedeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is redeployed.
if (event.getModuleTypeCode() == event.TYPE_EJBMODULE_CODE) {
String modID = event.getModuleName();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"Redeploying EJB Module: " + modID);
}
moduleUndeployed(event);
moduleDeployed(event);
}
| 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 boolean | moduleUnDeployed(boolean jsr77, java.lang.String moduleName, boolean clearRM)Unloads the given ejb module.
EJBModuleLoader modLoader =
(EJBModuleLoader) this.id2loader.remove(moduleName);
// removes this ejb module from reload monitor
if (clearRM) {
removeFromReloadMonitor(moduleName);
}
// module is not in the registry - must have been undeployed
if (modLoader == null) {
return true;
}
// set jsr77 state to STOPPING
try {
modLoader.setState(StateManageable.STOPPING_STATE);
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_setting_jsr77_state",mbe);
}
Application app = modLoader.getApplication();
RoleMapper.removeRoleMapper(app.getRoleMapper().getName());
if (jsr77) {
// delete jsr77 mBean for this ejbModule
try {
modLoader.deleteRootMBean();
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_deleting_jsr77_root_mbean",mbe);
}
} else {
// set jsr77 state to STOPPED
try {
modLoader.setState(StateManageable.STOPPED_STATE);
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_setting_jsr77_state",mbe);
}
}
boolean undeployed = modLoader.unload(jsr77);
if (undeployed) {
_logger.log(Level.INFO,
"core.ejb_module_unload_successful", moduleName);
} else {
_logger.log(Level.INFO,
"core.ejb_module_not_unloaded", moduleName);
}
return undeployed;
| private boolean | moduleUnDeployed(java.lang.String moduleName)Unloads the given stand alone ejb module.
This removes this ejb module from reload monitor list.
This gets called when the ejb module is undeployed.
return moduleUnDeployed(false, moduleName);
| private boolean | moduleUnDeployed(boolean jsr77, java.lang.String moduleName)Unloads the given stand alone ejb module.
This removes this ejb module from reload monitor list.
This gets called when the ejb module is undeployed.
return moduleUnDeployed(jsr77, moduleName, true);
| public synchronized void | moduleUndeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone J2EE module is undeployed.
boolean jsr77 = false;
String action = event.getAction();
if ((action.equals(BaseDeployEvent.UNDEPLOY)) ||
(action.equals(BaseDeployEvent.REDEPLOY))) {
jsr77 = true;
}
try {
if (event.getModuleTypeCode() == event.TYPE_EJBMODULE_CODE) {
String modID = event.getModuleName();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"Undeploying EJB Module: " + modID);
}
// refreshes the config context with the context from this event
this.configManager.refreshConfigContext(
event.getOldConfigContext() );
boolean undeployed = moduleUnDeployed(jsr77, modID);
if (!undeployed) {
String msg = localStrings.getString(
"standaloneejbmodulesmgr.ejbmodule_undeployed_failed",
modID);
registerException(event, msg);
}
}
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce.getMessage());
}
| public synchronized boolean | reload(MonitorableEntry entry)This is a callback from reload monitor when a change in time stamp
for a stand alone ejb module is detected.
String moduleName = entry.getId();
boolean status = false;
// redeploys the stand alone ejb module
try {
DeploymentRequest req = new DeploymentRequest(
this.configManager.getInstanceEnvironment(),
DeployableObjectType.EJB,
DeploymentCommand.DEPLOY);
// monitored file points to $APP_ROOT/.reload
req.setFileSource(entry.getMonitoredFile().getParentFile());
// application registration name
req.setName(moduleName);
// we are always trying a redeployment
req.setForced(true);
AutoDirReDeployer deployer = new AutoDirReDeployer(req);
status = deployer.redeploy();
} catch (IASDeploymentException de) {
_logger.log(Level.WARNING,"core.error_in_reload_ejb_module",de);
return false;
}
return status;
|
|