com.ibm.able.platform.examples
Class EServerTemplateAgent

com.ibm.able.platform.AblePlatformDefaultAgent
  |
  +--com.ibm.able.platform.AbleEServerDefaultAgent
        |
        +--com.ibm.able.platform.examples.EServerTemplateAgent
All Implemented Interfaces:
AbleEServerAgent, AblePlatformAgent, javax.agent.service.transport.MessageListener, java.io.Serializable

public class EServerTemplateAgent
extends AbleEServerDefaultAgent

This class is a simple eServer agent example. It is a time monitor agent. It uses the basics of Able to continusouly monitor the time. Everytime the minute or hour changes the agent will send a history log about the event. The logs could be in one of three formats, and the capability settings will decide how it will act. There will also be a second capability that will check for duplicate request logs. The interval that this agent will check the time at can be customized through a customization panel.

Depending on it's setting, everytime the hour or minute changes, the time capability will either send a history log with no time info, do nothing at all, or ask what it should do. When sending a request with what it should do, it will give the following options:

Depending on it's setting, the duplicate request capability will never log duplicate requests, always log duplicate requests, or ask if a duplicate request should be logged. When the capability is set to ask, these will be the choices:

This class will extend AbleEServerDefaultAgent. Extending this will give you what an agent needs to use the Able Admin Console. It allows you to use the logging service to send logs to, and to get these logs answered. It gives you the capability functionality so the agent can easily set this up and use it to determine how to handle situations. Others can then make use of these too, to change them or just view them. It also allows an agent to have a customization panel that the admin console can use to customize the agent and an about panel that will display information about the agent.

AbleEServerDefaultAgent contains the following variables that a subclass will use: AgentLoggingService myEServerLoggingService HashMap capabilities Vector capabilityOrder HashMap highCapabilitySettings HashMap mediumCapabilitySettings HashMap lowCapabilitySettings HashMap customCapabilitySettings

The follwing methods will be used to work with capabilities, logs and the customization panel. void setCapabilitySettings(Map theCapabilities, AbleSecureKey key) void setCapabilitySetting(Object capabilityName, int autonomyLevel, AbleSecureKey key) Map getCapabilities() Map getCapabilitySettings() AbleEServerCapability getCapability(Object capabilityName) Map[] getCapabilityPresets() AbleMessageContainer getCapabilitySettingsSummary(int autonomyLevel) AbleMessageContainer getCapabilitySettingsSummary(Map capabilities) Vector getCapabilityOrder() void setAgentAutonomyLevel(int agentAutonomyLevel, AbleSecureKey key) int getAutonomyLevel() void answerRequest(AbleAgentSituationReport agentReport, AbleSecureKey key) byte[] getCustomizerResource(String resourceName) void setCustomizerDataBean(Object dataBean, AbleSecureKey key) byte[] getCustomizerDataBean() byte[] getAboutDataBean() String[] getCustomizerInfo()

AbleEServerDefaultAgent extends AblePlatformDefaultAgent which gives you all of the JAS(Java Agent Specification) specific parts an agent needs to be part of a JAS platform.

The Life Cycle Service will use methods from AblePlatformDefaultAgent to perform the actions to an agent: create initialize reinitialize quit suspend reset resume getCreatedAgents quiesce

AblePlatformDefaultAgent also holds most of the attributes of an agent: agentAutonomyLevel agentLastUpdate agentStatus agentSummary agentType agentToAutoRegister agentToBindToRmi agentVendor agentVersion agentMovable agentPrincipal agentTrustLevel agentLocator agentKeyPair agentName agentDescrption

AblePlatformDefaultAgent also hold the important Jas services and parts: ServiceRoot AgentDirectoryService AgentNamingService TransportSystem

AblePlatformDefaultAgent extends AbleRemoteDefaultAgent which contains the following variables: agentAddr agentHost remoteStub

AbleRemoteDefaultAgent extends AbleDefaultAgent which contains the rest of the basic Able Agent functionality: defaultName beans activeDataSource eventConnections processList processListOK numEpochs userDefinedFunctions inputBufferTargetObject outputBufferTargetObject

See Also:
Serialized Form

Fields inherited from class com.ibm.able.platform.AbleEServerDefaultAgent
capabilities, capabilityOrder, customCapabilitySettings, highCapabilitySettings, lowCapabilitySettings, mediumCapabilitySettings, myEServerLoggingService
 
