© 2001 BEA Systems, Inc.

com.bea.commerce.platform.events
Class Event

java.lang.Object
  |
  +--com.beasys.commerce.foundation.AbstractConfigurableEntity
        |
        +--com.bea.commerce.platform.events.Event
All Implemented Interfaces:
BusinessPolicyManager, ConfigurableEntity, EventConstants, java.io.Serializable
Direct Known Subclasses:
TrackingEvent

public class Event
extends AbstractConfigurableEntity
implements ConfigurableEntity, java.io.Serializable, EventConstants

An event object. An event is characterized by having a type (some name) and a timestamp (when the event occurred). Once the event is created, it can not change type or time stamp.

An Event also has named attributes (as in a Map). The attribute names are strings, but the values can be any serializable object.

Event mimics ConfigurableEntity by implementing only one method - getProperty. Other methods of ConfigurableEntity are not supported and will throw UnsupportedOperationException if used.

See Also:
Serialized Form

Fields inherited from interface com.beasys.commerce.foundation.ConfigurableEntity
RESERVED_SCOPE_NAME
 
Fields inherited from interface com.bea.commerce.platform.events.EventConstants
ASYNCHRONOUS_LISTENER_CLASSES_PROPERTY, EVENT_LISTENER_CLASSES_PROPERTY, EVENT_MESSAGE_CATALOG, ILLEGAL_ARGUMENT_EXCEPTION_NULL_TYPE, LISTENER_CREATE_EXCEPTION, NULL_POINTER_EXCEPTION_ATTRIBUTE_KEY, TYPE_ALL
 
Constructor Summary
Event(java.lang.String theType)
          Construct a new Event.
Event(java.lang.String theType, long theTimeStamp)
          Construct a new Event.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String theKey)
          Get named event attribute.
 java.util.Iterator getAttributeNames()
          Return the attribute names that have been set on this event.
 java.lang.Object getProperty(java.lang.String theScopeName, java.lang.String theKey, ConfigurableEntity theSuccessorIgnored, java.lang.Object theDefaultValue)
          Mimic ConfigurableEntity.
 long getTimeStamp()
          Get the time stamp of this event (usually system time when the Event was constructed).
 java.lang.String getType()
          Get the type of this event.
 java.lang.Object removeAttribute(java.lang.String theKey)
          Remove the attribute.
 void setAttribute(java.lang.String theKey, java.io.Serializable theValue)
          Set a named event attribute.
 java.lang.String toString()
          Return a string representation of the Event.
 
Methods inherited from class com.beasys.commerce.foundation.AbstractConfigurableEntity
addBusinessPolicy, addPropertyValue, addPropertyValueMapped, getBusinessPolicy, getPersistableHandle, getProperty, getPropertyAsString, getPropertyAsString, getPropertyDefault, getPropertyNoDefault, getSuccessor, getUniqueId, removeBusinessPolicy, removeProperty, removeProperty, removePropertyValue, removePropertyValueMapped, removeSuccessor, setProperty, setProperty, setSuccessor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.beasys.commerce.foundation.ConfigurableEntity
addPropertyValue, addPropertyValueMapped, getPersistableHandle, getProperty, getPropertyAsString, getPropertyAsString, getPropertyDefault, getPropertyNoDefault, getSuccessor, getUniqueId, removeProperty, removeProperty, removePropertyValue, removePropertyValueMapped, removeSuccessor, setProperty, setProperty, setSuccessor
 
Methods inherited from interface com.beasys.commerce.foundation.BusinessPolicyManager
addBusinessPolicy, getBusinessPolicy, removeBusinessPolicy
 

Constructor Detail

Event

public Event(java.lang.String theType)
Construct a new Event. The event's type is required. The type may not be null nor an empty string. The type is simply the name of the event that occurred. It is used for dispatching the event to interested listeners. The event's timstamp is also set from the current system time.
Parameters:
theType - the event type.
Throws:
java.lang.IllegalArgumentException - if theType is null or an empty string.

Event

public Event(java.lang.String theType,
             long theTimeStamp)
Construct a new Event. The event's type is required. The type may not be null nor an empty string. The type is simply the name of the event that occurred. It is used for dispatching the event to interested listeners. The event's timstamp is also set from the current system time.

This constructor is provided so that an Event can be created when the tims time of the "event trigger" is not the same as the time when this object (that represents that trigger) is created. This constructor would not normally be used - normal applications should use the Event(String theType) constructor.

Parameters:
theType - the event type.
theTimeStamp - the timestamp for the event, in milliseconds since midnight, January 1, 1970 UTC.
Throws:
java.lang.IllegalArgumentException - if theType is null or an empty string.
Method Detail

getType

public java.lang.String getType()
Get the type of this event.
Returns:
the event type, as named when this Event object was created.

getTimeStamp

public long getTimeStamp()
Get the time stamp of this event (usually system time when the Event was constructed).
Returns:
the time stamp, measured in milliseconds since midnight, January 1, 1970 UTC.

setAttribute

public void setAttribute(java.lang.String theKey,
                         java.io.Serializable theValue)
Set a named event attribute.
Parameters:
theKey - the attribute name. Can not be null.
theValue - the value of the attribute.
Throws:
java.lang.NullPointerException - if theKey is null.

removeAttribute

public java.lang.Object removeAttribute(java.lang.String theKey)
Remove the attribute.
Parameters:
theKey - the attribute name.
Returns:
previous value associated with theKey, or null if there was no mapping for theKey.

getAttribute

public java.lang.Object getAttribute(java.lang.String theKey)
Get named event attribute.
Returns:
value associated with theKey, or null if there was no mapping for theKey.

getAttributeNames

public java.util.Iterator getAttributeNames()
Return the attribute names that have been set on this event. This iterator provides a "read-only" view of the attributes - remove is not supported.

toString

public java.lang.String toString()
Return a string representation of the Event. Returns as:
  Event [type @ timeStamp] { attributeKey=attributeValue, ... }
 
The time stamp is formated using java.util.Date.toString(). The attribute values are converted to string using String.valueOf().
Overrides:
toString in class java.lang.Object

getProperty

public java.lang.Object getProperty(java.lang.String theScopeName,
                                    java.lang.String theKey,
                                    ConfigurableEntity theSuccessorIgnored,
                                    java.lang.Object theDefaultValue)
Mimic ConfigurableEntity. This normally delegates to getAttribute(theKey). It is assumed that theScopeName should be the same as the eventType. If the attribute is not set, or theScopeName is not equal to the event type, then theDefaultValue is returned. The successor is ignored.
Specified by:
getProperty in interface ConfigurableEntity
Overrides:
getProperty in class AbstractConfigurableEntity
Parameters:
theScopeName - The scope name - should be the same as the event Type.
theKey - Name of the attribute to look up.
theSuccessorIgnored - Not used.
theDefaultValue - The value to return if the attribute is not set or if theScopeName is not the same as the Event Type.
Returns:
The value of the attribute.

© 2001 BEA Systems, Inc.

Copyright © 2001 BEA Systems, Inc. All Rights Reserved