org.jboss.ha.httpsession.server
Class ClusteredHTTPSessionService

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.ha.httpsession.server.ClusteredHTTPSessionService
All Implemented Interfaces:
ClusteredHTTPSessionServiceMBean (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)

public class ClusteredHTTPSessionService
extends ServiceMBeanSupport (src)
implements ClusteredHTTPSessionServiceMBean (src)

JMX Service implementation for ClusteredHTTPSessionServiceMBean

See Also:
ClusteredHTTPSessionServiceMBean (src)

Nested Class Summary
protected  class ClusteredHTTPSessionService.CleanupDaemon (src)
           
 
Field Summary
protected  ClusteredHTTPSessionService.CleanupDaemon (src) cleanup
           
protected static long CLEANUP_FREQUENCY
           
protected  java.security.MessageDigest digest
           
protected  ClusteredHTTPSessionHome (src) httpSessionHome
           
protected  LocalClusteredHTTPSessionHome (src) localHttpSessionHome
           
protected  java.util.Random random
           
protected static int SESSION_ID_BYTES
           
protected static java.lang.String SESSION_ID_HASH_ALGORITHM
           
protected static java.lang.String SESSION_ID_RANDOM_ALGORITHM
           
protected static java.lang.String SESSION_ID_RANDOM_ALGORITHM_ALT
           
protected  long sessionTimeout
           
protected  boolean useLocalBean
           
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
ClusteredHTTPSessionService()
           
 
Method Summary
protected  ClusteredHTTPSessionBusiness (src) createSession(java.lang.String id, SerializableHttpSession (src)  session)
           
protected  java.lang.String encode(byte[] data)
          Encode the bytes into a String with a slightly modified Base64-algorithm This code was written by Kevin Kelley and adapted by Thomas Peuss
protected  java.lang.String generateSessionId()
          Generate a session-id that is not guessable
protected  java.security.MessageDigest getDigest()
          get a MessageDigest hash-generator
 SerializableHttpSession (src) getHttpSession(java.lang.String sessionId, java.lang.ClassLoader tcl)
          Return the HttpSession associated to a session id.
protected  java.util.Random getRandom()
          get a random-number generator
 java.lang.String getSessionId()
          Generates a new session id available cluster-wide
 long getSessionTimeout()
          Indicate the duration, in ms, after which the session can be cleaned if no access occurs.
 boolean getUseLocalBean()
           
protected  void initRefToBean()
           
 void removeHttpSession(java.lang.String sessionId)
          Remove an HttpSession from the cluster (log off for example)
 void setHttpSession(java.lang.String sessionId, SerializableHttpSession (src)  session)
          Associate a new session with the session id.
 void setSessionTimeout(long miliseconds)
          Indicate the duration, in ms, after which the session can be cleaned if no access occurs.
 void setUseLocalBean(boolean useLocal)
          Indicates whether the service should use the local and home interfaces of the entity bean or the remote and remote home interfaces (depending if they are in the same JVM).
protected  void startService()
          Sub-classes should override this method to provide custum 'start' logic.
protected  void stopService()
          Sub-classes should override this method to provide custum 'stop' logic.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean (src)
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service (src)
create, destroy, start, stop
 

Field Detail

CLEANUP_FREQUENCY

protected static final long CLEANUP_FREQUENCY
See Also:
Constant Field Values (src)

SESSION_ID_BYTES

protected static final int SESSION_ID_BYTES
See Also:
Constant Field Values (src)

SESSION_ID_HASH_ALGORITHM

protected static final java.lang.String SESSION_ID_HASH_ALGORITHM
See Also:
Constant Field Values (src)

SESSION_ID_RANDOM_ALGORITHM

protected static final java.lang.String SESSION_ID_RANDOM_ALGORITHM
See Also:
Constant Field Values (src)

SESSION_ID_RANDOM_ALGORITHM_ALT

protected static final java.lang.String SESSION_ID_RANDOM_ALGORITHM_ALT
See Also:
Constant Field Values (src)

httpSessionHome

protected ClusteredHTTPSessionHome (src)  httpSessionHome

localHttpSessionHome

protected LocalClusteredHTTPSessionHome (src)  localHttpSessionHome

cleanup

protected ClusteredHTTPSessionService.CleanupDaemon (src)  cleanup

sessionTimeout

protected long sessionTimeout

useLocalBean

