com.mtgi.analytics
Class BehaviorEvent

java.lang.Object
  extended by com.mtgi.analytics.BehaviorEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BehaviorTrackingManagerImpl.FlushEvent

public class BehaviorEvent
extends Object
implements Serializable

Applications should generally not have to interact with BehaviorEvent directly. Represents an action taken directly or indirectly by a user. Each action is given a getType(), getName(), and application; has a start time and getDuration(); and is associated with a user and session id representing the user's current authenticated session with the application. Other data like parameter values can be stored in a semi-structured fashion in getData(). Generally the structure of the event data and the meaning of the getName() should depend on the type. BehaviorEvents may be composed of smaller child events, which themselves may be composed of child events, and so on; an event's children are accessed with #getChildren().

See Also:
BehaviorEventManager, Serialized Form

Constructor Summary
protected BehaviorEvent(BehaviorEvent parent, String type, String name, String application, String userId, String sessionId)
           
 
Method Summary
 EventDataElement addData()
          Add metadata to this event, if metadata has not already been added.
protected  void finalize()
           
 String getApplication()
          Get the name of the application in which this event took place.
 EventDataElement getData()
          If this event has extra data, it can be accessed here.
 Long getDuration()
          If this event is finished, return its duration.
 String getError()
          If this event ended in error, return a description of that error (null otherwise)
 Serializable getId()
          a unique identifier (e.g.
 String getName()
          Get the name of the event; for example, a method name for instrumented method calls, or a server request path for an instrumented servlet.
 BehaviorEvent getParent()
          If this event is a child of a larger composite event, return the event's parent.
 String getSessionId()
          If this event is part of an authenticated session, return an identifier of that session.
 Date getStart()
          If this event has started, return the date at which the event began.
 String getType()
          Get the type of this event.
 String getUserId()
          Get the user on whose behalf this event is executing.
protected  boolean isEnded()
           
protected  boolean isRoot()
           
protected  boolean isStarted()
           
 void setError(String error)
           
 void setError(Throwable t)
           
 void setId(Serializable id)
           
protected  void start()
          Notification that this event has started.
protected  void stop()
          Notification that this event is finished.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BehaviorEvent

protected BehaviorEvent(BehaviorEvent parent,
                        String type,
                        String name,
                        String application,
                        String userId,
                        String sessionId)
Method Detail

finalize

protected void finalize()
Overrides:
finalize in class Object

start

protected void start()
Notification that this event has started. getStart() will return the time at which the event began. This method should never be called directly by application code.

Throws:
IllegalStateException - if this event is already finished or started
See Also:
BehaviorTrackingManager.start(BehaviorEvent)

stop

protected void stop()
Notification that this event is finished. getDuration() will return the time elapsed since start() was called. This method should never be called directly by application code.

Throws:
IllegalStateException - if this event is already finished or was never started
See Also:
BehaviorTrackingManager.stop(BehaviorEvent)

isStarted

protected boolean isStarted()
Returns:
true if this event has started already

isEnded

protected boolean isEnded()
Returns:
true if this event is finished

isRoot

protected boolean isRoot()
Returns:
true if this event is not nested in some other event

getApplication

public String getApplication()
Get the name of the application in which this event took place.


getData

public EventDataElement getData()
If this event has extra data, it can be accessed here. Otherwise returns null.

See Also:
addData()

getDuration

public Long getDuration()
If this event is finished, return its duration. Otherwise return null.


getError

public String getError()
If this event ended in error, return a description of that error (null otherwise)


setError

public void setError(Throwable t)

setError

public void setError(String error)

getId

public Serializable getId()
a unique identifier (e.g. primary key) for this event


setId

public void setId(Serializable id)

getName

public String getName()
Get the name of the event; for example, a method name for instrumented method calls, or a server request path for an instrumented servlet.


getParent

public BehaviorEvent getParent()
If this event is a child of a larger composite event, return the event's parent. Otherwise returns null.


getSessionId

public String getSessionId()
If this event is part of an authenticated session, return an identifier of that session.


getStart

public Date getStart()
If this event has started, return the date at which the event began. Otherwise return null.


getType

public String getType()
Get the type of this event. Many applications will only use one type of event (e.g. "method"), though some may define several. A single application should generally have only a smaller number of event types, corresponding to the layer of the system at which the event originated (e.g. "method", "rendering", "database"). It is suggested that the value of "type" should give some meaning to how the value of getName() should be interpreted. For example, an event type of "request" could signify that getName() returns an HTTP request URL. Generally though type/name schemes are up to the application.


getUserId

public String getUserId()
Get the user on whose behalf this event is executing.


addData

public EventDataElement addData()
Add metadata to this event, if metadata has not already been added.

Returns:
A container for event data. Calling this method more than once always returns the same instance.

toString

public String toString()
Overrides:
toString in class Object