All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.meitca.concordia.Agent


java.lang.Object

   |

   +----COM.meitca.concordia.Agent


public abstract class Agent
extends Object
implements Serializable, Cloneable, Observer, EventHandler
A base class representing a mobile software Agent. All user-defined agents should be derived from the class Agent.

Concordia Agents have the ability to travel through a computer network. An Agent's travels are specified by its Itinerary, which is composed of a list of Destinations. Each Destination indicates the name of a machine on the network to which the Agent should travel, and the name of a method of the Agent that should be executed when the agent arrives at that host.

An Agent's travels are initiated by a process referred to as launching. Launching an Agent requires specifying some information about the Agent, such as its Itinerary, and then invoking the Agent's launch method. Once launch successfully completes, the Agent will be travelling.

A simple Agent could be constructed like the following:

    class MyAgent extends Agent {
        public void arrive() {
            System.out.println("Agent arrived at destination");
        }
    }
 

This agent could then be launched by following code;

     MyAgent agent = new MyAgent();
     Itinerary i = new Itinerary();
     i.addDestination(new Destination("host1", "arrive"));
     i.addDestination(new Destination("host2", "arrive"));
     i.addDestination(new Destination("host3", "arrive"));
     agent.setItinerary(i);
     agent.setHomeCodebaseURL("http://webserver/Agents");
     agent.launch();
 

This Agent's Itinerary specifies that it should travel in order to the machines named host1, host2, host3 and at each stop the Agent's arrive should be allowed to execute. Once the Itinerary is complete, the Agent will be garbage collected and will disappear from the network.

See Also:
Itinerary, Destination, EventHandler

Variable Index

 o ACTIVE
Agent is active.
 o COMPLETE
Agent has completed its travels.
 o INTRANSIT
Agent is intransit.
 o UNKNOWN
Agent is in an unknown state.

Constructor Index

 o Agent()
Constructs an Agent.

Method Index

 o addAgentListener(RemoteAgentListener, String, int)
Adds a new remote agent listener to the list of objects that wish to receive agent notification events.
 o addAgentListener(RemoteAgentListener, String, int, boolean)
Adds a new remote agent listener to the list of objects that wish to receive agent notification events.
 o clone()
Makes a clone of the agent.
 o completedItinerary()
This is called by the Concordia Server when the Agent completes its Itinerary.
 o completedTransport()
This is called by the Concordia Server when the Agent arrives at its new destination.
 o debug(String, int, String)
Logs a debug message to the Concordia log file on behalf of the Agent.
 o getAgentID()
Retrieves the Agent's ID.
 o getHomeCodebaseURL()
Returns a URL pointing to the Agent's codebase on its home machine.
 o getItinerary()
Returns a reference to the Agent's Itinerary.
 o getItineraryMethods()
This method retrieves a list of the methods of the Agent which are eligible to be included in the Agent's itinerary.
 o getRelatedClasses()
Retrieves a list of the Agent's related classes (classes whose bytecodes automatically travel with an Agent).
 o getStatus()
Returns the agent's status.
 o handleEvent(EventType)
An empty implementation of an event handler.
 o isCompressed()
Retrieves the value of the agent's Compressed property.
 o isEncrypted()
Retrieves the value of the agent's Encrypted property.
 o isPersistent()
Retrieves the value of the agent's Persistent property.
 o isQueued()
Retrieves the value of the agent's Queued property.
 o launch()
Launches the Agent.
 o makeEventHandler(boolean)
This method sets up this Agent's event handler.
 o makeEventManagerConnection(boolean)
This method establishes a connection with the Event Manager on the same host the Agent is currently executing on.
 o makeEventManagerConnection(String, boolean)
This method establishes a connection to a potentially remote Event Manager.
 o notifyListeners(AgentNotificationEvent)
Sends the specified notification event to all of the currently registered listeners.
 o postEvent(EventType)
Send an event to all objects registered to receive it.
 o prepareForTransport()
This is called by the Concordia Server immediately prior to the agent being transported to its next destination.
 o registerAllEvents()
