|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.iids.aos.agent.proxy.AgentProxyHandler
public class AgentProxyHandler
AgentProxyHandler implementation for the server side of an AgentProxy.
The idea is that a service agent registers itself with a proxy handler which allows agents to connect to the service using anAgentProxy
so the agents can invoke methods on the server.
TODO be more specific about the interface the service implements.
| Nested Class Summary | |
|---|---|
static class |
AgentProxyHandler.Mode
|
| Field Summary | |
|---|---|
protected java.lang.Object |
subject
|
| Constructor Summary | |
|---|---|
AgentProxyHandler(java.lang.Object subject,
AgentHandle local)
Shortcut for AgentProxyHandler(subject, local, remote, false)
|
|
AgentProxyHandler(java.lang.Object subject,
AgentHandle local,
AgentHandle remote)
Shortcut for AgentProxyHandler(subject, local, remote, false)
|
|
AgentProxyHandler(java.lang.Object subject,
AgentHandle local,
AgentHandle remote,
boolean assignNewHandle)
Create new proxy handler. |
|
| Method Summary | |
|---|---|
void |
close()
Close the handler that receives method invocation requests. |
protected void |
finalize()
|
static java.lang.reflect.Method |
findMethod(java.lang.Class<?> serviceClass,
java.lang.String methName,
java.lang.Object... args)
Helper method that finds a method from a corresponding class while paying respect to the autoboxed types. |
AgentHandle |
getAgentHandle()
Obtain the handle that is used to receive messages. |
static java.lang.Object |
getHandler(AgentHandle ah)
|
void |
handleRequest(AgentProxyMessage msg)
Handles request in foreground. |
protected java.lang.Object |
invokeRequest(java.lang.String methName,
java.lang.Object[] args)
|
boolean |
isClosed()
Test if the proxy handler is still running. |
void |
run(AgentProxyHandler.Mode mode)
This method runs the receive/reply loop of the server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.Object subject
| Constructor Detail |
|---|
public AgentProxyHandler(java.lang.Object subject,
AgentHandle local,
AgentHandle remote,
boolean assignNewHandle)
subject - The object which the method invocations
are executed on.local - A handle which is used to recieve messages.remote - Optional. If this is not-null, then incoming
method invocations are only accepted if they
are sent by this handle. Otherwise, invocations
are accepted from all handles.assignNewHandle - If this is true then the handle
local is used to create a new handle
which is used for receiving messages. This
handle is automatically removed once the
proxy handler is closed. If this is
false then the handle local is
used to receive messages.
public AgentProxyHandler(java.lang.Object subject,
AgentHandle local,
AgentHandle remote)
AgentProxyHandler(subject, local, remote, false)
subject - The Object to publish over proxy.local - The local handle to receive proxy invocations from.remote - The remote handle to receive messages from. If this
is null then messages from all sources are
accepted.
public AgentProxyHandler(java.lang.Object subject,
AgentHandle local)
AgentProxyHandler(subject, local, remote, false)
subject - The Object to publish over proxy.local - The local handle to receive proxy invocations from.| Method Detail |
|---|
public AgentHandle getAgentHandle()
public boolean isClosed()
true if the proxy handler is closed.public void close()
public void run(AgentProxyHandler.Mode mode)
handleRequest(org.iids.aos.agent.proxy.AgentProxyMessage) when needed. The thread can do other
work the rest of the time.
mode - The mode to run in. Foreground mode means that this method
blocks until the proxy handle was finished for some reason.
Background mode means this method returns directly and a
dedicated thread is responsible for receiving and
processing the proxy requests.
public static java.lang.reflect.Method findMethod(java.lang.Class<?> serviceClass,
java.lang.String methName,
java.lang.Object... args)
throws java.lang.NoSuchMethodException
Integer) when the class itself requires int.
Argument type mismatch can happen because invocation parameters must be
of type Serializable, which a plain int is not.
serviceClass - The class of the object to invoke the method on.methName - Name of method to invoke.args - The arguments for method methName
args.
java.lang.NoSuchMethodException
protected java.lang.Object invokeRequest(java.lang.String methName,
java.lang.Object[] args)
throws java.lang.Exception
java.lang.Exceptionpublic void handleRequest(AgentProxyMessage msg)
msg - The AgentProxyMessage to process.protected void finalize()
finalize in class java.lang.Objectpublic static java.lang.Object getHandler(AgentHandle ah)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||