|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.iids.aos.agent.proxy.AgentProxy<T>
T - public class AgentProxy<T>
Proxy for implementing a class on top of agent messages. Can be used to delegate various services implementations by (remote) agents. Functionally the same as the SystemServiceProxy. This class uses a dynamic proxy to dynamically generate an object the implements the interface for the class.
Note: Only in parameters are supported. In/out and out parameters are not supported.
To bind to a service use thebind(java.lang.Class, org.iids.aos.systemservices.communicator.structs.AgentHandle, org.iids.aos.systemservices.communicator.structs.AgentHandle, boolean) method. Examples can be found
in src/examples/proxy.
| Constructor Summary | |
|---|---|
|
AgentProxy()
|
protected |
AgentProxy(AgentHandle local,
AgentHandle remote)
|
protected |
AgentProxy(AgentHandle local,
AgentHandle remote,
boolean assignNewHandle)
|
| Method Summary | ||
|---|---|---|
static
|
bind(java.lang.Class<T> itfClass,
AgentHandle local,
AgentHandle remote)
The same as bind(itfClass, local, remote, false) |
|
static
|
bind(java.lang.Class<T> itfClass,
AgentHandle local,
AgentHandle remote,
boolean assignNewLocal)
Bind to a remote agent implementing the interface itfClass. |
|
void |
close()
|
|
protected void |
finalize()
|
|
static
|
getAgentProxy(T proxy)
Obtain the underlying AgentProxy of an object that is created through bind(java.lang.Class. |
|
AgentHandle |
getLocalHandle()
Get the handle that is used to connect to the agent service. |
|
AgentHandle |
getRemoteHandle()
Get the handle of the service this proxy is connected to. |
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Implementation of InvocationHandler interface. |
|
boolean |
isRunning()
See if the proxy is still active. |
|
void |
readExternal(java.io.ObjectInput in)
|
|
void |
setCacheableMethod(java.lang.String methodName)
This method is similar to setCacheableMethod(methodName, false) |
|
void |
setCacheableMethod(java.lang.String methodName,
boolean prefetch)
Indicate that the results of a method can be cached. |
|
void |
setCachedResult(java.lang.String mName,
java.lang.Object result)
|
|
protected void |
setItfClass(java.lang.Class<?> clazz)
|
|
protected void |
setLocalHandle(AgentHandle local)
|
|
protected void |
setLocalHandle(AgentHandle local,
boolean assignNewHandle)
|
|
void |
silentClose()
|
|
java.lang.String |
toString()
|
|
void |
waitForClose()
Wait for someone to close the proxy. |
|
void |
writeExternal(java.io.ObjectOutput out)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AgentProxy()
protected AgentProxy(AgentHandle local,
AgentHandle remote)
protected AgentProxy(AgentHandle local,
AgentHandle remote,
boolean assignNewHandle)
| Method Detail |
|---|
protected void setLocalHandle(AgentHandle local)
protected void setLocalHandle(AgentHandle local,
boolean assignNewHandle)
public AgentHandle getRemoteHandle()
public AgentHandle getLocalHandle()
public void close()
public void silentClose()
public boolean isRunning()
true if the proxy is not closed yet, otherwise this
method return false.public void waitForClose()
public java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
invoke in interface java.lang.reflect.InvocationHandlerjava.lang.Throwable - If the method invocation fails for some reason,
the exception of this method is thrown on by this method.
public static <T> T bind(java.lang.Class<T> itfClass,
AgentHandle local,
AgentHandle remote,
boolean assignNewLocal)
T - The typeitfClass - The interface for the proxy to bind to.local - The local agent handle to use for communicationremote - The remote handle on which the service runs.assignNewLocal - If true then a local handle is automatically
derived from the local handle, and cleaned up
after the proxy exits. This is convenient for
the times when you don't want to keep track of
all the proxied objects. Once the garbage collector
cleans up a proxy, the handle is removed.
public static <T> T bind(java.lang.Class<T> itfClass,
AgentHandle local,
AgentHandle remote)
bind(itfClass, local, remote, false)
T - The type of class to bind to.itfClass - The interface type this proxy will bind to.local - The local handle used to send invocations.remote - The remote handle to send invocations to.
protected void setItfClass(java.lang.Class<?> clazz)
public static <T> AgentProxy<T> getAgentProxy(T proxy)
bind(java.lang.Class, org.iids.aos.systemservices.communicator.structs.AgentHandle, org.iids.aos.systemservices.communicator.structs.AgentHandle, boolean) . This may be useful to observe
some properties of the proxy, such as the local handle of the proxy.
T - proxy - The proxied object to inspect.
public void setCacheableMethod(java.lang.String methodName,
boolean prefetch)
throws java.lang.Throwable
methodName - The name of the method to cacheprefetch - If true then the result value is
immediately obtained from the server.
java.lang.Throwablepublic void setCacheableMethod(java.lang.String methodName)
setCacheableMethod(methodName, false)
methodName -
public void setCachedResult(java.lang.String mName,
java.lang.Object result)
protected void finalize()
finalize in class java.lang.Object
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOException
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException
readExternal in interface java.io.Externalizablejava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||