Package org.infinispan.objectfilter.impl
Class BaseMatcher<TypeMetadata,AttributeMetadata,AttributeId extends Comparable<AttributeId>>
- java.lang.Object
-
- org.infinispan.objectfilter.impl.BaseMatcher<TypeMetadata,AttributeMetadata,AttributeId>
-
- All Implemented Interfaces:
Matcher
- Direct Known Subclasses:
ProtobufMatcher
,ReflectionMatcher
,RowMatcher
public abstract class BaseMatcher<TypeMetadata,AttributeMetadata,AttributeId extends Comparable<AttributeId>> extends Object implements Matcher
- Since:
- 7.0
- Author:
- anistor@redhat.com
-
-
Field Summary
Fields Modifier and Type Field Description protected org.infinispan.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata>
propertyHelper
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseMatcher(org.infinispan.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> propertyHelper)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Object
convert(Object instance)
Decorates a matching instance before it is presented to the caller of theObjectFilter.filter(Object)
.protected abstract MetadataAdapter<TypeMetadata,AttributeMetadata,AttributeId>
createMetadataAdapter(TypeMetadata entityType)
protected FilterRegistry<TypeMetadata,AttributeMetadata,AttributeId>
getFilterRegistryForType(boolean isDeltaFilter, TypeMetadata entityType)
ObjectFilter
getObjectFilter(String queryString)
ObjectFilter
getObjectFilter(String queryString, List<org.infinispan.objectfilter.impl.aggregation.FieldAccumulator> acc)
ObjectFilter
getObjectFilter(FilterSubscription filterSubscription)
Obtains an ObjectFilter instance that is capable of testing a single filter condition.ObjectFilter
getObjectFilter(Query query)
org.infinispan.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata>
getPropertyHelper()
void
match(Object userContext, Object eventType, Object instance)
Executes the registered filters and notifies each one of them whether it was satisfied or not by the given instance.void
matchDelta(Object userContext, Object eventType, Object instanceOld, Object instanceNew, Object joiningEvent, Object updatedEvent, Object leavingEvent)
Test two instances (which are actually before/after snapshots of the same instance) against all the subscribed filters and notify all callbacks registered for instances of the same instance type.FilterSubscription
registerFilter(String queryString, Map<String,Object> namedParameters, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
FilterSubscription
registerFilter(String queryString, Map<String,Object> namedParameters, FilterCallback callback, Object... eventType)
FilterSubscription
registerFilter(String queryString, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
FilterSubscription
registerFilter(String queryString, FilterCallback callback, Object... eventType)
FilterSubscription
registerFilter(Query query, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
FilterSubscription
registerFilter(Query query, FilterCallback callback, Object... eventType)
protected abstract org.infinispan.objectfilter.impl.predicateindex.MatcherEvalContext<TypeMetadata,AttributeMetadata,AttributeId>
startMultiTypeContext(boolean isDelta, Object userContext, Object eventType, Object instance)
Creates a newMatcherEvalContext
capable of dealing with multiple filters.protected abstract org.infinispan.objectfilter.impl.predicateindex.MatcherEvalContext<TypeMetadata,AttributeMetadata,AttributeId>
startSingleTypeContext(Object userContext, Object eventType, Object instance, MetadataAdapter<TypeMetadata,AttributeMetadata,AttributeId> metadataAdapter)
Creates a newMatcherEvalContext
capable of dealing with a single filter for a single type.void
unregisterFilter(FilterSubscription filterSubscription)
-
-
-
Field Detail
-
propertyHelper
protected final org.infinispan.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> propertyHelper
-
-
Constructor Detail
-
BaseMatcher
protected BaseMatcher(org.infinispan.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> propertyHelper)
-
-
Method Detail
-
getPropertyHelper
public org.infinispan.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> getPropertyHelper()
-
match
public void match(Object userContext, Object eventType, Object instance)
Executes the registered filters and notifies each one of them whether it was satisfied or not by the given instance.- Specified by:
match
in interfaceMatcher
- Parameters:
userContext
- an optional user provided object to be passed to matching subscribers along with the matching instance; can benull
eventType
- on optional event type discriminator that is matched against the even type specified when the filter was registered; can benull
instance
- the object to test against the registered filters; nevernull
-
matchDelta
public void matchDelta(Object userContext, Object eventType, Object instanceOld, Object instanceNew, Object joiningEvent, Object updatedEvent, Object leavingEvent)
Description copied from interface:Matcher
Test two instances (which are actually before/after snapshots of the same instance) against all the subscribed filters and notify all callbacks registered for instances of the same instance type. TheisDelta
parameter of the callback will betrue
.- Specified by:
matchDelta
in interfaceMatcher
- Parameters:
userContext
- an optional user provided object to be passed to matching subscribers along with the matching instance; can benull
eventType
- on optional event type discriminator that is matched against the event type specified when the filter was registered; can benull
instanceOld
- the 'before' object to test against the registered filters; nevernull
instanceNew
- the 'after' object to test against the registered filters; nevernull
joiningEvent
- the event to generate if the instance joins the matching setupdatedEvent
- the event to generate if a matching instance is updated and continues to the matchleavingEvent
- the event to generate if the instance leaves the matching set
-
getObjectFilter
public ObjectFilter getObjectFilter(Query query)
- Specified by:
getObjectFilter
in interfaceMatcher
-
getObjectFilter
public ObjectFilter getObjectFilter(String queryString)
- Specified by:
getObjectFilter
in interfaceMatcher
-
getObjectFilter
public ObjectFilter getObjectFilter(String queryString, List<org.infinispan.objectfilter.impl.aggregation.FieldAccumulator> acc)
- Specified by:
getObjectFilter
in interfaceMatcher
-
getObjectFilter
public ObjectFilter getObjectFilter(FilterSubscription filterSubscription)
Description copied from interface:Matcher
Obtains an ObjectFilter instance that is capable of testing a single filter condition.- Specified by:
getObjectFilter
in interfaceMatcher
- Parameters:
filterSubscription
- a filter subscription previously registered with this Matcher; the newly created ObjectFilter will be based on the same filter condition- Returns:
- the single-filter
-
registerFilter
public FilterSubscription registerFilter(Query query, FilterCallback callback, Object... eventType)
- Specified by:
registerFilter
in interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(Query query, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
- Specified by:
registerFilter
in interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(String queryString, FilterCallback callback, Object... eventType)
- Specified by:
registerFilter
in interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(String queryString, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
- Specified by:
registerFilter
in interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(String queryString, Map<String,Object> namedParameters, FilterCallback callback, Object... eventType)
- Specified by:
registerFilter
in interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(String queryString, Map<String,Object> namedParameters, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
- Specified by:
registerFilter
in interfaceMatcher
-
unregisterFilter
public void unregisterFilter(FilterSubscription filterSubscription)
- Specified by:
unregisterFilter
in interfaceMatcher
-
startMultiTypeContext
protected abstract org.infinispan.objectfilter.impl.predicateindex.MatcherEvalContext<TypeMetadata,AttributeMetadata,AttributeId> startMultiTypeContext(boolean isDelta, Object userContext, Object eventType, Object instance)
Creates a newMatcherEvalContext
capable of dealing with multiple filters. The context is created only if the given instance is recognized to be of a type that has some filters registered. If there are no filters,null
is returned to signal this condition and make the evaluation faster. This method must be called while holding the internal write lock.- Parameters:
isDelta
- indicates if this is a delta match of notuserContext
- an opaque value, possibly null, the is received from the caller and is to be handed to theFilterCallback
in case a match is detectedeventType
- on optional event type discriminatorinstance
- the instance to filter; nevernull
- Returns:
- the MatcherEvalContext or
null
if no filter was registered for the instance
-
startSingleTypeContext
protected abstract org.infinispan.objectfilter.impl.predicateindex.MatcherEvalContext<TypeMetadata,AttributeMetadata,AttributeId> startSingleTypeContext(Object userContext, Object eventType, Object instance, MetadataAdapter<TypeMetadata,AttributeMetadata,AttributeId> metadataAdapter)
Creates a newMatcherEvalContext
capable of dealing with a single filter for a single type. The context is created only if the given instance is recognized to be of a type that has some filters registered. If there are no filters,null
is returned to signal this condition and make the evaluation faster. This method must be called while holding the internal write lock.- Parameters:
userContext
- an opaque value, possibly null, the is received from the caller and is to be handed to theFilterCallback
in case a match is detectedinstance
- the instance to filter; nevernull
metadataAdapter
- the metadata adapter of expected instance type- Returns:
- the MatcherEvalContext or
null
if no filter was registered for the instance
-
createMetadataAdapter
protected abstract MetadataAdapter<TypeMetadata,AttributeMetadata,AttributeId> createMetadataAdapter(TypeMetadata entityType)
-
getFilterRegistryForType
protected final FilterRegistry<TypeMetadata,AttributeMetadata,AttributeId> getFilterRegistryForType(boolean isDeltaFilter, TypeMetadata entityType)
-
convert
protected Object convert(Object instance)
Decorates a matching instance before it is presented to the caller of theObjectFilter.filter(Object)
.- Parameters:
instance
- never null- Returns:
- the converted/decorated instance
-
-