Register interest in receiving all events posted to this EventManager.
 o registerEvents(Class[])
Register interest in receiving specified events.
 o removeAgentListener(RemoteAgentListener, String, int)
Removes the specified remote agent listener.
 o sendMessage(String, int, String)
Sends a message to the agent debugger or any other listener that is registered to receive AgentMessageNotificationEvents.
 o setCompressed(boolean)
Sets the agent's Compressed property.
 o setEncrypted(boolean)
Sets the agent's Encrypted property.
 o setHomeCodebaseURL(String)
Sets the URL of the Agent's codebase.
 o setItinerary(Itinerary)
Sets the Agent's Itinerary.
 o setPersistent(boolean)
Sets the agent's Persistent property.
 o setQueued(boolean)
Sets the agent's Queued property.
 o setRelatedClasses(String[])
Sets the list of the Agent's related classes (classes whose bytecodes automatically travel with an Agent).
 o toString()
Converts an Agent to a String.
 o unregisterAllEvents()
Remove registration for all events.
 o unregisterEvents(Class[])
Remove registration for specified events.

Variables

 o ACTIVE

 public static final int ACTIVE

Agent is active.

 o INTRANSIT

 public static final int INTRANSIT

Agent is intransit.

 o COMPLETE

 public static final int COMPLETE

Agent has completed its travels.

 o UNKNOWN

 public static final int UNKNOWN

Agent is in an unknown state.

Constructors

 o Agent

 public Agent()

Constructs an Agent. A network-unique ID will be generated for the Agent. This ID can be retrieved via the getAgentID method.

Methods

 o getAgentID

 public final String getAgentID()

Retrieves the Agent's ID. An Agent ID is a network-unique String which identifies a particular instance of an Agent. This ID can be used to identify an Agent during its travels.

Returns:
The Agent's ID.
 o getStatus

 public final int getStatus()

Returns the agent's status.

Returns:
The agent's status.
 o toString

 public final String toString()

Converts an Agent to a String. Implementation simply returns the Agent's ID.

Returns:
A String representation of the Agent.
Overrides:
toString in class Object
 o getItinerary

 public Itinerary getItinerary()

Returns a reference to the Agent's Itinerary. The Agent's Itinerary specifies how it travels through the network. The Itinerary is composed of a list of Destinations, each of which indicates the name of a machine on the network to which the Agent should travel, and the name of a method of the Agent which should be executed when the agent arrives at that host.

This method can be used by the Agent to modify the Itinerary while it is travelling. For example, an Agent can decide at runtime to add or remove destinations from its Itinerary as is done in the following example;

     class MyAgent extends Agent {
         public void method() {
             ...
             if (more_destinations) {
                 getItinerary().addDestination(new Destination("nexthost", "method"));
             }
             ...
         }
     }
 

Returns:
The Agent's Itinerary.
 o setItinerary

 public void setItinerary(Itinerary itin)

Sets the Agent's Itinerary. The Agent's Itinerary specifies how it travels through the network. The Itinerary is composed of a list of Destinations, each of which indicates the name of a machine on the network to which the Agent should travel, and the name of a method of the Agent which should be executed when the agent arrives at that host.

This method can be used to set or replace the Agent's Itinerary, as is done in the following example of Agent launching;

     MyAgent agent = new MyAgent();
     Itinerary i = new Itinerary();
     i.addDestination(new Destination("host1", "arrive"));
     i.addDestination(new Destination("host2", "arrive"));
     i.addDestination(new Destination("host3", "arrive"));
     agent.setItinerary(i);
     agent.launch();
 

 o getHomeCodebaseURL

 public String getHomeCodebaseURL()

Returns a URL pointing to the Agent's codebase on its home machine. An Agent's codebase represents a network accessible location from which the bytecodes that make up the Agent and other related classes can be retrieved. The Agent's codebase is very similar to the codebase of a World Wide Web applet.

