www.espertech.comDocumentation
The plug-in event representation based on Apache Axiom can process XML documents by means of the Streaming API for XML (StAX) and the concept of "pull parsing", which can gain performance improvements extracting data from XML documents.
The instructions below have been tested with Apache Axiom version 1.2.5. Please visit http://ws.apache.org/commons/axiom/
for more information.
Apache Axiom requires additional jar files that are not part of the EsperIO distribution and must be downloaded separately.
There are 3 steps to follow:
Enable Apache Axiom by adding the Axiom even representation to the engine configuration.
Register your application event type names.
Process org.apache.axiom.om.OMDocument
or OMElement
event objects.
To enable Apache Axiom event processing, use the code snippet shown next, or configure via confiugration XML:
Configuration config = new Configuration(); config.addPlugInEventRepresentation(new URI("type://xml/apacheaxiom/OMNode"), AxiomEventRepresentation.class.getName(), null);
Your application may register Axiom event types in advance. Here is sample code for adding event types based on Axiom:
ConfigurationEventTypeAxiom desc = new ConfigurationEventTypeAxiom(); desc.setRootElementName("measurement"); desc.addXPathProperty("measurement", "/sensor/measurement", XPathConstants.NUMBER); URI[] resolveURIs = new URI[] {new URI("type://xml/apacheaxiom/OMNode/SensorEvent")}; configuration.addPlugInEventType("SensorEvent", resolveURIs, desc);
The operation above is available at configuration time and also at runtime via ConfigurationOperations
. After registering an event type name as above, your application can create EPL statements.
To send Axiom OMDocument
or OMElement
events into the engine, your application code must obtain an EventSender
to process Axiom OMElement
events:
URI[] resolveURIs = new URI[] {new URI("type://xml/apacheaxiom/OMNode/SensorEvent")}; EventSender sender = epService.getEPRuntime().getEventSender(resolveURIs); String xml = "<measurement><temperature>98.6</temperature></measurement>"; InputStream s = new ByteArrayInputStream(xml.getBytes()); OMElement omElement = new StAXOMBuilder(s).getDocumentElement(); sender.sendEvent(omElement);
Configuring an Axiom event type via XML is easy. An Esper configuration XML can be found in the file esper-axiom-sample-configuration.xml
in the etc
folder of the EsperIO distribution.
The configuration XML for the ConfigurationEventTypeAxiom
class adheres to the schema esperio-axiom-configuration-6-0.xsd
also in the etc
folder of the EsperIO distribution.