public abstract class SessionIdGeneratorBase extends LifecycleBase implements SessionIdGenerator
Lifecycle.SingleUse
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
Constructor and Description |
---|
SessionIdGeneratorBase() |
Modifier and Type | Method and Description |
---|---|
protected void |
destroyInternal() |
String |
generateSessionId()
Generate and return a new session identifier.
|
String |
getJvmRoute()
Return the node identifier associated with this node which will be
included in the generated session ID.
|
protected void |
getRandomBytes(byte[] bytes) |
String |
getSecureRandomAlgorithm()
Get the name of the algorithm used to create the
SecureRandom
instances which generate new session IDs. |
String |
getSecureRandomClass()
Get the class name of the
SecureRandom implementation used to
generate session IDs. |
String |
getSecureRandomProvider()
Get the name of the provider used to create the
SecureRandom
instances which generate new session IDs. |
int |
getSessionIdLength()
Return the number of bytes for a session ID
|
protected void |
initInternal() |
void |
setJvmRoute(String jvmRoute)
Specify the node identifier associated with this node which will be
included in the generated session ID.
|
void |
setSecureRandomAlgorithm(String secureRandomAlgorithm)
Specify a non-default algorithm to use to create instances of
SecureRandom which are used to generate session IDs. |
void |
setSecureRandomClass(String secureRandomClass)
Specify a non-default
SecureRandom implementation to use. |
void |
setSecureRandomProvider(String secureRandomProvider)
Specify a non-default provider to use to create instances of
SecureRandom which are used to generate session IDs. |
void |
setSessionIdLength(int sessionIdLength)
Specify the number of bytes for a session ID
|
protected void |
startInternal()
Sub-classes must ensure that the state is changed to
LifecycleState.STARTING during the execution of this method. |
protected void |
stopInternal()
Sub-classes must ensure that the state is changed to
LifecycleState.STOPPING during the execution of this method. |
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
generateSessionId
public String getSecureRandomClass()
SecureRandom
implementation used to
generate session IDs.null
indicates that the
JRE provided SecureRandom
implementation will be usedpublic void setSecureRandomClass(String secureRandomClass)
SecureRandom
implementation to use. The
implementation must be self-seeding and have a zero-argument constructor.
If not specified, an instance of SecureRandom
will be generated.secureRandomClass
- The fully-qualified class namepublic String getSecureRandomAlgorithm()
SecureRandom
instances which generate new session IDs.null
or the empty string means
that platform default will be usedpublic void setSecureRandomAlgorithm(String secureRandomAlgorithm)
SecureRandom
which are used to generate session IDs. If no
algorithm is specified, SHA1PRNG is used. To use the platform default
(which may be SHA1PRNG), specify null
or the empty string. If an
invalid algorithm and/or provider is specified the SecureRandom
instances will be created using the defaults for this
SessionIdGenerator
implementation. If that fails, the
SecureRandom
instances will be created using platform defaults.secureRandomAlgorithm
- The name of the algorithmpublic String getSecureRandomProvider()
SecureRandom
instances which generate new session IDs.null
or the empty string means
that platform default will be usedpublic void setSecureRandomProvider(String secureRandomProvider)
SecureRandom
which are used to generate session IDs. If no
provider is specified, the platform default is used. To use the platform
default specify null
or the empty string. If an invalid algorithm
and/or provider is specified the SecureRandom
instances will be
created using the defaults for this SessionIdGenerator
implementation. If that fails, the SecureRandom
instances will be
created using platform defaults.secureRandomProvider
- The name of the providerpublic String getJvmRoute()
getJvmRoute
in interface SessionIdGenerator
public void setJvmRoute(String jvmRoute)
setJvmRoute
in interface SessionIdGenerator
jvmRoute
- The node identifierpublic int getSessionIdLength()
getSessionIdLength
in interface SessionIdGenerator
public void setSessionIdLength(int sessionIdLength)
setSessionIdLength
in interface SessionIdGenerator
sessionIdLength
- Number of bytespublic String generateSessionId()
generateSessionId
in interface SessionIdGenerator
protected void getRandomBytes(byte[] bytes)
protected void initInternal() throws LifecycleException
initInternal
in class LifecycleBase
LifecycleException
protected void startInternal() throws LifecycleException
LifecycleBase
LifecycleState.STARTING
during the execution of this method.
Changing state will trigger the Lifecycle.START_EVENT
event.
If a component fails to start it may either throw a
LifecycleException
which will cause it's parent to fail to start
or it can place itself in the error state in which case LifecycleBase.stop()
will be called on the failed component but the parent component will
continue to start normally.startInternal
in class LifecycleBase
LifecycleException
- Start error occurredprotected void stopInternal() throws LifecycleException
LifecycleBase
LifecycleState.STOPPING
during the execution of this method.
Changing state will trigger the Lifecycle.STOP_EVENT
event.stopInternal
in class LifecycleBase
LifecycleException
- Stop error occurredprotected void destroyInternal() throws LifecycleException
destroyInternal
in class LifecycleBase
LifecycleException
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.