org.bsf.remoting.http
Class HttpSessionServer

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--org.bsf.remoting.http.HttpSessionServer
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class HttpSessionServer
extends javax.servlet.http.HttpServlet

This is the servlet that intercept all the client calls and transmits these to the EJBs. All the client calls are Http POST calls that use url rewriting to keep the session id.

If the client uses authentication, it should call an authenticate(String login, String password) on a session.

The lookup on EJB are made through the _ejbContext InitialContext. This context is instantiated using the properties

See Also:
Serialized Form

Field Summary
private static javax.naming.Context _ejbContext
           
private static java.lang.String _ejbContextProperties
           
private  int _maxServiceIndex
           
(package private)  org.apache.commons.logging.Log log
           
protected static java.util.Hashtable serviceCache
           
private static java.lang.String STATEFULL_CACHE
           
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Constructor Summary
HttpSessionServer()
           
 
Method Summary
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          The only http call used by the client side is POST in order to deal with unlimited (??)
private  javax.ejb.EJBObject getEjbReference(HttpServiceRequest httpServiceRequest, javax.servlet.http.HttpServletRequest request)
          Retrieves the reference to the EJBObject by the definition or by the cache depending on the request.
private  javax.ejb.EJBObject getFromCache(HttpServiceKey serviceKey, javax.servlet.http.HttpServletRequest request)
          Retrieve the statefull service from cache
private  HttpServiceRequest getHttpServiceRequest(javax.servlet.http.HttpServletRequest request)
          gets the request from the http stream
private  java.lang.Class[] getParamTypes(java.lang.Object[] p_args)
          As we invoke the method on the remote service using the reflect package, we must know the classes of the arguments
private  javax.ejb.EJBObject getRemote(EJBDefinition p_service)
          Used for a call on a stateless service.
private  java.util.Map getStatefulCache(javax.servlet.http.HttpServletRequest request)
          Retrieve the stateful cache from the session.
 void init()
          Uses the properties defined in the servlet environment to instantiate the principalManager and the initial context properties.
private static void initEjbContext(java.lang.String jndiProperties)
           
private static java.lang.Object[] narrowArgs(java.lang.Object[] p_args)
          Allows the session to have remote EJBObject as arguments
private  HttpServiceResponse processRemoteCall(javax.ejb.EJBObject remoteService, HttpServiceRequest httpServiceRequest, javax.servlet.http.HttpServletRequest request)
           
private  void putInCache(HttpServiceKey p_serviceKey, javax.ejb.EJBObject p_stub, javax.servlet.http.HttpServletRequest request)
          We put in cache the handles to prepare the passivation
private  void writeHttpServiceResponse(javax.servlet.http.HttpServletResponse response, HttpServiceResponse httpServiceResponse)
          writes the response in the http stream
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

org.apache.commons.logging.Log log

serviceCache

protected static java.util.Hashtable serviceCache

_maxServiceIndex

private int _maxServiceIndex

_ejbContext

private static javax.naming.Context _ejbContext

_ejbContextProperties

private static java.lang.String _ejbContextProperties

STATEFULL_CACHE

private static final java.lang.String STATEFULL_CACHE
See Also:
Constant Field Values
Constructor Detail

HttpSessionServer

public HttpSessionServer()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Uses the properties defined in the servlet environment to instantiate the principalManager and the initial context properties.

Overrides:
init in class javax.servlet.GenericServlet
javax.servlet.ServletException

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
                      java.io.IOException
The only http call used by the client side is POST in order to deal with unlimited (??) size of stream.

Overrides:
doPost in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException

getEjbReference

private javax.ejb.EJBObject getEjbReference(HttpServiceRequest httpServiceRequest,
                                            javax.servlet.http.HttpServletRequest request)
Retrieves the reference to the EJBObject by the definition or by the cache depending on the request.


processRemoteCall

private HttpServiceResponse processRemoteCall(javax.ejb.EJBObject remoteService,
                                              HttpServiceRequest httpServiceRequest,
                                              javax.servlet.http.HttpServletRequest request)
                                       throws java.rmi.NoSuchObjectException
java.rmi.NoSuchObjectException

writeHttpServiceResponse

private void writeHttpServiceResponse(javax.servlet.http.HttpServletResponse response,
                                      HttpServiceResponse httpServiceResponse)
                               throws java.io.IOException
writes the response in the http stream

java.io.IOException

getHttpServiceRequest

private HttpServiceRequest getHttpServiceRequest(javax.servlet.http.HttpServletRequest request)
                                          throws java.io.IOException
gets the request from the http stream

java.io.IOException

getParamTypes

private java.lang.Class[] getParamTypes(java.lang.Object[] p_args)
As we invoke the method on the remote service using the reflect package, we must know the classes of the arguments


getRemote

private javax.ejb.EJBObject getRemote(EJBDefinition p_service)
Used for a call on a stateless service. The first time this method is called on a service the remote service is created by the invocation of the create method on the EJBHome.


putInCache

private void putInCache(HttpServiceKey p_serviceKey,
                        javax.ejb.EJBObject p_stub,
                        javax.servlet.http.HttpServletRequest request)
We put in cache the handles to prepare the passivation


getFromCache

private javax.ejb.EJBObject getFromCache(HttpServiceKey serviceKey,
                                         javax.servlet.http.HttpServletRequest request)
Retrieve the statefull service from cache


getStatefulCache

private java.util.Map getStatefulCache(javax.servlet.http.HttpServletRequest request)
Retrieve the stateful cache from the session. If the stateful cache hasn't been created yet, instantiate it.

Parameters:
request -
Returns:

narrowArgs

private static java.lang.Object[] narrowArgs(java.lang.Object[] p_args)
Allows the session to have remote EJBObject as arguments


initEjbContext

private static void initEjbContext(java.lang.String jndiProperties)