ADK CVS

tryllian.are
Class AgentEvent

java.lang.Object
  extended bytryllian.are.AgentEvent

public class AgentEvent
extends java.lang.Object

Indicates that something interesting has happened. Receiving AgentEvents is the primary method to give agents execution time. Upon receiving an agent event, an agent gets the chance to execute some code.

AgentEvents can convey the following kinds of information:

Heartbeat
Heartbeats are fired once in a while. The time between two heartbeats is the time it takes for every agent on the current system to receive at least one event. This means that when the system has a high load, the time between two heartbeats becomes significantly higher.
Message
A message sent to this agent by another agent
DeliveryReport
When an agent has sent a message, it might be deemed necessary by the MessageBroker to return a DeliveryReport. This can happen for instance for very high priority messages (not implemented yet) or messages that could not be delivered at all. DeliveryReports are not sent by default.

The underlying system has the chance to piggyback multiple types of events on one event. For instance, it is perfectly possible for an event to contain a heartbeat, a message and a deliveryreport.


Constructor Summary
AgentEvent(com.tryllian.are.core.delegate.AgentEventDelegate delegate)
          Creates a new AgentEvent.
 
Method Summary
 DeliveryReport getDeliveryReport()
          Returns the message delivery report, if there was any.
 Message getMessage()
          Returns the incoming message if there was any.
 long getTimeStamp()
          Returns the time in milliseconds at which this event was created.
 boolean isDeliveryReport()
          Check if this event contains a delivery report.
 boolean isHeartbeat()
          Check if this event contains a heartbeat.
 boolean isMessage()
          Check if this event contains an incoming message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentEvent

public AgentEvent(com.tryllian.are.core.delegate.AgentEventDelegate delegate)
Creates a new AgentEvent. This can only be done by the ARE Classloader.

Parameters:
delegate - the event delegate that does the actual work. This parameter can not be null.
Method Detail

isHeartbeat

public boolean isHeartbeat()
Check if this event contains a heartbeat.

Returns:
true if this event contains a heartbeat, false otherewise.

isMessage

public boolean isMessage()
Check if this event contains an incoming message.

Returns:
true if this event contains an incoming message, false otherwise.

isDeliveryReport

public boolean isDeliveryReport()
Check if this event contains a delivery report.

Returns:
truefalse otherwise.

getTimeStamp

public long getTimeStamp()
Returns the time in milliseconds at which this event was created.

Returns:
the time at which this event was created as returned by System.currentTimeMillis

getMessage

public Message getMessage()
Returns the incoming message if there was any.

Returns:
the incoming message if isMessage returns true, or null if isMessage returns false

getDeliveryReport

public DeliveryReport getDeliveryReport()
Returns the message delivery report, if there was any.

Returns:
the delivery report if isDeliveryReport is true, or null if isDeliveryReport returns false.

Copyright 2005, Tryllian Solutions B.V.