|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.cajo.utils.extra.ClientProxy
public final class ClientProxy
This class is used to send server item callbacks to a firewalled client.
A client whose firewall settings prohibit incoming socket connections is a
common problem. This class is called ClientProxy, as it is a stand-in
representation of a remote reference to a client, behind a firewall. This
allows server objects to be designed without regard to client firewall
issues. An intermediary process would give the server item a real remote
reference to the client object when there is no client firewall, or a
ClientProxy when there is. The client links the remote reference to this
ClientProxy, to the locally firewalled client, using an ItemProxy
object. The server item invokes methods on this client proxy
which result in an immediate callback invocation on the client.
Instances of ClientProxy can in turn be passed into a
TransparentItemProxy
via its get method,
to a address the firewalled client by interface. (either synchronously
or asynchronously)
Note: this paradigm is not threadsafe! It is expected that callbacks to the remote client will not be invoked reentrantly. Correspondingly, a unique instance of this object must be given to each remote client object. A practical usage example is available online.
Field Summary | |
---|---|
Remote |
remoteThis
This is the remoted reference to the server's ClientProxy. |
int |
timeout
This is the longest value, in milliseconds, that the server will wait for a client invocation to execute before it aborts it. |
Constructor Summary | |
---|---|
ClientProxy()
A server creates this object, then provides the remote reference member remoteThis to the client. |
Method Summary | |
---|---|
void |
cutOff()
This method abruptly terminates the ClientProxy link to the server. |
java.lang.Object |
invoke(java.lang.String method,
java.lang.Object args)
This method serves two fundamentally different, but symmetrical purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int timeout
public final Remote remoteThis
ItemProxy
constructor, to create a firewall traversing asynchronous callback link.
In order to work, logically, it can only be passed to one remote client.
Constructor Detail |
---|
public ClientProxy() throws java.rmi.RemoteException
ItemProxy
class completes the second half.
java.rmi.RemoteException
- If the remote reference creation fails.Method Detail |
---|
public void cutOff() throws java.rmi.NoSuchObjectException
java.rmi.NoSuchObjectException
- Should this method ever be called more
than once, on the same object.public java.lang.Object invoke(java.lang.String method, java.lang.Object args) throws java.lang.Exception
ItemProxy
calls this
method to have its calling thread blocked until the server item needs
to make an asynchronous callback. Secondly, the server item will also
invoke this method, and will have its thread blocked, until the
resulting data, or exception, is returned from the firewalled client,
via its ItemProxy.
invoke
in interface Invoke
method
- The name of the method on the firewalled remote client
to be invoked asynchronously.args
- The data to be provided the method of the callback method,
or data resulting from the client callback.
java.lang.InterruptedException
- If the client is not listening, or if
the callback timeout has expired.
java.rmi.RemoteException
- For any network related failures.
java.lang.Exception
- For any client specific reasons.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |