|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.xmlBlaster.engine.mime.xpath.XPathFilter
Filter content on an XPath expression.
Filter on the content of an xml mime message.
The applicable mime types for this filter can be specified using the
engine.mime.xpath.types parameter with semi-colon separated mime types
e.g. engine.mime.xpath.types=text/xml;image/svg+xml;application/xml
The filter will cache the message dom tree it produces,
keyd on message oid and message timestamp, and reuse it.
For example if there is 1000 subscribers with an XPathFilter,
it will not create 1000 DOM trees for each message, but one that will be reused in each match().
The backlog is 10 by default, and old entries will be discarded.
This is settable with the paramater engine.mime.xpath.maxcachesize.
For example:
MimeAccessPlugin[XPathFilter][1.0]=org.xmlBlaster.engine.mime.xpath.XPathFilter,engine.mime.xpath.maxcachesize=20.
Additional xpath functions can be loaded by setting the parameter engine.mime.xpath.extension_functions.
For a description of the parameter syntax and implementation requirements, see loadXPathExtensionFunctions
| Nested Class Summary | |
(package private) class |
XPathFilter.Entry
An entry in the domCache. |
| Field Summary | |
static java.lang.String |
DEFAULT_MAX_CACHE_SIZE
|
private java.util.LinkedList |
domCache
|
private Global |
glob
|
private static java.util.logging.Logger |
log
|
static java.lang.String |
MATCH_AGAINST_QOS
|
private boolean |
matchAgainstQos
|
static java.lang.String |
MAX_DOM_CACHE_SIZE
|
private int |
maxCacheSize
|
private java.lang.String |
ME
|
private java.lang.String[] |
mimeTypes
|
private PluginInfo |
pluginInfo
|
static java.lang.String |
XPATH_EXTENSTION_FUNCTIONS
|
static java.lang.String |
XPATH_MIME_TYPES
|
static java.lang.String |
XSL_CONTENT_TRANSFORMER_FILE_NAME
|
private java.lang.String |
xslContentTransformerFileName
|
| Constructor Summary | |
XPathFilter()
|
|
| Method Summary | |
private org.w3c.dom.Document |
getDocument(MsgUnit msg)
Get a dom document for message, from cache or create a new one. |
private org.w3c.dom.Document |
getDocument(java.lang.String xml)
Create a new dom document. |
java.lang.String[] |
getMimeExtended()
Get the content MIME version number for which this plugin applies |
java.lang.String[] |
getMimeTypes()
Get the content MIME type for which this plugin applies, currently "text/xml" and "image/svg+xml". |
java.lang.String |
getName()
Get a human readable name of this filter implementation |
java.lang.String |
getType()
Return plugin type for Plugin loader |
java.lang.String |
getVersion()
Return plugin version for Plugin loader |
private java.lang.String |
getXml(MsgUnit msg)
Access the XML string (from QoS or content). |
void |
init(Global glob,
PluginInfo pluginInfo)
This method is called by the PluginManager (enforced by I_Plugin). |
void |
initialize(ServerScope glob)
This is called after instantiation of the plugin |
protected void |
loadXPathExtensionFunctions(java.lang.String extensionClassList)
Load xpath extension functions from a semicolon separated list of classes. |
static void |
main(java.lang.String[] args)
Command line helper to test your XPath syntax. |
boolean |
match(SessionInfo receiver,
MsgUnit msgUnit,
Query query)
Check if the filter rule matches for this message. |
void |
shutdown()
Cleans up the resource. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String MAX_DOM_CACHE_SIZE
public static final java.lang.String DEFAULT_MAX_CACHE_SIZE
public static final java.lang.String MATCH_AGAINST_QOS
public static final java.lang.String XSL_CONTENT_TRANSFORMER_FILE_NAME
public static final java.lang.String XPATH_EXTENSTION_FUNCTIONS
public static final java.lang.String XPATH_MIME_TYPES
private final java.lang.String ME
private Global glob
private static java.util.logging.Logger log
private int maxCacheSize
private java.util.LinkedList domCache
private java.lang.String[] mimeTypes
private PluginInfo pluginInfo
private boolean matchAgainstQos
private java.lang.String xslContentTransformerFileName
| Constructor Detail |
public XPathFilter()
| Method Detail |
public void initialize(ServerScope glob)
initialize in interface I_AccessFilterglob - The Global handle of this xmlBlaster server instance.
public void init(Global glob,
PluginInfo pluginInfo)
throws XmlBlasterException
init in interface I_PluginXmlBlasterExceptionI_Plugin.init(org.xmlBlaster.util.Global,org.xmlBlaster.util.plugin.PluginInfo)public java.lang.String getType()
getType in interface I_Pluginpublic java.lang.String getVersion()
getVersion in interface I_Pluginpublic java.lang.String getName()
getName in interface I_AccessFilterpublic java.lang.String[] getMimeTypes()
getMimeTypes in interface I_AccessFilterpublic java.lang.String[] getMimeExtended()
getMimeExtended in interface I_AccessFilter
public boolean match(SessionInfo receiver,
MsgUnit msgUnit,
Query query)
throws XmlBlasterException
The dom tree generated will be cached for each message, to be used for other queries against the same message.
match in interface I_AccessFilterreceiver - The subject object describing the receivermsgUnit - The message to checkquery - The Query instance holding the xpath expression from your filter.XmlBlasterException - Is thrown on problems, for example if the MIME type
does not fit to message content.public void shutdown()
I_Plugin
shutdown in interface I_Plugin
protected void loadXPathExtensionFunctions(java.lang.String extensionClassList)
throws XmlBlasterException
List syntax:
The prefix may be the empty string. The class must implement the
function := prefix ":" function-name ":" class-name
extensionClassList := ( function (";" function)* )?
org.jaxen.Function interface.
Example string:
engine.mime.xpath.extension_functions=:recursive-text:org.xmlBlaster.engine.mime.xpath.RecursiveTextFunction
extensionClassList - semicolon separated list of function definitions
XmlBlasterException - if the syntax is incorrect, or the class could not be loaded
private org.w3c.dom.Document getDocument(MsgUnit msg)
throws XmlBlasterException
XmlBlasterExceptionprivate java.lang.String getXml(MsgUnit msg)
msg -
private org.w3c.dom.Document getDocument(java.lang.String xml)
throws XmlBlasterException
XmlBlasterExceptionpublic static void main(java.lang.String[] args)
Please pass on command line the XML of the message content, you then can interactively test your XPath query. Type 'q' to quit.
export CLASSPATH=$CLASSPATH:$XMLBLASTER_HOME/lib/jaxen.jar
java org.xmlBlaster.engine.mime.xpath.XPathFilter -inFile [someFile.xml]
java org.xmlBlaster.engine.mime.xpath.XPathFilter -inFile [someFile.xml] -xslContentTransformerFileName [someFile.xsl]
Example:
cd xmlBlaster/testsuite/data/xml
java org.xmlBlaster.engine.mime.xpath.XPathFilter -inFile Airport.xml -xslContentTransformerFileName transformToKeyValue.xsl
todo: Using http://jline.sourceforge.net/ for nicer command line input handling
Example:
java -cp /opt/download/jline-demo.jar:/opt/download/jline-0_9_5-demo.jar jline.example.Example simple
args - -inFile [fileName.xml] OR -xml [the xml string]
|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||