Class Interest<K>

java.lang.Object
org.springframework.data.gemfire.client.Interest<K>
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
KeyInterest, RegexInterest

public class Interest<K> extends Object implements org.springframework.beans.factory.InitializingBean
The Interest class holds details for registering a client interest.
Since:
1.0.0
See Also:
  • Pattern
  • InterestResultPolicy
  • InitializingBean
  • Constants
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Type of interest registration.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    protected static final boolean
     
    protected static final boolean
     
    protected final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Interest(K key)
    Constructs an instance of non-durable Interest initialized with the given key to register interest in, using the InterestResultPolicy.DEFAULT to initialize the client cache and receiving values by default.
    Interest(K key, org.apache.geode.cache.InterestResultPolicy policy)
    Constructs an instance of non-durable Interest initialized with the given key to register interest in, the given InterestResultPolicy used to initialize the client cache, receiving values by default.
    Interest(K key, org.apache.geode.cache.InterestResultPolicy policy, boolean durable)
    Constructs an instance of Interest initialized with the given key to register interest in, the given InterestResultPolicy used to initialize the client cache, the given boolean value to indicate whether interest registration should be durable, receiving values by default.
    Interest(K key, org.apache.geode.cache.InterestResultPolicy policy, boolean durable, boolean receiveValues)
    Constructs an instance of Interest initialized with the given key to register interest in, the given InterestResultPolicy used to initialize the client cache and the given boolean values indicating whether interest registration should be durable and whether to receive values during notifications.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    Builder method to specify the type of interest registration.
    protected boolean
    Determines whether the given String value contains at least 1 special character.
    Returns the key on which interest is registered.
    org.apache.geode.cache.InterestResultPolicy
    Returns the InterestResultPolicy used when interest is registered and determines whether KEYS, KEYS_VALUES or nothing (NONE) is initially fetched on initial registration.
    Returns the type of interest registration (e.g.
    protected boolean
    isAlphaNumericWhitespace(char character)
    Determines whether the given character is an alphanumeric or whitespace character.
    boolean
    Determines whether the interest registration is durable and persists between cache client sessions.
    boolean
    Determines whether this Interest is a KEY interest registration.
    protected boolean
    Determines whether the given character is a special character (non-alphanumeric, non-whitespace).
    boolean
    Returns the type of values received by the listener.
    boolean
    Determines whether this Interest is a REGEX interest registration.
    protected boolean
    Determines whether the given key is a Regular Expression (Regex).
    protected boolean
    Determines whether the given key is a Regular Expression (Regex).
    Builder method to mark this Interest as durable.
    static <K> Interest
    newInterest(K key)
    Factory method to construct a new instance of Interest initialized with the given key.
    receivesValues(boolean receiveValues)
    Builder method to set whether the interest event notifications will receive values along with keys.
    protected Interest.Type
    Attempts to resolve the Interest.Type based on the configured getKey().
    void
    setDurable(boolean durable)
    Sets whether interest registration is durable and persists between cache client sessions.
    void
    setKey(K key)
    Sets the key on which interest is registered.
    void
    setPolicy(Object policy)
    Sets the initial InterestResultPolicy used when interest is first registered and determines whether KEYS, KEYS_VALUE or nothing (NONE) is initially fetched.
    void
    setReceiveValues(boolean receiveValues)
    Switches between the different entities received by the listener.
    void
    Set the type of interest registration (e.g.
     
    usingPolicy(org.apache.geode.cache.InterestResultPolicy policy)
    Builder method to set the InterestResultPolicy used to initialize the cache.
    withKey(K key)
    Builder method to express the key of interest.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Interest

      public Interest(K key)
      Constructs an instance of non-durable Interest initialized with the given key to register interest in, using the InterestResultPolicy.DEFAULT to initialize the client cache and receiving values by default.
      Parameters:
      key - key(s) of interest.
      See Also:
    • Interest

      public Interest(K key, org.apache.geode.cache.InterestResultPolicy policy)
      Constructs an instance of non-durable Interest initialized with the given key to register interest in, the given InterestResultPolicy used to initialize the client cache, receiving values by default.
      Parameters:
      key - key(s) of interest.
      policy - initial InterestResultPolicy used to initialize the client cache.
      See Also:
    • Interest

      public Interest(K key, org.apache.geode.cache.InterestResultPolicy policy, boolean durable)
      Constructs an instance of Interest initialized with the given key to register interest in, the given InterestResultPolicy used to initialize the client cache, the given boolean value to indicate whether interest registration should be durable, receiving values by default.
      Parameters:
      key - key(s) of interest.
      policy - initial InterestResultPolicy used to initialize the client cache.
      durable - boolean value to indicate whether the interest registration should be durable.
      See Also:
    • Interest

      public Interest(K key, org.apache.geode.cache.InterestResultPolicy policy, boolean durable, boolean receiveValues)
      Constructs an instance of Interest initialized with the given key to register interest in, the given InterestResultPolicy used to initialize the client cache and the given boolean values indicating whether interest registration should be durable and whether to receive values during notifications.
      Parameters:
      key - key(s) of interest.
      policy - initial InterestResultPolicy used to initialize the client cache.
      durable - boolean value to indicate whether the interest registration should be durable.
      receiveValues - boolean value to indicate whether to receive value in notifications.
      See Also:
  • Method Details

    • newInterest

      public static <K> Interest newInterest(K key)
      Factory method to construct a new instance of Interest initialized with the given key.
      Type Parameters:
      K - Class type of the key.
      Parameters:
      key - key of interest.
      Returns:
      a new instance of Interest initialized with the given key.
      See Also:
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • resolveType

      protected Interest.Type resolveType(Interest.Type type)
      Attempts to resolve the Interest.Type based on the configured getKey().
      Parameters:
      type - provided Interest.Type used if non-null.
      Returns:
      the resolved Interest.Type.
      See Also:
    • isRegularExpression

      protected boolean isRegularExpression(Object key)
      Determines whether the given key is a Regular Expression (Regex). If the given key is "ALL_KEYS", a List or only contains letters, numbers and spaces, then the key is not considered a Regular Expression by GemFire, and can be handled with normal interest registration using Region.registerInterest(Object).
      Parameters:
      key - Object to evaluate.
      Returns:
      a boolean value indicating whether the given Object key is a Regular Expression.
      See Also:
    • isRegularExpression

      protected boolean isRegularExpression(String value)
      Determines whether the given key is a Regular Expression (Regex). If the given value contains at least 1 special character (e.g. *) and can be compiled using Pattern.compile(String), then the key is considered a Regular Expression and interest will be registered using Region.registerInterestRegex(String).
      Parameters:
      value - String to evaluate.
      Returns:
      a boolean value indicating whether the given String value is a Regular Expression.
      See Also:
    • containsNonAlphaNumericWhitespace

      protected boolean containsNonAlphaNumericWhitespace(String value)
      Determines whether the given String value contains at least 1 special character.
      Parameters:
      value - String to evaluate.
      Returns:
      a boolean value indicating whether the given String contains at least 1 special character, a non-alphanumeric, non-whitespace character.
      See Also:
    • isNotAlphaNumericWhitespace

      protected boolean isNotAlphaNumericWhitespace(char character)
      Determines whether the given character is a special character (non-alphanumeric, non-whitespace).
      Parameters:
      character - Character to evaluate.
      Returns:
      a boolean value indicating whether the given character is a special character.
      See Also:
    • isAlphaNumericWhitespace

      protected boolean isAlphaNumericWhitespace(char character)
      Determines whether the given character is an alphanumeric or whitespace character.
      Parameters:
      character - Character to evaluate.
      Returns:
      a boolean value indicating whether the given character is an alphanumeric or whitespace character.
      See Also:
    • isDurable

      public boolean isDurable()
      Determines whether the interest registration is durable and persists between cache client sessions.
      Returns:
      a boolean value indicating whether this interest registration is durable.
    • setDurable

      public void setDurable(boolean durable)
      Sets whether interest registration is durable and persists between cache client sessions.
      Parameters:
      durable - boolean value to indicate whether this interest registration is durable.
    • getKey

      public K getKey()
      Returns the key on which interest is registered.
      Returns:
      the key of interest.
    • setKey

      public void setKey(K key)
      Sets the key on which interest is registered.
      Parameters:
      key - the key of interest.
    • getPolicy

      public org.apache.geode.cache.InterestResultPolicy getPolicy()
      Returns the InterestResultPolicy used when interest is registered and determines whether KEYS, KEYS_VALUES or nothing (NONE) is initially fetched on initial registration.
      Returns:
      the policy
    • setPolicy

      public void setPolicy(Object policy)
      Sets the initial InterestResultPolicy used when interest is first registered and determines whether KEYS, KEYS_VALUE or nothing (NONE) is initially fetched. The argument is set as an Object to be able to accept both InterestResultPolicy and Strings, used in XML configuration meta-data.
      Parameters:
      policy - initial InterestResultPolicy to set.
      Throws:
      IllegalArgumentException - if the given policy is not a valid type.
      See Also:
      • InterestResultPolicy
    • isReceiveValues

      public boolean isReceiveValues()
      Returns the type of values received by the listener.
      Returns:
      the receiveValues
    • setReceiveValues

      public void setReceiveValues(boolean receiveValues)
      Switches between the different entities received by the listener.
      Parameters:
      receiveValues - the receiveValues to set
    • getType

      public Interest.Type getType()
      Returns the type of interest registration (e.g. based on KEY or Regex).
      Returns:
      a Interest.Type determining the type of interest.
      See Also:
    • setType

      public void setType(Interest.Type type)
      Set the type of interest registration (e.g. based on KEY or Regex).
      Parameters:
      type - Interest.Type qualifying the type of interest.
      See Also:
    • isKeyType

      public boolean isKeyType()
      Determines whether this Interest is a KEY interest registration.
      Returns:
      a boolean value indicating whether this is KEY interest.
      See Also:
    • isRegexType

      public boolean isRegexType()
      Determines whether this Interest is a REGEX interest registration.
      Returns:
      a boolean value indicating whether this is REGEX interest.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asType

      public Interest asType(Interest.Type type)
      Builder method to specify the type of interest registration.
      Parameters:
      type - Interest.Type of interest registration.
      Returns:
      this Interest.
      See Also:
    • makeDurable

      public Interest makeDurable()
      Builder method to mark this Interest as durable.
      Returns:
      this Interest.
      See Also:
    • receivesValues

      public Interest receivesValues(boolean receiveValues)
      Builder method to set whether the interest event notifications will receive values along with keys.
      Parameters:
      receiveValues - boolean to indicate that value should be sent along with keys on interest event notifications.
      Returns:
      this Interest.
      See Also:
    • usingPolicy

      public Interest usingPolicy(org.apache.geode.cache.InterestResultPolicy policy)
      Builder method to set the InterestResultPolicy used to initialize the cache.
      Parameters:
      policy - InterestResultPolicy.
      Returns:
      this Interest.
      See Also:
    • withKey

      public Interest withKey(K key)
      Builder method to express the key of interest.
      Parameters:
      key - key of interests.
      Returns:
      this Interest.
      See Also: