com.ibm.sensorevent.engine.baseagent
Class AbstractTaskAgent

java.lang.Object
  extended by com.ibm.sensorevent.engine.baseagent.AbstractTaskAgent
All Implemented Interfaces:
ITaskAgent
Direct Known Subclasses:
AbstractRUCAgent, IBMSEAbstractTaskAgent

public abstract class AbstractTaskAgent
extends java.lang.Object
implements ITaskAgent

AbstractTaskAgent contains the processing common to all Premises Server task agent message-driven beans and Reusable Components

The interface associated with this class is ITaskAgent.


Field Summary
protected  java.lang.String agentclassname
           
protected static java.lang.String AMITBUS
           
protected static java.lang.String AMITQ
           
protected static java.lang.String ANY
           
protected static java.lang.String COLON
           
static java.lang.String COPYRIGHT
           
protected static java.lang.String EVENT_PREFIX
           
protected static java.lang.String EVENT_PREFIX_SHORT
           
protected  ISensorEvent ise
           
protected  Message originalMsg
          The original JMS message passed to the MDB's onMessage method
protected static java.lang.String OUTBOUND
           
protected static java.util.HashMap registeredTopics
           
protected static java.lang.String SLASH
           
 
Constructor Summary
AbstractTaskAgent()
           
 
Method Summary
protected  java.util.HashMap<java.lang.String,java.lang.String> addHeader(java.util.HashMap<java.lang.String,java.lang.String> props, ISensorEvent ise)
           
 void broadCast(ISensorEvent ibmse)
          Publishes the event to the topic generated from the event's sourceId and eventType
 void broadCast(java.lang.String topic, ISensorEvent ibmse)
          Publishes the event to the topic
protected  java.lang.String getAgentname()
          Get the current agentname
protected  java.lang.String getAgentProperty(java.lang.String propname, java.lang.String defaultValue)
          Get a specific property for this agent.
protected  java.util.Map getAgentStore()
          This method will get the cache map for the current agent running associated with the current location (sourceid).
protected  java.util.Map getAgentStoreForGroup()
          This method will get the cache map for the current agent running associated with the current profileid (Configuration Group).
protected  java.util.Map getAgentStoreForSystem()
          This method will get the global cache map for the current agent.
protected  java.util.Map getAllAgentProperties()
          Get all the properties for this agent in the current configuration group
protected  IConverter getEventConverter()
          Returns an instance of the IConverter class defined in premises.properties
protected  java.lang.Object getJNDIObject(java.lang.String JNDIName)
          This is just an object store for retreived JNDI objects
protected  java.lang.String getMsgProperty(java.lang.String propname)
          Returns the string message property value from the original JMS message
 Message getOriginalMsg()
          Returns the original JSM message
protected  PremisesContext getPremisesContext()
          Get a read-only copy of all the context data for an agent.
protected  java.lang.String getPremisesHome()
          This method will return the Premises home directory as defined by the JVM property "premisis.home.directory"
protected  java.lang.String getProfileid()
          Get the current profileid
protected  java.lang.String getSourceid()
          Get the source ID.
protected  java.util.Map getSystemProperties()
          Get all of the properties associationed with the SystemAgent
protected  java.lang.String getValidId(java.lang.String id)
           
protected  java.lang.String getXML(ISensorEvent ise)
          Returns the ISensorEvent converted to XML
protected  boolean isIBMSE(java.util.Map map)
           
protected  boolean isIBMSE(java.lang.String xml)
           
protected  boolean isWBEPacket(java.lang.String xml)
           
