public final class ItemProxy extends Thread
ClientProxyfrom the server. It would then use an ItemProxy to link the remote item to the local client item. This class is a special purpose thread, which will make an outgoing call to the remote ClientProxy. This outgoing call will be blocked until the server has some data for it, at which point it will wake this thread, causing it to return with the callback method to be invoked on the local client object, and the data to be provided it. This object will call its local client, and return the resulting data, or exception to the server. This will result in this thread being put back to sleep again, until there is another callback. This lets local client objects be designed without regard for whether they will be behind a firewall or not. This technique enables asynchronous server callbacks using the client's outgoing socket, thereby solving the firewall issue. The development of this process was originally championed by project member Fredrik Larsen.
Normally, a client would not invoke a method on the remote reference it receives to the server's ClientProxy object. However, if the client wishes to forcibly terminate its connection with the server, it can invoke a no-arg cutOff method on the reference. (See the note below)Note: The server could cut its connection to the client at any time, either intentionally by invoking its cutOff method, or worse, by a server crash. If the client wishes to be notified of this event, it must define a null argument method called cutOff. This will be invoked by the ItemProxy, in that event the cutOff method must accept a single argument, of type Exception, it will describe the reason behind the disconnection. A practical usage example is available online.
|Constructor and Description|
The constructor links the remote object to the firewalled client.
|Modifier and Type||Method and Description|
The processing thread, and the crux of this technique.
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public ItemProxy(RemoteInvoke item, Object client)
ClientProxy, blocking until there is a callback method to be invoked.
item- A remote reference to a ClientProxy, from which the remote object will invoke asynchronous callbacks
client- The firewalled local object that wishes to receive asynchronous callbacks
public void run()
ClientProxy, to enter a blocking wait. The ClientProxy will wake the thread, providing it an object array containing two things; the name of the method to be called on the local object, and the data to be provided it. This thread will invoke the local object's method, and return the result, or exception, to the ClientProxy, beginning the cycle again.
Copyright © 2016. All Rights Reserved.