@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 clientCacheFactoryBean = new CacheFactoryBean();
clientCacheFactoryBean.setLazyInitialize(false);
clientCacheFactoryBean.setProperties(gemfireProperties());
clientCacheFactoryBean.setUseBeanFactoryLocator(false);
return clientCacheFactoryBean;
}
}
Alternatively, a 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 clientCacheFactoryBean = new ClientCacheFactoryBean();
clientCacheFactoryBean.setLazyInitialize(false);
clientCacheFactoryBean.setProperties(gemfireProperties());
clientCacheFactoryBean.setUseBeanFactoryLocator(false);
return clientCacheFactoryBean;
}
}
More advanced configurations can extend GemFireHttpSessionConfiguration
instead.GemFireHttpSessionConfiguration
,
EnableSpringHttpSession
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 |
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 regionName
Region.getName()
public abstract com.gemstone.gemfire.cache.RegionShortcut serverRegionShortcut
RegionShortcut