Class Interest<K>
java.lang.Object
org.springframework.data.gemfire.client.Interest<K>
- All Implemented Interfaces:
InitializingBean
- Direct Known Subclasses:
KeyInterest
,RegexInterest
The Interest class holds details for registering a client interest.
- Since:
- 1.0.0
- Author:
- Costin Leau, John Blum
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected static final boolean
protected static final boolean
protected final org.slf4j.Logger
-
Constructor Summary
ConstructorDescriptionConstructs an instance of non-durableInterest
initialized with the given key to register interest in, using theInterestResultPolicy.DEFAULT
to initialize the client cache and receiving values by default.Interest
(K key, InterestResultPolicy policy) Constructs an instance of non-durableInterest
initialized with the given key to register interest in, the givenInterestResultPolicy
used to initialize the client cache, receiving values by default.Interest
(K key, InterestResultPolicy policy, boolean durable) Constructs an instance ofInterest
initialized with the given key to register interest in, the givenInterestResultPolicy
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, InterestResultPolicy policy, boolean durable, boolean receiveValues) Constructs an instance ofInterest
initialized with the given key to register interest in, the givenInterestResultPolicy
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 TypeMethodDescriptionvoid
asType
(Interest.Type type) Builder method to specify the type of interest registration.protected boolean
Determines whether the givenString
value contains at least 1 special character.getKey()
Returns the key on which interest is registered.Returns theInterestResultPolicy
used when interest is registered and determines whether KEYS, KEYS_VALUES or nothing (NONE) is initially fetched on initial registration.getType()
Returns the type of interest registration (e.g. based on KEY or Regex).protected boolean
isAlphaNumericWhitespace
(char character) Determines whether the givencharacter
is an alphanumeric or whitespace character.boolean
Determines whether the interest registration is durable and persists between cache client sessions.boolean
Determines whether thisInterest
is a KEY interest registration.protected boolean
isNotAlphaNumericWhitespace
(char character) Determines whether the givencharacter
is a special character (non-alphanumeric, non-whitespace).boolean
Returns the type of values received by the listener.boolean
Determines whether thisInterest
is a REGEX interest registration.protected boolean
Determines whether the givenkey
is a Regular Expression (Regex).protected boolean
isRegularExpression
(String value) Determines whether the givenkey
is a Regular Expression (Regex).Builder method to mark thisInterest
as durable.static <K> Interest
newInterest
(K key) Factory method to construct a new instance ofInterest
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
resolveType
(Interest.Type type) Attempts to resolve theInterest.Type
based on the configuredgetKey()
.void
setDurable
(boolean durable) Sets whether interest registration is durable and persists between cache client sessions.void
Sets the key on which interest is registered.void
Sets the initialInterestResultPolicy
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
setType
(Interest.Type type) Set the type of interest registration (e.g. based on KEY or Regex).toString()
usingPolicy
(InterestResultPolicy policy) Builder method to set theInterestResultPolicy
used to initialize the cache.Builder method to express the key of interest.
-
Field Details
-
ALL_KEYS
- See Also:
-
DEFAULT_DURABLE
protected static final boolean DEFAULT_DURABLE- See Also:
-
DEFAULT_RECEIVE_VALUES
protected static final boolean DEFAULT_RECEIVE_VALUES- See Also:
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
Interest
Constructs an instance of non-durableInterest
initialized with the given key to register interest in, using theInterestResultPolicy.DEFAULT
to initialize the client cache and receiving values by default.- Parameters:
key
- key(s) of interest.- See Also:
-
Interest
Constructs an instance of non-durableInterest
initialized with the given key to register interest in, the givenInterestResultPolicy
used to initialize the client cache, receiving values by default.- Parameters:
key
- key(s) of interest.policy
- initialInterestResultPolicy
used to initialize the client cache.- See Also:
-
Interest
Constructs an instance ofInterest
initialized with the given key to register interest in, the givenInterestResultPolicy
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
- initialInterestResultPolicy
used to initialize the client cache.durable
- boolean value to indicate whether the interest registration should be durable.- See Also:
-
Interest
Constructs an instance ofInterest
initialized with the given key to register interest in, the givenInterestResultPolicy
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
- initialInterestResultPolicy
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
Factory method to construct a new instance ofInterest
initialized with the given key. -
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
resolveType
Attempts to resolve theInterest.Type
based on the configuredgetKey()
.- Parameters:
type
- providedInterest.Type
used if non-null.- Returns:
- the resolved
Interest.Type
. - See Also:
-
isRegularExpression
Determines whether the givenkey
is a Regular Expression (Regex). If the givenkey
is "ALL_KEYS", aList
or only contains letters, numbers and spaces, then thekey
is not considered a Regular Expression by GemFire, and can be handled with normal interest registration usingRegion.registerInterest(Object)
. -
isRegularExpression
Determines whether the givenkey
is a Regular Expression (Regex). If the givenvalue
contains at least 1 special character (e.g. *) and can be compiled usingPattern.compile(String)
, then thekey
is considered a Regular Expression and interest will be registered usingRegion.registerInterestRegex(String)
. -
containsNonAlphaNumericWhitespace
Determines whether the givenString
value contains at least 1 special character. -
isNotAlphaNumericWhitespace
protected boolean isNotAlphaNumericWhitespace(char character) Determines whether the givencharacter
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 givencharacter
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
Returns the key on which interest is registered.- Returns:
- the key of interest.
-
setKey
Sets the key on which interest is registered.- Parameters:
key
- the key of interest.
-
getPolicy
Returns theInterestResultPolicy
used when interest is registered and determines whether KEYS, KEYS_VALUES or nothing (NONE) is initially fetched on initial registration.- Returns:
- the policy
-
setPolicy
Sets the initialInterestResultPolicy
used when interest is first registered and determines whether KEYS, KEYS_VALUE or nothing (NONE) is initially fetched. The argument is set as anObject
to be able to accept bothInterestResultPolicy
andStrings
, used in XML configuration meta-data.- Parameters:
policy
- initialInterestResultPolicy
to set.- Throws:
IllegalArgumentException
- if the givenpolicy
is not a valid type.- See Also:
-
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
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
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 thisInterest
is a KEY interest registration.- Returns:
- a boolean value indicating whether this is KEY interest.
- See Also:
-
isRegexType
public boolean isRegexType()Determines whether thisInterest
is a REGEX interest registration.- Returns:
- a boolean value indicating whether this is REGEX interest.
- See Also:
-
toString
-
asType
Builder method to specify the type of interest registration.- Parameters:
type
-Interest.Type
of interest registration.- Returns:
- this
Interest
. - See Also:
-
makeDurable
Builder method to mark thisInterest
as durable.- Returns:
- this
Interest
. - See Also:
-
receivesValues
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
Builder method to set theInterestResultPolicy
used to initialize the cache.- Parameters:
policy
-InterestResultPolicy
.- Returns:
- this
Interest
. - See Also:
-
withKey
Builder method to express the key of interest.- Parameters:
key
- key of interests.- Returns:
- this
Interest
. - See Also:
-