Class GemFireHttpSessionConfiguration

java.lang.Object
org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration
org.springframework.session.data.gemfire.config.annotation.web.http.AbstractGemFireHttpSessionConfiguration
org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.context.annotation.ImportAware, org.springframework.context.ApplicationContextAware, org.springframework.context.EnvironmentAware

@Configuration @PropertySource(name="SpringSessionProperties", value="classpath:${spring-session-properties-location:spring-session.properties}", ignoreResourceNotFound=true) public class GemFireHttpSessionConfiguration extends AbstractGemFireHttpSessionConfiguration implements org.springframework.context.annotation.ImportAware
The GemFireHttpSessionConfiguration class is a Spring @Configuration class used to configure and initialize Pivotal GemFire/Apache Geode as a clustered, distributed and replicated HttpSession provider implementation in Spring Session.
Since:
1.1.0
See Also:
  • Field Details

    • DEFAULT_EXPOSE_CONFIGURATION_AS_PROPERTIES

      public static final boolean DEFAULT_EXPOSE_CONFIGURATION_AS_PROPERTIES
      Default expose Spring Session using Apache Geode or Pivotal GemFire configuration as Properties in Spring's Environment.
      See Also:
    • DEFAULT_USE_DATA_SERIALIZATION

      public static final boolean DEFAULT_USE_DATA_SERIALIZATION
      Indicates whether to employ Apache Geode/Pivotal's DataSerialization framework for Session de/serialization.
      See Also:
    • DEFAULT_MAX_INACTIVE_INTERVAL_IN_SECONDS

      public static final int DEFAULT_MAX_INACTIVE_INTERVAL_IN_SECONDS
      Default maximum interval in seconds in which a Session can remain inactive before it expires.
    • SESSION_REGION_KEY_CONSTRAINT

      protected static final Class<Object> SESSION_REGION_KEY_CONSTRAINT
      Key and Value class type constraints applied to the Session Region.
    • SESSION_REGION_VALUE_CONSTRAINT

      protected static final Class<AbstractGemFireOperationsSessionRepository.GemFireSession> SESSION_REGION_VALUE_CONSTRAINT
    • DEFAULT_CLIENT_REGION_SHORTCUT

      public static final org.apache.geode.cache.client.ClientRegionShortcut DEFAULT_CLIENT_REGION_SHORTCUT
      Default ClientRegionShortcut used to configure the data management policy of the ClientCache Region that will store Session state.
    • DEFAULT_IS_DIRTY_PREDICATE

      public static final IsDirtyPredicate DEFAULT_IS_DIRTY_PREDICATE
      Default IsDirtyPredicate strategy interface used to determine whether the users' application domain objects are dirty or not.
    • DEFAULT_SERVER_REGION_SHORTCUT

      public static final org.apache.geode.cache.RegionShortcut DEFAULT_SERVER_REGION_SHORTCUT
      Default RegionShortcut used to configure the data management policy of the Cache Region that will store Session state.
    • CONFIGURER_GET_CLIENT_REGION_SHORTCUT_METHOD_NAME

      public static final String CONFIGURER_GET_CLIENT_REGION_SHORTCUT_METHOD_NAME
    • CONFIGURER_GET_EXPOSE_CONFIGURATION_IN_PROPERTIES_METHOD_NAME

      public static final String CONFIGURER_GET_EXPOSE_CONFIGURATION_IN_PROPERTIES_METHOD_NAME
    • CONFIGURER_GET_INDEXABLE_SESSION_ATTRIBUTES_METHOD_NAME

      public static final String CONFIGURER_GET_INDEXABLE_SESSION_ATTRIBUTES_METHOD_NAME
    • CONFIGURER_GET_MAX_INACTIVE_INTERVAL_IN_SECONDS_METHOD_NAME

      public static final String CONFIGURER_GET_MAX_INACTIVE_INTERVAL_IN_SECONDS_METHOD_NAME
    • CONFIGURER_GET_POOL_NAME_METHOD_NAME

      public static final String CONFIGURER_GET_POOL_NAME_METHOD_NAME
    • CONFIGURER_GET_REGION_NAME_METHOD_NAME

      public static final String CONFIGURER_GET_REGION_NAME_METHOD_NAME
    • CONFIGURER_GET_SERVER_REGION_SHORTCUT_METHOD_NAME

      public static final String CONFIGURER_GET_SERVER_REGION_SHORTCUT_METHOD_NAME
    • CONFIGURER_GET_SESSION_EXPIRATION_POLICY_BEAN_NAME_METHOD_NAME

      public static final String CONFIGURER_GET_SESSION_EXPIRATION_POLICY_BEAN_NAME_METHOD_NAME
    • CONFIGURER_GET_SESSION_SERIALIZER_BEAN_NAME_METHOD_NAME

      public static final String CONFIGURER_GET_SESSION_SERIALIZER_BEAN_NAME_METHOD_NAME
    • DEFAULT_POOL_NAME

      public static final String DEFAULT_POOL_NAME
      Name of the connection Pool used by the client Region to send Session state to the cluster of Apache Geode servers.
      See Also:
    • DEFAULT_SESSION_EXPIRATION_POLICY_BEAN_NAME

      public static final String DEFAULT_SESSION_EXPIRATION_POLICY_BEAN_NAME
      Default name for the SessionExpirationPolicy bean.
      See Also:
    • DEFAULT_SESSION_REGION_NAME

      public static final String DEFAULT_SESSION_REGION_NAME
      Default name of (Client)Cache Region used to store Session state.
      See Also:
    • SESSION_DATA_SERIALIZER_BEAN_NAME

      public static final String SESSION_DATA_SERIALIZER_BEAN_NAME
      Set of defaults for Session serialization.
      See Also:
    • SESSION_PDX_SERIALIZER_BEAN_NAME

      public static final String SESSION_PDX_SERIALIZER_BEAN_NAME
      See Also:
    • SESSION_SERIALIZER_BEAN_ALIAS

      public static final String SESSION_SERIALIZER_BEAN_ALIAS
      See Also:
    • DEFAULT_SESSION_SERIALIZER_BEAN_NAME

      public static final String DEFAULT_SESSION_SERIALIZER_BEAN_NAME
      See Also:
    • SPRING_SESSION_DATA_GEMFIRE_SESSION_SERIALIZER_BEAN_NAME_PROPERTY

      public static final String SPRING_SESSION_DATA_GEMFIRE_SESSION_SERIALIZER_BEAN_NAME_PROPERTY
      See Also:
    • SPRING_SESSION_GEMFIRE_PROPERTY_SOURCE

      protected static final String SPRING_SESSION_GEMFIRE_PROPERTY_SOURCE
    • DEFAULT_INDEXABLE_SESSION_ATTRIBUTES

      public static final String[] DEFAULT_INDEXABLE_SESSION_ATTRIBUTES
      Defaults names of all Session attributes that will be indexed by Apache Geode.
  • Constructor Details

    • GemFireHttpSessionConfiguration

      public GemFireHttpSessionConfiguration()
  • Method Details

    • setClientRegionShortcut

      public void setClientRegionShortcut(org.apache.geode.cache.client.ClientRegionShortcut shortcut)
      Gets the ClientRegionShortcut used to configure the data management policy of the ClientCache Region that will store Session state. Defaults to ClientRegionShortcut.PROXY.
      Parameters:
      shortcut - ClientRegionShortcut used to configure the data management policy of the ClientCache Region.
      See Also:
    • getClientRegionShortcut

      public org.apache.geode.cache.client.ClientRegionShortcut getClientRegionShortcut()
      Gets the ClientRegionShortcut used to configure the data management policy of the ClientCache Region that will store Session state. Defaults to ClientRegionShortcut.PROXY.
      Returns:
      the ClientRegionShortcut used to configure the data management policy of the ClientCache Region.
      See Also:
      • ClientRegionShortcut
    • setExposeConfigurationAsProperties

      public void setExposeConfigurationAsProperties(boolean exposeConfigurationAsProperties)
      Sets whether to expose the configuration of Spring Session using Apache Geode or Pivotal GemFire as Properties in the Spring Environment.
      Parameters:
      exposeConfigurationAsProperties - boolean indicating whether to expose the configuration of Spring Session using Apache Geode or Pivotal GemFire as Properties in the Spring Environment.
      See Also:
    • isExposeConfigurationAsProperties

      public boolean isExposeConfigurationAsProperties()
      Determines whether the configuration for Spring Session using Apache Geode or Pivotal GemFire should be exposed in the Spring Environment as Properties. Currently, users may configure Spring Session for Apache Geode or Pivotal GemFire using attributes on this Annotation, using the well-known and documented Properties (e.g. spring.session.data.gemfire.session.expiration.max-inactive-interval-seconds) or using the SpringSessionGemFireConfigurer declared as a bean in the Spring application context. The Properties that are exposed will use the well-known property names that are documented in this Annotation's attributes. The values of the resulting Properties follows the precedence as outlined in the documentation: first any SpringSessionGemFireConfigurer bean defined takes precedence, followed by explicit Properties declared in Spring Boot application.properties and finally, this Annotation's attribute values. Defaults to false. Use spring.session.data.gemfire.session.configuration.expose in Spring Boot application.properties.
      Returns:
      a boolean value indicating whether to expose the configuration of Spring Session using Apache Geode or Pivotal GemFire in the Spring Environment as Properties.
    • setIndexableSessionAttributes

      public void setIndexableSessionAttributes(String[] indexableSessionAttributes)
      Sets the names of all Session attributes that will be indexed.
      Parameters:
      indexableSessionAttributes - an array of Strings containing the names of all Session attributes for which an Index will be created.
      See Also:
    • getIndexableSessionAttributes

      public String[] getIndexableSessionAttributes()
      Get the names of all Session attributes that will be indexed.
      Returns:
      an array of Strings containing the names of all Session attributes for which an Index will be created. Defaults to an empty array if unspecified.
    • setIsDirtyPredicate

      @Autowired(required=false) public void setIsDirtyPredicate(IsDirtyPredicate dirtyPredicate)
      Configures the IsDirtyPredicate strategy interface, as a bean from the Spring context, used to determine whether the users' application domain objects are dirty or not.
      Parameters:
      dirtyPredicate - IsDirtyPredicate strategy interface bean used to determine whether the users' application domain objects are dirty or not.
      See Also:
    • getIsDirtyPredicate

      public IsDirtyPredicate getIsDirtyPredicate()
      Returns the configured IsDirtyPredicate strategy interface bean, declared in the Spring context, used to determine whether the users' application domain objects are dirty or not. Defaults to DEFAULT_IS_DIRTY_PREDICATE.
      Returns:
      the configured IsDirtyPredicate strategy interface bean used to determine whether the users' application domain objects are dirty or not.
      See Also:
    • setMaxInactiveIntervalInSeconds

      public void setMaxInactiveIntervalInSeconds(int maxInactiveIntervalInSeconds)
      Sets the maximum interval in seconds in which a Session can remain inactive before it expires.
      Parameters:
      maxInactiveIntervalInSeconds - integer value specifying the maximum interval in seconds that a Session can remain inactive before it expires.
      See Also:
    • getMaxInactiveIntervalInSeconds

      public int getMaxInactiveIntervalInSeconds()
      Gets the maximum interval in seconds in which a Session can remain inactive before it expires.
      Returns:
      an integer value specifying the maximum interval in seconds that a Session can remain inactive before it expires.
    • setPoolName

      public void setPoolName(String poolName)
      Sets the name of the Pool used by the client Region to send Session to the cluster of servers during cache operations.
      Parameters:
      poolName - String containing the name of a Pool.
      See Also:
    • getPoolName

      public String getPoolName()
      Returns the name of the Pool used by the client Region to send Session to the cluster of servers during cache operations.
      Returns:
      a String containing the name of a Pool.
      See Also:
      • Pool.getName()
    • setServerRegionShortcut

      public void setServerRegionShortcut(org.apache.geode.cache.RegionShortcut shortcut)
      Sets the RegionShortcut used to configure the data management policy of the Cache Region that will store Session state. Defaults to RegionShortcut.PARTITION.
      Parameters:
      shortcut - RegionShortcut used to configure the data management policy of the Cache Region.
      See Also:
    • getServerRegionShortcut

      public org.apache.geode.cache.RegionShortcut getServerRegionShortcut()
      Gets the RegionShortcut used to configure the data management policy of the Cache Region that will store Session state. Defaults to RegionShortcut.PARTITION.
      Returns:
      the RegionShortcut used to configure the data management policy of the Cache Region.
      See Also:
      • RegionShortcut
    • setSessionExpirationPolicyBeanName

      public void setSessionExpirationPolicyBeanName(String sessionExpirationPolicyBeanName)
      Sets the name of the bean configured in the Spring application context implementing the SessionExpirationPolicy for Session expiration.
      Parameters:
      sessionExpirationPolicyBeanName - String containing the name of the bean configured in the Spring application context implementing the SessionExpirationPolicy for Session expiration.
    • getSessionExpirationPolicyBeanName

      public Optional<String> getSessionExpirationPolicyBeanName()
      Returns an Optional name of the bean configured in the Spring application context implementing the SessionExpirationPolicy for Session expiration.
      Returns:
      an Optional name of the bean configured in the Spring application context implementing the SessionExpirationPolicy for Session expiration.
    • setSessionRegionName

      public void setSessionRegionName(String sessionRegionName)
      Sets the name of the (Client)Cache Region used to store Session state.
      Parameters:
      sessionRegionName - String specifying the name of the (Client)Cache Region used to store Session state.
      See Also:
    • getSessionRegionName

      public String getSessionRegionName()
      Returns the name of the (Client)Cache Region used to store Session state.
      Returns:
      a String specifying the name of the (Client)Cache Region used to store Session state.
      See Also:
      • Region.getName()
    • setSessionSerializerBeanName

      public void setSessionSerializerBeanName(String sessionSerializerBeanName)
      Sets the bean name of the Spring bean declared in the Spring application context defining the serialization strategy for serializing the Session. The serialization strategy and bean referred to by its name must be an implementation of SessionSerializer. Defaults to SessionDataSerializer.
      Parameters:
      sessionSerializerBeanName - bean name of the SessionSerializer used to serialize the Session.
      See Also:
    • getSessionSerializerBeanName

      public String getSessionSerializerBeanName()
      Returns the configured bean name of the Spring bean declared in the Spring application context defining the serialization strategy for serializing the Session. The serialization strategy and bean referred to by its name must be an implementation of SessionSerializer. Defaults to SessionDataSerializer.
      Returns:
      the bean name of the SessionSerializer used to serialize the Session.
      See Also:
    • isUsingDataSerialization

      protected boolean isUsingDataSerialization()
      Determine whether the configured serialization strategy is using Apache Geode / Pivotal GemFire's DataSerialization framework.
      Returns:
      a boolean value indicating whether the configured serialization strategy is using Apache Geode / Pivotal GemFire's DataSerialization framework.
      See Also:
    • setImportMetadata

      public void setImportMetadata(org.springframework.core.type.AnnotationMetadata importMetadata)
      Callback with the AnnotationMetadata of the class containing @Import annotation that imported this @Configuration class. The @Configuration class should also be annotated with EnableGemFireHttpSession.
      Specified by:
      setImportMetadata in interface org.springframework.context.annotation.ImportAware
      Parameters:
      importMetadata - AnnotationMetadata of the application class importing this Configuration class.
      See Also:
      • AnnotationMetadata
      • applySpringSessionGemFireConfigurer()
      • exposeSpringSessionGemFireConfiguration()
    • registerSessionSerializerBeanAlias

      @PostConstruct public void registerSessionSerializerBeanAlias()
    • sessionDataSerializer

      @Bean("SessionDataSerializer") public Object sessionDataSerializer()
      SessionSerializer bean implemented with Apache Geode/Pivotal GemFire DataSerialization framework.
      Returns:
      a DataSerialization SessionSerializer implementation.
      See Also:
    • sessionPdxSerializer

      @Bean("SessionPdxSerializer") public Object sessionPdxSerializer()
      SessionSerializer bean implemented with Apache Geode/Pivotal GemFire PDX serialization framework.
      Returns:
      a PDX serialization SessionSerializer implementation.
      See Also:
    • sessionRegion

      @Bean(name="ClusteredSpringSessions") public SessionCacheTypeAwareRegionFactoryBean<Object,org.springframework.session.Session> sessionRegion(org.apache.geode.cache.GemFireCache gemfireCache, @Qualifier("sessionRegionAttributes") org.apache.geode.cache.RegionAttributes<Object,org.springframework.session.Session> sessionRegionAttributes)
      Defines the Region used to store and manage Session state in either a client-server or peer-to-peer (p2p) topology.
      Parameters:
      gemfireCache - reference to the GemFireCache.
      sessionRegionAttributes - RegionAttributes used to configure the Region.
      Returns:
      a SessionCacheTypeAwareRegionFactoryBean used to configure and initialize the cache Region used to store and manage Session state.
      See Also:
    • sessionRegionAttributes

      @Bean public org.springframework.data.gemfire.RegionAttributesFactoryBean sessionRegionAttributes(org.apache.geode.cache.GemFireCache gemfireCache)
      Defines a RegionAttributes used to configure and initialize the cache Region used to store Session state. Expiration is also configured for the Region on the basis that the cache Region is a not a proxy on either the client or server.
      Parameters:
      gemfireCache - reference to the GemFireCache.
      Returns:
      an instance of RegionAttributes used to configure and initialize cache Region used to store and manage Session state.
      See Also:
      • RegionAttributesFactoryBean
      • GemFireCache
      • PartitionAttributes
      • isExpirationAllowed(GemFireCache)
    • sessionRegionTemplate

      @Bean @DependsOn("ClusteredSpringSessions") public org.springframework.data.gemfire.GemfireTemplate sessionRegionTemplate(org.apache.geode.cache.GemFireCache gemfireCache)
      Defines a GemfireTemplate bean used to interact with the (Client)Cache Region used to store Session state.
      Parameters:
      gemfireCache - reference to the single GemFireCache instance used by the GemfireTemplate to perform cache Region data access operations.
      Returns:
      a GemfireTemplate used to interact with the (Client)Cache Region used to store Session state.
      See Also:
    • sessionRepository

      @Bean public GemFireOperationsSessionRepository sessionRepository(@Qualifier("sessionRegionTemplate") org.springframework.data.gemfire.GemfireOperations gemfireOperations)
      Defines the SessionRepository bean used to interact with Apache Geode or Pivotal GemFire as the Spring Session provider.
      Parameters:
      gemfireOperations - instance of GemfireOperations used to manage Session state in Apache Geode or Pivotal GemFire.
      Returns:
      a GemFireOperationsSessionRepository for managing (clustering/replicating) Session state in Apache Geode or Pivotal GemFire.
      See Also:
    • principalNameIndex

      @Bean @DependsOn("ClusteredSpringSessions") @Profile("!disable-spring-session-data-gemfire-indexes") public org.springframework.data.gemfire.IndexFactoryBean principalNameIndex(org.apache.geode.cache.GemFireCache gemfireCache)
      Defines an OQL Index bean on the GemFireCache Region storing and managing Sessions, specifically on the principalName property for quick lookup of Sessions by principalName.
      Parameters:
      gemfireCache - reference to the GemFireCache.
      Returns:
      a IndexFactoryBean to create an OQL Index on the principalName property for Sessions stored in the GemFireCache Region.
      See Also:
      • IndexFactoryBean
      • GemFireCache
    • sessionAttributesIndex

      @Bean @DependsOn("ClusteredSpringSessions") @Profile("!disable-spring-session-data-gemfire-indexes") public SessionAttributesIndexFactoryBean sessionAttributesIndex(org.apache.geode.cache.GemFireCache gemfireCache)
      Defines an OQL Index bean on the GemFireCache Region storing and managing Sessions, specifically on all Session attributes for quick lookup and queries on Session attribute names with a given value.
      Parameters:
      gemfireCache - reference to the GemFireCache.
      Returns:
      a IndexFactoryBean to create an OQL Index on attributes of Sessions stored in the GemFireCache Region.
      See Also:
      • IndexFactoryBean
      • GemFireCache