Methods Summary |
---|
public void | addResourceDeployEvent(java.lang.String action, java.lang.String target, java.lang.String resName)Adds a resource deploy event to the event stack.
EventStack stack = EventContext.getEventStackFromThreadLocal();
ConfigContext ctx = stack.getConfigContext();
stack.setTarget(target);
stack.setConfigChangeList( ctx.getConfigChangeList());
ResourceDeployEvent event = createResourceDeployEvent(action, resName);
EventContext.addEvent(event);
|
protected static java.lang.String | convertResourceType(java.lang.String type)Converts config bean type to resource deploy event type.
// XXX see if we can avoid this type conversion
// may be do hash instead of string comparision
if (type==null) {
return null;
} else {
type = type.trim();
}
if ( type.equals(ServerTags.CUSTOM_RESOURCE)
|| type.equals(Resources.CUSTOM_RESOURCE) ) {
return ResourceDeployEvent.RES_TYPE_CUSTOM;
}
if ( type.equals(ServerTags.EXTERNAL_JNDI_RESOURCE)
|| type.equals(Resources.EXTERNAL_JNDI_RESOURCE) ) {
return ResourceDeployEvent.RES_TYPE_EXTERNAL_JNDI;
}
if ( type.equals(ServerTags.JDBC_RESOURCE)
|| type.equals(Resources.JDBC_RESOURCE) ) {
return ResourceDeployEvent.RES_TYPE_JDBC;
}
if ( type.equals(ServerTags.MAIL_RESOURCE)
|| type.equals(Resources.MAIL_RESOURCE) ) {
return ResourceDeployEvent.RES_TYPE_MAIL;
}
if ( type.equals(ServerTags.PERSISTENCE_MANAGER_FACTORY_RESOURCE)
|| type.equals(Resources.PERSISTENCE_MANAGER_FACTORY_RESOURCE)) {
return ResourceDeployEvent.RES_TYPE_PMF;
}
if ( type.equals(ServerTags.ADMIN_OBJECT_RESOURCE)
|| type.equals(Resources.ADMIN_OBJECT_RESOURCE) ) {
return ResourceDeployEvent.RES_TYPE_AOR;
}
if ( type.equals(ServerTags.CONNECTOR_RESOURCE)
|| type.equals(Resources.CONNECTOR_RESOURCE) ) {
return ResourceDeployEvent.RES_TYPE_CR;
}
if ( type.equals(ServerTags.RESOURCE_ADAPTER_CONFIG)
|| type.equals(Resources.RESOURCE_ADAPTER_CONFIG) ) {
return ResourceDeployEvent.RES_TYPE_RAC;
}
if ( type.equals(ServerTags.JDBC_CONNECTION_POOL)
|| type.equals(Resources.JDBC_CONNECTION_POOL) ) {
return ResourceDeployEvent.RES_TYPE_JCP;
}
if ( type.equals(ServerTags.CONNECTOR_CONNECTION_POOL)
|| type.equals(Resources.CONNECTOR_CONNECTION_POOL) ) {
return ResourceDeployEvent.RES_TYPE_CCP;
}
return type; // unsupported type
|
public ApplicationDeployEvent | createApplicationDeployEvent(java.lang.String action, java.lang.String appName, boolean cascade, boolean forceDeploy, int loadUnloadAction)Returns an application deploy event. This assumes that the event stack
is populated before this method is called.
EventStack stack = EventContext.getEventStackFromThreadLocal();
String target = stack.getTarget();
assert(target != null);
// name of the current server instance
String instName =
ApplicationServer.getServerContext().getInstanceName();
ApplicationDeployEvent ade = new ApplicationDeployEvent(instName,
appName, action, cascade, forceDeploy, loadUnloadAction);
ade.setTargetDestination(target);
// adds all the config changes
DependencyResolver dr =
new DependencyResolver(stack.getConfigContext(), target);
ade.addDependentConfigChange(dr.resolveApplications(appName, action));
ade.addConfigChange( (ArrayList) stack.getConfigChangeList() );
return ade;
|
public ApplicationDeployEvent | createApplicationDeployEvent(java.lang.String action, java.lang.String appName)Returns an application deploy event. This assumes that the event stack
is populated before this method is called.
Example Usage:
ConfigContext ctx = stack.getConfigContext();
EventStack stack = EventContext.getEventStackFromThreadLocal();
stack.setTarget(targetName);
stack.setConfigChangeList(ctx.getConfigChangeList());
EventBuilder builder = new EventBuilder();
ApplicationDeployEvent event = builder.createApplicationDeployEvent(
BaseDeployEvent.REMOVE_REFERENCE, referenceName);
AdminEventResult result = AdminEventMulticaster.multicast(event);
Instead of using multicaster, you may also schedule the event
to be sent out by the interceptor. This will release the lock
for concurrent config users. Call the following API if you want
to schedule the event:
EventContext.addEvent(event);
return createApplicationDeployEvent(action, appName, false);
|
public ApplicationDeployEvent | createApplicationDeployEvent(java.lang.String action, java.lang.String appName, boolean cascade)Returns an application deploy event. This assumes that the event stack
is populated before this method is called.
return createApplicationDeployEvent(action, appName, cascade, false);
|
public ApplicationDeployEvent | createApplicationDeployEvent(java.lang.String action, java.lang.String appName, boolean cascade, boolean forceDeploy)Returns an application deploy event. This assumes that the event stack
is populated before this method is called.
return createApplicationDeployEvent(action, appName, cascade,
forceDeploy, Constants.LOAD_UNSET);
|
public ConfigChangeEvent | createConfigChangeEvent(java.lang.String target, java.util.ArrayList configChangeList)Creates config change event.
String instName =
ApplicationServer.getServerContext().getInstanceName();
ConfigChangeEvent cce =
new ConfigChangeEvent(instName, configChangeList);
cce.setTargetDestination(target);
return cce;
|
public LogLevelChangeEvent | createLogLevelChangeEvent(com.sun.enterprise.config.ConfigContext ctx, java.lang.String target, java.lang.String newLogLevel, java.lang.String moduleName)Creates log level change event.
// name of the current server instance runtime
String instName =
ApplicationServer.getServerContext().getInstanceName();
// log level change event
LogLevelChangeEvent lde = new LogLevelChangeEvent(instName);
lde.setTargetDestination(target);
// FIXME: get the change list from each thread local
//rde.addConfigChange( ctx.getConfigChangeList() );
// setEventKey
// do i need to set old log level ????
lde.setModuleName(moduleName);
lde.setNewLogLevel(newLogLevel);
return lde;
|
public BaseDeployEvent | createModAppDeployEvent(java.lang.String action, java.lang.String name, com.sun.enterprise.config.ConfigContext ctx, java.util.ArrayList configChanges, java.lang.String target)Returns a module aor app deploy event.
// name of the current server instance runtime
String instName =
ApplicationServer.getServerContext().getInstanceName();
BaseDeployEvent event=getAppOrModuleEvent(instName, ctx, name, action);
event.setTargetDestination(target);
// adds all the config changes
DependencyResolver dr = new DependencyResolver(ctx, target);
event.addDependentConfigChange(dr.resolveApplications(name,action));
event.addConfigChange( configChanges );
return event;
|
public ModuleDeployEvent | createModuleDeployEvent(java.lang.String action, java.lang.String moduleName, java.lang.String moduleType)Returns a module deploy event.
return createModuleDeployEvent(action, moduleName, moduleType, false);
|
public ModuleDeployEvent | createModuleDeployEvent(java.lang.String action, java.lang.String moduleName, java.lang.String moduleType, boolean cascade)Returns a module deploy event.
return createModuleDeployEvent(action, moduleName, moduleType,
cascade, false);
|
public ModuleDeployEvent | createModuleDeployEvent(java.lang.String action, java.lang.String moduleName, java.lang.String moduleType, boolean cascade, boolean forceDeploy)Returns a module deploy event.
EventStack stack = EventContext.getEventStackFromThreadLocal();
String target = stack.getTarget();
assert(target != null);
String instName =
ApplicationServer.getServerContext().getInstanceName();
ModuleDeployEvent mde =
new ModuleDeployEvent(instName, moduleName, moduleType,
action, cascade);
mde.setTargetDestination(target);
// sets the force deploy flag in the event
mde.setForceDeploy(forceDeploy);
// adds all the config changes
DependencyResolver dr =
new DependencyResolver(stack.getConfigContext(), target);
mde.addDependentConfigChange(dr.resolveApplications(moduleName,action));
mde.addConfigChange( (ArrayList) stack.getConfigChangeList() );
return mde;
|
public MonitoringEvent | createMonitoringEvent(com.sun.enterprise.config.ConfigContext ctx, java.lang.String target, java.lang.String component, java.lang.String action, java.lang.Object command)Creates a monitoring event.
String instName =
ApplicationServer.getServerContext().getInstanceName();
MonitoringEvent me =
new MonitoringEvent(instName, component, action, command);
me.setTargetDestination(target);
return me;
|
public MonitoringLevelChangeEvent | createMonitoringLevelChangeEvent(com.sun.enterprise.config.ConfigContext ctx, java.lang.String target, java.lang.String component, java.lang.String monitoringLevel)Creates monitoring level change event.
String instName =
ApplicationServer.getServerContext().getInstanceName();
MonitoringLevelChangeEvent mle =
new MonitoringLevelChangeEvent(instName);
mle.setTargetDestination(target);
return mle;
|
public ResourceDeployEvent | createResourceDeployEvent(java.lang.String action, java.lang.String resName)Returns a resource deploy event. This assumes that the event
stack is populated before this is called.
EventStack stack = EventContext.getEventStackFromThreadLocal();
return createResourceDeployEvent(action, resName,
stack.getConfigContext(),
(ArrayList)stack.getConfigChangeList(),
stack.getTarget());
|
public ResourceDeployEvent | createResourceDeployEvent(java.lang.String action, java.lang.String resName, com.sun.enterprise.config.ConfigContext ctx, java.util.ArrayList configChanges, java.lang.String target)Returns a resource deploy event.
// name of the current server instance runtime
String instName =
ApplicationServer.getServerContext().getInstanceName();
// resource type from target string
String resType = getResourceTypeByName(ctx, resName, target);
// resource deploy event
ResourceDeployEvent rde = new ResourceDeployEvent(instName,
resName, resType, action);
rde.setTargetDestination(target);
// adds all the config changes
DependencyResolver dr = new DependencyResolver(ctx, target);
rde.addDependentConfigChange(
dr.resolveResources(resName, action, resType) );
rde.addConfigChange( configChanges );
// setEventKey
return rde;
|
private static BaseDeployEvent | getAppOrModuleEvent(java.lang.String instName, com.sun.enterprise.config.ConfigContext ctx, java.lang.String name, java.lang.String action)Creates application deploy event.
String type = getAppOrModuleType(ctx, name);
if (type!=null) {
if (type.equals(BaseDeployEvent.APPLICATION)) {
// application deploy event
return (BaseDeployEvent)new ApplicationDeployEvent(instName,
name, action);
} else {
// module deploy event
return (BaseDeployEvent)new ModuleDeployEvent(instName, name,
type, action);
}
} else { //for deffered type set
return new BaseDeployEvent(instName, null, name, action);
}
|
private static java.lang.String | getAppOrModuleType(com.sun.enterprise.config.ConfigContext ctx, java.lang.String name)Returns application type.
//first try to find
ConfigBean[] beans = ((Domain)ctx.getRootConfigBean()).
getApplications().getAllChildBeans();
ConfigBean bean = null;
if (beans!=null) {
for(int i=0; i<beans.length; i++) {
if(name.equals(beans[i].getAttributeValue("name"))) {
bean = beans[i];
break;
}
}
}
if (bean==null) {
return null;
}
String type = null;
if (bean instanceof
com.sun.enterprise.config.serverbeans.J2eeApplication) {
type = BaseDeployEvent.APPLICATION;
}
if (bean instanceof
com.sun.enterprise.config.serverbeans.ConnectorModule) {
type = ModuleDeployEvent.TYPE_CONNECTOR;
} else if (bean instanceof
com.sun.enterprise.config.serverbeans.EjbModule) {
type = ModuleDeployEvent.TYPE_EJBMODULE;
} else if (bean instanceof
com.sun.enterprise.config.serverbeans.WebModule) {
type = ModuleDeployEvent.TYPE_WEBMODULE;
} else if (bean instanceof
com.sun.enterprise.config.serverbeans.AppclientModule) {
type = ModuleDeployEvent.TYPE_APPCLIENT;
}
return type;
|
static java.lang.String | getResourceType(com.sun.enterprise.config.ConfigContext ctx, java.lang.String id, boolean includePool)Returns the resource type of a given resource.
Resources root = ((Domain)ctx.getRootConfigBean()).getResources();
ConfigBean res = root.getJdbcResourceByJndiName(id);
if ( res != null ) {
return Resources.JDBC_RESOURCE;
}
res = root.getMailResourceByJndiName(id);
if ( res != null ) {
return Resources.MAIL_RESOURCE;
}
res = root.getCustomResourceByJndiName(id);
if ( res != null ) {
return Resources.CUSTOM_RESOURCE;
}
res = root.getExternalJndiResourceByJndiName(id);
if ( res != null ) {
return Resources.EXTERNAL_JNDI_RESOURCE;
}
res = root.getPersistenceManagerFactoryResourceByJndiName(id);
if ( res != null) {
return Resources.PERSISTENCE_MANAGER_FACTORY_RESOURCE;
}
res = root.getAdminObjectResourceByJndiName(id);
if ( res != null ) {
return Resources.ADMIN_OBJECT_RESOURCE;
}
res = root.getConnectorResourceByJndiName(id);
if ( res != null ) {
return Resources.CONNECTOR_RESOURCE;
}
res = root.getResourceAdapterConfigByResourceAdapterName(id);
if ( res != null ) {
return Resources.RESOURCE_ADAPTER_CONFIG;
}
if (includePool) {
res = root.getJdbcConnectionPoolByName(id);
if ( res != null ) {
return Resources.JDBC_CONNECTION_POOL;
}
res = root.getConnectorConnectionPoolByName(id);
if ( res != null ) {
return Resources.CONNECTOR_CONNECTION_POOL;
}
}
return null;
|
protected static java.lang.String | getResourceTypeByName(com.sun.enterprise.config.ConfigContext ctx, java.lang.String resName, java.lang.String target)Helper method to obtain ResourceDeployEvent's resource type
correspondent to its name
String type = getTypeFromTarget(target);
if (type == null) {
type = getResourceType(ctx, resName, true);
}
return convertResourceType(type);
|
static java.lang.String | getTypeFromTarget(java.lang.String target)Returns the type (as defined in domain.xml) from a target.
Target has the following three parts:
||
String type = null;
String msg = "\n NAZRUL Could not determine resource type for target "
+ target;
try {
if (target != null) {
StringTokenizer st = new StringTokenizer(target, "|");
int tokens = st.countTokens();
if (tokens == 3) {
String prefix = st.nextToken();
String name = st.nextToken();
type = st.nextToken();
}
}
} catch (Exception e) { }
return type;
|
public static BaseDeployEvent | resolveModAppDeployEventType(BaseDeployEvent eventToResolve, com.sun.enterprise.config.ConfigContext ctx)Provides deferred type resolution (usually on remote instance side).
// name of the current server instance runtime
String instName = eventToResolve.getInstanceName();
String name = eventToResolve.getJ2EEComponentName();
String action = eventToResolve.getAction();
BaseDeployEvent event=getAppOrModuleEvent(instName, ctx, name, action);
event.setCascade(eventToResolve.getCascade());
event.setEventId(eventToResolve.getEventId());
if (eventToResolve.getDependentChangeList()!=null) {
event.addDependentConfigChange(
eventToResolve.getDependentChangeList());
}
if (eventToResolve.getConfigChangeList()!=null) {
event.addConfigChange(eventToResolve.getConfigChangeList());
}
if (eventToResolve.getTargetDestination()!=null) {
event.setTargetDestination(eventToResolve.getTargetDestination());
}
return event;
|