jade.jademx.agent
Class JademxPingAgent

java.lang.Object
  extended by jade.core.Agent
      extended by jade.jademx.agent.JademxAgent
          extended by jade.jademx.agent.JademxPingAgent
All Implemented Interfaces:
jade.core.TimerListener, jade.jademx.mbean.JadeJMXAgent, java.io.Serializable, java.lang.Runnable, javax.management.DynamicMBean

public class JademxPingAgent
extends jade.jademx.agent.JademxAgent

sample agent to demonstrate building agent using jademx.

Author:
David Bernstein, Caboodle Networks, Inc.
See Also:
Serialized Form

Nested Class Summary
private  class JademxPingAgent.PingInitiator
          behaviour to send a ping and get response
private static class JademxPingAgent.PingOntology
          the ping ontology
private  class JademxPingAgent.PingResponder
          behaviour to respond to a ping
private  class JademxPingAgent.PingResponse
          response to ping.
 
Nested classes/interfaces inherited from class jade.core.Agent
jade.core.Agent.Interrupted
 
Field Summary
private static java.lang.String ATTR_RESPONSE_DESC
          response attribute description
static java.lang.String ATTR_RESPONSE_NAME
          response attribute name
private static java.lang.String ATTR_RESPONSE_TYPE
          response attribute type
private  jade.content.lang.Codec codec
          my codec
private  jade.content.ContentManager contentManager
          my content manager
static java.lang.String DEFAULT_ANSWER
          default answer
private static java.lang.String DESCRIPTION
          description for MBeanInfo
private  jade.util.Logger logger
          my logger
private  javax.management.MBeanInfo mBeanInfoMerged
          MBeanInfo for this class and superclass(es)
private  javax.management.MBeanInfo mBeanInfoSuper
          MBeanInfo for superclass(es)
private  javax.management.MBeanInfo mBeanInfoThisLevel
          MBeanInfo for for this class but not superclass(es)
static java.lang.String NOTIF_PINGED_NAME
          notification that have been pinged
private  jade.content.onto.Ontology ontology
          my ontology
private static java.lang.String OPER_PING_AGENT_FULL_NAME_PARM_DESC
          ping agentFullName parameter description
private static java.lang.String OPER_PING_AGENT_FULL_NAME_PARM_NAME
          ping agentFullName parameter name
private static java.lang.String OPER_PING_AGENT_FULL_NAME_PARM_TYPE
          ping agentFullName parameter type
private static java.lang.String OPER_PING_DESC
          ping operation description
static java.lang.String OPER_PING_NAME
          ping operation name
static java.lang.String[] OPER_PING_SIGNATURE
          signature for a ping operation
static java.lang.String OPER_PING_TYPE
          return type for ping operation
static java.lang.String PING
          name of ping schema
private  int pingCount
          count pings for benefit of reply-with in messages
private  java.lang.String response
          response to a ping.
 
Fields inherited from class jade.jademx.agent.JademxAgent
ATTR_UNIT_TEST_ACTUAL_MESSAGE_NAME, ATTR_UNIT_TEST_CMP_CONTENT_NAME, ATTR_UNIT_TEST_CMP_CONVERSATION_ID_NAME, ATTR_UNIT_TEST_CMP_ENCODING_NAME, ATTR_UNIT_TEST_CMP_ENVELOPE_NAME, ATTR_UNIT_TEST_CMP_IN_REPLY_TO_NAME, ATTR_UNIT_TEST_CMP_LANGUAGE_NAME, ATTR_UNIT_TEST_CMP_ONTOLOGY_NAME, ATTR_UNIT_TEST_CMP_PERFORMATIVE_NAME, ATTR_UNIT_TEST_CMP_PROTOCOL_NAME, ATTR_UNIT_TEST_CMP_RECEIVER_NAME, ATTR_UNIT_TEST_CMP_REPLY_BY_NAME, ATTR_UNIT_TEST_CMP_REPLY_TO_NAME, ATTR_UNIT_TEST_CMP_REPLY_WITH_NAME, ATTR_UNIT_TEST_CMP_SENDER_NAME, ATTR_UNIT_TEST_CMP_USER_PROPERTIES_NAME, ATTR_UNIT_TEST_EXPECTED_MESSAGE_NAME, ATTR_UNIT_TEST_IGNORE_CONTENT_AID_ADDRESSES_NAME, ATTR_UNIT_TEST_INJECT_MESSAGE_NAME, ATTR_UNIT_TEST_NEWLINES_NORMALIZED_NAME, ATTR_UNIT_TEST_TIMEOUT_NAME, NOTIF_INFO_DESCRIPTION, NOTIF_UNIT_TEST_FAILURE_NAME, NOTIF_UNIT_TEST_SUCCESS_NAME, OPER_UNIT_TEST_ADD_VARIABLE_NAME, OPER_UNIT_TEST_ADD_VARIABLE_SIGNATURE, OPER_UNIT_TEST_ADD_VARIABLE_TYPE, OPER_UNIT_TEST_CLEAR_VARIABLES_NAME, OPER_UNIT_TEST_CLEAR_VARIABLES_SIGNATURE, OPER_UNIT_TEST_CLEAR_VARIABLES_TYPE, OPER_UNIT_TEST_INJECT_AND_EXPECT_NAME, OPER_UNIT_TEST_INJECT_AND_EXPECT_SIGNATURE, OPER_UNIT_TEST_INJECT_AND_EXPECT_TYPE
 
