Tuesday, April 9, 2013

How to Create a Custom Filter Class in Coherence

Usecase :  How to query Coherence cache using Custom created filters. By default Coherence API provides variety of filters like AndFilter, OrFilter, EqualsFilter, etc. You might have a requirement to create a custom Filter and use this filter to query cache.

Implementation:

Create a Custom Filter class , which implements Filter and PortableObject interfaces as shown below. This class must override evaluate method and which contains the filter logic. Make sure to add annotation to below class as @Portable



After creating Custom Filter class, Configure this in pof-config.xml as shown below. Make sure type-id must be unique in this file.
Finally, query the coherence cache as shown below using newly created custom filter.

No comments:

Post a Comment