ResourceDeployEventpublic class ResourceDeployEvent extends com.sun.enterprise.admin.event.BaseDeployEvent implements CloneableResource deployment event. This event is generated whenever a application
server resource is deployed, undeployed, redeployed, enabled or disabled. |
Fields Summary |
---|
public static final String | RES_TYPE_CUSTOMConstant to denote custom resource type. | public static final String | RES_TYPE_EXTERNAL_JNDIConstant to denote external jndi resource type. | public static final String | RES_TYPE_JDBCConstant to denote jdbc resource type. | public static final String | RES_TYPE_MAILConstant to denote mail resource type. | public static final String | RES_TYPE_JMSConstant to denote jms resource type. | public static final String | RES_TYPE_PMFConstant to denote persistence manager factory resource type. | public static final String | RES_TYPE_JCPConstant to denote jdbc connection pool resource type. | public static final String | RES_TYPE_AORConstant to denote admin object resource type. | public static final String | RES_TYPE_CCPConstant to denote connector connection pool resource type. | public static final String | RES_TYPE_CRConstant to denote connector resource type. | public static final String | RES_TYPE_RACConstant to denote resource adapter config type. | static final String | eventTypeEvent type | private String | resourceTypeResource type. The valid values are Custom, external | private boolean | resourceExistsResource exists. This is set to true if the event is created with
action code of REDEPLOY, UNDEPLOY, ENABLE OR DISABLE. Otherwise, it
is set to false. | private boolean | noOp | private static com.sun.enterprise.util.i18n.StringManager | localStrings |
Constructors Summary |
---|
public ResourceDeployEvent(String instance, String resourceName, String resourceType, String actionCode)Create a new ResourceDeployEvent for the specified instance,
resource (type and name) and action code.
super(eventType, instance, BaseDeployEvent.RESOURCE, resourceName,
actionCode);
if(resourceType!=null)
setResourceType(resourceType);
if (DEPLOY.equals(actionCode)) {
resourceExists = false;
}
| private ResourceDeployEvent(String type, Object source, long seqNumber, long time)
super(type, source, seqNumber, time);
setResourceType(type);
this.j2eeComponentType = BaseDeployEvent.RESOURCE;
// WARNING: actionName & j2eeComponentName is not set
|
Methods Summary |
---|
public java.lang.Object | clone()
ResourceDeployEvent re = (ResourceDeployEvent) super.clone();
return re;
| public java.lang.String | getResourceName()Get name of the resource that was affected by deployment action.
return getJ2EEComponentName();
| public java.lang.String | getResourceType()Get resource type - one of RES_TYPE_CUSTOM, RES_TYPE_EXTERNAL_JNDI,
RES_TYPE_JDBC, RES_TYPE_MAIL, RES_TYPE_JMS, RES_TYPE_PMF, RES_TYPE_JCP.
return resourceType;
| boolean | isNoOp()Is this event a no-op. An event can be no-op if a resource is created
and then removed without reconfiguring the instance.
return noOp;
| private void | setActionForAdd()Set appropriate action code for a ConfigChange of type Add. This method
is called while processing config changes after the initial creation of
the event.
if (resourceExists) {
String currentAction = getAction();
if (UNDEPLOY.equals(currentAction)) {
setAction(REDEPLOY);
} else {
// throw new IllegalStateException("Existing resource with "
// + "action " + currentAction + ". Can not Add!");
}
} else {
if (noOp) {
setAction(DEPLOY);
noOp = false;
} else {
// Add can come again for properties associated to the resource
// So do not throw exception
// throw new IllegalStateException("Can not add new resource "
// + "again!");
}
}
| private void | setActionForDelete()
if (resourceExists) {
String currentAction = getAction();
if (UNDEPLOY.equals(currentAction)) {
// throw new IllegalStateException("Resource already removed."
// + "Can not remove again!");
} else {
setAction(UNDEPLOY);
}
} else {
if (noOp) {
// throw new IllegalStateException("New resource already "
// + "removed. Can not remove again!");
} else {
noOp = true;
}
}
| private void | setActionForUpdate()
// FIX
// Do Nothing??
// String currentAction = getAction();
// if (ENABLE.equals(currentAction) || DISABLE.equals(currentAction)) {
// throw new IllegalStateException("A resource can have only "
// + "one Config Change entry of type update!");
// }
| void | setNewAction(java.lang.String newAction)Set action for specified action. If action is unknown then the method
throws IllegalArgumentException. If the new action can not be applied in
current state, the method throws IllegalStateException.
if (DEPLOY.equals(newAction)) {
setActionForAdd();
} else if (REDEPLOY.equals(newAction)) {
setActionForUpdate();
} else if (UNDEPLOY.equals(newAction)) {
setActionForDelete();
} else {
String msg = localStrings.getString( "admin.event.illegal_new_action", newAction );
throw new IllegalArgumentException( msg );
}
| public void | setResourceType(java.lang.String resType)Helper method to validate and set resource type.
boolean valid = false;
if (RES_TYPE_CUSTOM.equals(resType)
|| RES_TYPE_EXTERNAL_JNDI.equals(resType)
|| RES_TYPE_JDBC.equals(resType)
|| RES_TYPE_MAIL.equals(resType)
|| RES_TYPE_JMS.equals(resType)
|| RES_TYPE_PMF.equals(resType)
|| RES_TYPE_JCP.equals(resType)
|| RES_TYPE_AOR.equals(resType)
|| RES_TYPE_CCP.equals(resType)
|| RES_TYPE_CR.equals(resType)
|| RES_TYPE_RAC.equals(resType)) {
valid = true;
}
if (!valid) {
String msg = localStrings.getString( "admin.event.invalid_resource_type", resType );
throw new IllegalArgumentException( msg );
}
this.resourceType = resType;
| public java.lang.String | toString()
return "ResourceDeployEvent -- " + getAction() + " " + resourceType + "/" + getJ2EEComponentName();
|
|