Annotation Interface EnableHazelcastHttpSession
@Retention(RUNTIME)
@Target(TYPE)
@Documented
@Import(HazelcastHttpSessionConfiguration.class)
public @interface EnableHazelcastHttpSession
Add this annotation to an
@Configuration
class to expose the
SessionRepositoryFilter
as a bean named springSessionRepositoryFilter
and backed by Hazelcast. In order to leverage the annotation, a single
HazelcastInstance
must be provided. For example:
@Configuration(proxyBeanMethods = false) @EnableHazelcastHttpSession public class HazelcastHttpSessionConfig { @Bean public HazelcastInstance embeddedHazelcast() { Config hazelcastConfig = new Config(); return Hazelcast.newHazelcastInstance(hazelcastConfig); } }More advanced configurations can extend
HazelcastHttpSessionConfiguration
instead.- Since:
- 1.1
- See Also:
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionFlush mode for the Hazelcast sessions.int
The session timeout in seconds.Save mode for the session.This is the name of the Map that will be used in Hazelcast to store the session data.
-
Element Details
-
maxInactiveIntervalInSeconds
int maxInactiveIntervalInSecondsThe session timeout in seconds. By default, it is set to 1800 seconds (30 minutes). This should be a non-negative integer.- Returns:
- the seconds a session can be inactive before expiring
- Default:
- 1800
-
sessionMapName
String sessionMapNameThis is the name of the Map that will be used in Hazelcast to store the session data. Default is "spring:session:sessions".- Returns:
- the name of the Map to store the sessions in Hazelcast
- Default:
- "spring:session:sessions"
-
flushMode
FlushMode flushModeFlush mode for the Hazelcast sessions. The default isON_SAVE
which only updates the backing Hazelcast whenSessionRepository.save(Session)
is invoked. In a web environment this happens just before the HTTP response is committed.Setting the value to
IMMEDIATE
will ensure that the any updates to the Session are immediately written to the Hazelcast instance.- Returns:
- the
FlushMode
to use - Since:
- 2.2.0
- Default:
- ON_SAVE
-
saveMode
SaveMode saveModeSave mode for the session. The default isSaveMode.ON_SET_ATTRIBUTE
, which only saves changes made to session.- Returns:
- the save mode
- Since:
- 2.2.0
- Default:
- ON_SET_ATTRIBUTE
-