org.bsf.remoting.http
Class HttpSessionClient

java.lang.Object
  |
  +--org.bsf.remoting.http.HttpSessionClient

public class HttpSessionClient
extends java.lang.Object

This class handle the http protocole for the application server communication. Client classes can make http calls in parallel threads. The number of thread is limited by the field maxThreadCount. The parameters of the communication (port, host, ...)can be set by the ressource BsfModules.xml.


Field Summary
protected static HttpSessionClient _instance
           
private static java.lang.String AUTHENTICATED_SERVLET
           
private  java.lang.String context
          The context used at deployment time.
private  int curUsedThread
          The number of thread that are currently making a call
private static java.lang.String DEFAULT_PROTOCOL
          Default call method is http
private static int DEFAULT_THREAD_COUNT
          Default Server File
private  java.lang.String host
          Where is the server
private static org.apache.commons.logging.Log log
           
private  java.lang.String login
          Used for authentification
private  int maxThreadCount
          The number of parallel thread used to perform the http call.
private static java.lang.String MIME_TYPE
          BSF default mime type
private  java.lang.String pass
          password used for basic authentification
private  int port
          Http Port used
private  java.lang.String protocol
          The method used to transmit the call, the default is http but it can be https to secure the communication
private static int requestNb
           
private static java.lang.String SERVER_CONTEXT
          Default Server File
private static java.lang.String SERVER_HOST
          Default Server Host
private static int SERVER_PORT
          Default Server Port
private  java.lang.String sessionId
           
private static java.lang.String UNAUTHENTICATED_SERVLET
           
 
Constructor Summary
protected HttpSessionClient()
          Default constructor
 
Method Summary
private  java.lang.String getAuthenticatedServerFile()
           
static HttpSessionClient getInstance()
          Singleton instanciation
 int getThreadCount()
           
private  void getThreadLock()
          This method is used to limit the concurrent http call to the max fixed by maxThreadCount and to wait the end of the first call that will return the session id.
private  java.lang.String getUnauthenticatedServerFile()
           
 java.lang.Object invoke(EJBDefinition p_service, java.lang.reflect.Method m, java.lang.Object[] args)
          Invokes a stateless remote service
 java.lang.Object invoke(HttpServiceKey p_servicekey, java.lang.reflect.Method m, java.lang.Object[] args)
          Invokes a statefull remote service
private  java.lang.Object invokeHttp(HttpServiceRequest request)
          Performs the http call.
private  boolean isAuthenticatedCall()
           
private  void releaseThreadLock()
           
 void setContext(java.lang.String context)
          Set the context used at deployment time.
 void setHost(java.lang.String host)
           
 void setLogin(java.lang.String login)
           
 void setPassword(java.lang.String pass)
           
 void setPort(int port)
           
 void setProtocol(java.lang.String protocol)
          sets the used protocol.
 void setServerFile(java.lang.String serverFile)
          Deprecated. setServerContext should be used instead.
 void setThreadCount(int threadCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

requestNb

private static int requestNb

sessionId

private java.lang.String sessionId

AUTHENTICATED_SERVLET

private static final java.lang.String AUTHENTICATED_SERVLET
See Also:
Constant Field Values

UNAUTHENTICATED_SERVLET

private static final java.lang.String UNAUTHENTICATED_SERVLET
See Also:
Constant Field Values

DEFAULT_PROTOCOL

private static final java.lang.String DEFAULT_PROTOCOL
Default call method is http

See Also:
Constant Field Values

SERVER_HOST

private static final java.lang.String SERVER_HOST
Default Server Host

See Also:
Constant Field Values

SERVER_PORT

private static final int SERVER_PORT
Default Server Port

See Also:
Constant Field Values

SERVER_CONTEXT

private static final java.lang.String SERVER_CONTEXT
Default Server File

See Also:
Constant Field Values

DEFAULT_THREAD_COUNT

private static final int DEFAULT_THREAD_COUNT
Default Server File

See Also:
Constant Field Values

MIME_TYPE

private static final java.lang.String MIME_TYPE
BSF default mime type

See Also:
Constant Field Values

protocol

private java.lang.String protocol
The method used to transmit the call, the default is http but it can be https to secure the communication


host

private java.lang.String host
Where is the server


context

private java.lang.String context
The context used at deployment time.


login

private java.lang.String login
Used for authentification


pass

private java.lang.String pass
password used for basic authentification


port

private int port
Http Port used


maxThreadCount

private int maxThreadCount
The number of parallel thread used to perform the http call.


curUsedThread

private int curUsedThread
The number of thread that are currently making a call


_instance

protected static HttpSessionClient _instance
Constructor Detail

HttpSessionClient

protected HttpSessionClient()
Default constructor

Method Detail

invoke

public java.lang.Object invoke(EJBDefinition p_service,
                               java.lang.reflect.Method m,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Invokes a stateless remote service

java.lang.Throwable

invoke

public java.lang.Object invoke(HttpServiceKey p_servicekey,
                               java.lang.reflect.Method m,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Invokes a statefull remote service

java.lang.Throwable

invokeHttp

private java.lang.Object invokeHttp(HttpServiceRequest request)
                             throws java.lang.Throwable
Performs the http call.

java.lang.Throwable

getThreadLock

private void getThreadLock()
This method is used to limit the concurrent http call to the max fixed by maxThreadCount and to wait the end of the first call that will return the session id.


releaseThreadLock

private void releaseThreadLock()

getInstance

public static HttpSessionClient getInstance()
                                     throws java.lang.IllegalStateException
Singleton instanciation

java.lang.IllegalStateException

isAuthenticatedCall

private boolean isAuthenticatedCall()

setHost

public void setHost(java.lang.String host)

setProtocol

public void setProtocol(java.lang.String protocol)
sets the used protocol. The default one is http but you can set it to https to use a secure communication.

Parameters:
protocol -

setServerFile

public void setServerFile(java.lang.String serverFile)
Deprecated. setServerContext should be used instead.

Parameters:
serverFile - the deployment context and the servlet. For instance /myApp/httpSession.

setContext

public void setContext(java.lang.String context)
Set the context used at deployment time. For instance if the packaging of the remoting war inside of the ear use the context myApp, you should call setContext("myApp") on the HttpServiceFactory to reach the server.

Parameters:
context -

getUnauthenticatedServerFile

private java.lang.String getUnauthenticatedServerFile()
Returns:
the server file to call for a unauthenticated call

getAuthenticatedServerFile

private java.lang.String getAuthenticatedServerFile()
Returns:
the server file to call for an authenticated call

setPort

public void setPort(int port)

getThreadCount

public int getThreadCount()

setThreadCount

public void setThreadCount(int threadCount)

setLogin

public void setLogin(java.lang.String login)

setPassword

public void setPassword(java.lang.String pass)