You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-dev@ws.apache.org by Adi <ad...@gmail.com> on 2007/09/19 17:26:52 UTC

How to add a new Filter and FilterFactory?

Sorry for cross posting to both user and dev groups but I think the topic is
relevant to both.

We are using muse to get notifications whenever there are changes in  a data
model. We need to filter some of the notifications based on the attribute of
one of the data obejcts.

Use case :  Subscribe to a topic "XOBJ_UPDATES" and receive messages only
when a property in a message (xObj.location) matches a regular expression.

Our approach: Use a FilterCollection of TopicFilter and a custom Filter say
MessageElementFilter.
Implement a MessageElementFilter which will match the value of the element
to the regular expression in the accepts( ) method.

Right now I am not able to figure out how to hookup a custom Filter and its
handler on the producer side. The FilterFactory appears to allow only three
types of filters.  Is there a way to replace FilterFactory with another
custom MyFilterFactory.

Any suggestion/advice is welcome.

Thanks.

-- 
Adi

RE: How to add a new Filter and FilterFactory?

Posted by Ch...@swisscom.com.
Hi Adi,

I'm just replying to user as it there has been a fixed issue over this.
What will cause a problem is issue
https://issues.apache.org/jira/browse/MUSE-264.  I can send you a simple
notificationproducer to solve that issue (just replace the entry in the
muse.xml) if you'd like.

FilterFactory.getInstance().addHandler(new RegexFilterHandler()); can
add the filter handler.

If all you are filtering is the messages itself (not the resource or its
other properties) then you only need to implement a FilterHandler and
derive a TopicFilter.  FilterHandler creates filters and needs to be
added to FilterFactory.  This allows both receiving and persisting of
subscriptions.  

Make sure the above code line is called before you do any subscriptions
(best place is before before the muse environment/isolation layer is
started).  You may need to customise the platform your using though (I
am using my own platform so its easier for me to call the addHandler
first).

You have to choose a new filter dialect URI and check for it in the
FilterHandler.  The FilterHandler then also must take care of
XML->Filter instance and the Filter must do the -> XML.  

Since you'll receive the entire message from your TopicFilter you can
parse it for the element and do the regex.

HTH

cheers
Chris

-----Original Message-----
From: Adi [mailto:adi.pandit@gmail.com] 
Sent: Wednesday, September 19, 2007 5:27 PM
To: muse-user@ws.apache.org; muse-dev@ws.apache.org
Subject: How to add a new Filter and FilterFactory?

Sorry for cross posting to both user and dev groups but I think the
topic is relevant to both.

We are using muse to get notifications whenever there are changes in  a
data model. We need to filter some of the notifications based on the
attribute of one of the data obejcts.

Use case :  Subscribe to a topic "XOBJ_UPDATES" and receive messages
only when a property in a message (xObj.location) matches a regular
expression.

Our approach: Use a FilterCollection of TopicFilter and a custom Filter
say MessageElementFilter.
Implement a MessageElementFilter which will match the value of the
element to the regular expression in the accepts( ) method.

Right now I am not able to figure out how to hookup a custom Filter and
its handler on the producer side. The FilterFactory appears to allow
only three types of filters.  Is there a way to replace FilterFactory
with another custom MyFilterFactory.

Any suggestion/advice is welcome.

Thanks.

--
Adi

---------------------------------------------------------------------
To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org