|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.almende.eve.agent.Agent
public abstract class Agent
Constructor Summary | |
---|---|
Agent()
|
Method Summary | ||
---|---|---|
void |
clear()
Deprecated. |
|
void |
create()
This method is called once in the life time of an agent, at the moment the agent is being created by the AgentFactory. |
|
|
createAgentProxy(String url,
Class<T> agentInterface)
Create a proxy to an other agent. |
|
void |
delete()
This method is called once in the life time of an agent, at the moment the agent is being deleted by the AgentFactory. |
|
void |
destroy()
This method can is called when the agent is uninitialized, and is needed finalize the state of the agent. |
|
protected void |
finalize()
|
|
AgentFactory |
getAgentFactory()
Get the agent factory. |
|
State |
getContext()
Deprecated. Use getState() instead |
|
abstract String |
getDescription()
Retrieve a description of the agents functionality |
|
String |
getId()
Get the Id of this agent |
|
List<Object> |
getMethods(Boolean asJSON)
Get all available methods of this agent |
|
Scheduler |
getScheduler()
Get a scheduler to schedule tasks for the agent to be executed later on. |
|
State |
getState()
Get the agents state. |
|
String |
getType()
Retrieve the type name of this agent, its class |
|
List<String> |
getUrls()
Get the urls of this agent, for example "http://mysite.com/agents/key". |
|
abstract String |
getVersion()
Retrieve the agents version number |
|
void |
init()
This method is called directly after the agent and its state is initiated. |
|
String |
onSubscribe(String event,
String callbackUrl,
String callbackMethod)
Let an other agent subscribe to one of this agents events When the event is triggered, a callback will be send to the provided callbackUrl. |
|
void |
onTrigger(String url,
String method,
com.fasterxml.jackson.databind.node.ObjectNode params)
Asynchronously trigger an event. |
|
void |
onUnsubscribe(String subscriptionId,
String event,
String callbackUrl,
String callbackMethod)
Let an other agent unsubscribe from one of this agents events - If subscriptionId is provided, the subscription with this id will be deleted - If the parameter callbackUrl and optionally event and/or callbackMethod, all subscriptions with matching parameters will be deleted. |
|
void |
send(String url,
String method)
Send a request to an agent in JSON-RPC format |
|
|
send(String url,
String method,
Class<T> type)
Send a request to an agent in JSON-RPC format |
|
void |
send(String url,
String method,
Object params)
Send a request to an agent in JSON-RPC format |
|
|
send(String url,
String method,
Object params,
Class<T> type)
Send a request to an agent in JSON-RPC format |
|
|
sendAsync(String url,
JSONRequest request,
AsyncCallback<T> callback,
Class<T> type)
Send an asynchronous JSON-RPC request to an agent sendAsync is not supported on Google App Engine |
|
|
sendAsync(String url,
String method,
com.fasterxml.jackson.databind.node.ObjectNode params,
AsyncCallback<T> callback,
Class<T> type)
Send an asynchronous JSON-RPC request to an agent sendAsync is not supported on Google App Engine |
|
void |
setAgentFactory(AgentFactory agentFactory)
|
|
void |
setState(State state)
Set the state of the agent instance. |
|
protected String |
subscribe(String url,
String event,
String callbackMethod)
Subscribe to an other agents event |
|
String |
toString()
|
|
void |
trigger(String event,
Object params)
Trigger an event |
|
protected void |
unsubscribe(String url,
String subscriptionId)
Unsubscribe from an other agents event |
|
protected void |
unsubscribe(String url,
String event,
String callbackMethod)
Unsubscribe from an other agents event |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Agent()
Method Detail |
---|
public abstract String getDescription()
AgentInterface
getDescription
in interface AgentInterface
public abstract String getVersion()
AgentInterface
getVersion
in interface AgentInterface
public void create()
public void delete()
public void init()
public void destroy()
protected void finalize()
finalize
in class Object
public final void setState(State state)
state
- public final State getState()
state
- @Deprecated public final State getContext()
state
- public final Scheduler getScheduler()
state
- public final void setAgentFactory(AgentFactory agentFactory)
public final AgentFactory getAgentFactory()
@Deprecated public void clear() throws Exception
Exception
public final String onSubscribe(String event, String callbackUrl, String callbackMethod)
onSubscribe
in interface AgentInterface
event
- callbackUrl
- callbackMethod
-
public final void onUnsubscribe(String subscriptionId, String event, String callbackUrl, String callbackMethod)
onUnsubscribe
in interface AgentInterface
subscriptionId
- event
- callbackUrl
- callbackMethod
- public final void onTrigger(String url, String method, com.fasterxml.jackson.databind.node.ObjectNode params) throws Exception
url
- method
- params
-
Exception
protected String subscribe(String url, String event, String callbackMethod) throws Exception
url
- event
- callbackMethod
-
Exception
protected void unsubscribe(String url, String subscriptionId) throws Exception
url
- subscriptionId
-
Exception
protected void unsubscribe(String url, String event, String callbackMethod) throws Exception
url
- event
- callbackMethod
-
Exception
public final void trigger(String event, Object params) throws Exception
event
- params
- An ObjectNode, Map, or POJO
Exception
JSONRPCException
public final List<Object> getMethods(Boolean asJSON)
getMethods
in interface AgentInterface
asJSON
- If true, result is in a JSON format easily parsable by
a machine. If false (default), the returned list
contains human readable strings.
public final <T> T send(String url, String method, Object params, Class<T> type) throws Exception
url
- The url of the agentmethod
- The name of the methodparams
- A Object containing the parameter values of the method.
This can be an ObjectNode, Map, or POJO.type
- The return type of the method
Exception
public final <T> T send(String url, String method, Class<T> type) throws Exception
url
- The url of the agentmethod
- The name of the method
Exception
public final void send(String url, String method, Object params) throws Exception
url
- The url of the agentmethod
- The name of the methodparams
- A Object containing the parameter values of the method.
This can be an ObjectNode, Map, or POJO.
Exception
public final <T> T createAgentProxy(String url, Class<T> agentInterface)
url
- agentInterface
- A Java Interface, extending AgentInterface
public final void send(String url, String method) throws Exception
url
- The url of the agentmethod
- The name of the method
Exception
public final <T> void sendAsync(String url, String method, com.fasterxml.jackson.databind.node.ObjectNode params, AsyncCallback<T> callback, Class<T> type) throws Exception
url
- The url of the agent to be calledmethod
- The name of the methodparams
- A JSONObject containing the parameter
values of the methodcallback
- An AsyncCallback of which the onSuccess or
onFailure method will be executed on callback.type
- The type of result coming from the callback.
Exception
JSONException
public final <T> void sendAsync(String url, JSONRequest request, AsyncCallback<T> callback, Class<T> type) throws Exception
url
- The url of the agent to be calledrequest
- JSON-RPC request containing method and paramscallback
- An AsyncCallback of which the onSuccess or
onFailure method will be executed on callback.type
- The type of result coming from the callback.
Exception
JSONException
public final List<String> getUrls()
getUrls
in interface AgentInterface
public final String getId()
getId
in interface AgentInterface
public final String getType()
getType
in interface AgentInterface
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |