metaglue.AgentPrimer
Class EHAInvocationHandler
java.lang.Object
|
+--metaglue.AgentPrimer.EHAInvocationHandler
- All Implemented Interfaces:
- EHAWrapper, InvocationHandler, Serializable
- public class EHAInvocationHandler
- extends Object
- implements Serializable, InvocationHandler, EHAWrapper
An invocation handler which can forward method calls to a remote
agent. This also handles EHAWrapper methods so that we can update
the agent being processed in real time. RemoteExceptions are
processed and the agent is restarted if necessary.
Subclasses of AgentAgent may want to carefully tailor the
behavior for their proxies. One way to do that is to override the
isPermitted() or invoke() methods in a subclass of
EHAInvocationHandler, and specify the subclass in a
getProxyHandlerClass method() in an appropriate subclass of
AgentAgent.
Created: Tue Aug 28 12:20:49 2001
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
callerAgent
protected transient MetagluePrimitives callerAgent
DEBUG
protected boolean DEBUG
- Turn on debugging for every EHA call.
EHAInvocationHandler
public EHAInvocationHandler(MetagluePrimitives ap,
AgentID aid,
Catalog c)
setDebugging
public void setDebugging(boolean debug)
- Turn debugging on or off.
getAgent
public Agent getAgent()
- Specified by:
getAgent
in interface EHAWrapper
setAgent
public void setAgent(Agent a)
- Specified by:
setAgent
in interface EHAWrapper
getAgtID
public AgentID getAgtID()
- Specified by:
getAgtID
in interface EHAWrapper
setAgtID
public void setAgtID(AgentID aid)
- Specified by:
setAgtID
in interface EHAWrapper
invoke
public Object invoke(Object proxy,
Method method,
Object[] args)
throws Throwable
- Sends all method calls either to this invocation handler (for the
EHAWrapper calls) or to the wrapped agent. Remote exceptions are
unwrapped and handled locally.
- Specified by:
invoke
in interface InvocationHandler
- Parameters:
proxy
- the proxy object forwarding the method.method
- the method being called.args
- the set of arguments to pass to the method.- Returns:
- the result of the invocation.
- See Also:
isPermitted(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
instantiate
protected void instantiate(Agent a)
- Reset the wrapped agent to the given one.
- Parameters:
a
- an Agent
that will be the destination for
forwarded method calls.
isPermitted
protected boolean isPermitted(Object proxy,
Method method,
Object[] args)
- Says whether or not it is permitted to call the given method with
the given arguments. This implementation always returns true;
subclasses can override this method to provide more complex
behavior.
- Parameters:
proxy
- the proxy obejct forwarding the method.method
- the method being called.args
- the array of arguments being passed to the method.- Returns:
- whether it is permissible to call the method
callAgentMethod
protected Object callAgentMethod(Object proxy,
Method method,
Object[] args)
throws Throwable
resetErrorCount
protected void resetErrorCount()
handleRemoteException
protected boolean handleRemoteException(RemoteException re,
Method m)