protected  void log(java.lang.String tracemsg)
          Log a message to the WAS logger
 void publish(java.lang.String topic, java.io.Serializable obj, java.util.Map properties)
          Publishes the serializable object with data properties to the topic
 void publish(java.lang.String topic, java.lang.String message)
          Publishes the string with data properties to the topic
 void publish(java.lang.String topic, java.lang.String message, java.util.Map properties)
          Publishes the string with data properties to the topic
 void publishOutbound(ISensorEvent ibmse)
          Takes the IBM Sensor event then converts it into XML then publishes the XML to the Premises Server output channel framework.
 void publishOutbound(java.lang.String topic, java.lang.String message)
          Publishes the message to the Premises Server output channels by matching the Premises Server event templates for the topic
 void publishOutbound(java.lang.String topic, java.lang.String message, java.util.HashMap<java.lang.String,java.lang.String> props)
          Publishes the String message to the Premises Server output channel framework by matching the Premises Server event templates with the topic.
 void publishToCEP(java.lang.String eventname, java.util.Map<java.lang.String,java.lang.Object> eventmap)
          Publishes to complex event processing engine
protected  void resetAgentStore()
          This method will invalidate the agentstore cache for this agent for the location(sourceid) level; If the ibmse/PremisesMaps cache object is configured for disk offload, this will also invalidate the agentstore on the disk.
protected  void resetAgentStoreForGroup()
          This method will invalidate the agentstore for this agent at the profileid (configuration group) level; If the ibmse/PremisesMaps cache object is configured for disk offload, this will also invalidate the agentstore on the disk.
protected  void resetAgentStoreForSystem()
          This method will invalidate the agentstore cache for this agent system wide; If the ibmse/PremisesMaps cache object is configured for disk offload, this will also invalidate the agentstore on the disk.
protected  void setAgentname(java.lang.String agentname)
          Set the current agentname
 void setOriginalMsg(Message originalMsg)
          Sets the original JMS message
protected  void setProfileid(java.lang.String profileid)
           
