Class ClientCacheFactoryBean

All Implemented Interfaces:
EventListener, 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.GemFireCache>, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.context.Phased, org.springframework.dao.support.PersistenceExceptionTranslator

public class ClientCacheFactoryBean extends CacheFactoryBean implements org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
Spring FactoryBean used to construct, configure and initialize a ClientCache.
Since:
1.0.0
See Also:
  • Field Details

    • DEFAULT_POOL_RESOLVER

      protected static final PoolResolver DEFAULT_POOL_RESOLVER
  • Constructor Details

    • ClientCacheFactoryBean

      public ClientCacheFactoryBean()
  • Method Details

    • applyCacheConfigurers

      protected void applyCacheConfigurers()
      Applies the composite ClientCacheConfigurers to this ClientCacheFactoryBean before the ClientCache is created.
      Overrides:
      applyCacheConfigurers in class CacheFactoryBean
      See Also:
    • applyClientCacheConfigurers

      protected void applyClientCacheConfigurers(ClientCacheConfigurer... clientCacheConfigurers)
      Applies the array of ClientCacheConfigurers to this ClientCacheFactoryBean before the ClientCache is created.
      Parameters:
      clientCacheConfigurers - array of ClientCacheConfigurers applied to this ClientCacheFactoryBean.
      See Also:
    • applyClientCacheConfigurers

      protected void applyClientCacheConfigurers(Iterable<ClientCacheConfigurer> clientCacheConfigurers)
      Apples the Iterable of ClientCacheConfigurers to this ClientCacheFactoryBean before the ClientCache is created.
      Parameters:
      clientCacheConfigurers - Iterable of ClientCacheConfigurers applied to this ClientCacheFactoryBean.
      See Also:
    • doFetchCache

      protected <T extends org.apache.geode.cache.GemFireCache> T doFetchCache()
      Fetches an existing ClientCache instance from the ClientCacheFactory.
      Overrides:
      doFetchCache in class CacheFactoryBean
      Type Parameters:
      T - parameterized Class type extension of GemFireCache.
      Returns:
      an existing ClientCache instance if available.
      Throws:
      org.apache.geode.cache.CacheClosedException - if an existing ClientCache instance does not exist.
      See Also:
    • doGetObjectType

      protected Class<? extends org.apache.geode.cache.GemFireCache> doGetObjectType()
      Returns the type of GemFireCache constructed by this ClientCacheFactoryBean. Returns ClientCache Class.
      Overrides:
      doGetObjectType in class CacheFactoryBean
      Returns:
      the type of GemFireCache constructed by this ClientCacheFactoryBean.
      See Also:
      • FactoryBean.getObjectType()
    • resolveProperties

      @NonNull protected Properties resolveProperties()
      Resolves the Apache Geode Properties used to configure the ClientCache.
      Overrides:
      resolveProperties in class AbstractConfigurableCacheFactoryBean
      Returns:
      the resolved Apache Geode Properties used to configure the ClientCache.
      See Also:
      • DistributedSystem.getProperties()
    • createFactory

      @NonNull protected Object createFactory(@NonNull Properties gemfireProperties)
      Constructs a new instance of ClientCacheFactory initialized with the given Apache Geode Properties used to construct, configure and initialize a new ClientCache instance.
      Overrides:
      createFactory in class CacheFactoryBean
      Parameters:
      gemfireProperties - Properties used by the ClientCacheFactory to configure the ClientCache.
      Returns:
      a new instance of ClientCacheFactory initialized with the given Apache Geode Properties.
      See Also:
    • configureFactory

      @NonNull protected Object configureFactory(@NonNull Object factory)
      Configures the ClientCacheFactory used to create the ClientCache.
      Overrides:
      configureFactory in class CacheFactoryBean
      Parameters:
      factory - ClientCacheFactory used to create the ClientCache.
      Returns:
      the configured ClientCacheFactory.
      See Also:
    • configurePdx

      @NonNull protected org.apache.geode.cache.client.ClientCacheFactory configurePdx(@NonNull org.apache.geode.cache.client.ClientCacheFactory clientCacheFactory)
      Configures the ClientCache to use PDX serialization.
      Parameters:
      clientCacheFactory - ClientCacheFactory to configure with PDX.
      Returns:
      the given ClientCacheFactory.
      See Also:
    • configurePool

      @NonNull protected org.apache.geode.cache.client.ClientCacheFactory configurePool(@NonNull org.apache.geode.cache.client.ClientCacheFactory clientCacheFactory)
      Configure the DEFAULT Pool of the ClientCacheFactory using a given Pool instance or a named Pool instance.
      Parameters:
      clientCacheFactory - ClientCacheFactory used to configure the DEFAULT Pool.
      See Also:
      • ClientCacheFactory
      • Pool
    • resolvePool

      @Nullable protected org.apache.geode.cache.client.Pool resolvePool()
      Resolves the Pool used to configure the ClientCache, DEFAULT Pool.
      Returns:
      the resolved Pool used to configure the ClientCache, DEFAULT Pool.
      See Also:
    • createCache

      @NonNull protected <T extends org.apache.geode.cache.GemFireCache> T createCache(@NonNull Object factory)
      Creates a new ClientCache instance using the provided factory.
      Overrides:
      createCache in class CacheFactoryBean
      Type Parameters:
      T - parameterized Class type extending GemFireCache.
      Parameters:
      factory - instance of ClientCacheFactory.
      Returns:
      a new instance of ClientCache created by the provided factory.
      See Also:
      • ClientCacheFactory.create()
      • ClientCache
      • GemFireCache
    • onApplicationEvent

      public void onApplicationEvent(@NonNull org.springframework.context.event.ContextRefreshedEvent event)
      Inform the Apache Geode cluster of servers that this ClientCache is ready to receive events and updates iff the client is durable.
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
      Parameters:
      event - ApplicationContextEvent fired when the ApplicationContext is refreshed.
      See Also:
    • close

      protected void close(@NonNull org.apache.geode.cache.GemFireCache cache)
      Null-safe method used to RegionService.close() the ClientCache and preserve durability.
      Overrides:
      close in class AbstractBasicCacheFactoryBean
      Parameters:
      cache - GemFireCache to close.
      See Also:
    • addLocators

      public void addLocators(ConnectionEndpoint... locators)
    • addLocators

      public void addLocators(Iterable<ConnectionEndpoint> locators)
    • addServers

      public void addServers(ConnectionEndpoint... servers)
    • addServers

      public void addServers(Iterable<ConnectionEndpoint> servers)
    • setClientCacheConfigurers

      public void setClientCacheConfigurers(ClientCacheConfigurer... clientCacheConfigurers)
      Null-safe operation to set an array of ClientCacheConfigurers used to apply additional configuration to this ClientCacheFactoryBean when using Annotation-based configuration.
      Parameters:
      clientCacheConfigurers - array of ClientCacheConfigurers used to apply additional configuration to this ClientCacheFactoryBean.
      See Also:
    • setClientCacheConfigurers

      public void setClientCacheConfigurers(List<ClientCacheConfigurer> clientCacheConfigurers)
      Null-safe operation to set an List of ClientCacheConfigurers to apply additional configuration to this ClientCacheFactoryBean when using Annotation-based configuration.
      Parameters:
      clientCacheConfigurers - List of ClientCacheConfigurers used to apply additional configuration to this ClientCacheFactoryBean.
      See Also:
    • getCompositeClientCacheConfigurer

      @NonNull public ClientCacheConfigurer getCompositeClientCacheConfigurer()
      Returns a reference to the Composite ClientCacheConfigurer used to apply additional configuration to this ClientCacheFactoryBean on Spring container initialization.
      Returns:
      the Composite ClientCacheConfigurer.
      See Also:
    • setDurableClientId

      public void setDurableClientId(String durableClientId)
      Set the GemFire System property 'durable-client-id' to indicate to the server that this client is durable.
      Parameters:
      durableClientId - a String value indicating the durable client id.
    • getDurableClientId

      public String getDurableClientId()
      Gets the value of the GemFire System property 'durable-client-id' indicating to the server whether this client is durable.
      Returns:
      a String value indicating the durable client id.
    • setDurableClientTimeout

      public void setDurableClientTimeout(Integer durableClientTimeout)
      Set the GemFire System property 'durable-client-timeout' indicating to the server how long to track events for the durable client when disconnected.
      Parameters:
      durableClientTimeout - an Integer value indicating the timeout in seconds for the server to keep the durable client's queue around.
    • getDurableClientTimeout

      public Integer getDurableClientTimeout()
      Get the value of the GemFire System property 'durable-client-timeout' indicating to the server how long to track events for the durable client when disconnected.
      Returns:
      an Integer value indicating the timeout in seconds for the server to keep the durable client's queue around.
    • setEnableAutoReconnect

      public final void setEnableAutoReconnect(Boolean enableAutoReconnect)
      Description copied from class: CacheFactoryBean
      Controls whether auto-reconnect functionality introduced in GemFire 8 is enabled or not.
      Overrides:
      setEnableAutoReconnect in class CacheFactoryBean
      Parameters:
      enableAutoReconnect - a boolean value to enable/disable auto-reconnect functionality.
    • getEnableAutoReconnect

      public final Boolean getEnableAutoReconnect()
      Description copied from class: CacheFactoryBean
      Gets the value for the auto-reconnect setting.
      Overrides:
      getEnableAutoReconnect in class CacheFactoryBean
      Returns:
      a boolean value indicating whether auto-reconnect was specified (non-null) and whether it was enabled or not.
    • setFreeConnectionTimeout

      public void setFreeConnectionTimeout(Integer freeConnectionTimeout)
    • getFreeConnectionTimeout

      public Integer getFreeConnectionTimeout()
    • setIdleTimeout

      public void setIdleTimeout(Long idleTimeout)
    • getIdleTimeout

      public Long getIdleTimeout()
    • setKeepAlive

      public void setKeepAlive(Boolean keepAlive)
      Sets whether the server(s) should keep the durable client's queue alive for the duration of the timeout when the client voluntarily disconnects.
      Parameters:
      keepAlive - a boolean value indicating to the server to keep the durable client's queues alive.
    • getKeepAlive

      public Boolean getKeepAlive()
      Gets the user specified value for whether the server(s) should keep the durable client's queue alive for the duration of the timeout when the client voluntarily disconnects.
      Returns:
      a boolean value indicating whether the server should keep the durable client's queues alive.
    • isKeepAlive

      public boolean isKeepAlive()
      Determines whether the server(s) should keep the durable client's queue alive for the duration of the timeout when the client voluntarily disconnects.
      Returns:
      a boolean value indicating whether the server should keep the durable client's queues alive.
    • setLoadConditioningInterval

      public void setLoadConditioningInterval(Integer loadConditioningInterval)
    • getLoadConditioningInterval

      public Integer getLoadConditioningInterval()
    • setLocators

      public void setLocators(ConnectionEndpoint[] locators)
    • setLocators

      public void setLocators(Iterable<ConnectionEndpoint> locators)
    • getLocators

      protected ConnectionEndpointList getLocators()
    • setMaxConnections

      public void setMaxConnections(Integer maxConnections)
    • getMaxConnections

      public Integer getMaxConnections()
    • setMinConnections

      public void setMinConnections(Integer minConnections)
    • getMinConnections

      public Integer getMinConnections()
    • setMultiUserAuthentication

      public void setMultiUserAuthentication(Boolean multiUserAuthentication)
    • getMultiUserAuthentication

      public Boolean getMultiUserAuthentication()
    • setPool

      public void setPool(@Nullable org.apache.geode.cache.client.Pool pool)
      Sets the Pool used by this ClientCache to obtain connections to the Apache Geode cluster.
      Parameters:
      pool - Pool used by this ClientCache to obtain connections to the Apache Geode cluster.
      See Also:
      • Pool
    • getPool

      @Nullable public org.apache.geode.cache.client.Pool getPool()
      Gets the Pool used by this ClientCache to obtain connections to the Apache Geode cluster.
      Returns:
      Pool used by this ClientCache to obtain connections to the Apache Geode cluster.
      See Also:
      • Pool
    • setPoolName

      public void setPoolName(@Nullable String poolName)
      Sets the name of the Pool used by this ClientCache to obtain connections to the Apache Geode cluster.
      Parameters:
      poolName - name of the Pool used by this ClientCache to obtain connections to the Apache Geode cluster.
    • getPoolName

      @Nullable public String getPoolName()
      Gets the name of the Pool used by this ClientCache to obtain connections to the Apache Geode cluster.
      Returns:
      name of the Pool used by this ClientCache to obtain connections to the Apache Geode cluster.
    • setPoolResolver

      public void setPoolResolver(@Nullable PoolResolver poolResolver)
      Sets (configures) the PoolResolver used by this ClientCache to resolve Pool objects. The Pool objects may be managed or un-managed depending on the PoolResolver implementation.
      Parameters:
      poolResolver - PoolResolver used to resolve the configured Pool.
      See Also:
    • getPoolResolver

      @NonNull public PoolResolver getPoolResolver()
      Gets the configured PoolResolver used by this ClientCache to resolve Pool objects.
      Returns:
      the configured PoolResolver. If no PoolResolver was configured, then return the default, PoolManagerPoolResolver.
      See Also:
    • setPingInterval

      public void setPingInterval(Long pingInterval)
    • getPingInterval

      public Long getPingInterval()
    • setPrSingleHopEnabled

      public void setPrSingleHopEnabled(Boolean prSingleHopEnabled)
    • getPrSingleHopEnabled

      public Boolean getPrSingleHopEnabled()
    • setReadTimeout

      public void setReadTimeout(Integer readTimeout)
    • getReadTimeout

      public Integer getReadTimeout()
    • setReadyForEvents

      public void setReadyForEvents(Boolean readyForEvents)
      Sets the readyForEvents property to indicate whether the cache client should notify the server that it is ready to receive updates.
      Parameters:
      readyForEvents - sets a boolean flag to notify the server that this durable client is ready to receive updates.
      See Also:
    • getReadyForEvents

      public Boolean getReadyForEvents()
      Gets the user-configured value for deciding that this client is ready to receive events from the server(s).
      Returns:
      a Boolean indicating whether this client is ready to receive events from the server(s).
    • isReadyForEvents

      public boolean isReadyForEvents()
      Determines whether this GemFire cache client is ready for events. If 'readyForEvents' was explicitly set, then it takes precedence over all other considerations (e.g. durability).
      Returns:
      a boolean value indicating whether this GemFire cache client is ready for events.
      See Also:
    • setRetryAttempts

      public void setRetryAttempts(Integer retryAttempts)
    • getRetryAttempts

      public Integer getRetryAttempts()
    • setServerConnectionTimeout

      public void setServerConnectionTimeout(Integer serverConnectionTimeout)
    • getServerConnectionTimeout

      public Integer getServerConnectionTimeout()
    • setServerGroup

      public void setServerGroup(String serverGroup)
    • getServerGroup

      public String getServerGroup()
    • setServers

      public void setServers(ConnectionEndpoint[] servers)
    • setServers

      public void setServers(Iterable<ConnectionEndpoint> servers)
    • getServers

      protected ConnectionEndpointList getServers()
    • setSocketBufferSize

      public void setSocketBufferSize(Integer socketBufferSize)
    • getSocketBufferSize

      public Integer getSocketBufferSize()
    • setSocketConnectTimeout

      public void setSocketConnectTimeout(Integer socketConnectTimeout)
    • getSocketConnectTimeout

      public Integer getSocketConnectTimeout()
    • setSocketFactory

      public void setSocketFactory(@Nullable org.apache.geode.cache.client.SocketFactory socketFactory)
    • getSocketFactory

      @NonNull public org.apache.geode.cache.client.SocketFactory getSocketFactory()
    • setStatisticsInterval

      public void setStatisticsInterval(Integer statisticsInterval)
    • getStatisticsInterval

      public Integer getStatisticsInterval()
    • setSubscriptionAckInterval

      public void setSubscriptionAckInterval(Integer subscriptionAckInterval)
    • getSubscriptionAckInterval

      public Integer getSubscriptionAckInterval()
    • setSubscriptionEnabled

      public void setSubscriptionEnabled(Boolean subscriptionEnabled)
    • getSubscriptionEnabled

      public Boolean getSubscriptionEnabled()
    • setSubscriptionMessageTrackingTimeout

      public void setSubscriptionMessageTrackingTimeout(Integer subscriptionMessageTrackingTimeout)
    • getSubscriptionMessageTrackingTimeout

      public Integer getSubscriptionMessageTrackingTimeout()
    • setSubscriptionRedundancy

      public void setSubscriptionRedundancy(Integer subscriptionRedundancy)
    • getSubscriptionRedundancy

      public Integer getSubscriptionRedundancy()
    • setThreadLocalConnections

      public void setThreadLocalConnections(Boolean threadLocalConnections)
    • getThreadLocalConnections

      public Boolean getThreadLocalConnections()
    • setUseClusterConfiguration

      public final void setUseClusterConfiguration(Boolean useClusterConfiguration)
      Description copied from class: CacheFactoryBean
      Sets the state of the use-shared-configuration Pivotal GemFire/Apache Geode distribution configuration setting.
      Overrides:
      setUseClusterConfiguration in class CacheFactoryBean
      Parameters:
      useClusterConfiguration - boolean value to set the use-shared-configuration Pivotal GemFire/Apache Geode distribution configuration setting.
    • getUseClusterConfiguration

      public final Boolean getUseClusterConfiguration()
      Description copied from class: CacheFactoryBean
      Return the state of the use-shared-configuration Pivotal GemFire/Apache Geode distribution configuration setting.
      Overrides:
      getUseClusterConfiguration in class CacheFactoryBean
      Returns:
      the current boolean value for the use-shared-configuration Pivotal GemFire/Apache Geode distribution configuration setting.