Fields inherited from class com.ibm.able.platform.AblePlatformDefaultAgent
agentLastUpdate, agentMovable, agentStatus, agentSummary, agentToAutoRegister, agentToBindToRmi, agentType, agentVendor, agentVersion, myAgentInboxes, myJasAbleLocator, myJasAgentAttributes, myJasAgentDescription, myJasAgentDirectoryService, myJasAgentName, myJasAgentNamingService, myJasDefaultLocator, myJasMessageTransportService, myJasServiceRoot, myJasTransportSystem, myJasVerifiableDirectoryService, myJasVerifiableNamingService, myKeyPair, myPrincipal, myReceiveMessageMethod, myRequestKey, mySecSppt, myTrustLevel, myVerifiableAgentName
 
Constructor Summary
EServerTemplateAgent()
          Create this template Time Agent using the defualt name
EServerTemplateAgent(java.lang.String name)
          Create this template Time Agent, setting a name for the agent.
EServerTemplateAgent(java.lang.String name, java.lang.String comment)
          Create this template Time Agent, setting a name for the agent, and a comment.
 
Method Summary
protected  void _answerRequest(AbleAgentSituationReport agentReport, AbleSecureKey key)
          When an AbleAgentSituationReport comes into this agent's answerRequest method, if secure, the AbleAgentSituationReport is first authenticated, and then authorized.
protected  java.lang.Object _getAboutDataBean()
          Get the about databean for this agent.
protected  java.lang.Object _getCustomizerDataBean()
          Get the databean for this agent.
protected  java.lang.String[] _getCustomizerInfo()
          Return a String [] array with the following information: --Return null for Strings 0,1, and 2 if there is no Customizer panel-- [0] - Name of Customizer AUIML file and resource bundle class.
protected  void _setCustomizerDataBean(java.lang.Object dataBean, AbleSecureKey key)
          The user will enter values into the customizer panel on the client, and the AUIML data bean will get serialized and sent to this agent with this method.
protected  void authenticateAndAuthorizeCaller(AbleAgentSituationReport asr, AbleSecureKey key)
          This method is what handles authenticating and authorizing the caller who is answering one of the agent's logged situations.
protected  void authorizeCapabilityChangeRequest(AbleSecureKey key)
          This method is what handles authorizing a capability change request to this agent.
protected  void lclInit(java.lang.Object capabilities)
          Initialize the basic ABLE agent processing features.
 void process()
          The processTimerEvent method will call this main processing method for this agent.
 void processTimerEvent()
          Since we are using Timer Event processing, this is the method that will be called.
protected  void validateRequest(AbleAgentSituationReport reportToValidate)
          This method will decide if this request is still a valid request that help is needed on.
 
Methods inherited from class com.ibm.able.platform.AbleEServerDefaultAgent
_init, _init, _quitAll, answerRequest, createAbleAgentSituationReport, getAboutDataBean, getAutonomyLevel, getCapabilities, getCapability, getCapabilityOrder, getCapabilityPresets, getCapabilitySettings, getCapabilitySettingsSummary, getCapabilitySettingsSummary, getCustomizerDataBean, getCustomizerInfo, getCustomizerResource, logAbleAgentSituationReport, logHistory, makeCapabilitySettingsSummary, removeAbleAgentSituationReports, setAgentAutonomyLevel, setAgentAutonomyLevel, setCapabilitySetting, setCapabilitySettings, setCustomizerDataBean, updateAbleAgentSituationReport, verifyCapabilities
 
