org.eclipse.jetty.server.session

## Class AbstractSessionIdManager

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.server.session.AbstractSessionIdManager

- All Implemented Interfaces:
    SessionIdManager, LifeCycle
  Direct Known Subclasses:
    HashSessionIdManager, JDBCSessionIdManager

      public abstract class AbstractSessionIdManager
      extends AbstractLifeCycle
      implements SessionIdManager

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `AbstractLifeCycle.AbstractLifeCycleListener`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `LifeCycle.Listener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Random` | `_random`
    `protected long` | `_reseed`
    `protected boolean` | `_weakRandom`
    `protected String` | `_workerName`

    - ### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractSessionIdManager()`
    `AbstractSessionIdManager(Random random)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doStart()`
    `protected void` | `doStop()`
    `Random` | `getRandom()`
    `long` | `getReseed()`
    `String` | `getWorkerName()` Get the workname.
    `void` | `initRandom()` Set up a random number generator for the sessionids.
    `String` | `newSessionId(javax.servlet.http.HttpServletRequest request, long created)` Create a new session id if necessary.
    `void` | `setRandom(Random random)`
    `void` | `setReseed(long reseed)` Set the reseed probability.
    `void` | `setWorkerName(String workerName)` Set the workname.

    - ### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.jetty.server.SessionIdManager

      `addSession, getClusterId, getNodeId, idInUse, invalidateAll, removeSession`

    - ### Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

- - ### Field Detail

    - #### _random

          protected Random _random

    - #### _weakRandom

          protected boolean _weakRandom

    - #### _workerName

          protected String _workerName

    - #### _reseed

          protected long _reseed

  - ### Constructor Detail

    - #### AbstractSessionIdManager

          public AbstractSessionIdManager()

    - #### AbstractSessionIdManager

          public AbstractSessionIdManager(Random random)

  - ### Method Detail

    - #### getReseed

          public long getReseed()

      Returns:
        the reseed probability

    - #### setReseed

          public void setReseed(long reseed)

      Set the reseed probability.
      Parameters:
        `reseed` - If non zero then when a random long modulo the reseed value == 1, the `SecureRandom` will be reseeded.

    - #### getWorkerName

          public String getWorkerName()

      Get the workname. If set, the workername is dot appended to the session ID and can be used to assist session affinity in a load balancer.
      Specified by:
        `getWorkerName` in interface `SessionIdManager`
      Returns:
        String or null

    - #### setWorkerName

          public void setWorkerName(String workerName)

      Set the workname. If set, the workername is dot appended to the session ID and can be used to assist session affinity in a load balancer.
      Parameters:
        `workerName` -

    - #### getRandom

          public Random getRandom()

    - #### setRandom

          public void setRandom(Random random)

    - #### newSessionId

          public String newSessionId(javax.servlet.http.HttpServletRequest request,
                            long created)

      Create a new session id if necessary.
      Specified by:
        `newSessionId` in interface `SessionIdManager`
      Returns:
        the new session id
      See Also:
        `SessionIdManager.newSessionId(javax.servlet.http.HttpServletRequest, long)`

    - #### doStart

          protected void doStart()
                          throws Exception

      Overrides:
        `doStart` in class `AbstractLifeCycle`
      Throws:
        `Exception`

    - #### doStop

          protected void doStop()
                         throws Exception

      Overrides:
        `doStop` in class `AbstractLifeCycle`
      Throws:
        `Exception`

    - #### initRandom

          public void initRandom()

      Set up a random number generator for the sessionids. By preference, use a SecureRandom but allow to be injected.

Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.