Event Class

com.bea.p13n.events
Event Class

public class Event

    extends AbstractConfigurableEntity
    implements ConfigurableEntity, EventConstants, Serializable

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.


Hierarchy
Object
  AbstractConfigurableEntity
    Event
All Implemented Interfaces

ConfigurableEntity, EventConstants, Serializable
Direct Known Subclasses

TrackingEvent

Field Summary

   
Fields from  com.bea.p13n.property.AbstractConfigurableEntity
CE_METHOD_CACHE, instanceClass, PREFIX_GET, PREFIX_SET, propertyCache, textFormatter
 
Fields from interface com.bea.p13n.property.ConfigurableEntity
RESERVED_PROPERTY_SET
 
Fields from interface com.bea.p13n.events.EventConstants
TYPE_ALL
 

Constructor Summary

Event(String theType, long theTimeStamp)

Construct a new Event.
Event(String theType)

Construct a new Event.
 

Method Summary

public String
getApplication()
Get the application name that dispatched this event.
public Object
getAttribute(String theKey)
Get named event attribute.
public Iterator
getAttributeNames()
Return the attribute names that have been set on this event.
public Object
getProperty(String propertySet, String propertyName)
Mimics the getProperty method on thr ConfigurableEntity interface.
public long
getTimeStamp()
Get the time stamp of this event (usually system time when the Event was constructed).
public String
getType()
Get the type of this event.
public Object
removeAttribute(String theKey)
Remove the attribute.
public void
setApplication(String appName)
Set the application name for this event.
public void
setAttribute(String theKey, Serializable theValue)
Set a named event attribute.
public String
toString()
Return a string representation of the Event.
 
Methods from  com.bea.p13n.property.AbstractConfigurableEntity
createMapKey, getCachedProperty, getExplicitProperty, getExplicitSetter, getImplicitProperty, getJndiName, getPkString, getPropertyAsString, getPropertyCache, getPropertyNoDefault, getUniqueId, hasExplicitGetter, hasExplicitSetter, removeExplicitProperty, removeProperty, setExplicitProperty, setProperty, upcaseFirst
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
   
Methods from interface com.bea.p13n.property.ConfigurableEntity
getJndiName, getPkString, getProperty, getPropertyAsString, getPropertyNoDefault, getUniqueId, removeProperty, setProperty
 

Constructor Detail

Event

public Event(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, and the application name is set from the calling component's application context.

This constructor is provided so that an Event can be created when the 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.


Event

public Event(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.
 

Method Detail

getApplication() Method

public String getApplication()
Get the application name that dispatched this event.

Returns

application name, as named when this Event object was dispatched.

getAttribute(String) Method

public Object getAttribute(String theKey)
Get named event attribute.

Returns

value associated with theKey, or null if there was no mapping for theKey.

getAttributeNames() Method

public 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.


getProperty(String, String) Method

public Object getProperty(String propertySet, 
                          String propertyName)
Mimics the getProperty method on thr ConfigurableEntity interface.

This method delegates to the getAttribute, passing the propertyName parameter as the key argument. It is assumed that the propertySet parameter is the same as the event type.

Overrides
AbstractConfigurableEntity.getProperty(String, String)

Parameters

propertySet
The name of the property set to look in
propertyName
The name of the property to retrieve.

Returns

the value for this property, or null if all searches failed

getTimeStamp() Method

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.

getType() Method

public String getType()
Get the type of this event.

Returns

the event type, as named when this Event object was created.

removeAttribute(String) Method

public Object removeAttribute(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.

setApplication(String) Method

public void setApplication(String appName)
Set the application name for this event. The application is mutable because it may not be set by the object that created the Event object (eg, in the case of externally-connected applications). If the application name is null when the object is dispatched, the EventServiceBean will call this method with its application name.

Parameters

appName
name.

setAttribute(String, Serializable) Method

public void setAttribute(String theKey, 
                         Serializable theValue)
Set a named event attribute.

Parameters

theKey
the attribute name. Can not be null.
theValue
the value of the attribute.

toString() Method

public 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
Object.toString()