Methods inherited from class com.ibm.able.platform.AblePlatformDefaultAgent
_reset, _resumeAll, _suspendAll, addAgentInbox, addJasAgentAttribute, broadcastTransportMessage, Copyright, createLocatorAndBindToMethod, getAgentAutonomyLevel, getAgentInboxes, getAgentLastUpdate, getAgentStatus, getAgentSummary, getAgentType, getAgentVendor, getAgentVersion, getAndSetAgentDescription, getAndSetAgentNames, getAndSetTransportServices, getAndValidateServiceRoot, getJasAgentAttributes, getJasAgentName, getNewAgentDescription, getPlatformAgentName, getPrincipal, getTransportMessageContent, getTransportMessageContent2, init, init, initializeAgent, initializeAgent, isAgentMovable, isAgentToAutoRegister, isAgentToBindToRmi, loadAgentDescriptionWithAbleAttributes, loadAgentDescriptionWithAbleLocator, loadAgentDescriptionWithAgentName, loadAgentDescriptionWithBaseLocators, loadAgentDescriptionWithPublicKey, loadAgentDescriptionWithUserAttributes, logException, lookUpAgent, lookUpAgent, main, maybeDeregisterWithAgentDirectoryService, maybeRebindToRmi, maybeRegisterWithAgentDirectoryService, maybeUnbindFromRmi, preInit, preInit, process, quitAgent, quitAll, receiveMessage, removeAgentInbox, removeAgentInboxes, removeJasAgentAttribute, reset, resetAgent, resumeAgent, resumeAll, sendTransportMessage, sendTransportMessage, setAgentMovable, setAgentNameUniqueID, setAgentSummary, setAgentToAutoRegister, setAgentToBindToRmi, setAgentType, setAgentVendor, setAgentVersion, setPrincipal, setRequestKey, setRestartedFromPersistence, suspendAgent, suspendAll, toString, updateDescriptionWithAgentDirectoryService
 
Methods inherited from interface com.ibm.able.platform.AblePlatformAgent
getAgentAutonomyLevel, getAgentLastUpdate, getAgentStatus, getAgentSummary, getAgentType, getAgentVendor, getAgentVersion, getJasAgentAttributes, getJasAgentName, getPlatformAgentName, initializeAgent, initializeAgent, isAgentMovable, isAgentToAutoRegister, isAgentToBindToRmi, preInit, preInit, quitAgent, resetAgent, resumeAgent, suspendAgent
 
Methods inherited from interface javax.agent.service.transport.MessageListener
equals, hashCode
 

Constructor Detail

EServerTemplateAgent

public EServerTemplateAgent()
                     throws java.rmi.RemoteException,
                            com.ibm.able.AbleException
Create this template Time Agent using the defualt name

Throws:
java.rmi.RemoteException - On all remote errors.

AbleException - On errors setting up the capabilities.

EServerTemplateAgent

public EServerTemplateAgent(java.lang.String name)
                     throws java.rmi.RemoteException,
                            com.ibm.able.AbleException
Create this template Time Agent, setting a name for the agent.

Throws:
java.rmi.RemoteException - On all remote errors.

AbleException - On errors setting up the capabilities.

EServerTemplateAgent

public EServerTemplateAgent(java.lang.String name,
                            java.lang.String comment)
                     throws java.rmi.RemoteException,
                            com.ibm.able.AbleException
Create this template Time Agent, setting a name for the agent, and a comment.

Throws:
java.rmi.RemoteException - On all remote errors.

AbleException - On errors setting up the capabilities.
Method Detail

lclInit

protected void lclInit(java.lang.Object capabilities)
                throws com.ibm.able.AbleException
Initialize the basic ABLE agent processing features. Setup the timer event processing, and reset the variables that will be used to create the summary of this agent.

If theCapabilities are not null, they will be used to set the current capabilities and settings of this agent.

Overrides:
lclInit in class AbleEServerDefaultAgent
Parameters:
theCapabilities - A Map[] that will be used to set the agents capabilities and settings.

Throws:
On - all errors calling the super lclInit

processTimerEvent

public void processTimerEvent()
                       throws com.ibm.able.AbleException
Since we are using Timer Event processing, this is the method that will be called.

process

public void process()
             throws com.ibm.able.AbleException
The processTimerEvent method will call this main processing method for this agent. This is the method that we will use to determine if an event that our capabilities is monitoring has occured. If it has, we will send it along to the actOnProblemSituationEncountered method

Throws:
AbleException - On all errors thrown from actOnProblemSituationEncountered.

authenticateAndAuthorizeCaller

protected void authenticateAndAuthorizeCaller(AbleAgentSituationReport asr,
                                              AbleSecureKey key)
                                       throws com.ibm.able.AbleException
This method is what handles authenticating and authorizing the caller who is answering one of the agent's logged situations.

Overrides:
authenticateAndAuthorizeCaller in class AbleEServerDefaultAgent
Parameters:
asr - AbleAgentSituationReport that is the answer to one of the agents logged situations

key - The AbleSecureKey the answering entity used to answer this situation

Throws:
AbleException - If the caller is not authorized.

validateRequest

protected void validateRequest(AbleAgentSituationReport reportToValidate)
                        throws com.ibm.able.AbleException
