com.jproxy.proxy.callback
Class HttpCallbackClient

java.lang.Object
  |
  +--com.jproxy.proxy.util.ThreadSupport
        |
        +--com.jproxy.proxy.callback.HttpCallbackClient
All Implemented Interfaces:
CallbackClient, java.lang.Runnable, java.io.Serializable

public class HttpCallbackClient
extends ThreadSupport
implements java.io.Serializable, CallbackClient

The HttpCallbackClient class. The class implemnts client-side Tunnel server for callback support. It uses CallbackServer to get asynchronous requests. Then it delegates requests to instance of Invocator that perform a requests. The class also has methods to control thread that handles polling. The class has several static helper-methods.

See Also:
HttpCallbackClient, CallbackServer, Invocator, com.jproxy.server.ClassFileServer, Serialized Form

Field Summary
static java.lang.String CLASSSERVER_CLASSPATH
          The classpath for dynamic class downloading for client-side HttpServer
static int DEFAULT_POLLING_TIME
          If CALLBACK_POLLING_TIME is not set then DEFAULT_POLLING_TIME is used
static int DEFAULT_PORT
          If CALLBACK_PORT is not set then DEFAULT_PORT is used
 
Constructor Summary
HttpCallbackClient(java.lang.String _serverUrlStr, java.util.Hashtable env, CallbackServer _server)
          Contructs instance.
 
Method Summary
 void body()
          ThreadSupport implementation Performs popAll on the CallbackServer object every pollingTime.
 void call(java.lang.Object arg)
          Passes request for method call to Invocator
static CallbackClient createCallbackClient(java.lang.String serverUrlStr, java.util.Hashtable env)
           
 java.lang.Object createCallbackProxy(java.lang.String methodName, java.lang.Object listener)
          Creates callback proxy
static CallbackServer createCallbackServer(java.lang.String serverUrlStr, java.util.Hashtable env)
          The static method-helper that creates instance of HttpCallbackServer on Tunneling server.
static void destroyCallbackClient(java.lang.String serverUrlStr)
           
 CallbackServer getCallbackServer()
          Returns proxy to CallbackServer.
 Invocator getInvocator()
          Returns Invocator.
 void start()
          Starts the thread that performs polling of CallbackServer located on Tunneling server.
 void stop()
          Stops the thread that performs polling of CallbackServer remote object.
 
Methods inherited from class com.jproxy.proxy.util.ThreadSupport
isRunning, isStopping, run
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jproxy.proxy.callback.CallbackClient
isRunning
 

Field Detail

CLASSSERVER_CLASSPATH

public static final java.lang.String CLASSSERVER_CLASSPATH
The classpath for dynamic class downloading for client-side HttpServer

DEFAULT_PORT

public static final int DEFAULT_PORT
If CALLBACK_PORT is not set then DEFAULT_PORT is used

DEFAULT_POLLING_TIME

public static final int DEFAULT_POLLING_TIME
If CALLBACK_POLLING_TIME is not set then DEFAULT_POLLING_TIME is used
Constructor Detail

HttpCallbackClient

public HttpCallbackClient(java.lang.String _serverUrlStr,
                          java.util.Hashtable env,
                          CallbackServer _server)
                   throws TunnelException
Contructs instance. During construction instance of client-side Invocator is created.
Parameters:
env - the environment hashtable
server - the CallbackServer remote object
Method Detail

createCallbackProxy

public java.lang.Object createCallbackProxy(java.lang.String methodName,
                                            java.lang.Object listener)
                                     throws TunnelException
Creates callback proxy
Specified by:
createCallbackProxy in interface CallbackClient
Parameters:
methodName - method for which proxy has to be created
listener - the listener for the callback

getCallbackServer

public CallbackServer getCallbackServer()
Returns proxy to CallbackServer.
Specified by:
getCallbackServer in interface CallbackClient

start

public void start()
Starts the thread that performs polling of CallbackServer located on Tunneling server.
Specified by:
start in interface CallbackClient
Overrides:
start in class ThreadSupport

stop

public void stop()
Stops the thread that performs polling of CallbackServer remote object. It just sets stop flag and returns. You have to check isRunning flag to be sure if thread is stopped.
Specified by:
stop in interface CallbackClient
Overrides:
stop in class ThreadSupport

getInvocator

public Invocator getInvocator()
Returns Invocator. The instance of Invocator is used to perform requests.
Specified by:
getInvocator in interface CallbackClient

body

public void body()
          throws java.lang.InterruptedException
ThreadSupport implementation Performs popAll on the CallbackServer object every pollingTime.

call

public void call(java.lang.Object arg)
Passes request for method call to Invocator
Specified by:
call in interface CallbackClient
Parameters:
arg - the argument passed to Invocator

createCallbackClient

public static CallbackClient createCallbackClient(java.lang.String serverUrlStr,
                                                  java.util.Hashtable env)
                                           throws java.lang.Throwable

createCallbackServer

public static CallbackServer createCallbackServer(java.lang.String serverUrlStr,
                                                  java.util.Hashtable env)
                                           throws java.lang.Throwable
The static method-helper that creates instance of HttpCallbackServer on Tunneling server.
Parameters:
serverUrlStr - URL String of Tunneling server where object must be created

destroyCallbackClient

public static void destroyCallbackClient(java.lang.String serverUrlStr)
                                  throws java.lang.Exception


Copyright © JProxy LLC. All Rights Reserved.