org.springframework.session.data.gemfire.config.annotation.web.http.support

## Class GemFireCacheTypeAwareRegionFactoryBean<K,V>

- java.lang.Object
- - org.springframework.session.data.gemfire.config.annotation.web.http.support.GemFireCacheTypeAwareRegionFactoryBean<K,V>

Type Parameters:
  `K` - the type of keys
  `V` - the type of values

All Implemented Interfaces:
  org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.FactoryBean<org.apache.geode.cache.Region<K,V>>, org.springframework.beans.factory.InitializingBean

    public class GemFireCacheTypeAwareRegionFactoryBean<K,V>
    extends java.lang.Object
    implements org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.FactoryBean<org.apache.geode.cache.Region<K,V>>, org.springframework.beans.factory.InitializingBean

The `GemFireCacheTypeAwareRegionFactoryBean` class is a Spring `FactoryBean` used to construct, configure and initialize the GemFire cache `Region` used to store and manage Session state.

Since:
  1.1.0
See Also:
  `GemFireCache`, `Region`, `RegionAttributes`, `RegionShortcut`, `ClientRegionShortcut`, `Pool`, `BeanFactory`, `BeanFactoryAware`, `FactoryBean`, `InitializingBean`, `GenericRegionFactoryBean`, `ClientRegionFactoryBean`, `GemFireHttpSessionConfiguration`

### Field Summary

Fields
`protected static org.apache.geode.cache.client.ClientRegionShortcut` `DEFAULT_CLIENT_REGION_SHORTCUT`
`protected static java.lang.String` `DEFAULT_GEMFIRE_POOL_NAME`
`protected static org.apache.geode.cache.RegionShortcut` `DEFAULT_SERVER_REGION_SHORTCUT`
`protected static java.lang.String` `DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME`

### Constructor Summary

