Class PeerRegionFactoryBean<K,V>

All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<org.apache.geode.cache.Region<K,V>>, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, EvictingRegionFactoryBean, ExpiringRegionFactoryBean<K,V>
Direct Known Subclasses:
GenericRegionFactoryBean, LocalRegionFactoryBean, PartitionedRegionFactoryBean, ReplicatedRegionFactoryBean

public abstract class PeerRegionFactoryBean<K,V> extends ConfigurableRegionFactoryBean<K,V> implements org.springframework.beans.factory.DisposableBean, EvictingRegionFactoryBean, ExpiringRegionFactoryBean<K,V>, org.springframework.context.SmartLifecycle
Spring FactoryBean and abstract base class extended by other SDG FactoryBeans used to construct, configure and initialize peer Regions. This FactoryBean allows for very easy and flexible creation of peer Regions. For client Regions, see the ClientRegionFactoryBean.
See Also:
  • Constructor Details

    • PeerRegionFactoryBean

      public PeerRegionFactoryBean()
  • Method Details

    • createRegion

      protected org.apache.geode.cache.Region<K,V> createRegion(org.apache.geode.cache.GemFireCache gemfireCache, String regionName)
      Creates a new Region with the given name.
      Overrides:
      createRegion in class ResolvableRegionFactoryBean<K,V>
      Parameters:
      gemfireCache - reference to the GemFireCache.
      regionName - name of the new Region.
      Returns:
      a new Region with the given name.
      See Also:
      • GemFireCache
      • Region
    • createRegionFactory

      protected org.apache.geode.cache.RegionFactory<K,V> createRegionFactory(org.apache.geode.cache.Cache cache)
      Create a new instance of RegionFactory initialized with the given Cache that is then used to construct, configure and initialize the Region specified by this PeerRegionFactoryBean.
      Parameters:
      cache - reference to the Cache.
      Returns:
      a RegionFactory used to construct, configure and initialize the Region specified by this PeerRegionFactoryBean.
      See Also:
      • Cache.createRegionFactory(RegionShortcut)
      • Cache.createRegionFactory(RegionAttributes)
      • Cache.createRegionFactory()
      • RegionFactory
    • configure

      protected org.apache.geode.cache.RegionFactory<K,V> configure(org.apache.geode.cache.RegionFactory<K,V> regionFactory)
      Configures the RegionFactory based on the configuration settings of this PeerRegionFactoryBean.
      Parameters:
      regionFactory - RegionFactory to configure
      Returns:
      the given RegionFactory.
      See Also:
      • RegionFactory
    • postProcess

      protected org.apache.geode.cache.RegionFactory<K,V> postProcess(org.apache.geode.cache.RegionFactory<K,V> regionFactory)
      Post-process the RegionFactory used to create the Region specified by this PeerRegionFactoryBean during initialization. The RegionFactory has been already constructed, configured and initialized by this PeerRegionFactoryBean before this method gets invoked.
      Parameters:
      regionFactory - RegionFactory used to create the Region.
      Returns:
      the given RegionFactory.
      See Also:
      • RegionFactory
    • mergeRegionAttributes

      protected <K, V> org.apache.geode.cache.RegionFactory<K,V> mergeRegionAttributes(org.apache.geode.cache.RegionFactory<K,V> regionFactory, org.apache.geode.cache.RegionAttributes<K,V> regionAttributes)
      Intelligently merges the given RegionAttributes with the configuration setting of the RegionFactory. This method is used to merge the RegionAttributes and PartitionAttributes with the RegionFactory that is created when the user specified a RegionShortcut. This method gets called by the createRegionFactory method depending upon the value passed to the Cache.createRegionFactory() method (i.e. whether there was a RegionShortcut specified or not).
      Type Parameters:
      K - the Class type fo the Region key.
      V - the Class type of the Region value.
      Parameters:
      regionFactory - the GemFire RegionFactory used to configure and create the Region that is the product of this PeerRegionFactoryBean.
      regionAttributes - the RegionAttributes containing the Region configuration settings to merge to the RegionFactory.
      Returns:
      the RegionFactory with the configuration settings of the RegionAttributes merged.
      See Also:
      • isUserSpecifiedEvictionAttributes(RegionAttributes)
      • validateRegionAttributes(RegionAttributes)
      • RegionAttributes
      • RegionFactory
    • mergePartitionAttributes

      protected <K, V> void mergePartitionAttributes(org.apache.geode.cache.RegionFactory<K,V> regionFactory, org.apache.geode.cache.RegionAttributes<K,V> regionAttributes)
      Merges the RegionAttributes into the RegionFactory.
      Parameters:
      regionFactory - RegionFactory to configure.
      regionAttributes - RegionAttributes used to configure the RegionFactory if not null.
      See Also:
      • RegionAttributes
      • RegionFactory
    • isNotPersistent

      protected boolean isNotPersistent()
      Returns true when the user explicitly specified a value for the persistent attribute and it is false. If the persistent attribute was not explicitly specified, then the persistence setting is implicitly undefined and will be determined by the Data Policy.
      Returns:
      true when the user specified an explicit value for the persistent attribute and it is false; false otherwise.
      See Also:
    • isPersistent

      protected boolean isPersistent()
      Returns true when the user explicitly specified a value for the persistent attribute and it is true. If the persistent attribute was not explicitly specified, then the persistence setting is implicitly undefined and will be determined by the Data Policy.
      Returns:
      true when the user specified an explicit value for the persistent attribute and it is true; false otherwise.
      See Also:
    • resolveDataPolicy

      protected void resolveDataPolicy(org.apache.geode.cache.RegionFactory<K,V> regionFactory, Boolean persistent, org.apache.geode.cache.DataPolicy dataPolicy)
      Validates and sets the Data Policy on the RegionFactory used to create and configure the Region from this FactoryBean.
      Parameters:
      regionFactory - the RegionFactory used by this FactoryBean to create and configure the Region.
      persistent - a boolean value indicating whether the Region should be persistent and persist it's data to disk.
      dataPolicy - the configured Data Policy for the Region.
      See Also:
    • resolveDataPolicy

      protected void resolveDataPolicy(org.apache.geode.cache.RegionFactory<K,V> regionFactory, Boolean persistent, String dataPolicy)
      Validates the configured Data Policy and may override it, taking into account the 'persistent' attribute and constraints for the Region type.
      Parameters:
      regionFactory - the GemFire RegionFactory used to create the desired Region.
      persistent - a boolean value indicating whether the Region should persist it's data to disk.
      dataPolicy - requested Data Policy as set by the user in the Spring GemFire configuration meta-data.
      See Also:
      • DataPolicy
      • RegionFactory
    • destroy

      public void destroy() throws Exception
      Closes and destroys this Region.
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
      Throws:
      Exception - if destroy() fails.
      See Also:
      • DisposableBean
      • Region.close()
      • Region.destroyRegion()
    • setAsyncEventQueues

      public void setAsyncEventQueues(@NonNull org.apache.geode.cache.asyncqueue.AsyncEventQueue[] asyncEventQueues)
      Configures an array of AsyncEventQueues for this Region, which are used to perform asynchronous data access operations, e.g. asynchronous, write-behind operations. This method clears any existing, registered AsyncEventQueues (AEQ) already associated with this Region. Use addAsyncEventQueues(AsyncEventQueue[]) or addAsyncEventQueueIds(String[]) to append to the existing AEQs already registered instead.
      Parameters:
      asyncEventQueues - array of AsyncEventQueues registered with and used by this Region to perform asynchronous data access operations.
      See Also:
    • setAsyncEventQueueIds

      public void setAsyncEventQueueIds(@NonNull String[] asyncEventQueueIds)
      Configures an array of AsyncEventQueues (AEQ) for this Region by AEQ ID. This method clears any existing, registered AsyncEventQueues (AEQ) already associated with this Region by AEQ ID. Use addAsyncEventQueues(AsyncEventQueue[]) or addAsyncEventQueueIds(String[]) to append to the existing AEQs already registered instead. or addAsyncEventQueueIds(String[]) to append to the existing AEQs already registered instead.
      Parameters:
      asyncEventQueueIds - array of Strings specifying AEQ IDs to be registered with this Region.
      See Also:
    • addAsyncEventQueues

      public void addAsyncEventQueues(@NonNull org.apache.geode.cache.asyncqueue.AsyncEventQueue[] asyncEventQueues)
      Registers the array of AsyncEventQueues (AEQ) with this Region by appending to the already existing, registered AEQs for this Region.
      Parameters:
      asyncEventQueues - array of AsyncEventQueues to register with this Region.
      See Also:
    • addAsyncEventQueueIds

      public void addAsyncEventQueueIds(@NonNull String[] asyncEventQueueIds)
      Registers the array of AsyncEventQueues (AEQ) with this Region by ID by appending to the already existing, registered AEQs for this Region.
      Parameters:
      asyncEventQueueIds - array of AsyncEventQueue IDs to register with this Region.
      See Also:
    • setAttributes

      public void setAttributes(org.apache.geode.cache.RegionAttributes<K,V> attributes)
      Sets the RegionAttributes used to configure this Region. Specifying RegionAttributes allows full control in configuring various Region settings. Used only when the Region is created and not when the Region is looked up.
      Parameters:
      attributes - RegionAttributes used to configure this Region.
      See Also:
      • RegionAttributes
    • getAttributes

      public org.apache.geode.cache.RegionAttributes<K,V> getAttributes()
      Returns the RegionAttributes used to configure this Region.
      Returns:
      the RegionAttributes used to configure this Region.
      See Also:
      • RegionAttributes
    • setCacheListeners

      public void setCacheListeners(org.apache.geode.cache.CacheListener<K,V>[] cacheListeners)
      Configures CacheListeners used to listen for entry events on this Region. Used only when a new Region is created and not looked up. Overrides the Region settings specified in RegionAttributes set with setAttributes(RegionAttributes).
      Parameters:
      cacheListeners - array CacheListeners to register with this Region.
      See Also:
      • CacheListener
    • setCacheLoader

      public void setCacheLoader(org.apache.geode.cache.CacheLoader<K,V> cacheLoader)
      Configures the CacheLoader used by this Region to perform synchronous read-through data access operations to an underlying, external data source. Used only when a new Region is created and not looked up. Overrides the Region settings specified in RegionAttributes set with setAttributes(RegionAttributes).
      Parameters:
      cacheLoader - CacheLoader to register for this Region.
      See Also:
      • CacheLoader
    • setCacheWriter

      public void setCacheWriter(org.apache.geode.cache.CacheWriter<K,V> cacheWriter)
      Configures the CacheWriter used by this Region to perform synchronous write-through data access operations to an underlying, external data source. Used only when a new Region is created and not looked up. Overrides the Region settings specified in RegionAttributes set with setAttributes(RegionAttributes).
      Parameters:
      cacheWriter - CacheWriter to register for this Region.
      See Also:
      • CacheWriter
    • setClose

      public void setClose(boolean close)
      Configure whether to close this Region during shutdown. Defaults to true.
      Parameters:
      close - boolean value indicating whether this Region should be closed during shutdown.
      See Also:
    • setCompressor

      public void setCompressor(org.apache.geode.compression.Compressor compressor)
      Configures the Compressor used to compress this Region's data.
      Parameters:
      compressor - Compressor used to compress this Region's data.
      See Also:
      • Compressor
    • setCustomEntryIdleTimeout

      public void setCustomEntryIdleTimeout(org.apache.geode.cache.CustomExpiry<K,V> customEntryIdleTimeout)
      Specified by:
      setCustomEntryIdleTimeout in interface ExpiringRegionFactoryBean<K,V>
    • setCustomEntryTimeToLive

      public void setCustomEntryTimeToLive(org.apache.geode.cache.CustomExpiry<K,V> customEntryTimeToLive)
      Specified by:
      setCustomEntryTimeToLive in interface ExpiringRegionFactoryBean<K,V>
    • setDestroy

      public void setDestroy(boolean destroy)
      Configure whether to destroy this Region during shutdown. Defaults to false.
      Parameters:
      destroy - value indicating whether this Region should be destroyed during shutdown.
      See Also:
    • setDataPolicy

      public void setDataPolicy(org.apache.geode.cache.DataPolicy dataPolicy)
      Configure the DataPolicy for this Region.
      Parameters:
      dataPolicy - DataPolicy used when configuring this Region.
      Since:
      1.4.0
      See Also:
      • DataPolicy
    • getDataPolicy

      public org.apache.geode.cache.DataPolicy getDataPolicy()
      Returns resolved DataPolicy as configured with the RegionFactory when creating this Region.
      Returns:
      the configured, resolved DataPolicy used by this Region.
      Throws:
      IllegalStateException - if the DataPolicy has not been configured or is not resolvable.
      See Also:
      • DataPolicy
    • setDiskStoreName

      public void setDiskStoreName(String diskStoreName)
      Configures the name of the DiskStore used by this Region for overflow and/or persistence.
      Parameters:
      diskStoreName - String containing the name of the DiskStore bean configured for this Region.
    • setEntryIdleTimeout

      public void setEntryIdleTimeout(org.apache.geode.cache.ExpirationAttributes entryIdleTimeout)
      Specified by:
      setEntryIdleTimeout in interface ExpiringRegionFactoryBean<K,V>
    • setEntryTimeToLive

      public void setEntryTimeToLive(org.apache.geode.cache.ExpirationAttributes entryTimeToLive)
      Specified by:
      setEntryTimeToLive in interface ExpiringRegionFactoryBean<K,V>
    • setEvictionAttributes

      public void setEvictionAttributes(org.apache.geode.cache.EvictionAttributes evictionAttributes)
      Specified by:
      setEvictionAttributes in interface EvictingRegionFactoryBean
    • setGatewaySenders

      public void setGatewaySenders(@NonNull org.apache.geode.cache.wan.GatewaySender[] gatewaySenders)
      Configures the GatewaySenders used to send data and events from this Region to a matching Region in a remote cluster. This method clears all existing, registered GatewaySenders already associated with this Region. Use addGatewaySenders(GatewaySender[]) or addGatewaySendersIds(String[]) to append to the existing, registered GatewaySenders for this Region.
      Parameters:
      gatewaySenders - GatewaySenders used to send data and events from this Region to a matching Region in a remote cluster.
      See Also:
    • setGatewaySenderIds

      public void setGatewaySenderIds(@NonNull String[] gatewaySenderIds)
      Configures the GatewaySenders by ID used to send data and events from this Region to a matching Region in a remote cluster. This method clears all existing, registered GatewaySenders already associated with this Region. Use addGatewaySenders(GatewaySender[]) or addGatewaySendersIds(String[]) to append to the existing, registered GatewaySenders for this Region.
      Parameters:
      gatewaySenderIds - String array containing GatewaySender IDs to register with this Region.
      See Also:
    • addGatewaySenders

      public void addGatewaySenders(@NonNull org.apache.geode.cache.wan.GatewaySender[] gatewaySenders)
      Registers the array of GatewaySenders with this Region by appending to the already existing, registered GatewaySenders for this Region.
      Parameters:
      gatewaySenders - array of GatewaySenders to register with this Region.
      See Also:
    • addGatewaySendersIds

      public void addGatewaySendersIds(@NonNull String[] gatewaySenderIds)
      Registers the array of GatewaySender IDs with this Region by appending to the already existing, registered GatewaySenders for this Region.
      Parameters:
      gatewaySenderIds - array of GatewaySender IDs to register with this Region.
      See Also:
    • setOffHeap

      public void setOffHeap(Boolean offHeap)
      Configures this Region with the capability to store data in off-heap memory.
      Parameters:
      offHeap - Boolean value indicating whether to enable the use of off-heap memory for this Region.
      See Also:
      • RegionFactory.setOffHeap(boolean)
    • getOffHeap

      public Boolean getOffHeap()
      Returns a Boolean value indicating whether off-heap memory was enabled for this Region. Off-heap memory will be enabled for this Region if this method returns a non-null, Boolean value evaluating to true.
      Returns:
      a Boolean value indicating whether off-heap memory use is enabled for this Region.
    • isOffHeap

      public boolean isOffHeap()
      Returns a boolean value indicating whether off-heap memory use was enabled for this Region.
      Returns:
      a boolean value indicating whether off-heap memory use was enabled for this Region.
      See Also:
    • setKeyConstraint

      public void setKeyConstraint(Class<K> keyConstraint)
      Configures the key constraint used to enforce key types for this Region.
      Parameters:
      keyConstraint - Class specifying the key type constraint for this Region.
      See Also:
      • RegionFactory.setKeyConstraint(Class)
      • RegionAttributes.getKeyConstraint()
      • Class
    • setPersistent

      public void setPersistent(Boolean persistent)
      Configures whether to enable persistence for this Region. When persistence is enable, then data in the Region is persisted to disk using the configured, specified DiskStore, or the DEFAULT DiskStore if a DiskStore was not explicitly configured.
      Parameters:
      persistent - Boolean value indicating whether to enaable persistence for this Region.
    • setRegionIdleTimeout

      public void setRegionIdleTimeout(org.apache.geode.cache.ExpirationAttributes regionIdleTimeout)
      Specified by:
      setRegionIdleTimeout in interface ExpiringRegionFactoryBean<K,V>
    • setRegionTimeToLive

      public void setRegionTimeToLive(org.apache.geode.cache.ExpirationAttributes regionTimeToLive)
      Specified by:
      setRegionTimeToLive in interface ExpiringRegionFactoryBean<K,V>
    • setScope

      public void setScope(org.apache.geode.cache.Scope scope)
      Configures the Region's Scope, which affects data distribution and acknowledgement strategy (useful in consistency) for the Region.
      Parameters:
      scope - Scope used to configure the Region's data distribution and acknowledgement strategy.
      See Also:
      • Scope
    • getScope

      public org.apache.geode.cache.Scope getScope()
      Returns the configured Scope of the Region affecting data distribution and acknowledgement strategy (useful in consistency) for the Region.
      Returns:
      the configured Scope of the Region.
      See Also:
      • Scope
    • setShortcut

      public void setShortcut(org.apache.geode.cache.RegionShortcut shortcut)
      Configures the Region with the given RegionShortcut.
      Parameters:
      shortcut - RegionShortcut used to configure pre-defined defaults for the Region.
      See Also:
      • RegionShortcut
    • getShortcut

      public org.apache.geode.cache.RegionShortcut getShortcut()
      Returns the configured RegionShortcut.
      Returns:
      the configured RegionShortcut.
      See Also:
      • RegionShortcut
    • setStatisticsEnabled

      public void setStatisticsEnabled(Boolean statisticsEnabled)
    • getStatisticsEnabled

      public Boolean getStatisticsEnabled()
    • isStatisticsEnabled

      public boolean isStatisticsEnabled()
    • resolveStatisticsEnabled

      protected boolean resolveStatisticsEnabled()
    • setValueConstraint

      public void setValueConstraint(Class<V> valueConstraint)
      Configures the value constraint used to enforce value types for this Region.
      Parameters:
      valueConstraint - Class specifying the value type constraint for this Region.
      See Also:
      • RegionFactory.setValueConstraint(Class)
      • RegionAttributes.getValueConstraint()
      • Class
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop(Runnable callback)
      Specified by:
      stop in interface org.springframework.context.SmartLifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface org.springframework.context.Phased
      Specified by:
      getPhase in interface org.springframework.context.SmartLifecycle
    • isAutoStartup

      public boolean isAutoStartup()
      Specified by:
      isAutoStartup in interface org.springframework.context.SmartLifecycle