org.glassfish.cafe.api
Class Agent<T>

java.lang.Object
  extended by org.glassfish.cafe.api.Agent<T>
Type Parameters:
T - The type of application data in this Agent.
All Implemented Interfaces:
Serializable

public abstract class Agent<T>
extends Object
implements Serializable

Agent objects encapsulate application logic related to a Communication artifact like Communication, Participant etc. An instance of this class will be attached to the Communication artifacts by the application. Thus it is available during any kind of events pertaining to that artifact.

Author:
binod
See Also:
Serialized Form

Constructor Summary
Agent()
           
 
Method Summary
 T get()
          Return the application specific data.
 CommunicationContext<?,?,?> getCommunicationContext()
          Retrieve the CommunicationContext object in the Application Link.
 void invoke()
          Invoke the the agent to perform application specific tasks.
 void invoke(CommunicationEvent.Type cevent)
          Invoke the the agent to perform application specific tasks.
 void invoke(ParticipantEvent.Type pvent)
          Invoke the the agent to perform application specific tasks.
 boolean isCallbackEnabled()
          Gets the callback enabled flag.
 void set(T applicationData)
          Set application specific data.
 void setCallbackEnabled(boolean callbackEnabled)
          Sets the callback enabled flag.
 void setCommunicationContext(CommunicationContext<?,?,?> context)
          Set the CommunicationContext object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Agent

public Agent()
Method Detail

isCallbackEnabled

public boolean isCallbackEnabled()
Gets the callback enabled flag.

Returns:
true if container has to invoke this agent.

setCallbackEnabled

public void setCallbackEnabled(boolean callbackEnabled)
Sets the callback enabled flag.

Parameters:
callbackEnabled - true of container has to callback.

setCommunicationContext

public final void setCommunicationContext(CommunicationContext<?,?,?> context)
Set the CommunicationContext object. Application is expected to make a clone of the CommunicationContext for invoking this method.

Parameters:
context - An instance of CommunicationContext object.

getCommunicationContext

public final CommunicationContext<?,?,?> getCommunicationContext()
Retrieve the CommunicationContext object in the Application Link.

Returns:
Return an instance of CommunicationContext.

invoke

public void invoke()
Invoke the the agent to perform application specific tasks. Typically called by the application itself when the agent is not a call back agent.


invoke

public void invoke(CommunicationEvent.Type cevent)
Invoke the the agent to perform application specific tasks. The event gives an indication to the application as to what has caused the invocation. Used for call back agents to communicate the event type.


invoke

public void invoke(ParticipantEvent.Type pvent)
Invoke the the agent to perform application specific tasks. The event gives an indication to the application as to what has caused the invocation.


set

public final void set(T applicationData)
Set application specific data. Most of the time, application would need to save state in the agent.

Parameters:
applicationData - An Application Data object.

get

public final T get()
Return the application specific data.

Returns:
The saved application specific data.


Copyright © 2010. All Rights Reserved.