org.springframework.session.data.gemfire

## Class GemFireOperationsSessionRepository

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

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>

    public class GemFireOperationsSessionRepository
    extends AbstractGemFireOperationsSessionRepository

The `GemFireOperationsSessionRepository` class is a Spring `SessionRepository` implementation that interfaces with and uses GemFire to back and store Spring Sessions.

Since:
  1.1.0
See Also:
  `GemfireOperations`, `ExpiringSession`, `AbstractGemFireOperationsSessionRepository`

### Nested Class Summary

### Nested classes/interfaces inherited from class org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository

`AbstractGemFireOperationsSessionRepository.GemFireSession, AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes, AbstractGemFireOperationsSessionRepository.GemFireSessionAttributesInstantiator, AbstractGemFireOperationsSessionRepository.GemFireSessionInstantiator`

### Field Summary

Fields
`protected static java.lang.String` `FIND_SESSIONS_BY_INDEX_NAME_VALUE_QUERY`
`protected static java.lang.String` `FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY`

### Fields inherited from class org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository

`logger`

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

`PRINCIPAL_NAME_INDEX_NAME`

### Constructor Summary

Constructors
Constructor and Description
`GemFireOperationsSessionRepository(org.springframework.data.gemfire.GemfireOperations template)` Constructs an instance of GemFireOperationsSessionRepository initialized with the required GemfireOperations object used to perform data access operations to manage Session state.

### Method Summary

All Methods Instance Methods Concrete Methods
`org.springframework.session.ExpiringSession` `createSession()` Constructs a new `ExpiringSession` instance backed by GemFire.
`void` `delete(java.lang.String sessionId)` Deletes (removes) any existing `ExpiringSession` from GemFire.
`java.util.Map<java.lang.String,org.springframework.session.ExpiringSession>` `findByIndexNameAndIndexValue(java.lang.String indexName, java.lang.String indexValue)` Looks up all available Sessions with the particular attribute indexed by name having the given value.
`org.springframework.session.ExpiringSession` `getSession(java.lang.String sessionId)` Gets a copy of an existing, non-expired `ExpiringSession` by ID.
`protected java.lang.String` `prepareQuery(java.lang.String indexName)` Prepares the appropriate GemFire OQL query based on the indexed Session attribute name.
`void` `save(org.springframework.session.ExpiringSession session)` Saves the specified `ExpiringSession` to GemFire.

### Methods inherited from class org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository

`afterCreate, afterDestroy, afterInvalidate, afterPropertiesSet, delete, getApplicationEventPublisher, getFullyQualifiedRegionName, getMaxInactiveIntervalInSeconds, getTemplate, handleCreated, handleDeleted, handleDestroyed, handleExpired, publishEvent, setApplicationEventPublisher, setMaxInactiveIntervalInSeconds, touch`

### 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`

### Field Detail

#### FIND_SESSIONS_BY_INDEX_NAME_VALUE_QUERY

    protected static final java.lang.String FIND_SESSIONS_BY_INDEX_NAME_VALUE_QUERY

See Also:
  Constant Field Values

#### FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY

    protected static final java.lang.String FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY

See Also:
  Constant Field Values

### Constructor Detail

#### GemFireOperationsSessionRepository

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

Constructs an instance of GemFireOperationsSessionRepository initialized with the required GemfireOperations object used to perform data access operations to manage Session state.

Parameters:
  `template` - the GemfireOperations object used to access and manage Session state in GemFire.
See Also:
  `GemfireOperations`

### Method Detail

#### findByIndexNameAndIndexValue

    public java.util.Map<java.lang.String,org.springframework.session.ExpiringSession> findByIndexNameAndIndexValue(java.lang.String indexName,
                                                                                                                    java.lang.String indexValue)

Looks up all available Sessions with the particular attribute indexed by name having the given value.

Parameters:
  `indexName` - name of the indexed Session attribute. (e.g. `FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME` ).
  `indexValue` - value of the indexed Session attribute to search on (e.g. username).
Returns:
  a mapping of Session ID to Session instances.
See Also:
  `ExpiringSession`, `Map`, `prepareQuery(String)`

#### prepareQuery

    protected java.lang.String prepareQuery(java.lang.String indexName)

Prepares the appropriate GemFire OQL query based on the indexed Session attribute name.

Parameters:
  `indexName` - a String indicating the name of the indexed Session attribute.
Returns:
  an appropriate GemFire OQL statement for querying on a particular indexed Session attribute.

#### createSession

    public org.springframework.session.ExpiringSession createSession()

Constructs a new `ExpiringSession` instance backed by GemFire.

Returns:
  an instance of `ExpiringSession` backed by GemFire.
See Also:
  `AbstractGemFireOperationsSessionRepository.GemFireSession.create(int)`, `ExpiringSession`, `AbstractGemFireOperationsSessionRepository.getMaxInactiveIntervalInSeconds()`

#### getSession

    public org.springframework.session.ExpiringSession getSession(java.lang.String sessionId)

Gets a copy of an existing, non-expired `ExpiringSession` by ID. If the Session is expired, then it is deleted.

Parameters:
  `sessionId` - a String indicating the ID of the Session to get.
Returns:
  an existing `ExpiringSession` by ID or null if not Session exists.
See Also:
  `AbstractGemFireOperationsSessionRepository.GemFireSession.from(ExpiringSession)`, `ExpiringSession`, `delete(String)`

#### save

    public void save(org.springframework.session.ExpiringSession session)

Saves the specified `ExpiringSession` to GemFire.

Parameters:
  `session` - the `ExpiringSession` to save.
See Also:
  `GemfireOperations.put(Object, Object)`, `ExpiringSession`

#### delete

    public void delete(java.lang.String sessionId)

Deletes (removes) any existing `ExpiringSession` from GemFire. This operation also results in a SessionDeletedEvent.

Parameters:
  `sessionId` - a String indicating the ID of the Session to remove from GemFire.
See Also:
  `GemfireOperations.remove(Object)`, `AbstractGemFireOperationsSessionRepository.handleDeleted(String, ExpiringSession)`