While an Agent is executing on a machine on a network, it may attempt to construct an object whose bytecodes have not been previously installed on that machine. For example, if an Agent called MyAgent attempted to create an object of class MyAgentObject via code like the following;

     MyAgentObject obj = new MyAgentObject();
 

If the bytecodes for the MyAgentObject class (which would be stored in a file names MyAgentObject.class) were note present on the server on which the Agent was running, then the Concordia Server would need to send a network request to load those bytecodes. The codebase URL specifies where that network request should be sent.

In most cases, the codebase URL should be set to an HTTP URL pointing to a location on a web server where the Agent's bytecodes have been stored.

Returns:
The URL of the Agents codebase or null if the URL is not available
 o setHomeCodebaseURL

 public void setHomeCodebaseURL(String url)

Sets the URL of the Agent's codebase. An Agent's codebase represents a network accessible location from which the bytecodes that make up the Agent and other related classes can be retrieved. The Agent's codebase is very similar to the codebase of a World Wide Web applet.

While an Agent is executing on a machine on a network, it may attempt to construct an object whose bytecodes have not been previously installed on that machine. For example, if an Agent called MyAgent attempted to create an object of class MyAgentObject via code like the following;

     MyAgentObject obj = new MyAgentObject();
 

If the bytecodes for the MyAgentObject class (which would be stored in a file named MyAgentObject.class) were not present on the server on which the Agent was running, then the Concordia Server would need to send a network request to load those bytecodes. The codebase URL specifies where that network request should be sent.

In most cases, the codebase URL should be set to an HTTP URL pointing to a location on a web server where the Agent's bytecodes would have been stored.

NOTE: An Agent's codebase URL CANNOT be changed once the Agent has begun travelling.

 o getRelatedClasses

 public String[] getRelatedClasses()

Retrieves a list of the Agent's related classes (classes whose bytecodes automatically travel with an Agent). As an Agent travels around the network, it can pull with it the bytecodes for objects it will need. For example, if an Agent called MyAgent attempted to create an object of class MyAgentObject via code like the following;

     MyAgentObject obj = new MyAgentObject();
 

it is possible that the bytecodes for the MyAgentObject class (which would be stored in a file named MyAgentObject.class) may not be present on the server on which the Agent is running. Normally in such cases, the Concordia Server will send a network request to the Agent's codebase to retrieve the needed class. Once a class has been downloaded from the Agent's codebase it will from then on automatically be pushed with the Agent as it travels.

A programmer or user can optionally specify a list of Agent related classes. These classes are pushed with the Agent as it travels beginning at launch time. The use of related classes can be more efficient since it avoids the initial download needed to retrieve classes needed by the Agent.

The getRelatedClasses method retrieves this list. The method returns a String array containing the full names of the classes (including all package names).

Returns:
A String array containing the full names of the Agent's related classes (including all package names).
 o setRelatedClasses

 public void setRelatedClasses(String classes[])

Sets the list of the Agent's related classes (classes whose bytecodes automatically travel with an Agent). As an Agent travels around the network, it can pull with it the bytecodes for objects it will need. For example, if an Agent called MyAgent attempted to create an object of class MyAgentObject via code like the following;

     MyAgentObject obj = new MyAgentObject();
 

it is possible that the bytecodes for the MyAgentObject class (which would be stored in a file named MyAgentObject.class) may not be present on the server on which the Agent is running. Normally in such cases, the Concordia Server will send a network request to the Agent's codebase to retrieve the needed class. Once a class has been downloaded from the Agent's codebase it will from then on automatically be pushed with the Agent as it travels.

A programmer or user can optionally specify a list of Agent related classes. These classes are pushed with the Agent as it travels beginning at launch time. The use of related classes can be more efficient since it avoids the initial download needed to retrieve classes needed by the Agent.

The setRelatedClasses method is used to specify this list. The method takes as a parameter a String array containing the full names of the classes (including all package names).

For example, if there was an Agent called MyAgent which was part of a package named test, and that Agent made use of two other classes called MyClass1 and MyClass2 (also part of the test package), the programmer could specify the related classes list in the following manner;

     test.MyAgent agent = new test.MyAgent();
     String[] related = {"test.MyClass1", "test.MyClass2"};
     agent.setRelatedClasses(related);
 

Parameters:
classes - a String array containing the full names of the classes (including all package names).
 o getItineraryMethods

 public String[] getItineraryMethods()

This method retrieves a list of the methods of the Agent which are eligible to be included in the Agent's itinerary. In order for a method to be eligible for inclusion in an Itinerary, the method must be public, must take no parameters, and must have a return type of void.

 o setQueued

 public void setQueued(boolean useQueue)

Sets the agent's Queued property. This property specifies whether Queue Manager should be used when transmitting an agent. Specifying a false value for this property disables queuing for this agent. Specifying a true value for this property enables queuing. This property defaults to true.

The following code demonstrates the use of this feature:

     MyAgent agent1 = new MyAgent();
     agent1.setQueued(true);
     agent1.launch(); // agent WILL be queued
     MyAgent agent2 = new MyAgent();
     agent2.setQueued(false);
     agent2.launch(); // agent WILL NOT be queued
 

Note: The Queue Manager (which provides for reliable agent delivery) is only available in the commercially licensed version of Concordia. In the evaluation version of Concordia queuing is not available and this property will have no effect.

Note: This property defaults to true in order to maintain backwards code compatibility with Concordia V1.1.2. Future versions of Concordia may exhibit different behavior. In any event, it is preferable for a developer to explicitly specify after creating and agent whether or not queuing is desired.

 o isQueued

 public boolean isQueued()

Retrieves the value of the agent's Queued property. This property specifies wether queuing should be used when transmitting an agent. A false value for this property disables queueing for this agent. A true value for this property enables queueing. This property defaults to true.

 o setPersistent

 public void setPersistent(boolean persist)

Sets the agent's Persistent property. This property specifies wether the agent should be persisted to disk when running on a server. Specifying a false value for this property disables persistence for this agent. Specifying a true value for this property enables queueing. This property defaults to true.

The following code demonstrates the use of this feature:

     MyAgent agent1 = new MyAgent();
     agent1.setPersistent(true);
     agent1.launch(); // agent WILL be persistent
     MyAgent agent2 = new MyAgent();
     agent2.setPersistent(false);
     agent2.launch(); // agent WILL NOT be persistent
 

Note: Agent persistence is only available in the commercially licensed version of Concordia. In the evaluation version of Concordia this property will have no effect.

Note: This property defaults to true in order to maintain backwards code compatibility with Concordia V1.1.2. Future versions of Concordia may exhibit different behavior. In any event, it is preferable for a developer to explicitly specify after creating and agent whether or not persistence is desired.

 o isPersistent

 public boolean isPersistent()

Retrieves the value of the agent's Persistent property. This property specifies wether the agent should be persisted to disk when running on a server. A false value for this property disables persistence for this agent. A true value for this property enables persistence. This This property defaults to true.

 o setEncrypted

 public void setEncrypted(boolean encrypt)

Sets the agent's Encrypted property. This property specifies wether encryption should be used when transmitting an agent. Specifying a false value for this property disables encryption for this agent. Specifying a true value for this property enables encryption. This property defaults to false.

The following code demonstrates the use of this feature:

     MyAgent agent1 = new MyAgent();
     agent1.setEncrypted(true);
     agent1.launch(); // agent WILL be encrypted
     MyAgent agent2 = new MyAgent();
     agent2.setEncrypted(false);
     agent2.launch(); // agent WILL NOT be encrypted
 

Note: Agent encryption is only available in the domestic or export encryption version of Concordia. In the evaluation and commercial version of Concordia this property will have no effect.

 o isEncrypted

 public boolean isEncrypted()

Retrieves the value of the agent's Encrypted property. This property specifies whether encryption should be used when transmitting an agent. A false value for this property disables encryption for this agent. A true value for this property enables encryption. This property defaults to false.

 o setCompressed

 public void setCompressed(boolean compress)

