|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
gnu.cajo.utils.extra.ItemProxy
public final class ItemProxy
This class is used to receive server item callbacks by a firewalled
client. A client whose firewall settings prohibit incoming socket
connections is a common problem. To solve this, a client would request
a remote reference to a ClientProxy
from 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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
ItemProxy(RemoteInvoke item,
java.lang.Object client)
The constructor links the remote object to the firewalled client. |
Method Summary | |
---|---|
void |
run()
The processing thread, and the crux of this technique. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ItemProxy(RemoteInvoke item, java.lang.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 callbacksclient
- The firewalled local object that wishes to receive
asynchronous callbacksMethod Detail |
---|
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.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |