FileDocCategorySizeDatePackage
AdminEvent.javaAPI DocGlassfish v2 API14240Fri May 04 22:33:34 BST 2007com.sun.enterprise.admin.event

AdminEvent

public class AdminEvent extends Notification implements Cloneable
Superclass of all admin events. This is the marker object for all events in administration.

Fields Summary
private EventKey
eKey
private static long
eventCounter
private String
targetDest
unresolved/abstract target destination
private String
effectiveDest
Resolved destination based on target destination. This is where the notification event is delivered. Target destination always refers to concrete server end point.
private int
hops
Number of times this event is forwarded from one server instance to another server.
private static final int
MAX_HOPS
maximum number of times an event is allowed to be forwarded
static final String
eventType
Event type is required for all sub-classes of Notification. It is a string representation for the event using dotted notation (for example - network.alarm.router)
private transient com.sun.enterprise.config.ConfigContext
configContext
Config context. This object provides access to a snapshot of config updated with all changes in this event at the time event processing starts on the instance to which the event applies.
private transient com.sun.enterprise.config.ConfigContext
oldConfigContext
Old config context. The object provides access to config context before applying changes from this event.
private static com.sun.enterprise.util.i18n.StringManager
localStrings
ArrayList
configChangeList
List of config changes.
List
dependentChangeList
List of dependent config changes.
Constructors Summary
public AdminEvent(String instanceName)
Create a new admin event for specified ias instance.

param
instanceName name of ias instance


                        
       
        this(eventType, instanceName);
    
public AdminEvent(String eventType, String instanceName)
Create a new admin event for specified ias instance.

param
eventType type of the event
param
instanceName name of ias instance

        super(eventType, instanceName, ++eventCounter,
                System.currentTimeMillis());
    
protected AdminEvent(String type, Object source, long seqNumber, long time)

        super(type, source, seqNumber, time);
    
Methods Summary
synchronized voidaddConfigChange(com.sun.enterprise.config.ConfigChange change)
Add specified change to the event.

param
change the change to add to this event

        assertNotNull(change);
        if (configChangeList == null) {
            configChangeList = new ArrayList();
        }
        configChangeList.add(change);
    
public synchronized voidaddConfigChange(java.util.ArrayList changeList)
Add specified changes to the event.

param
changeList the list of changes to add to this event

        if (changeList == null) {
			String msg = localStrings.getString( "admin.event.null_configchangelist" );
            throw new IllegalArgumentException( msg );
        }
        if (configChangeList == null) {
            configChangeList = new ArrayList();
        }
        configChangeList.addAll(changeList);
    
public synchronized voidaddDependentConfigChange(java.util.List list)

        if (list == null) {
            String msg = localStrings.getString( "admin.event.null_configchangelist" );
            throw new IllegalArgumentException( msg );
        }

        if (dependentChangeList == null) {
            dependentChangeList = new ArrayList();
        }
        dependentChangeList.addAll(list);
    
private voidassertNotNull(com.sun.enterprise.config.ConfigChange change)
Assert that specified ConfigChange is not null.

throws
IllegalArgumentException if specified ConfigChange is null.

        if (change == null) {
			String msg = localStrings.getString( "admin.event.null_configchange" );
            throw new IllegalArgumentException( msg );
        }
    
public java.lang.Objectclone()
Returns a top level clone of this object.

return
a clone of this object

 
        return super.clone();
    
public intgetActionType()
Get action type for this event.

        return 0;
    
public java.lang.StringgetConfigChangeInfo()
Get config change info. This method returns a string that lists config changes associated to this event. Returns an empty string if no changes are associated to this event.

        StringBuffer buf = new StringBuffer();
        if (configChangeList != null) {
            Iterator iter = configChangeList.iterator();
            while (iter.hasNext()) {
                ConfigChange change = (ConfigChange)iter.next();
                buf.append(change.toString());
            }
        }
        return buf.toString();
    
public java.util.ArrayListgetConfigChangeList()

        return configChangeList;
    
public com.sun.enterprise.config.ConfigContextgetConfigContext()
Get config context. This returns a snapshot of config context with all changes in this event at the time event processing started on the receiving server instance. Event listeners should use this object to get a consistent view of context instead of system wide context because that can be updated during event processing. This method will return null if called before the event processing has started. So, it is intended for use by event listeners only.

return
the snapshot of config context.

        return configContext;
    
public java.util.ListgetDependentChangeList()

        return dependentChangeList;
    
public java.lang.StringgetEffectiveDestination()
Gets the effective destination for this event

return
name of the effective destination

        return effectiveDest;
    
public EventKeygetEventId()
Get event key information

        return eKey;
    
public java.lang.StringgetEventInfo()
Get detailed event information. Unless overidden in sub classes, this method returns exactly same value as concatenation of toString() and getConfigChangeInfo() methods. The intent of this method is to return a detailed string representation of the event that can be used for debugging.

        return toString() + getConfigChangeInfo();
    
public intgetHopCount()
Returns the current hop count (number of times this event has been forwarded) of this event.

return
current hop count

        return hops;
    
public java.lang.StringgetInstanceName()
Return name of the instance to which this event applies. The difference from getSource() is that this returns a String object, so there is no need to cast the return value.

see
getSource()
return
name of the instance to which the event applies

        return (String)getSource();
    
public com.sun.enterprise.config.ConfigContextgetOldConfigContext()
Get old config context. This returns a reference of config context prior to applying any changes from this event. This method will return null if called before event processing has started. This is just a reference to global config context at the time event processing started. Even though this is not a snapshot of config context (i.e. cloned copy), it is still sufficient for the usage in getting old config values, because once a context has been made global it is immutable.

        return oldConfigContext;
    
public java.lang.ObjectgetSource()
Return name of the instance to which this event applies. (This interpretation is slightly different from EventObject.getSource() where it is expected to return the object on which event happened - so instead of the instance object it returns the name of the instance.)

return
name of the instance to which event applies

        return super.getSource();
    
public java.lang.StringgetTargetDestination()
Each event will have 2 destinations, target and effective destination target destination would be for example cluster1. effective destination would be endpoints of target destination.

return
name of the target destination

        return targetDest;
    
public intincrementHopCount()
Increments the current hop count.

return
incremented hop count

        return ++hops;
    
booleanisNoOp()
Is this event a no-op. The default implementation always returns false. However, the sub-classes can override and provide a more intelligent implementation.

return
true if the event is a no op, false otherwise.

        return false;
    
public booleanisValidHopCount()
Returns true if current hop count is less than or equal to maximum hop allowed for this event.

return
true if current hop count is less than or equal to maximum hop allowed

        return (hops <= MAX_HOPS) ? true : false;
    
synchronized voidremoveConfigChange(com.sun.enterprise.config.ConfigChange change)
Remove specified config change from the event.

param
change the change to add to this event

        assertNotNull(change);
        if (configChangeList != null) {
            int ndx = configChangeList.indexOf(change);
            if (ndx != -1) {
                configChangeList.remove(ndx);
            }
        }
    
private voidsetAction(int action)
Set action to specified value. If action is not one of allowed,

        return;
    
voidsetContext(com.sun.enterprise.config.ConfigContext ctx)
Set config context to specified value. Event listeners can use this to get a consistent view of config. This config context should contain all changes from this event.

param
ctx the config context

        configContext = ctx;
    
public voidsetEffectiveDestination(java.lang.String eDest)
Sets the effective destination

param
eDest effective destination info

        effectiveDest = eDest;
    
public voidsetEventId(EventKey ek)
Set event key information

        eKey = ek;
     
voidsetOldContext(com.sun.enterprise.config.ConfigContext ctx)
Set old config context to specified value. This context will not have changes from this event.

param
ctx the old config context

        oldConfigContext = ctx;
    
public voidsetTargetDestination(java.lang.String tarDest)
Sets the target destination

param
tarDest target destination info

        targetDest = tarDest;
    
public java.lang.StringtoString()
Return a String representation.

        int numChg = (configChangeList == null) ? 0 : configChangeList.size();
        return this.getClass().getName() + " -- " + this.getInstanceName()
                + " [" + numChg + " Change(s), Id:" + this.getSequenceNumber()
                + ", ts:" + this.getTimeStamp() + "]";