Sets the agent's Compressed property. This property specifies whether the agent should be compressed when transmited. Specifying a false value for this property disables compression for this agent. Specifying a true value for this property enables compression. This property defaults to false.

The following code demonstrates the use of this feature:

     MyAgent agent1 = new MyAgent();
     agent1.setCompressed(true);
     agent1.launch(); // agent WILL be compressed
     MyAgent agent2 = new MyAgent();
     agent2.setCompressed(false);
     agent2.launch(); // agent WILL NOT be compressed
 

Note: Agent compression is only available when using Concordia's TCP socket level transport layer. If RMI is used as an agent transport layer, this property will have no effect.

 o isCompressed

 public boolean isCompressed()

Retrieves the value of the agent's Compressed property. This property specifies whether the agent should be compressed when transmited. A false value for this property disables compression for this agent. A true value for this property enables compression. This property defaults to false.

 o launch

 public void launch() throws LaunchException

Launches the Agent. As in the following example;

     MyAgent agent = new MyAgent();
     Itinerary i = new Itinerary();
     i.addDestination(new Destination("host1", "arrive"));
     agent.setItinerary(i);
     agent.launch();
 

Throws: LaunchException
If an error occurs during the launch. More information on the error can be retrieved from the message included in the exception.
 o debug

 public void debug(String facility,

                   int level,

                   String message)

Logs a debug message to the Concordia log file on behalf of the Agent. Concordia logging can be used for debugging purposes or for error logging. Here's an example:

 import COM.meitca.concordia.*;
 public class DebugAgent extends Agent {
     public void doit() {
         // A simple debug message
         debug("DebugAgent", 1, "Agent arrived at server");
         // More verbose information
         debug("DebugAgent", 3, "AgentID is " + getAgentID());
         // use the default facility name
        debug(null, 3, "Agent's class is " + getClass().getName());
     }
 }
 

Parameters:
facility - The facilty is a string which can be used to classify this debug message. Concordia logging supports enabling or disabling debugging on a per facility bases. Using facilities, a developer or administrator can filter out unwanted or unrelated information and focus in on particular areas of interest. Agent developers can specify application specific facility names to aid in their debugging. A null value can be specified for the facility parameter. In this case a default facility names of Agent will be used.
level - The debugging level specifies the level of detail at which this message should be logged. In general, when configuring Concordia server logging, an Administrator specifies the detail level for logging. This level is a numeric value. A value of 0 specifies very high level information. The larger the number specified the finer the level of detail and the more verbose the debug output. Agent developers should generally specify low numeric values of high level debug output and high numeric values for verbose output.
message - Ths debug message to log.
 o clone

 public Object clone() throws CloneNotSupportedException

Makes a clone of the agent. The clone will be identical to the intial agent, however it will have a different agent ID and will have its own fresh copy of the Itinerary. This Itinerary will be reset to the initial destination. Any subclass that overrides clone must call into super before any other processing.

Overrides:
clone in class Object
 o prepareForTransport

 public void prepareForTransport() throws AgentTransportException

This is called by the Concordia Server immediately prior to the agent being transported to its next destination. Its purpose is to perform any cleanup required before the Agent migrates to its next destination.

Derived Agents can override this method to perform any final processing needed before transport. For example, an Agent may override this method to free up machine-specific resources (such as open files or network connections), or to notify other Agents or objects that the Agent is traveling.

Throws: AgentTransportException
If the cleanup fails and the Agent cannot be transported.
 o completedTransport

 public void completedTransport() throws AgentTransportException

This is called by the Concordia Server when the Agent arrives at its new destination. Its purpose is to perform any initialization required by the Agent when it arrives at a new destination.

Derived Agents can override this method to perform any processing needed on arrival. For example, an Agent may override this method to open or create machine-specific resources (such as files or network connections), or to notify other Agent's or objects that the Agent has completed traveling.

Throws: AgentTransportException
If the initialization fails.
 o completedItinerary

 public void completedItinerary() throws AgentTransportException

