org.springframework.session.data.gemfire

## Class AbstractGemFireOperationsSessionRepository

- java.lang.Object
- - org.apache.geode.cache.util.CacheListenerAdapter<java.lang.Object,org.springframework.session.ExpiringSession>
  - - org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository

All Implemented Interfaces:
  org.apache.geode.cache.CacheCallback, org.apache.geode.cache.CacheListener<java.lang.Object,org.springframework.session.ExpiringSession>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware, org.springframework.session.FindByIndexNameSessionRepository<org.springframework.session.ExpiringSession>, org.springframework.session.SessionRepository<org.springframework.session.ExpiringSession>

Direct Known Subclasses:
  GemFireOperationsSessionRepository

    public abstract class AbstractGemFireOperationsSessionRepository
    extends org.apache.geode.cache.util.CacheListenerAdapter<java.lang.Object,org.springframework.session.ExpiringSession>
    implements org.springframework.context.ApplicationEventPublisherAware, org.springframework.session.FindByIndexNameSessionRepository<org.springframework.session.ExpiringSession>, org.springframework.beans.factory.InitializingBean

`AbstractGemFireOperationsSessionRepository` is an abstract base class encapsulating functionality common to all implementations that support `SessionRepository` operations backed by Apache Geode.

Since:
  1.1.0
See Also:
  `DataSerializable`, `DataSerializer`, `Delta`, `Instantiator`, `Region`, `CacheListenerAdapter`, `InitializingBean`, `ApplicationEventPublisher`, `ApplicationEventPublisherAware`, `GemfireOperations`, `Expression`, `ExpiringSession`, `FindByIndexNameSessionRepository`, `Session`, `SessionRepository`, `GemFireHttpSessionConfiguration`, `EnableGemFireHttpSession`

### Nested Class Summary

Nested Classes
`static class` `AbstractGemFireOperationsSessionRepository.GemFireSession` GemFireSession is a GemFire representation model of a Spring `ExpiringSession` that stores and manages Session state information in GemFire.
`static class` `AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes` The GemFireSessionAttributes class is a container for Session attributes implementing both the `DataSerializable` and `Delta` GemFire interfaces for efficient storage and distribution (replication) in GemFire.
`static class` `AbstractGemFireOperationsSessionRepository.GemFireSessionAttributesInstantiator` GemFireSessionAttributesInstantiator is a GemFire `Instantiator` use to instantiate instances of the `AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes` object used in GemFire's data serialization framework when persisting Session attributes state in GemFire.
`static class` `AbstractGemFireOperationsSessionRepository.GemFireSessionInstantiator` GemFireSessionInstantiator is a GemFire `Instantiator` use to instantiate instances of the `AbstractGemFireOperationsSessionRepository.GemFireSession` object used in GemFire's data serialization framework when persisting Session state in GemFire.

### Field Summary

Fields
`protected org.apache.commons.logging.Log` `logger`

### Fields inherited from interface org.springframework.session.FindByIndexNameSessionRepository

`PRINCIPAL_NAME_INDEX_NAME`

### Constructor Summary

Constructors
Constructor and Description
`AbstractGemFireOperationsSessionRepository(org.springframework.data.gemfire.GemfireOperations template)` Constructs an instance of AbstractGemFireOperationsSessionRepository with a required GemfireOperations instance used to perform GemFire data access operations and interactions supporting the SessionRepository operations.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `afterCreate(org.apache.geode.cache.EntryEvent<java.lang.Object,org.springframework.session.ExpiringSession> event)` Callback method triggered when an entry is created in the GemFire cache `Region`.
`void` `afterDestroy(org.apache.geode.cache.EntryEvent<java.lang.Object,org.springframework.session.ExpiringSession> event)` Callback method triggered when an entry is destroyed in the GemFire cache `Region`.
`void` `afterInvalidate(org.apache.geode.cache.EntryEvent<java.lang.Object,org.springframework.session.ExpiringSession> event)` Callback method triggered when an entry is invalidated in the GemFire cache `Region`.
`void` `afterPropertiesSet()` Callback method during Spring bean initialization that will capture the fully-qualified name of the GemFire cache `Region` used to manage Session state and register this SessionRepository as a GemFire `CacheListener`.
`protected org.springframework.session.ExpiringSession` `delete(org.springframework.session.Session session)` Deletes the given `Session` from GemFire.
`protected org.springframework.context.ApplicationEventPublisher` `getApplicationEventPublisher()` Gets the ApplicationEventPublisher used to publish Session events corresponding to GemFire cache events.
`protected java.lang.String` `getFullyQualifiedRegionName()` Gets the fully-qualified name of the GemFire cache `Region` used to store and manage Session data.
`int` `getMaxInactiveIntervalInSeconds()` Gets the maximum interval in seconds in which a Session can remain inactive before it is considered expired.
`org.springframework.data.gemfire.GemfireOperations` `getTemplate()` Gets a reference to the GemfireOperations (template) used to perform data access operations and other interactions on the GemFire cache `Region` backing this SessionRepository.
`protected void` `handleCreated(java.lang.String sessionId, org.springframework.session.ExpiringSession session)` Causes Session created events to be published to the Spring application context.
`protected void` `handleDeleted(java.lang.String sessionId, org.springframework.session.ExpiringSession session)` Causes Session deleted events to be published to the Spring application context.
`protected void` `handleDestroyed(java.lang.String sessionId, org.springframework.session.ExpiringSession session)` Causes Session destroyed events to be published to the Spring application context.
`protected void` `handleExpired(java.lang.String sessionId, org.springframework.session.ExpiringSession session)` Causes Session expired events to be published to the Spring application context.
`protected void` `publishEvent(org.springframework.context.ApplicationEvent event)` Publishes the specified ApplicationEvent to the Spring application context.
`void` `setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)` Sets the ApplicationEventPublisher used to publish Session events corresponding to GemFire cache events.
`void` `setMaxInactiveIntervalInSeconds(int maxInactiveIntervalInSeconds)` Sets the maximum interval in seconds in which a Session can remain inactive before it is considered expired.
`protected <T extends org.springframework.session.ExpiringSession> T` `touch(T expiringSession)` Updates the `ExpiringSession.setLastAccessedTime(long)` property of the `ExpiringSession`.