protected boolean useLocalBean

digest

protected java.security.MessageDigest digest

random

protected java.util.Random random
Constructor Detail

ClusteredHTTPSessionService

public ClusteredHTTPSessionService()
Method Detail

setHttpSession

public void setHttpSession(java.lang.String sessionId,
                           SerializableHttpSession (src)  session)
                    throws EJBException (src) 
Description copied from interface: ClusteredHTTPSessionServiceMBean (src)
Associate a new session with the session id. To reduce the cluster communication, if the only thing that has changed in the session is the last accessed time, the new session is kept in cache but not replicated on the other nodes. Thus, if you use a front-end load-balancer that support sticky session, that is not a problem because a client will always target the same node and receive the updated session available in cache. Nevertheless, as soon as an attribute is modified in the session, it is replicated in the cluster.

Specified by:
setHttpSession in interface ClusteredHTTPSessionServiceMBean (src)
Throws:
EJBException (src)

getHttpSession

public SerializableHttpSession (src)  getHttpSession(java.lang.String sessionId,
                                              java.lang.ClassLoader tcl)
                                       throws EJBException (src) 
Description copied from interface: ClusteredHTTPSessionServiceMBean (src)
Return the HttpSession associated to a session id. As all session id are shared for all Web Applications, all sessions ids accross all applications and all nodes must be distincts! The creation and last access time of the session may not be correct if they are the only thing that has been modified on a distant node (and no attribute). See setHttpSession for more information.

Specified by:
getHttpSession in interface ClusteredHTTPSessionServiceMBean (src)
Throws:
EJBException (src)

removeHttpSession

public void removeHttpSession(java.lang.String sessionId)
                       throws EJBException (src) 
Description copied from interface: ClusteredHTTPSessionServiceMBean (src)
Remove an HttpSession from the cluster (log off for example)

Specified by:
removeHttpSession in interface ClusteredHTTPSessionServiceMBean (src)
Throws:
EJBException (src)

getSessionTimeout

public long getSessionTimeout()
Description copied from interface: ClusteredHTTPSessionServiceMBean (src)
Indicate the duration, in ms, after which the session can be cleaned if no access occurs.

Specified by:
getSessionTimeout in interface ClusteredHTTPSessionServiceMBean (src)

setSessionTimeout

public void setSessionTimeout(long miliseconds)
Description copied from interface: ClusteredHTTPSessionServiceMBean (src)
Indicate the duration, in ms, after which the session can be cleaned if no access occurs.

Specified by:
setSessionTimeout in interface ClusteredHTTPSessionServiceMBean (src)

getSessionId

public java.lang.String getSessionId()
Description copied from interface: ClusteredHTTPSessionServiceMBean (src)
Generates a new session id available cluster-wide

Specified by:
getSessionId in interface ClusteredHTTPSessionServiceMBean (src)

setUseLocalBean

public void setUseLocalBean(boolean useLocal)
Description copied from interface: ClusteredHTTPSessionServiceMBean (src)
Indicates whether the service should use the local and home interfaces of the entity bean or the remote and remote home interfaces (depending if they are in the same JVM).

Specified by:
setUseLocalBean in interface ClusteredHTTPSessionServiceMBean (src)

getUseLocalBean

public boolean getUseLocalBean()
Specified by:
getUseLocalBean in interface ClusteredHTTPSessionServiceMBean (src)

startService

protected void startService()
                     throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'start' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
startService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'stop' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
stopService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

initRefToBean

protected void initRefToBean()
                      throws java.lang.Exception
Throws:
java.lang.Exception

createSession

protected ClusteredHTTPSessionBusiness (src)  createSession(java.lang.String id,
                                                     SerializableHttpSession (src)  session)
                                              throws java.lang.Exception
Throws:
java.lang.Exception

generateSessionId

protected java.lang.String generateSessionId()
Generate a session-id that is not guessable

Returns:
generated session-id

encode

protected java.lang.String encode(byte[] data)
Encode the bytes into a String with a slightly modified Base64-algorithm This code was written by Kevin Kelley and adapted by Thomas Peuss

Parameters:
data - The bytes you want to encode
Returns:
the encoded String

getRandom

protected java.util.Random getRandom()
get a random-number generator

Returns:
a random-number generator

getDigest

protected java.security.MessageDigest getDigest()
get a MessageDigest hash-generator

Returns:
a hash generator