public class SessionConfiguration extends Object implements Serializable
The parameters are configured using following system properties:
com.amadeus.session.distributable set to true enables session to
be stored in distributed storage.
com.amadeus.session.timeout specifies default session inactivity
timeout in seconds. Default value is 1800 seconds.
com.amadeus.session.non-cachable specifies comma-separated list
of session attributes that must be synchronized with repository. By default,
this list is empty. com.amadeus.session.replication-trigger
specifies repository behavior when accessing attributes. See
SessionConfiguration.ReplicationTrigger enumeration for details. Default value is
SessionConfiguration.ReplicationTrigger.SET_AND_NON_PRIMITIVE_GET.
com.amadeus.session.logging.mdc.enabled activates adding current
session id to logging systems Mapped Diagnostic Context (MDC).
com.amadeus.session.logging.mdc.name specifies key used to store
current session id to logging systems Mapped Diagnostic Context (MDC).
| Modifier and Type | Class and Description |
|---|---|
static interface |
SessionConfiguration.AttributeProvider
Attribute provider can be used via call to
initializeFrom(AttributeProvider) to set up
SessionConfiguration. |
static class |
SessionConfiguration.ReplicationTrigger
Strategies for detecting when does an attribute change.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
COMMIT_ON_ALL_CONCURRENT
Specifies if commit should be done on all concurrent requests to session.
|
static SessionConfiguration.ReplicationTrigger |
DEFAULT_REPLICATION_TRIGGER
Default strategy for detecting that attribute changed.
|
static String |
DEFAULT_SESSION_ID_LENGTH
Default session id length when using
RandomIdProvider is 30 bytes. |
static String |
DEFAULT_SESSION_ID_NAME
Default name for the cookie or URL element.
|
static String |
DEFAULT_SESSION_NAMESPACE
Default session namespace is
default |
static String |
DEFAULT_SESSION_TIMEOUT
Default session timeout in seconds.
|
static int |
DEFAULT_SESSION_TIMEOUT_VALUE_NUM
Default session timeout is 30 minutes.
|
static String |
DEFAULT_SESSION_TIMESTAMP
Default session timestamp is
false |
static String |
DEFAULT_STICKY_SESSIONS
By default, sessions are sticky.
|
static String |
DELEGATE_WRITER
Set to
true if session should delegate PrintWriter implementation to container. |
static String |
DISABLED_SESSION
ServletContext parameter or system property disabled session management.
|
static String |
DISTRIBUTABLE_SESSION
Indicates if sessions can be distributed or not.
|
static String |
FORCE_DISTRIBUTABLE
Non-distributable web apps will be treated as distributable if this
parameter is set to
true. |
static String |
INTERCEPT_LISTENERS
Specifies if listeners should be discovered using interception of native
session.
|
static String |
LOG_MDC_SESSION_ENABLED
Is session id stored in logging MDC.
|
static String |
LOG_MDC_SESSION_NAME
The name of the logging MDC attribute where session id is stored.
|
static String |
LOGGING_MDC_DEFAULT_KEY
Default key used to store session id in logging system's MDC.
|
static String |
NODE_ID
System property containing the id of node.
|
static String |
NON_CACHEABLE_ATTRIBUTES
List of attributes that must be retrieved from repository (i.e.
|
static String |
PROVIDER_CONFIGURATION
ServletContext parameter or system property containing the configuration
for the
SessionRepository. |
static String |
REPOSITORY_FACTORY_NAME
ServletContext parameter or system property containing the name of
SessionRepositoryFactory implementation. |
static String |
REUSE_CONCURRENT_SESSION
ServletContext parameter or system property activating sharing of instances
of session during concurrent requests.
|
static String |
SESSION_ENCRYPTION_KEY
Specifies key to be used for encryption.
|
static String |
SESSION_HOST
Enables overriding the name of the host.
|
static String |
SESSION_ID_LENGTH
ServletContext parameter or system property specifying the length of the
generates session ids.
|
static String |
SESSION_ID_NAME
ServletContext parameter or system property containing the name of the
cookie or URL element for propagating session.
|
static String |
SESSION_ID_PROVIDER
ServletContext parameter or system property indicating what provider
generates session ids.
|
static String |
SESSION_NAMESPACE
The namespace for sessions.
|
static String |
SESSION_PROPAGATOR_NAME
ServletContext parameter or system property containing the name of the
SessionTracking implementation or value from
com.amadeus.session.servlet.SessionPropagation enumeration. |
static String |
SESSION_REPLICATION_TRIGGER
Strategy for for triggering replication.
|
static String |
SESSION_TIMESTAMP
Indicate if generated session prefixed with!Timestamp.
|
static String |
STICKY_SESSIONS
Activates sticky session strategy.
|
| Constructor and Description |
|---|
SessionConfiguration()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAttribute(String key,
String defaultValue)
Returns value of attribute from attribute provider if it was supplied or
from system property if it is not present or if there is no attribute
provider
|
String |
getEncryptionKey()
Returns encryption key to use.
|
String |
getLoggingMdcKey()
Returns key used to store current session id to logging system's Mapped
Diagnostic Context (MDC).
|
int |
getMaxInactiveInterval()
Returns maximum inactivity interval before session expires in seconds.
|
String |
getNamespace()
Namespace for session.
|
String |
getNode()
Returns id of the current node
|
Set<String> |
getNonCacheable()
Returns set of keys that should not be cached locally.
|
static String |
getPropertySecured(String key,
String def)
Returns value of system property, and logs information if access to
properties is protected.
|
String |
getProviderConfiguration()
Returns configuration string for the repository provider.
|
SessionConfiguration.ReplicationTrigger |
getReplicationTrigger()
Returns strategy used to detect if attribute changed.
|
String |
getRepositoryFactory()
Gets the class name or the unique identifier of the repository factory.
|
String |
getSessionIdName()
Returns name of identifier that is used to stored session id.
|
String |
getSessionTracking()
Returns class name or unique id of the session tracking.
|
String |
getTrueNamespace()
Returns configured namespace of the session (may be
null). |
void |
initializeFrom(SessionConfiguration.AttributeProvider provider)
Allows setting up configuration from external source.
|
boolean |
isAllowedCachedSessionReuse()
Returns
true if multiple concurrent threads that operate on
same session can re-use session from local cache. |
boolean |
isCommitOnAllConcurrent()
Returns
true if commit of attributes should be done on all
concurrent requests to session. |
boolean |
isDelegateWriter() |
boolean |
isDistributable()
Returns
true if session can be stored remote repository. |
boolean |
isForceDistributable()
Returns
true if distribution/replication should be used even
when web app is marked as non-distributable. |
boolean |
isInterceptListeners() |
boolean |
isLoggingMdcActive()
Returns
true if session information should be stored in
logging systems Mapped Diagnostic Context (MDC). |
boolean |
isSticky()
Returns
true if sessions are sticky. |
boolean |
isTimestampSufix()
Returns
true if session id is expected to be suffixed by !timestamp. |
boolean |
isUsingEncryption()
Returns
true if session should be encrypted before storing in
repository. |
void |
setAllowedCachedSessionReuse(boolean allowedCachedSessionReuse)
Enables or disables sharing of session instances between multiple
concurrent threads.
|
void |
setAttribute(String key,
String value)
Sets attribute value.
|
void |
setCommitOnAllConcurrent(boolean commitOnAllConcurrent)
Controls if commit of attributes should be done on all concurrent requests
to session.
|
void |
setDelegateWriter(boolean delegateWriter) |
void |
setDistributable(boolean distributable)
Sets whether session can be stored in remote repository.
|
void |
setEncryptionKey(String key)
Sets encryption key to use.
|
void |
setForceDistributable(boolean forceDistributable)
Sets whether distribution/replication should be used even when web app is
marked as non-distributable.
|
void |
setInterceptListeners(boolean interceptListeners) |
void |
setLoggingMdcActive(boolean loggingMdcActive)
Sets whether session information should be stored in logging systems Mapped
Diagnostic Context (MDC).
|
void |
setLoggingMdcKey(String loggingMdcKey)
Sets key used to store current session id to logging system's Mapped
Diagnostic Context (MDC).
|
void |
setMaxInactiveInterval(int maxInactiveInterval)
Sets maximum inactivity interval before session expires
|
void |
setNamespace(String namespace)
Sets namespace of the session.
|
void |
setNode(String node)
Sets id of the node
|
void |
setNonCacheable(Set<String> nonCacheable)
Sets set of keys that should not be cached locally.
|
void |
setNonCacheable(String nonCacheableAttributesCsv)
Sets set of keys that should not be cached locally by extracting keys from
comma-separated list provided as parameter.
|
void |
setProviderConfiguration(String providerConfiguration)
Sets configuration string for the repository provider.
|
void |
setReplicationTrigger(SessionConfiguration.ReplicationTrigger replicationTrigger)
Sets strategy used to detect if attribute changed.
|
void |
setRepositoryFactory(String repositoryFactory)
Sets the class name or the unique identifier of the repository factory.
|
void |
setSessionIdName(String sessionIdName)
Sets name of session identifier.
|
void |
setSessionTracking(String sessionTracking)
Sets class name or unique id of the session tracking.
|
void |
setSticky(boolean sticky)
Sets stickiness of sessions.
|
void |
setTimestampSufix(boolean timestamp)
Add timestamp suffix to session id if set to true.
|
void |
setUsingEncryption(boolean usingEncryption)
Sets whether the session data is stored in encrypted form in repository.
|
String |
toString() |
public static final String DISTRIBUTABLE_SESSION
public static final String FORCE_DISTRIBUTABLE
true.public static final String DEFAULT_SESSION_TIMEOUT
public static final String NON_CACHEABLE_ATTRIBUTES
public static final String SESSION_REPLICATION_TRIGGER
SessionConfiguration.ReplicationTrigger
enumeration.public static final SessionConfiguration.ReplicationTrigger DEFAULT_REPLICATION_TRIGGER
public static final String LOG_MDC_SESSION_ENABLED
public static final String LOG_MDC_SESSION_NAME
public static final String LOGGING_MDC_DEFAULT_KEY
public static final String STICKY_SESSIONS
public static final String DEFAULT_STICKY_SESSIONS
public static final String SESSION_NAMESPACE
public static final String DEFAULT_SESSION_NAMESPACE
defaultpublic static final String SESSION_TIMESTAMP
public static final String DEFAULT_SESSION_TIMESTAMP
falsepublic static final int DEFAULT_SESSION_TIMEOUT_VALUE_NUM
public static final String SESSION_HOST
initNode() for details.public static final String PROVIDER_CONFIGURATION
SessionRepository. See each implementation for detailed
format. By convention, items in the format are separated by commas.public static final String REPOSITORY_FACTORY_NAME
SessionRepositoryFactory implementation. The value is either name
of the class or registered repository name such as redis,
in-memorypublic static final String SESSION_PROPAGATOR_NAME
SessionTracking implementation or value from
com.amadeus.session.servlet.SessionPropagation enumeration.public static final String SESSION_ID_NAME
DEFAULT_SESSION_ID_NAME,
Constant Field Valuespublic static final String DEFAULT_SESSION_ID_NAME
SESSION_ID_NAME,
Constant Field Valuespublic static final String NODE_ID
public static final String DISABLED_SESSION
public static final String REUSE_CONCURRENT_SESSION
public static final String SESSION_ID_PROVIDER
public static final String SESSION_ID_LENGTH
RandomIdProvider.public static final String DEFAULT_SESSION_ID_LENGTH
RandomIdProvider is 30 bytes.public static final String INTERCEPT_LISTENERS
public static final String COMMIT_ON_ALL_CONCURRENT
public static final String SESSION_ENCRYPTION_KEY
public static final String DELEGATE_WRITER
true if session should delegate PrintWriter implementation to container. By default it is
false and session replacer provides it's own implementation.public void setEncryptionKey(String key)
null, encryption is
deactivated.key - encryption key to use or nullpublic void initializeFrom(SessionConfiguration.AttributeProvider provider)
provider - the external source for attributespublic int getMaxInactiveInterval()
public void setMaxInactiveInterval(int maxInactiveInterval)
maxInactiveInterval - inactivity interval in secondspublic boolean isDistributable()
true if session can be stored remote repository.true if session can be stored remote repositorypublic void setDistributable(boolean distributable)
distributable - true if session can be stored remote repositorypublic Set<String> getNonCacheable()
public void setNonCacheable(Set<String> nonCacheable)
nonCacheable - set of attribute names that can't be cached locallypublic void setNonCacheable(String nonCacheableAttributesCsv)
nonCacheableAttributesCsv - list of non cacheable attributes in comma-separated listpublic SessionConfiguration.ReplicationTrigger getReplicationTrigger()
public void setReplicationTrigger(SessionConfiguration.ReplicationTrigger replicationTrigger)
replicationTrigger - new replication strategy to usepublic boolean isLoggingMdcActive()
true if session information should be stored in
logging systems Mapped Diagnostic Context (MDC).true if session information should be stored in MDCpublic void setLoggingMdcActive(boolean loggingMdcActive)
loggingMdcActive - true if logging should add information to MDCpublic String getLoggingMdcKey()
public void setLoggingMdcKey(String loggingMdcKey)
loggingMdcKey - the key value to use. If value is null,
LOGGING_MDC_DEFAULT_KEY is used as keypublic boolean isSticky()
true if sessions are sticky. Sticky sessions should be
expired on the last node that used them.true if session is stickypublic void setSticky(boolean sticky)
isSticky().sticky - true if session is stickpublic boolean isTimestampSufix()
true if session id is expected to be suffixed by !timestamp.true if session id to be suffixed by !timestamp.public void setTimestampSufix(boolean timestamp)
isTimestampSufix().timestamp - true if session is expected to be suffixed by timestamppublic String getNode()
public void setNode(String node)
node - id/name of the current nodepublic String getNamespace()
null (if null, value
default).public String getTrueNamespace()
null).public void setNamespace(String namespace)
namespace - name to usepublic String getProviderConfiguration()
public void setProviderConfiguration(String providerConfiguration)
providerConfiguration - the string used to configure providerpublic String getRepositoryFactory()
public void setRepositoryFactory(String repositoryFactory)
repositoryFactory - the name of the repository factorypublic String getSessionTracking()
SessionTracking is the class responsible for reading and
propagating session id.public void setSessionTracking(String sessionTracking)
getSessionTracking().sessionTracking - the unique id or name of the session tracking classpublic String getSessionIdName()
public void setSessionIdName(String sessionIdName)
sessionIdName - new session identifierpublic boolean isAllowedCachedSessionReuse()
true if multiple concurrent threads that operate on
same session can re-use session from local cache.true if concurrent threads can access same sessionpublic void setAllowedCachedSessionReuse(boolean allowedCachedSessionReuse)
allowedCachedSessionReuse - true if concurrent threads can access same sessionpublic static String getPropertySecured(String key, String def)
key - property keydef - default value for propertypublic String getAttribute(String key, String defaultValue)
key - key that identifies attribute or system propertydefaultValue - default value for keypublic void setAttribute(String key, String value)
SessionConfiguration.key - the name of the attributevalue - the value of the attributepublic boolean isInterceptListeners()
public void setInterceptListeners(boolean interceptListeners)
interceptListeners - the interceptListeners to setpublic boolean isForceDistributable()
true if distribution/replication should be used even
when web app is marked as non-distributable.true if distribution/replication should be used even
when web app is marked as non-distributable.public void setForceDistributable(boolean forceDistributable)
forceDistributable - true if distribution/replication should be used even
when web app is marked as non-distributable.public boolean isCommitOnAllConcurrent()
true if commit of attributes should be done on all
concurrent requests to session.true if commit should be done on all concurrent
requestspublic void setCommitOnAllConcurrent(boolean commitOnAllConcurrent)
commitOnAllConcurrent - true if commit should be done on all concurrent
requestspublic boolean isUsingEncryption()
true if session should be encrypted before storing in
repository.true if session should be encrypted before storing in
repositorypublic void setUsingEncryption(boolean usingEncryption)
true, encryption key must be set also.usingEncryption - true if session data is stored in encrypted formpublic String getEncryptionKey()
null.public boolean isDelegateWriter()
public void setDelegateWriter(boolean delegateWriter)
Copyright © 2018 Amadeus s.a.s.. All rights reserved.