Fields inherited from class jade.core.Agent
AP_ACTIVE, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_WAITING, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN
 
Constructor Summary
JademxPingAgent()
          make a Jademx ping agent
 
Method Summary
private  javax.management.MBeanInfo constructMBeanInfo()
          create a new MBeanInfo object to describe this agent.
 java.lang.Object getAttribute(java.lang.String attribute)
          get an attribute value
 javax.management.MBeanInfo getMBeanInfo()
          this is a merge of the agent, this class, and this class's superclass.
 java.lang.String getResponse()
          get response
 java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
          invoke an action
 java.lang.String ping(java.lang.String pingeeAgentFullName)
          perform ping operation
 void setAttribute(javax.management.Attribute attribute)
           
 void setResponse(java.lang.String response)
          set the response
protected  void setup()
           
 
Methods inherited from class jade.jademx.agent.JademxAgent
, assertExpectedMessage, assertExpectedMessage, assertIsJademxAgent, assertIsJademxAgent, changedMBeanInfo, getAttributes, getUnitTestActualMessage, getUnitTestExpectedMessage, getUnitTestInjectMessage, getUnitTestTimeout, isJademxBound, isUnitTestCmpContent, isUnitTestCmpConversationId, isUnitTestCmpEncoding, isUnitTestCmpEnvelope, isUnitTestCmpInReplyTo, isUnitTestCmpLanguage, isUnitTestCmpOntology, isUnitTestCmpPerformative, isUnitTestCmpProtocol, isUnitTestCmpReceiver, isUnitTestCmpReplyBy, isUnitTestCmpReplyTo, isUnitTestCmpReplyWith, isUnitTestCmpSender, isUnitTestCmpUserProperties, isUnitTestIgnoreContentAIDAddresses, isUnitTestNewlinesNormalized, notifyListeners, setAttributes, setJadeAgent, setMBeanInfo, setUnitTestActualMessage, setUnitTestCmpContent, setUnitTestCmpConversationId, setUnitTestCmpEncoding, setUnitTestCmpEnvelope, setUnitTestCmpInReplyTo, setUnitTestCmpLanguage, setUnitTestCmpOntology, setUnitTestCmpPerformative, setUnitTestCmpProtocol, setUnitTestCmpReceiver, setUnitTestCmpReplyBy, setUnitTestCmpReplyTo, setUnitTestCmpReplyWith, setUnitTestCmpSender, setUnitTestCmpUserProperties, setUnitTestExpectedMessage, setUnitTestIgnoreContentAIDAddresses, setUnitTestInjectMessage, setUnitTestNewlinesNormalized, setUnitTestTimeout, unitTestAddVariable, unitTestClearVariables, unitTestInjectAndExpect
 
Methods inherited from class jade.core.Agent
addBehaviour, afterClone, afterMove, beforeClone, beforeMove, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, clean, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAMS, getArguments, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getHap, getHelper, getLocalName, getName, getO2AObject, getProperty, getQueueSize, getState, here, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, receive, receive, removeBehaviour, restartLater, restore, restoreBufferedState, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setQueueSize, takeDown, waitUntilStarted, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ANSWER

public static final java.lang.String DEFAULT_ANSWER
default answer

See Also:
Constant Field Values

response

private java.lang.String response
response to a ping. access must be synchronized because it's accessed both by the MBeanServer thread and by the JADE agent thread.


logger

private final jade.util.Logger logger
my logger


codec

private jade.content.lang.Codec codec
my codec


ontology

private jade.content.onto.Ontology ontology
my ontology


contentManager

private jade.content.ContentManager contentManager
my content manager


ATTR_RESPONSE_NAME

public static final java.lang.String ATTR_RESPONSE_NAME
response attribute name

See Also:
Constant Field Values

ATTR_RESPONSE_DESC

private static final java.lang.String ATTR_RESPONSE_DESC
response attribute description

See Also:
Constant Field Values

ATTR_RESPONSE_TYPE