This method will decide if this request is still a valid request that help is needed on. If the request is an hour changing event, the request will not longer be valid if it is more than 6 minutes old. If it is a minute changing event, it will no longer be valid if it is more than 3 minutes old.

Overrides:
validateRequest in class AbleEServerDefaultAgent
Parameters:
reportToValidate - The AbleAgentSituationReport that is to be validated.

Throws:
AbleException - When the request is no longer valid.

_answerRequest

protected void _answerRequest(AbleAgentSituationReport agentReport,
                              AbleSecureKey key)
When an AbleAgentSituationReport comes into this agent's answerRequest method, if secure, the AbleAgentSituationReport is first authenticated, and then authorized. Once past those checks, an AbleEServerAgentAnswerThread is created with this AbleAgentSituationReport passed into it. This new thread will call this _answerRequest method which will process the answer.

Any failures in answering the request that came back to this method will get logged to the Logging Service as a History Log.

Overrides:
_answerRequest in class AbleEServerDefaultAgent
Parameters:
agentReport - The answered AbleAgentSituationReport that this agent had previoulsy logged.

key - The AbleSecureKey that was used to answer this request

authorizeCapabilityChangeRequest

protected void authorizeCapabilityChangeRequest(AbleSecureKey key)
                                         throws com.ibm.able.AbleException
This method is what handles authorizing a capability change request to this agent. When secure, this agent will only let someone change it's capabilities if it's level is greater than or equal to the level of this agent. This assumes the key has already been verified.

Overrides:
authorizeCapabilityChangeRequest in class AbleEServerDefaultAgent
Parameters:
key - The AbleSecureKey of the entity trying to make the change request.

Throws:
AbleException - If the caller is not authorized.

_getCustomizerInfo

protected java.lang.String[] _getCustomizerInfo()
Return a String [] array with the following information: --Return null for Strings 0,1, and 2 if there is no Customizer panel-- [0] - Name of Customizer AUIML file and resource bundle class. E.g.: "com.ibm.agent.CustomizerPanel" [1] - The Customizer data bean class to use with the AUIML panel. The _setCustomizerData() method should be expecting a class of this type. e.g.: "com.ibm.agent.CustomizerDataBean" [2] - Name of Customizer panel in auiml file. E.g.: "MainPanel" --The following three Strings are only required if there is an About panel-- [3] - Name of AUIML file that has the About panel. E.g.: "com.ibm.agent.AboutPanel" [4] - The About data bean class to use with the AUIML panel. E.g.: "com.ibm.agent.AboutDataBean" [5] - Name of About panel in auiml file. E.g.: "AboutPanel"

Example: myString [0] = "com.ibm.agent.CustomizerPanel" myString [1] = "com.ibm.agent.CustomizerDataBean" myString [2] = "MainPanel"

Default implementation is to return null. This tells the console that the agent doesn't have a customizer panel.

Overrides:
_getCustomizerInfo in class AbleEServerDefaultAgent
Returns:
String []

_setCustomizerDataBean

protected void _setCustomizerDataBean(java.lang.Object dataBean,
                                      AbleSecureKey key)
                               throws com.ibm.able.AbleException
The user will enter values into the customizer panel on the client, and the AUIML data bean will get serialized and sent to this agent with this method.

Overrides:
_setCustomizerDataBean in class AbleEServerDefaultAgent
Parameters:
dataBean - The dataBean that is used to customize this agent.

key - AbleSecureKey used to secure the call.

Throws:
AbleException - On all errors authenticiating and authorizing the caller.

_getCustomizerDataBean

protected java.lang.Object _getCustomizerDataBean()
                                           throws com.ibm.able.AbleException
Get the databean for this agent. It can then be changed and sent back to the agent through the _setCustomizerDataBean method.

Overrides:
_getCustomizerDataBean in class AbleEServerDefaultAgent
Returns:
The dataBean that can be used to customize this agent.

Throws:
AbleException - On any error creating the bean.

_getAboutDataBean

protected java.lang.Object _getAboutDataBean()
                                      throws com.ibm.able.AbleException
Get the about databean for this agent. It is a simple bean that will describe what this agent does.

Overrides:
_getAboutDataBean in class AbleEServerDefaultAgent
Returns:
The dataBean that can be used to describe this agent.

Throws:
AbleException - On any error creating the bean.