@Documented @Retention(value=RUNTIME) @Target(value=TYPE) @Configuration @Import(value=GemFireHttpSessionConfiguration.class) public @interface EnableGemFireHttpSession
@Configuration
class to expose the SessionRepositoryFilter
as a bean named "springSessionRepositoryFilter" and backed by Pivotal GemFire or Apache Geode.
In order to leverage the annotation, a single Pivotal GemFire/Apache Geode
Cache
or ClientCache
instance must be provided.
For example:
@Configuration
@EnableGemFireHttpSession
public class GemFirePeerCacheHttpSessionConfiguration {
@Bean
public Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", "ExamplePeer");
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("log-level", "warning");
return gemfireProperties;
}
@Bean
public CacheFactoryBean gemfireCache() throws Exception {
CacheFactoryBean cache = new CacheFactoryBean();
cache.setProperties(gemfireProperties());
return cache;
}
}
Alternatively, Spring Session can be configured to use Pivotal GemFire (Apache Geode) as a client
using a dedicated GemFire Server cluster and a ClientCache
.
For example:
@Configuration
@EnableGemFireHttpSession
public class GemFireClientCacheHttpSessionConfiguration {
@Bean
public Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", "ExampleClient");
gemfireProperties.setProperty("log-level", "warning");
return gemfireProperties;
}
@Bean
public ClientCacheFactoryBean gemfireCache() throws Exception {
ClientCacheFactoryBean clientCache = new ClientCacheFactoryBean();
clientCache.setClose(true)
clientCache.setProperties(gemfireProperties());
return clientCache;
}
@Bean
public PoolFactoryBean gemfirePool() {
PoolFactoryBean pool = new PoolFactoryBean();
pool.addServer(new ConnectionEndpoint("serverHost", 40404);
return pool;
}
}
More advanced configurations can extend GemFireHttpSessionConfiguration
instead.EnableSpringHttpSession
,
GemFireHttpSessionConfiguration
Modifier and Type | Optional Element and Description |
---|---|
com.gemstone.gemfire.cache.client.ClientRegionShortcut |
clientRegionShortcut
Defines the GemFire ClientCache Region DataPolicy.
|
String[] |
indexableSessionAttributes
Identifies the Session attributes by name that should be indexed for query
operations.
|
int |
maxInactiveIntervalInSeconds
Defines the maximum interval in seconds that a Session can remain inactive before
it is considered expired.
|
String |
poolName
Specifies the name of the specific GemFire
Pool used
by the Spring Session Data GemFire client Region ('ClusteredSpringSessions') when performing
cache operations. |
String |
regionName
Defines the name of the GemFire (Client)Cache Region used to store Sessions.
|
com.gemstone.gemfire.cache.RegionShortcut |
serverRegionShortcut
Defines the GemFire, Peer Cache Region DataPolicy.
|
public abstract com.gemstone.gemfire.cache.client.ClientRegionShortcut clientRegionShortcut
ClientRegionShortcut
public abstract String[] indexableSessionAttributes
public abstract int maxInactiveIntervalInSeconds
public abstract String poolName
Pool
used
by the Spring Session Data GemFire client Region ('ClusteredSpringSessions') when performing
cache operations. This is attribute is only used in the client/server topology.Pool
to be used
by the client Region used to manage (HTTP) Sessions.GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME
public abstract String regionName
Region.getName()
public abstract com.gemstone.gemfire.cache.RegionShortcut serverRegionShortcut
RegionShortcut