Constructors
Constructor and Description
`GemFireCacheTypeAwareRegionFactoryBean()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `afterPropertiesSet()` Post-construction initialization callback to create, configure and initialize the GemFire cache `Region` used to store, replicate (distribute) and manage Session state.
`protected org.springframework.beans.factory.BeanFactory` `getBeanFactory()` Gets a reference to the Spring `BeanFactory` responsible for creating GemFire components.
`protected org.apache.geode.cache.client.ClientRegionShortcut` `getClientRegionShortcut()` Returns the `Region` data policy used by the GemFire cache client to manage Session state.
`protected org.apache.geode.cache.GemFireCache` `getGemfireCache()` Returns a reference to the GemFire cache used to construct the appropriate `Region`.
`org.apache.geode.cache.Region<K,V>` `getObject()` Returns a reference to the constructed GemFire cache `Region` used to store and manage Session state.
`java.lang.Class<?>` `getObjectType()` Returns the specific type of GemFire cache `Region` this factory creates when initialized or Region.class when uninitialized.
`protected java.lang.String` `getPoolName()` Returns the name of the GemFire `Pool` used by the client Region for managing Sessions during cache operations involving the server.
`protected org.apache.geode.cache.RegionAttributes<K,V>` `getRegionAttributes()` Returns the GemFire `RegionAttributes` used to configure the GemFire cache `Region` used to store and manage Session state.
`protected java.lang.String` `getRegionName()` Returns the configured name of the GemFire cache `Region` use to store and manage Session state.
`protected org.apache.geode.cache.RegionShortcut` `getServerRegionShortcut()` Returns the `Region` data policy used by the GemFire peer cache to manage Session state.
`boolean` `isSingleton()` Returns true indicating the GemFire cache `Region` created by this factory is the sole instance.
`protected org.apache.geode.cache.Region<K,V>` `newClientRegion(org.apache.geode.cache.GemFireCache gemfireCache)` Constructs a GemFire cache `Region` using the client-server GemFire topology to store and manage Session state in a GemFire server cluster accessible from a GemFire cache client.
`protected org.apache.geode.cache.Region<K,V>` `newServerRegion(org.apache.geode.cache.GemFireCache gemfireCache)` Constructs a GemFire cache `Region` using a peer-to-peer (p2p) GemFire topology to store and manage Session state in a GemFire server cluster accessible from a GemFire cache client.
`protected org.springframework.data.gemfire.client.Interest<K>[]` `registerInterests(boolean register)` Decides whether interests will be registered for all keys.
`void` `setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)` Sets a reference to the Spring `BeanFactory` responsible for creating GemFire components.
`void` `setClientRegionShortcut(org.apache.geode.cache.client.ClientRegionShortcut clientRegionShortcut)` Sets the `Region` data policy used by the GemFire cache client to manage Session state.
`void` `setGemfireCache(org.apache.geode.cache.GemFireCache gemfireCache)` Sets a reference to the GemFire cache used to construct the appropriate `Region`.
`void` `setPoolName(java.lang.String poolName)` Sets the name of the GemFire `Pool` used by the client Region for managing Sessions during cache operations involving the server.
`void` `setRegionAttributes(org.apache.geode.cache.RegionAttributes<K,V> regionAttributes)` Sets the GemFire `RegionAttributes` used to configure the GemFire cache `Region` used to store and manage Session state.
`void` `setRegionName(java.lang.String regionName)` Sets the name of the GemFire cache `Region` use to store and manage Session state.
`void` `setServerRegionShortcut(org.apache.geode.cache.RegionShortcut serverRegionShortcut)` Sets the `Region` data policy used by the GemFire peer cache to manage Session state.

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

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

### Field Detail

#### DEFAULT_CLIENT_REGION_SHORTCUT

    protected static final org.apache.geode.cache.client.ClientRegionShortcut DEFAULT_CLIENT_REGION_SHORTCUT

#### DEFAULT_SERVER_REGION_SHORTCUT

    protected static final org.apache.geode.cache.RegionShortcut DEFAULT_SERVER_REGION_SHORTCUT

#### DEFAULT_GEMFIRE_POOL_NAME

    protected static final java.lang.String DEFAULT_GEMFIRE_POOL_NAME

See Also:
  Constant Field Values

#### DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME

    protected static final java.lang.String DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME

See Also:
  Constant Field Values

### Constructor Detail

#### GemFireCacheTypeAwareRegionFactoryBean

    public GemFireCacheTypeAwareRegionFactoryBean()

### Method Detail

#### afterPropertiesSet

    public void afterPropertiesSet()
                            throws java.lang.Exception

Post-construction initialization callback to create, configure and initialize the GemFire cache `Region` used to store, replicate (distribute) and manage Session state. This method intelligently handles both client-server and peer-to-peer (p2p) GemFire supported distributed system topologies.

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
Throws:
  `java.lang.Exception` - if the initialization of the GemFire cache `Region` fails.
See Also:
  `GemFireUtils.isClient(GemFireCache)`, `getGemfireCache()`, `newClientRegion(GemFireCache)`, `newServerRegion(GemFireCache)`

#### newServerRegion

    protected org.apache.geode.cache.Region<K,V> newServerRegion(org.apache.geode.cache.GemFireCache gemfireCache)
                                                          throws java.lang.Exception

Constructs a GemFire cache `Region` using a peer-to-peer (p2p) GemFire topology to store and manage Session state in a GemFire server cluster accessible from a GemFire cache client.

Parameters:
  `gemfireCache` - a reference to the GemFire `Cache`.
Returns:
  a peer-to-peer-based GemFire cache `Region` to store and manage Session state.
Throws:
  `java.lang.Exception` - if the instantiation, configuration and initialization of the GemFire cache `Region` fails.
See Also:
  `GenericRegionFactoryBean`, `GemFireCache`, `Region`, `getRegionAttributes()`, `getRegionName()`, `getServerRegionShortcut()`

#### newClientRegion

    protected org.apache.geode.cache.Region<K,V> newClientRegion(org.apache.geode.cache.GemFireCache gemfireCache)
                                                          throws java.lang.Exception

Constructs a GemFire cache `Region` using the client-server GemFire topology to store and manage Session state in a GemFire server cluster accessible from a GemFire cache client.

Parameters:
  `gemfireCache` - a reference to the GemFire `Cache`.
Returns:
  a client-server-based GemFire cache `Region` to store and manage Session state.
Throws:
  `java.lang.Exception` - if the instantiation, configuration and initialization of the GemFire cache `Region` fails.
See Also:
  `ClientRegionFactoryBean`, `GemFireCache`, `Region`, `getClientRegionShortcut()`, `getRegionAttributes()`, `getRegionName()`, `registerInterests(boolean)`

#### registerInterests

    protected org.springframework.data.gemfire.client.Interest<K>[] registerInterests(boolean register)

Decides whether interests will be registered for all keys. Interests is only registered on a client and typically only when the client is a (CACHING) PROXY to the server (i.e. non-LOCAL only).

Parameters:
  `register` - a boolean value indicating whether interests should be registered.
Returns:
  an array of Interests KEY/VALUE registrations.
See Also:
  `Interest`

#### getObject

    public org.apache.geode.cache.Region<K,V> getObject()
                                                 throws java.lang.Exception

Returns a reference to the constructed GemFire cache `Region` used to store and manage Session state.

Specified by:
  `getObject` in interface `org.springframework.beans.factory.FactoryBean<org.apache.geode.cache.Region<K,V>>`
Returns:
  the `Region` used to store and manage Session state.
Throws:
  `java.lang.Exception` - if the `Region` reference cannot be obtained.
See Also:
  `Region`

#### getObjectType

    public java.lang.Class<?> getObjectType()

Returns the specific type of GemFire cache `Region` this factory creates when initialized or Region.class when uninitialized.

Specified by:
  `getObjectType` in interface `org.springframework.beans.factory.FactoryBean<org.apache.geode.cache.Region<K,V>>`
Returns:
  the GemFire cache `Region` class type constructed by this factory.
See Also:
  `Region`, `Class`

#### isSingleton

    public boolean isSingleton()

Returns true indicating the GemFire cache `Region` created by this factory is the sole instance.

Specified by:
  `isSingleton` in interface `org.springframework.beans.factory.FactoryBean<org.apache.geode.cache.Region<K,V>>`
Returns:
  true to indicate the GemFire cache `Region` storing and managing Sessions is a Singleton.

#### setBeanFactory

    public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)

Sets a reference to the Spring `BeanFactory` responsible for creating GemFire components.

Specified by:
  `setBeanFactory` in interface `org.springframework.beans.factory.BeanFactoryAware`
Parameters:
  `beanFactory` - reference to the Spring `BeanFactory`
Throws:
  `java.lang.IllegalArgumentException` - if the `BeanFactory` reference is null.
See Also:
  `BeanFactory`

#### getBeanFactory

    protected org.springframework.beans.factory.BeanFactory getBeanFactory()

Gets a reference to the Spring `BeanFactory` responsible for creating GemFire components.

Returns:
  a reference to the Spring `BeanFactory`
Throws:
  `java.lang.IllegalStateException` - if the `BeanFactory` reference is null.
See Also:
  `BeanFactory`

#### setClientRegionShortcut

    public void setClientRegionShortcut(org.apache.geode.cache.client.ClientRegionShortcut clientRegionShortcut)

Sets the `Region` data policy used by the GemFire cache client to manage Session state.

Parameters:
  `clientRegionShortcut` - a `ClientRegionShortcut` to specify the client `Region` data management policy.
See Also:
  `ClientRegionShortcut`

#### getClientRegionShortcut

    protected org.apache.geode.cache.client.ClientRegionShortcut getClientRegionShortcut()

Returns the `Region` data policy used by the GemFire cache client to manage Session state. Defaults to `ClientRegionShortcut.PROXY`.

Returns:
  a `ClientRegionShortcut` specifying the client `Region` data management policy.
See Also:
  `GemFireHttpSessionConfiguration.DEFAULT_CLIENT_REGION_SHORTCUT`, `ClientRegionShortcut`

#### setGemfireCache

    public void setGemfireCache(org.apache.geode.cache.GemFireCache gemfireCache)

Sets a reference to the GemFire cache used to construct the appropriate `Region`.

Parameters:
  `gemfireCache` - a reference to the GemFire cache.
Throws:
  `java.lang.IllegalArgumentException` - if the `GemFireCache` reference is null.

#### getGemfireCache

    protected org.apache.geode.cache.GemFireCache getGemfireCache()

Returns a reference to the GemFire cache used to construct the appropriate `Region`.

Returns:
  a reference to the GemFire cache.
Throws:
  `java.lang.IllegalStateException` - if the `GemFireCache` reference is null.

#### setPoolName

    public void setPoolName(java.lang.String poolName)

Sets the name of the GemFire `Pool` used by the client Region for managing Sessions during cache operations involving the server.

Parameters:
  `poolName` - the name of a GemFire `Pool`.
See Also:
  `Pool.getName()`

#### getPoolName

    protected java.lang.String getPoolName()

Returns the name of the GemFire `Pool` used by the client Region for managing Sessions during cache operations involving the server.

Returns:
  the name of a GemFire `Pool`.
See Also:
  `Pool.getName()`

#### setRegionAttributes

    public void setRegionAttributes(org.apache.geode.cache.RegionAttributes<K,V> regionAttributes)

Sets the GemFire `RegionAttributes` used to configure the GemFire cache `Region` used to store and manage Session state.

Parameters:
  `regionAttributes` - the GemFire `RegionAttributes` used to configure the GemFire cache `Region`.
See Also:
  `RegionAttributes`

#### getRegionAttributes

    protected org.apache.geode.cache.RegionAttributes<K,V> getRegionAttributes()

Returns the GemFire `RegionAttributes` used to configure the GemFire cache `Region` used to store and manage Session state.

Returns:
  the GemFire `RegionAttributes` used to configure the GemFire cache `Region`.
See Also:
  `RegionAttributes`

#### setRegionName

    public void setRegionName(java.lang.String regionName)

Sets the name of the GemFire cache `Region` use to store and manage Session state.

Parameters:
  `regionName` - a String specifying the name of the GemFire cache `Region`.

#### getRegionName

    protected java.lang.String getRegionName()

Returns the configured name of the GemFire cache `Region` use to store and manage Session state. Defaults to "ClusteredSpringSessions"

Returns:
  a String specifying the name of the GemFire cache `Region`.
See Also:
  `Region.getName()`

#### setServerRegionShortcut

    public void setServerRegionShortcut(org.apache.geode.cache.RegionShortcut serverRegionShortcut)

Sets the `Region` data policy used by the GemFire peer cache to manage Session state.

Parameters:
  `serverRegionShortcut` - a `RegionShortcut` to specify the peer `Region` data management policy.
See Also:
  `RegionShortcut`

#### getServerRegionShortcut

    protected org.apache.geode.cache.RegionShortcut getServerRegionShortcut()

Returns the `Region` data policy used by the GemFire peer cache to manage Session state. Defaults to `RegionShortcut.PARTITION`.

Returns:
  a `RegionShortcut` specifying the peer `Region` data management policy.
See Also:
  `RegionShortcut`