FileDocCategorySizeDatePackage
ResourceDeployEvent.javaAPI DocGlassfish v2 API14136Fri May 04 22:33:36 BST 2007com.sun.enterprise.admin.event

ResourceDeployEvent

public class ResourceDeployEvent extends com.sun.enterprise.admin.event.BaseDeployEvent implements Cloneable
Resource 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_CUSTOM
Constant to denote custom resource type.
public static final String
RES_TYPE_EXTERNAL_JNDI
Constant to denote external jndi resource type.
public static final String
RES_TYPE_JDBC
Constant to denote jdbc resource type.
public static final String
RES_TYPE_MAIL
Constant to denote mail resource type.
public static final String
RES_TYPE_JMS
Constant to denote jms resource type.
public static final String
RES_TYPE_PMF
Constant to denote persistence manager factory resource type.
public static final String
RES_TYPE_JCP
Constant to denote jdbc connection pool resource type.
public static final String
RES_TYPE_AOR
Constant to denote admin object resource type.
public static final String
RES_TYPE_CCP
Constant to denote connector connection pool resource type.
public static final String
RES_TYPE_CR
Constant to denote connector resource type.
public static final String
RES_TYPE_RAC
Constant to denote resource adapter config type.
static final String
eventType
Event type
private String
resourceType
Resource type. The valid values are Custom, external
private boolean
resourceExists
Resource 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.

param
instance name of the server instance to which resource has been deployed, undeployed or redployed.
param
resourceName name of the resource that has been deployed, undeployed, redeployed, enabled or disabled
param
resourceType of the resource, one of RES_TYPE_CUSTOM, RES_TYPE_EXTERNAL_JNDI, RES_TYPE_JDBC, RES_TYPE_MAIL, RES_TYPE_JMS, RES_TYPE_PMF, RES_TYPE_JCP.
param
actionCode what happened to the resource, the valid values are BaseDeployEvent.DEPLOY, BaseDeployEvent.REDEPLOY, BaseDeployEvent.UNDEPLOY, BaseDeployEvent.ENABLE or BaseDeployEvent.DISABLE
throws
IllegalArgumentException if resourceType or actionCode is invalid


                                                                                                                                               
        
                
        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.Objectclone()

        ResourceDeployEvent re = (ResourceDeployEvent) super.clone();
        return re;
    
public java.lang.StringgetResourceName()
Get name of the resource that was affected by deployment action.

return
name of the resource

        return getJ2EEComponentName();
    
public java.lang.StringgetResourceType()
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
resource type

        return resourceType;
    
booleanisNoOp()
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 voidsetActionForAdd()
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.

throws
IllegalStateException if Add operation is invalid in current context.

        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 voidsetActionForDelete()

throws
IllegalStateException if Delete operation is invalid in current context.

        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 voidsetActionForUpdate()

throws
IllegalStateException if Update operation is invalid in current context.

        // 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!");
        // }
    
voidsetNewAction(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 voidsetResourceType(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.StringtoString()

        return "ResourceDeployEvent -- " + getAction() + " " + resourceType + "/" + getJ2EEComponentName();