private static final java.lang.String ATTR_RESPONSE_TYPE
response attribute type


OPER_PING_NAME

public static final java.lang.String OPER_PING_NAME
ping operation name

See Also:
Constant Field Values

OPER_PING_DESC

private static final java.lang.String OPER_PING_DESC
ping operation description

See Also:
Constant Field Values

OPER_PING_AGENT_FULL_NAME_PARM_NAME

private static final java.lang.String OPER_PING_AGENT_FULL_NAME_PARM_NAME
ping agentFullName parameter name

See Also:
Constant Field Values

OPER_PING_AGENT_FULL_NAME_PARM_TYPE

private static final java.lang.String OPER_PING_AGENT_FULL_NAME_PARM_TYPE
ping agentFullName parameter type


OPER_PING_AGENT_FULL_NAME_PARM_DESC

private static final java.lang.String OPER_PING_AGENT_FULL_NAME_PARM_DESC
ping agentFullName parameter description

See Also:
Constant Field Values

OPER_PING_SIGNATURE

public static final java.lang.String[] OPER_PING_SIGNATURE
signature for a ping operation


OPER_PING_TYPE

public static final java.lang.String OPER_PING_TYPE
return type for ping operation


NOTIF_PINGED_NAME

public static final java.lang.String NOTIF_PINGED_NAME
notification that have been pinged

See Also:
Constant Field Values

DESCRIPTION

private static final java.lang.String DESCRIPTION
description for MBeanInfo

See Also:
Constant Field Values

mBeanInfoMerged

private javax.management.MBeanInfo mBeanInfoMerged
MBeanInfo for this class and superclass(es)


mBeanInfoSuper

private javax.management.MBeanInfo mBeanInfoSuper
MBeanInfo for superclass(es)


mBeanInfoThisLevel

private javax.management.MBeanInfo mBeanInfoThisLevel
MBeanInfo for for this class but not superclass(es)


pingCount

private int pingCount
count pings for benefit of reply-with in messages


PING

public static final java.lang.String PING
name of ping schema

See Also:
Constant Field Values
Constructor Detail

JademxPingAgent

public JademxPingAgent()
make a Jademx ping agent

Method Detail

constructMBeanInfo

private javax.management.MBeanInfo constructMBeanInfo()
create a new MBeanInfo object to describe this agent.

Returns:
new MBeanInfo object to describe this agent.

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo()
this is a merge of the agent, this class, and this class's superclass.

Specified by:
getMBeanInfo in interface javax.management.DynamicMBean
Overrides:
getMBeanInfo in class jade.jademx.agent.JademxAgent
Returns:
MBean information for ping agent including JademxAgent

setup

protected void setup()
Overrides:
setup in class jade.jademx.agent.JademxAgent

ping

public java.lang.String ping(java.lang.String pingeeAgentFullName)
                      throws java.lang.Exception
perform ping operation

Parameters:
pingeeAgentFullName - full JADE name of agent to ping
Returns:
current response
Throws:
java.lang.Exception

setResponse

public void setResponse(java.lang.String response)
set the response

Parameters:
response - response to set

getResponse

public java.lang.String getResponse()
get response

Returns:
response

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException,
                                     javax.management.ReflectionException
get an attribute value

Specified by:
getAttribute in interface javax.management.DynamicMBean
Overrides:
getAttribute in class jade.jademx.agent.JademxAgent
Parameters:
attribute - name of attribute to get
Returns:
attribute value
Throws:
javax.management.AttributeNotFoundException - no such attribute
javax.management.MBeanException - exception from getter
javax.management.ReflectionException - exception invoking getter

setAttribute

public void setAttribute(javax.management.Attribute attribute)
                  throws javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.MBeanException,
                         javax.management.ReflectionException
Specified by:
setAttribute in interface javax.management.DynamicMBean
Overrides:
setAttribute in class jade.jademx.agent.JademxAgent
Parameters:
attribute -
Throws:
javax.management.AttributeNotFoundException - no such attribte
javax.management.InvalidAttributeValueException - bad attribute value
javax.management.MBeanException - exception from setter
javax.management.ReflectionException - exception invoking setter

invoke

public java.lang.Object invoke(java.lang.String actionName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException,
                               javax.management.ReflectionException
invoke an action

Specified by:
invoke in interface javax.management.DynamicMBean
Overrides:
invoke in class jade.jademx.agent.JademxAgent
Parameters:
actionName - name of action to invoke
params - action parameters
signature - action signature
Returns:
object result
Throws:
javax.management.MBeanException - wrap action exception
javax.management.ReflectionException - wrap action invocation exception


Copyright © 2005-2006 Caboodle Networks, Inc.
LGPL license