### Methods inherited from class org.apache.geode.cache.util.CacheListenerAdapter

`afterRegionClear, afterRegionCreate, afterRegionDestroy, afterRegionInvalidate, afterRegionLive, afterUpdate, close`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.springframework.session.FindByIndexNameSessionRepository

`findByIndexNameAndIndexValue`

### Methods inherited from interface org.springframework.session.SessionRepository

`createSession, delete, getSession, save`

### Field Detail

#### logger

    protected final org.apache.commons.logging.Log logger

### Constructor Detail

#### AbstractGemFireOperationsSessionRepository

    public AbstractGemFireOperationsSessionRepository(org.springframework.data.gemfire.GemfireOperations template)

Constructs an instance of AbstractGemFireOperationsSessionRepository with a required GemfireOperations instance used to perform GemFire data access operations and interactions supporting the SessionRepository operations.

Parameters:
  `template` - the GemfireOperations instance used to interact with GemFire.
See Also:
  `GemfireOperations`

### Method Detail

#### setApplicationEventPublisher

    public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)

Sets the ApplicationEventPublisher used to publish Session events corresponding to GemFire cache events.

Specified by:
  `setApplicationEventPublisher` in interface `org.springframework.context.ApplicationEventPublisherAware`
Parameters:
  `applicationEventPublisher` - the Spring ApplicationEventPublisher used to publish Session-based events.
See Also:
  `ApplicationEventPublisher`

#### getApplicationEventPublisher

    protected org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()

Gets the ApplicationEventPublisher used to publish Session events corresponding to GemFire cache events.

Returns:
  the Spring ApplicationEventPublisher used to publish Session-based events.
See Also:
  `ApplicationEventPublisher`

#### getFullyQualifiedRegionName

    protected java.lang.String getFullyQualifiedRegionName()

Gets the fully-qualified name of the GemFire cache `Region` used to store and manage Session data.

Returns:
  a String indicating the fully qualified name of the GemFire cache `Region` used to store and manage Session data.

#### setMaxInactiveIntervalInSeconds

    public void setMaxInactiveIntervalInSeconds(int maxInactiveIntervalInSeconds)

Sets the maximum interval in seconds in which a Session can remain inactive before it is considered expired.

Parameters:
  `maxInactiveIntervalInSeconds` - an integer value specifying the maximum interval in seconds that a Session can remain inactive before it is considered expired.

#### getMaxInactiveIntervalInSeconds

    public int getMaxInactiveIntervalInSeconds()

Gets the maximum interval in seconds in which a Session can remain inactive before it is considered expired.

Returns:
  an integer value specifying the maximum interval in seconds that a Session can remain inactive before it is considered expired.

#### getTemplate

    public org.springframework.data.gemfire.GemfireOperations getTemplate()

Gets a reference to the GemfireOperations (template) used to perform data access operations and other interactions on the GemFire cache `Region` backing this SessionRepository.

Returns:
  a reference to the GemfireOperations used to interact with GemFire.
See Also:
  `GemfireOperations`

#### afterPropertiesSet

    public void afterPropertiesSet()
                            throws java.lang.Exception

Callback method during Spring bean initialization that will capture the fully-qualified name of the GemFire cache `Region` used to manage Session state and register this SessionRepository as a GemFire `CacheListener`. Additionally, this method registers GemFire `Instantiator`s for the `AbstractGemFireOperationsSessionRepository.GemFireSession` and `AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes` types to optimize GemFire's instantiation logic on deserialization using the data serialization framework when accessing the `Session`'s state stored in GemFire.

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
Throws:
  `java.lang.Exception` - if an error occurs during the initialization process.

