org.addsimplicity.anicetus.entity
Class GlobalInfo

java.lang.Object
  extended by org.addsimplicity.anicetus.entity.GlobalInfo
All Implemented Interfaces:
java.util.Map<java.lang.String,java.lang.Object>
Direct Known Subclasses:
ExecInfo, TelemetryEvent, TelemetryState

public abstract class GlobalInfo
extends java.lang.Object
implements java.util.Map<java.lang.String,java.lang.Object>

GlobalInfo serves as the base object for all telemetry artifacts. Telemetry artifacts are maps that have type safe helper methods for setting and accessing properties. The map interface is preserved however to allow applications to add any arbitrary information to the telemetry object without having to extend it. This class will always set the entity identifier to a random UUID and the timestamp to the current time in milliseconds.

Author:
Dan Pritchett (driveawedge@yahoo.com)

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
protected GlobalInfo()
          Construct a telemetry artifact without a parent.
protected GlobalInfo(GlobalInfo parent)
          Construct a telemetry object as a child of the specified parent.
 
Method Summary
 void clear()
          Clear all entries in the map.
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
           
 boolean equals(java.lang.Object o)
          Equality is defined as entityId equivalence.
 java.lang.Object get(java.lang.Object key)
           
 java.util.UUID getEntityId()
          Return the entity identifier for this artifact.
 java.lang.String getExecutionContext()
          Return the execution context.
 java.lang.String getMessage()
          Return the message associated with the artifact.
 java.util.UUID getParentId()
          Return the entity id of the parent of this artifact.
 java.lang.String getReportingNode()
          Return the node where this artifact was created.
 long getTimeStamp()
          Return the time stamp when this artifact was created.
 int hashCode()
          The hash code is implemented as the entity identifier hash code.
 boolean isEmpty()
           
 java.util.Set<java.lang.String> keySet()
           
 java.lang.Object put(java.lang.String key, java.lang.Object value)
           
 void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> t)
           
 java.lang.Object remove(java.lang.Object key)
           
 void setEntityId(java.util.UUID id)
          Set the entity identifier for this artifact.
 void setExceptionAsMessage(java.lang.Throwable exception)
          Set the message to the formatted exception.
 void setExecutionContext(java.lang.String context)
          Set the execution context for this artifact.
 void setMessage(java.lang.String message)
          Set a message on this artifact.
 void setParentId(java.util.UUID parent)
          Set the GUID of the parent of this artifact.
 void setReportingNode(java.lang.String node)
          Set the reporting node where this artifact is created.
 void setTimeStamp(long timeStamp)
          Set the time stamp when this artifact was created.
 int size()
           
 java.util.Collection<java.lang.Object> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalInfo

protected GlobalInfo()
Construct a telemetry artifact without a parent.


GlobalInfo

protected GlobalInfo(GlobalInfo parent)
Construct a telemetry object as a child of the specified parent. If the parent implements TelemetryContainer, this object will be added as a child. Note that any object can serve as a parent from a closure perspective, which means that in the telemetry stream this object will refer to the parent object by GUID, regardless of whether the parent can contain this object in the Java structure.

Parameters:
parent - The parent of this object.
Method Detail

clear

public void clear()
Clear all entries in the map.

Specified by:
clear in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.clear()

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.containsKey(java.lang.Object)

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.containsValue(java.lang.Object)

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
Specified by:
entrySet in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.entrySet()

equals

public boolean equals(java.lang.Object o)
Equality is defined as entityId equivalence.

Specified by:
equals in interface java.util.Map<java.lang.String,java.lang.Object>
Overrides:
equals in class java.lang.Object
Returns:
true for two objects with the same entityId property.

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.get(java.lang.Object)

getEntityId

public java.util.UUID getEntityId()
Return the entity identifier for this artifact. Entity identifiers are typically generated using the random UUID method.

Returns:
the entity identifier.
See Also:
UUID.randomUUID()

getExecutionContext

public java.lang.String getExecutionContext()
Return the execution context. The execution context is typically defined as the process and thread where this artifact was created.

Returns:
the execution context.

getMessage

public java.lang.String getMessage()
Return the message associated with the artifact. Artifacts support an optional message string that may be set by the application.

Returns:
the message.

getParentId

public java.util.UUID getParentId()
Return the entity id of the parent of this artifact.

Returns:
the parent entity identifier or null if this artifact has no parent.

getReportingNode

public java.lang.String getReportingNode()
Return the node where this artifact was created. This is typically a host name or IP address.

Returns:
the reporting node.

getTimeStamp

public long getTimeStamp()
Return the time stamp when this artifact was created. This is the number of milliseconds since January 1, 1970 00:00:00 GMT.

Returns:
the creation time stamp.

hashCode

public int hashCode()
The hash code is implemented as the entity identifier hash code.

Specified by:
hashCode in interface java.util.Map<java.lang.String,java.lang.Object>
Overrides:
hashCode in class java.lang.Object
See Also:
UUID.hashCode()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.isEmpty()

keySet

public java.util.Set<java.lang.String> keySet()
Specified by:
keySet in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.keySet()

put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.put(java.lang.Object, java.lang.Object)

putAll

public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> t)
Specified by:
putAll in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.putAll(java.util.Map)

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.remove(java.lang.Object)

setEntityId

public void setEntityId(java.util.UUID id)
Set the entity identifier for this artifact. This value is automatically set when new artifacts are created. This method is primarily used for deserializing existing streams.

Parameters:
id - The GUID to be used as the entity identifer.

setExceptionAsMessage

public void setExceptionAsMessage(java.lang.Throwable exception)
Set the message to the formatted exception. The exception is converted to a string, including the stack trace and set as the message.

Parameters:
exception - The exception to format.
See Also:
Throwable.printStackTrace()

setExecutionContext

public void setExecutionContext(java.lang.String context)
Set the execution context for this artifact. This is typically the process identifer and optionally the thread identifier.

Parameters:
context - The execution context.

setMessage

public void setMessage(java.lang.String message)
Set a message on this artifact. Messages are application defined text related to the artifact.

Parameters:
message - The message.

setParentId

public void setParentId(java.util.UUID parent)
Set the GUID of the parent of this artifact.

Parameters:
parent - The parent entity identifier.

setReportingNode

public void setReportingNode(java.lang.String node)
Set the reporting node where this artifact is created. This is typically the host name or IP address.

Parameters:
node - The reporting node identifier.

setTimeStamp

public void setTimeStamp(long timeStamp)
Set the time stamp when this artifact was created. The time stamp is set automatically when an artifact is created. This method is primarily for deserializing previously created artifacts. Time stamps are expressed as the number of milliseconds since January 1, 1970 00:00:00 GMT.

Parameters:
timeStamp - The time stamp when the artifact was created.
See Also:
System.currentTimeMillis()

size

public int size()
Specified by:
size in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.size()

values

public java.util.Collection<java.lang.Object> values()
Specified by:
values in interface java.util.Map<java.lang.String,java.lang.Object>
See Also:
Map.values()


Copyright © 2009 Add Simplicity. All Rights Reserved.