This is called by the Concordia Server when the Agent completes its Itinerary. Its purpose is to perform any cleanup required after the Agent completes its itinerary.

Derived Agents can override this method to perform any cleanup needed when an Agent finishes execution. For example, an Agent may override this method to release references to other objects so they can be garbage collected (and so the Agent can be garbage collected, if they hold circular references to each other).

Throws: AgentTransportException
If the cleanup fails.
 o handleEvent

 public void handleEvent(EventType event) throws EventException

An empty implementation of an event handler. Subclasses must override this method to handle application-specific events, if they wish to receive any.

An Agent's event handler would typically look like:

    public void handleEvent(EventType event) {
        if (event instanceof MyEvent1)
            handleMyEvent1();
        else if (event instanceof MyEvent2)
            handleMyEvent2();
    }
 

Parameters:
event - The event to handle.
Throws: EventException
If an error occurs handling the event.
 o makeEventHandler

 public void makeEventHandler(boolean sync) throws EventHandlerException

This method sets up this Agent's event handler. Agents must call this method before they can receive any events. After calling this method, the Agent must invoke the makeEventManagerConnection method.

Parameters:
sync - This argument indicates if events should be handled synchronously (true) or asynchronously (false). A value of false for this argument causes a new thread to be created to run the event handler. A value of true indicates that events are handled within the Agent's main thread of execution.
Throws: EventHandlerException
If an error occurs setting up the event handler.
 o makeEventManagerConnection

 public void makeEventManagerConnection(boolean useProxy) throws NoSuchObjectException, RemoteException

This method establishes a connection with the Event Manager on the same host the Agent is currently executing on.

Parameters:
useProxy - This argument specifies if the Agent should create a direct connection to the Event Manager or utilize a proxy. The proxy establishes a persistent connection to the Event Manager. So using a proxy shields the Agent from Event Manager failures. A value of true for this argument indicates that the Agent will use a proxy. A value of false specifies that the Agent will communicate directly with the Event Manager.
Throws: NoSuchObjectException
If the Event Manager could not be located.
Throws: RemoteException
If a network error occurs when trying to contact the Event Manager
 o makeEventManagerConnection

 public void makeEventManagerConnection(String url,

                                        boolean useProxy) throws NoSuchObjectException, RemoteException

This method establishes a connection to a potentially remote Event Manager.

Parameters:
url - The Event Manager's RMI URL. This URL can be constructed by calling the static EventManagerURL method, passing it the host on which the Event Manager is running.

useProxy - This argument specifies if the Agent should create a direct connection to the Event Manager or utilize a proxy. The proxy establishes a persistent connection to the Event Manager. So using a proxy shields the Agent from Event Manager failures.
Throws: NoSuchObjectException
The Event Manager could not be located.
Throws: RemoteException
if a network error occurs when trying to contact the Event Manager
 o registerEvents

 public void registerEvents(Class eventClass[]) throws RemoteException, IOException, ServerUnavailableException, SecurityException

Register interest in receiving specified events.

The calling sequence for registering for specific events looks like:

     makeEventHandler(false);
     makeEventManagerConnection(false);
     Class events[] = {MyEvent1.class, MyEvent2.class};
     registerEvents(events);
 

Any events received by the Agent are handled by the handleEvent method.

Parameters:
eventClass - An array of Class objects describing the events that an object is interested in receiving.
Throws: RemoteException
If the Event Manager cannot be contacted.
Throws: ServerUnavailableException
If the Event Manager is down or suspended.
Throws: SecurityException
If the Event.Register permission is denied for the default user.
 o registerAllEvents

 public void registerAllEvents() throws RemoteException, IOException, ServerUnavailableException, SecurityException

Register interest in receiving all events posted to this EventManager.

The calling sequence for registering for all events looks like:

     makeEventHandler(false);
     makeEventManagerConnection(false);
     registerAllEvents();
 

Any events received by the Agent are handled by the handleEvent method.