protected  void setSourceid(java.lang.String sourceid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

registeredTopics

protected static java.util.HashMap registeredTopics

OUTBOUND

protected static final java.lang.String OUTBOUND
See Also:
Constant Field Values

EVENT_PREFIX

protected static final java.lang.String EVENT_PREFIX
See Also:
Constant Field Values

EVENT_PREFIX_SHORT

protected static final java.lang.String EVENT_PREFIX_SHORT
See Also:
Constant Field Values

SLASH

protected static final java.lang.String SLASH
See Also:
Constant Field Values

ANY

protected static final java.lang.String ANY
See Also:
Constant Field Values

COLON

protected static final java.lang.String COLON
See Also:
Constant Field Values

AMITBUS

protected static final java.lang.String AMITBUS
See Also:
Constant Field Values

AMITQ

protected static final java.lang.String AMITQ
See Also:
Constant Field Values

ise

protected ISensorEvent ise

originalMsg

protected Message originalMsg
The original JMS message passed to the MDB's onMessage method


agentclassname

protected java.lang.String agentclassname
Constructor Detail

AbstractTaskAgent

public AbstractTaskAgent()
Method Detail

publish

public void publish(java.lang.String topic,
                    java.lang.String message)
Publishes the string with data properties to the topic

Parameters:
topic - topic to publish to
message - string to publish
properties - data properties to include when publishing

publish

public void publish(java.lang.String topic,
                    java.lang.String message,
                    java.util.Map properties)
Publishes the string with data properties to the topic

Specified by:
publish in interface ITaskAgent
Parameters:
topic - topic to publish to
message - string to publish
properties - data properties to include when publishing

publish

public void publish(java.lang.String topic,
                    java.io.Serializable obj,
                    java.util.Map properties)
Publishes the serializable object with data properties to the topic

Specified by:
publish in interface ITaskAgent
Parameters:
topic - topic to publish to
obj - serializable object to publish
properties - data properties to include when publishing

broadCast

public void broadCast(java.lang.String topic,
                      ISensorEvent ibmse)
Publishes the event to the topic

Specified by:
broadCast in interface ITaskAgent
Parameters:
topic - topic to publish to
ibmse - event to publish

broadCast

public void broadCast(ISensorEvent ibmse)
Publishes the event to the topic generated from the event's sourceId and eventType

Specified by:
broadCast in interface ITaskAgent
Parameters:
ibmse -

publishToCEP

public void publishToCEP(java.lang.String eventname,
                         java.util.Map<java.lang.String,java.lang.Object> eventmap)
Publishes to complex event processing engine

Specified by:
publishToCEP in interface ITaskAgent
Parameters:
eventname - event name
eventmap - data

publishOutbound

public void publishOutbound(ISensorEvent ibmse)
Takes the IBM Sensor event then converts it into XML then publishes the XML to the Premises Server output channel framework. The output channel framework will use the eventtype of the event to match with the Premises Server event templates. The type of XML that is sent out is determined by the com.ibm.sensorevent.converter system property.

Specified by:
publishOutbound in interface ITaskAgent
Parameters:
ibmse - The IBMSensorEvent to publish

publishOutbound

public void publishOutbound(java.lang.String topic,
                            java.lang.String message,
                            java.util.HashMap<java.lang.String,java.lang.String> props)
Publishes the String message to the Premises Server output channel framework by matching the Premises Server event templates with the topic. If the props parm is not null, then the properties in that HashMap become properties on the JMS message that is routed to the output channel framework.

Parameters:
topic - what topic to publish on
message - the message to publish
props - any properties that should be associated with this message

publishOutbound

public void publishOutbound(java.lang.String topic,
                            java.lang.String message)
Publishes the message to the Premises Server output channels by matching the Premises Server event templates for the topic

Parameters:
topic - what topic to publish on
message - the message to publish

getMsgProperty

protected java.lang.String getMsgProperty(java.lang.String propname)
                                   throws JMSException
Returns the string message property value from the original JMS message

Parameters:
propname - message property name
Returns:
String value
Throws:
JMSException

getXML

protected java.lang.String getXML(ISensorEvent ise)
Returns the ISensorEvent converted to XML

Parameters:
ise - the event to convert

getOriginalMsg

public Message getOriginalMsg()
Returns the original JSM message


setOriginalMsg

public void setOriginalMsg(Message originalMsg)
Sets the original JMS message

Parameters:
originalMsg - the message

isIBMSE

protected boolean isIBMSE(java.lang.String xml)

isIBMSE

protected boolean isIBMSE(java.util.Map map)

isWBEPacket

protected boolean isWBEPacket(java.lang.String xml)

getEventConverter

protected IConverter getEventConverter()
Returns an instance of the IConverter class defined in premises.properties


addHeader

protected java.util.HashMap<java.lang.String,java.lang.String> addHeader(java.util.HashMap<java.lang.String,java.lang.String> props,
                                                                         ISensorEvent ise)

getValidId

protected java.lang.String getValidId(java.lang.String id)
                               throws java.lang.Exception
Throws:
java.lang.Exception

getPremisesContext

protected PremisesContext getPremisesContext()
Get a read-only copy of all the context data for an agent. This context object contains maps of all context data : Location meta-data Configuration Group meta-data Category meta-data Agent properties System propeties

Returns:
PremisesContext

getSystemProperties

protected java.util.Map getSystemProperties()
                                     throws javax.naming.NamingException
Get all of the properties associationed with the SystemAgent

Returns:
Map containing all of the systemagent properties
Throws:
javax.naming.NamingException

getAllAgentProperties

protected java.util.Map getAllAgentProperties()
                                       throws javax.naming.NamingException
Get all the properties for this agent in the current configuration group

Returns:
Map containing all the propertis for this agent
Throws:
javax.naming.NamingException

getAgentProperty

protected java.lang.String getAgentProperty(java.lang.String propname,
                                            java.lang.String defaultValue)
                                     throws javax.naming.NamingException
Get a specific property for this agent. This method will return a property value. If the value is null, this mehtod will return the defaultValue

Parameters:
propname - property name whose value is needed
defaultValue - value that is returned if the property value is null
Returns:
String containing the property value or default value
Throws:
javax.naming.NamingException

getPremisesHome

protected java.lang.String getPremisesHome()
                                    throws java.lang.Exception
This method will return the Premises home directory as defined by the JVM property "premisis.home.directory"

Returns:
String the Premises home directory
Throws:
java.lang.Exception

getAgentStore

protected java.util.Map getAgentStore()
                               throws javax.naming.NamingException
This method will get the cache map for the current agent running associated with the current location (sourceid). If there is no map for this current agent name and location(sourceid) combination, then a new map will be created and returned. If the current sourceid is null(not set) then the application will receive the Global agent cache map for this agent. See getAgentStoreForSystem.

Returns:
Map containing the cache data for this agent; This cache is available only to this agent when it is being called as a result of events from this specific location. The user may need to add a
Throws:
javax.naming.NamingException

getAgentStoreForGroup

protected java.util.Map getAgentStoreForGroup()
                                       throws javax.naming.NamingException
This method will get the cache map for the current agent running associated with the current profileid (Configuration Group). If there is no map for this current agent and profileid (Configuration Group) combination, then a new map will be created and returned. If the current profileid is null(not set) then the application will receive the Global Agent cache map for this agent. See getAgentStoreForSystem.

Returns:
Map containing the cache data for this agent; This cache is available to this agent or RUC only when it is being called as a result of events from any location that share a profileid (configuration group). The user may need to add a
Throws:
javax.naming.NamingException

getAgentStoreForSystem

protected java.util.Map getAgentStoreForSystem()
                                        throws javax.naming.NamingException
This method will get the global cache map for the current agent. If there is no map for this current agent, then a new map will be created and returned

Returns:
Map containing the cache data for this agent; This cache is available to this agent or RUC regardless of the sourceid or profileid. The user may need to add a
Throws:
javax.naming.NamingException

resetAgentStore

protected void resetAgentStore()
                        throws javax.naming.NamingException
This method will invalidate the agentstore cache for this agent for the location(sourceid) level; If the ibmse/PremisesMaps cache object is configured for disk offload, this will also invalidate the agentstore on the disk.

Throws:
javax.naming.NamingException

resetAgentStoreForGroup

protected void resetAgentStoreForGroup()
                                throws javax.naming.NamingException
This method will invalidate the agentstore for this agent at the profileid (configuration group) level; If the ibmse/PremisesMaps cache object is configured for disk offload, this will also invalidate the agentstore on the disk.

Throws:
javax.naming.NamingException

resetAgentStoreForSystem

protected void resetAgentStoreForSystem()
                                 throws javax.naming.NamingException
This method will invalidate the agentstore cache for this agent system wide; If the ibmse/PremisesMaps cache object is configured for disk offload, this will also invalidate the agentstore on the disk.

Throws:
javax.naming.NamingException

getJNDIObject

protected java.lang.Object getJNDIObject(java.lang.String JNDIName)
                                  throws javax.naming.NamingException
This is just an object store for retreived JNDI objects

Parameters:
JNDIName - String JNDI object name
Returns:
Throws:
javax.naming.NamingException

log

protected void log(java.lang.String tracemsg)
Log a message to the WAS logger

Parameters:
tracemsg - String message to logged.

getAgentname

protected java.lang.String getAgentname()
Get the current agentname

Returns:
String agentname

setAgentname

protected void setAgentname(java.lang.String agentname)
Set the current agentname

Parameters:
agentname - String current agentname

getSourceid

protected java.lang.String getSourceid()
Get the source ID.

Returns:
String current souceid

getProfileid

protected java.lang.String getProfileid()
Get the current profileid

Returns:
String profileid

setSourceid

protected void setSourceid(java.lang.String sourceid)

setProfileid

protected void setProfileid(java.lang.String profileid)


Copyright © 2005 - 2009 IBM Corp. All Rights Reserved.