ResourceManagerpublic class ResourceManager extends Object implements com.sun.enterprise.admin.event.ResourceDeployEventListenerHandles resource deploy events. When a resource is updated/added,
admin server sends a notification to the server instance. This object
is the listener for all resource events.
Resource deployers throws UnsupportedOperationException when
an operation is not supported and requires a server restart. It
catches the UnsupportedOperationException and notifies
admin event multicaster with RESTART_NEEDED flag. |
Fields Summary |
---|
static Logger | _loggerlogger for this manager | private ServerContext | serverContext_context of the server instance runtime | private ResourceDeployerFactory | factory_resource deployer factory | private static com.sun.enterprise.util.i18n.StringManager | localStrings |
Constructors Summary |
---|
public ResourceManager(ServerContext sc)Constructor.
serverContext_ = sc;
factory_ = new ResourceDeployerFactory();
|
Methods Summary |
---|
private Resources | getResources(ConfigContext ctx)Returns the config resources bean from the given config context.
//Resources rbeans = ServerBeansFactory.getServerBean(ctx).getResources();
Resources rbeans = ServerBeansFactory.getDomainBean(ctx).getResources();
if (rbeans == null) {
String msg = localStrings.getString("resourceManager.resource_not_found");
throw new ConfigException(msg); //XXX
}
return rbeans;
| public void | resourceDeployed(com.sun.enterprise.admin.event.ResourceDeployEvent event)
assert(event.getJ2EEComponentType() == BaseDeployEvent.RESOURCE);
try {
Resources rbeans = getResources(event.getConfigContext());
String type = event.getResourceType();
ResourcesUtil.setEventConfigContext(event.getConfigContext());
Object resource =
factory_.getResource(type, event.getResourceName(), rbeans);
if (ResourcesUtil.createInstance().isEnabled((ConfigBean) resource)) {
factory_.getResourceDeployer(type).deployResource(resource);
}
_logger.log(Level.INFO, "core.resourcedeployed",
type + ":" + event.getResourceName());
} catch (Exception e) {
_logger.log(Level.SEVERE,"core.resourcedeploy_error", e);
throw new AdminEventListenerException(e.getMessage());
} finally {
ResourcesUtil.resetEventConfigContext();
}
| public void | resourceDisabled(com.sun.enterprise.admin.event.ResourceDeployEvent event)
assert(event.getJ2EEComponentType() == BaseDeployEvent.RESOURCE);
try {
Resources rbeans = getResources(event.getConfigContext());
String type = event.getResourceType();
Object resource =
factory_.getResource(type, event.getResourceName(), rbeans);
factory_.getResourceDeployer(type).disableResource(resource);
_logger.log(Level.INFO, "core.resourcedisabled",
type + ":" + event.getResourceName());
} catch (UnsupportedOperationException nse) {
AdminEventMulticaster.notifyFailure(event, AdminEventResult.RESTART_NEEDED);
_logger.log(Level.INFO,"core.resource_disabled_restart_needed", event.getResourceName());
} catch (Exception e) {
_logger.log(Level.SEVERE,"core.resourcedisabled_error",e);
throw new AdminEventListenerException(e.getMessage());
}
| public void | resourceEnabled(com.sun.enterprise.admin.event.ResourceDeployEvent event)
assert(event.getJ2EEComponentType() == BaseDeployEvent.RESOURCE);
try {
Resources rbeans = getResources(event.getConfigContext());
String type = event.getResourceType();
Object resource =
factory_.getResource(type, event.getResourceName(), rbeans);
factory_.getResourceDeployer(type).enableResource(resource);
_logger.log(Level.INFO, "core.resourceenabled",
type + ":" + event.getResourceName());
} catch (UnsupportedOperationException nse) {
AdminEventMulticaster.notifyFailure(event, AdminEventResult.RESTART_NEEDED);
_logger.log(Level.INFO,"core.resource_enabled_restart_needed", event.getResourceName());
} catch (Exception e) {
_logger.log(Level.SEVERE,"core.resourceenabled_error",e);
throw new AdminEventListenerException(e.getMessage());
}
| public void | resourceRedeployed(com.sun.enterprise.admin.event.ResourceDeployEvent event)
assert(event.getJ2EEComponentType() == BaseDeployEvent.RESOURCE);
try {
Resources rbeans = getResources(event.getConfigContext());
String type = event.getResourceType();
Object resource =
factory_.getResource(type, event.getResourceName(), rbeans);
factory_.getResourceDeployer(type).redeployResource(resource);
_logger.log(Level.INFO, "core.resourceredeployed",
type + ":" + event.getResourceName());
} catch (UnsupportedOperationException nse) {
AdminEventMulticaster.notifyFailure(event, AdminEventResult.RESTART_NEEDED);
_logger.log(Level.INFO,"core.resource_redeployed_restart_needed", event.getResourceName());
} catch (Exception e) {
_logger.log(Level.SEVERE,"core.resourceredeploy_error",e);
throw new AdminEventListenerException(e.getMessage());
}
| public void | resourceReferenceAdded(com.sun.enterprise.admin.event.ResourceDeployEvent event)
resourceDeployed(event);
| public void | resourceReferenceRemoved(com.sun.enterprise.admin.event.ResourceDeployEvent event)
resourceUndeployed(event);
| public void | resourceUndeployed(com.sun.enterprise.admin.event.ResourceDeployEvent event)
assert(event.getJ2EEComponentType() == BaseDeployEvent.RESOURCE);
try {
// use config context prior to applying any changes
Resources rbeans = getResources(event.getOldConfigContext());
String type = event.getResourceType();
Object resource =
factory_.getResource(type, event.getResourceName(), rbeans);
ResourcesUtil.setEventConfigContext(event.getConfigContext());
factory_.getResourceDeployer(type).undeployResource(resource);
_logger.log(Level.INFO, "core.resourceundeployed",
type + ":" + event.getResourceName());
} catch (UnsupportedOperationException nse) {
AdminEventMulticaster.notifyFailure(event, AdminEventResult.RESTART_NEEDED);
_logger.log(Level.INFO,"core.resource_undeployed_restart_needed", event.getResourceName());
} catch (Exception e) {
_logger.log(Level.SEVERE,"core.resourceundeploy_error",e);
throw new AdminEventListenerException(e.getMessage());
} finally {
ResourcesUtil.resetEventConfigContext();
}
|
|