Throws: RemoteException
If an error occurrs setting up network connections.
Throws: ServerUnavailableException
If the Event Manager is down or suspended.
Throws: SecurityException
If the Event.Register permission or the Event.RegisterAll permission is denied for the default user.
 o unregisterEvents

 public void unregisterEvents(Class eventClass[]) throws RemoteException, IOException, ServerUnavailableException, EventManagerException

Remove registration for specified events.

Parameters:
eventClass - An array of Class objects describing the events that an object is no longer interested in receiving.
Throws: ServerUnavailableException
If the Event Manager is down or suspended.
Throws: RemoteException
If an error occurrs setting up network connections.
Throws: EventManagerException
If the Agent is not registered for one or more of the specified exceptions.
 o unregisterAllEvents

 public void unregisterAllEvents()

Remove registration for all events. This method is often called by finalizers, so it does not propagate any errors.

 o postEvent

 public void postEvent(EventType event) throws RemoteException, IOException, EventException, ServerUnavailableException, SecurityException

Send an event to all objects registered to receive it.

The calling sequence for sending an event looks like:

     makeEventManagerConnection(false);
     EventType myEvent = new MyEvent();
     postEvent(myEvent);
 

Parameters:
event - The event to post.
Throws: RemoteException
If an error occurrs setting up network connections.
Throws: EventException
If an error occurs posting the event.
Throws: ServerUnavailableException
If the Event Manager is down or suspended.
Throws: SecurityException
If the Event.Post resource permission is denied for the default user.
 o addAgentListener

 public final void addAgentListener(RemoteAgentListener listener,

                                    String listenerName,

                                    int mask)

Adds a new remote agent listener to the list of objects that wish to receive agent notification events. If the listener is already in the list, the event types of interest is added to the set of event types that are already registered.

Parameters:
listener - Remote reference to the listener. If this parameter is null, the listenerName argument must be a valid URL.
listenerName - URL of the listener. If listner is null, this URL will be used to fetch a remote reference to the listener. Otherwise, may be null.
 o addAgentListener

 public final void addAgentListener(RemoteAgentListener listener,

                                    String listenerName,

                                    int mask,

                                    boolean local)

Adds a new remote agent listener to the list of objects that wish to receive agent notification events. If the listener is already in the list, the event types of interest is added to the set of event types that are already registered.

Parameters:
listener - Remote reference to the listener. If this parameter is null, the listenerName argument must be a valid URL.
listenerName - URL of the listener. If listner is null, this URL will be used to fetch a remote reference to the listener. Otherwise, may be null.
mask - A bitmask representing the types of notification events that are of interest to the listener.
clonable - If false, this listener should not be copied to any new agents that this agent may launch.
 o removeAgentListener

 public final void removeAgentListener(RemoteAgentListener listener,

                                       String listenerName,

                                       int mask)

Removes the specified remote agent listener. The listener may be referenced by the remote reference or the URL, or both. The mask of requested event types is removed from the bitmask. if the resulting event mask indicates that no more event types are to be sent, the listener is removed from the list of listeners.

Parameters:
listener - Remote reference to the listener. If this parameter is null, the listenerName argument must be a valid URL.
listenerName - URL of the listener. If listner is null, this URL will be used to fetch a remote reference to the listener. Otherwise, may be null.
 o notifyListeners

 public final void notifyListeners(AgentNotificationEvent event)

Sends the specified notification event to all of the currently registered listeners. The event is sent to each listener sequentially, although the order in which listeners receive the event is unspecified.

Parameters:
event - Event to send
 o sendMessage

 public void sendMessage(String facility,

                         int level,

                         String message)

Sends a message to the agent debugger or any other listener that is registered to receive AgentMessageNotificationEvents.

Parameters:
facility - An arbitrary string which represents the general category or purpose of the message.
level - An arbitrary integer which represents the relative priority or severity of the message
message - A string containing the content of the message. Embedded newlines are supported.


All Packages  Class Hierarchy  This Package  Previous  Next  Index