#### afterCreate

    public void afterCreate(org.apache.geode.cache.EntryEvent<java.lang.Object,org.springframework.session.ExpiringSession> event)

Callback method triggered when an entry is created in the GemFire cache `Region`.

Specified by:
  `afterCreate` in interface `org.apache.geode.cache.CacheListener<java.lang.Object,org.springframework.session.ExpiringSession>`
Overrides:
  `afterCreate` in class `org.apache.geode.cache.util.CacheListenerAdapter<java.lang.Object,org.springframework.session.ExpiringSession>`
Parameters:
  `event` - `EntryEvent` containing the details of the cache `Region` operation.
See Also:
  `EntryEvent`, `handleCreated(String, ExpiringSession)`

#### afterDestroy

    public void afterDestroy(org.apache.geode.cache.EntryEvent<java.lang.Object,org.springframework.session.ExpiringSession> event)

Callback method triggered when an entry is destroyed in the GemFire cache `Region`.

Specified by:
  `afterDestroy` in interface `org.apache.geode.cache.CacheListener<java.lang.Object,org.springframework.session.ExpiringSession>`
Overrides:
  `afterDestroy` in class `org.apache.geode.cache.util.CacheListenerAdapter<java.lang.Object,org.springframework.session.ExpiringSession>`
Parameters:
  `event` - an EntryEvent containing the details of the cache operation.
See Also:
  `EntryEvent`, `handleDestroyed(String, ExpiringSession)`

#### afterInvalidate

    public void afterInvalidate(org.apache.geode.cache.EntryEvent<java.lang.Object,org.springframework.session.ExpiringSession> event)

Callback method triggered when an entry is invalidated in the GemFire cache `Region`.

Specified by:
  `afterInvalidate` in interface `org.apache.geode.cache.CacheListener<java.lang.Object,org.springframework.session.ExpiringSession>`
Overrides:
  `afterInvalidate` in class `org.apache.geode.cache.util.CacheListenerAdapter<java.lang.Object,org.springframework.session.ExpiringSession>`
Parameters:
  `event` - an EntryEvent containing the details of the cache operation.
See Also:
  `EntryEvent`, `handleExpired(String, ExpiringSession)`

#### delete

    protected org.springframework.session.ExpiringSession delete(org.springframework.session.Session session)

Deletes the given `Session` from GemFire.

Parameters:
  `session` - `Session` to delete.
Returns:
  null.
See Also:
  `Session`, `SessionRepository.delete(String)`

#### handleCreated

    protected void handleCreated(java.lang.String sessionId,
                                 org.springframework.session.ExpiringSession session)

Causes Session created events to be published to the Spring application context.

Parameters:
  `sessionId` - a String indicating the ID of the Session.
  `session` - a reference to the Session triggering the event.
See Also:
  `SessionCreatedEvent`, `ExpiringSession`, `publishEvent(ApplicationEvent)`

#### handleDeleted

    protected void handleDeleted(java.lang.String sessionId,
                                 org.springframework.session.ExpiringSession session)

Causes Session deleted events to be published to the Spring application context.

Parameters:
  `sessionId` - a String indicating the ID of the Session.
  `session` - a reference to the Session triggering the event.
See Also:
  `SessionDeletedEvent`, `ExpiringSession`, `publishEvent(ApplicationEvent)`

#### handleDestroyed

    protected void handleDestroyed(java.lang.String sessionId,
                                   org.springframework.session.ExpiringSession session)

Causes Session destroyed events to be published to the Spring application context.

Parameters:
  `sessionId` - a String indicating the ID of the Session.
  `session` - a reference to the Session triggering the event.
See Also:
  `SessionDestroyedEvent`, `ExpiringSession`, `publishEvent(ApplicationEvent)`

#### handleExpired

    protected void handleExpired(java.lang.String sessionId,
                                 org.springframework.session.ExpiringSession session)

Causes Session expired events to be published to the Spring application context.

Parameters:
  `sessionId` - a String indicating the ID of the Session.
  `session` - a reference to the Session triggering the event.
See Also:
  `SessionExpiredEvent`, `ExpiringSession`, `publishEvent(ApplicationEvent)`

#### publishEvent

    protected void publishEvent(org.springframework.context.ApplicationEvent event)

Publishes the specified ApplicationEvent to the Spring application context.

Parameters:
  `event` - the ApplicationEvent to publish.
See Also:
  `ApplicationEventPublisher.publishEvent(ApplicationEvent)`, `ApplicationEvent`

#### touch

    protected <T extends org.springframework.session.ExpiringSession> T touch(T expiringSession)

Updates the `ExpiringSession.setLastAccessedTime(long)` property of the `ExpiringSession`.

Type Parameters:
  `T` - `Class` sub-type of the `ExpiringSession`.
Parameters:
  `expiringSession` - `ExpiringSession` to touch.
Returns:
  the `ExpiringSession`.
See Also:
  `ExpiringSession.setLastAccessedTime(long)`