REQUIREMENT mime.plugin.access.regex |
Type | NEW |
Priority | MEDIUM |
Status | CLOSED |
Topic | XmlBlaster allows to access messages filtered with regular expressions | ||||||||
Des cription |
XmlBlaster allows you to query messages based on their meta information with XPath. Sometimes this is not enough and you want to do sort of a full text search over the message content. For this frequent use case we deliver a plugin using regular expressions to check the message content. The plugin is registered for all message mime types, which allows you to do regular expression filtering on any message content. This filter is available for synchronous access with get() and asynchronous access with subscribe()
and as a filter for xmlBlaster cluster support.
Multiple filters can be specified in one subscribe/get invocation. Each of them may address another plugin. They are sequentially executed and if one filter denies access (the match() method returns 'false') the message is not delivered. The filters are logically AND connected.
The cascading approach for XPath/exact query and filters:
|
||||||||
Example any |
Example key and QoS of a get() or subscribe() invocation:<key queryType='XPATH'> //StockData </key> <qos> <filter type='GnuRegexFilter'> a*b </filter> </qos> All messages containing the xml meta information element <StockData/> are selected. Those message are further filtered to contain any number of 'a' and ending with exactly one 'b'. Don't forget to put your query in a <![CDATA[ ... ]]> section if you use "<" in your query string. |
||||||||
Example Java |
Code snippet in Java with the get() methodimport org.xmlBlaster.client.qos.GetQos; import org.xmlBlaster.util.MsgUnit; import org.xmlBlaster.util.qos.AccessFilterQos; GetQos qos = new GetQos(glob); qos.addAccessFilter(new AccessFilterQos(glob, "GnuRegexFilter", "1.0", "a*b")); MsgUnit[] msgUnits = con.get( "<key queryType='XPATH'> //StockData </key>", qos.toXml());
The code snippet You can play with regular expressions, just invoke (you need xmlBlaster.jar in your CLASSPATH): java RETest "aaa*b" "aab" |
||||||||
Example Java |
Command line exampleStart the server java -jar lib/xmlBlaster.jarStart a subscriber java -cp lib/xmlBlaster.jar javaclients.HelloWorldSubscribe -oid Hello -filter.type GnuRegexFilter -filter.query ".*A"Start a publisher with matching content java -cp lib/xmlBlaster.jar javaclients.HelloWorldPublish -numPublish 100 -oid Hello -content "xxA"Start a publisher with NO matching content java -cp lib/xmlBlaster.jar javaclients.HelloWorldPublish -numPublish 100 -oid Hello -content "12B"Now you can play with the full text filtering feature |
||||||||
Configure |
These parameters allow to configure the regex plugin.
NOTE: Configuration parameters are specified on command line (-someValue 17) or in the
xmlBlaster.properties file (someValue=17). See requirement "util.property" for details. |
||||||||
See | http://www.cacas.org/java/gnu/regexp/ | ||||||||
See | http://developer.java.sun.com/developer/technicalArticles/releases/1.4regex/ | ||||||||
See API | org.xmlBlaster.engine.mime.regex.GnuRegexFilter | ||||||||
See API | org.xmlBlaster.util.qos.AccessFilterQos | ||||||||
See API | org.xmlBlaster.engine.mime.I_AccessFilter | ||||||||
See API | org.xmlBlaster.util.plugin.I_Plugin | ||||||||
See REQ | mime.plugin.accessfilter.howto | ||||||||
See REQ | mime.plugin.accessfilter | ||||||||
See REQ | cluster | ||||||||
See TEST | org.xmlBlaster.test.mime.TestGetRegexFilter |
This page is generated from the requirement XML file xmlBlaster/doc/requirements/mime.plugin.access.regex.xml