StandAloneConnectorModulesManagerpublic class StandAloneConnectorModulesManager extends AbstractManager implements com.sun.enterprise.admin.event.ModuleDeployEventListenerConnector Manager 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 | localStrings |
Constructors Summary |
---|
StandAloneConnectorModulesManager(com.sun.enterprise.instance.ConnectorModulesManager connectorManager, ClassLoader parentClassLoader)Connector Manager is responsible for loading connector when deploy event is invoked.
It is assumed that the next two params are set by the Startup Code.
// this.configManager=configManager;
super(parentClassLoader, connectorManager);
AdminEventListenerRegistry.addModuleDeployEventListener(this);
|
Methods Summary |
---|
protected AbstractLoader | getLoader(java.lang.String moduleId)
return new ConnectorModuleLoader(moduleId, this.parentClassLoader,
(ConnectorModulesManager) this.configManager);
| private boolean | moduleDeployed(boolean jsr77, com.sun.enterprise.config.ConfigContext config, java.lang.String moduleName)Loads the given stand alone connector module.
boolean result = false;
boolean loadJSR77 = jsr77 || loadJSR77(moduleName, DeployableObjectType.CONN);
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"In connector moduleDeployed event,name=" + moduleName);
}
AbstractLoader modLoader = getLoader(moduleName);
_logger.log(Level.FINEST, "After get loader");
// create jsr77 mBean
if (loadJSR77) {
try {
modLoader.createRootMBean();
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_creating_jsr77_root_mbean",mbe);
throw new AdminEventListenerException(mbe.getMessage());
}
}
if (isEnabled(config, moduleName)) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"Loading enabled moduleName: " + moduleName);
}
// 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);
// 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;
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE,
"Successfully loaded moduleName: " + moduleName);
}
} else {
_logger.log(Level.WARNING,
"core.error_while_loading_connector_module" + " " +
moduleName);
// delete root and leaf mBeans if it is a deploy event
try {
if (loadJSR77) {
modLoader.deleteLeafAndRootMBeans();
}
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_deleting_jsr77_leaf_and_root_mbeans",mbe);
throw new AdminEventListenerException(mbe.getMessage());
}
// set jsr77 state to FAILED
try {
modLoader.setState(StateManageable.FAILED_STATE);
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"core.error_while_setting_jsr77_state",mbe);
}
String msg = localStrings.getString(
"connector.error_while_loading_connector_module", moduleName);
throw new AdminEventListenerException(msg);
}
} else {
//setting result to false if module is not enabled.
result = false;
}
return result;
| public synchronized void | moduleDeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone connector module is deployed.
if (event.getModuleType().equals(event.TYPE_CONNECTOR)) {
DeployEventListenerHelper.getDeployEventListenerHelper().synchronize(event);
}
if(event.getForceDeploy() ) {
moduleEnabled(event);
return;
} else {
//As of 8.1 PE/SE/EE, RA Configs will not be deployed in the connector
//backend when created, but would be lazily loaded while
//the connector module is deployed in the backend.
try {
ConnectorResourcesLoader connectorResourcesLoader = null;
connectorResourcesLoader= new ConnectorResourcesLoader();
connectorResourcesLoader.loadRAConfigs(event.getModuleName());
} catch (ConfigException e) {
_logger.log(Level.WARNING, "" + e.getMessage());
AdminEventListenerException aele = new AdminEventListenerException();
aele.initCause(e);
throw aele;
}
realDeployed(event);
}
| public synchronized void | moduleDisabled(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone connector module is disabled.
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"In StandAloneConnectorModulesManager moduleDisabled");
}
if (event.getModuleType().equals(event.TYPE_CONNECTOR)) {
String modID = event.getModuleName();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "Module : " + modID + " disabled...");
}
AbstractLoader modLoader =
(ConnectorModuleLoader) this.id2loader.get(modID);
event.setCascade(true);
realUndeployed(event);
}
| public synchronized void | moduleEnabled(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone connector module is enabled.
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"In StandAloneConnectorModulesManager moduleEnabled");
}
if (event.getModuleType().equals(event.TYPE_CONNECTOR)) {
String modID = event.getModuleName();
if (!isEnabled(event.getConfigContext(), event.getModuleName())) {
return;
}
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "Module : " + modID + " enabled...");
}
String appName = event.getModuleName();
ConnectorResourcesLoader connectorResourcesLoader = null;
try {
connectorResourcesLoader=
new ConnectorResourcesLoader();
}catch(ConfigException ce) {
String msg = localStrings.getString(
"connector.connector_enable_failed",appName);
_logger.log(Level.SEVERE,
"core.failed_to_get_connectorresourcesloader");
throw new AdminEventListenerException(msg);
}
try {
ResourcesUtil.setEventConfigContext(event.getConfigContext());
connectorResourcesLoader.loadRAConfigs(appName);
realDeployed(event);
connectorResourcesLoader.load(appName);
} catch(AdminEventListenerException ex) {
throw ex;
} catch(Throwable th) {
AdminEventListenerException aele =
new AdminEventListenerException();
aele.initCause(th);
throw aele;
}finally {
ResourcesUtil.resetEventConfigContext();
}
}
| public synchronized void | moduleRedeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone connector module is redeployed.
if (event.getModuleType().equals(event.TYPE_CONNECTOR)) {
String modID = event.getModuleName();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "ReDeploying 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 cascade)Unloads the given stand alone connector module.
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"In connector moduleUndeployed event,name=" + moduleName);
}
// get loader
AbstractLoader modLoader = (ConnectorModuleLoader) this.id2loader.remove(moduleName);
if (modLoader == null) {
return true;
}
modLoader.setCascade(cascade);
// 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);
}
boolean undeployed = modLoader.unload(jsr77);
if (undeployed) {
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);
}
}
}
return undeployed;
| public synchronized void | moduleUndeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Invoked when a standalone connector module is undeployed.
//If forceDeploy is true, we need to disable module instead of undeploying it
if(event.getForceDeploy() ) {
try {
moduleDisabled(event);
} catch (AdminEventListenerException aele) {
_logger.log(Level.FINEST, "Error while UnDeploying module: " + event.getModuleName());
throw aele;
}
} else {
realUndeployed(event);
}
| private void | realDeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Performs the deployment of a standalone connector module
This is method is used by moduleDeployed and moduleEnabled
to perform common operations
boolean jsr77 = false;
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"In StandAloneConnectorModulesManager moduleDeployed");
_logger.log(Level.FINEST, "ModuleType=" + event.getModuleType());
}
if (event.getModuleType().equals(event.TYPE_CONNECTOR)) {
String modID = event.getModuleName();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "modID=" + modID);
}
try {
// refreshes the config context with the context from this event
this.configManager.refreshConfigContext(event.getConfigContext());
// set jsr77 flag
// which is used to signify if the event is deploy or undeploy
// to create or delete jsr77 mBeans
String action = event.getAction();
if ((action.equals(BaseDeployEvent.DEPLOY)) ||
(action.equals(BaseDeployEvent.REDEPLOY))) {
jsr77 = true;
}
if (isEnabled(event.getConfigContext(), modID) &&
!moduleDeployed(jsr77, event.getConfigContext(), modID)) {
// throw an exception is load fails
String msg = localStrings.getString("connector.connector_deployed_failed",
modID);
throw new AdminEventListenerException(msg);
}
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce.getMessage());
}
}
| private void | realUndeployed(com.sun.enterprise.admin.event.ModuleDeployEvent event)Performs the undeployment of a standalone connector module
This is used by moduleUndeployed and moduleDisabled and
and houses all their common operations
boolean jsr77 = false;
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"In StandAloneConnectorModulesManager moduleUndeployed");
}
String action = event.getAction();
if ((action.equals(BaseDeployEvent.UNDEPLOY)) ||
(action.equals(BaseDeployEvent.REDEPLOY))) {
jsr77 = true;
}
try {
if (event.getModuleType().equals(event.TYPE_CONNECTOR)) {
String modID = event.getModuleName();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "UnDeploying module: " + modID);
}
boolean undeployed = false;
try {
ResourcesUtil.setEventConfigContext(event.getConfigContext());
undeployed = moduleUndeployed(jsr77, modID, event.getCascade());
} finally {
ResourcesUtil.resetEventConfigContext();
}
if (!undeployed) {
String msg = localStrings.getString("connector.connector_undeployed_failed",
modID);
throw new AdminEventListenerException(msg);
}
// refreshes the config context with the context from this event
this.configManager.refreshConfigContext(event.getConfigContext());
}
} catch (ConfigException ce) {
throw new AdminEventListenerException(ce.getMessage());
}
|
|