Developing a Custom XML Processor
The XML connector is able to run user-supplied code to process XML documents.
Develop Regular and Split Processors
Every XML processor must implement com.exalead.papi.connectors.filesystem.xml.processors.common.PAPIXMLConnector .
However two typical implementations are more reusable: PAPIDOMProcessor and PAPISAXProcessor .
All processors are given a com.exalead.papi.helper.Document attribute called papiDocument where processor results must be applied.
Develop Regular Processors
To develop your own SAX processor, implement a regular SAX ContentHandler but extend PAPISAXProcessor , instead of DefaultHandler .
For example:
package com.exalead.papi.connectors.filesystem.xml.processors; import com.exalead.papi.connectors.filesystem.xml.processors.common.PAPISAXProcessor; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class CustomSAXProcessor extends PAPISAXProcessor { @Override public void startDocument() throws SAXException { /* TODO */ } @Override public void endDocument() throws SAXException { /* TODO */ } @Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { /* TODO */ } @Override public void endElement(String arg0, String localName, String arg2) throws SAXException { /* TODO */ } @Override public void characters(char[] arg0, int arg1, int arg2) throws SAXException { /* TODO */ } }
If you want to develop a DOM processor, extend PAPIDOMProcessor , and implement the process(org.w3c.dom.Document) method.
package com.exalead.papi.connectors.filesystem.xml.processors; import com.exalead.papi.connectors.filesystem.xml.processors.common.PAPIDOMProcessor; import org.w3c.dom.Document; public class CustomDOMProcessor extends PAPIDOMProcessor { @Override public void process(Document domDocument) throws Exception { /* TODO */ } }
Develop Split Processors
To develop a splitting processor, extend either PAPIDOMProcessor or PAPISAXProcessor , and implement SplitProcessor .
For a configuration example, see processors.ChildSplitProcessor .
Compile and Deploy a Custom Processor
Requirements
For requirements on developing custom Java components, see "Customizing CloudView" in the Exalead CloudView Programmer's Guide .
Compile a Custom Processor
To compile a custom processor, you need the following jars in your build path:
• <DATADIR>/resource/all-arch/builtin_plugins_deployed/core-java-connectors-plugin/lib/core-java-connectors-plugin.jar
• <INSTALLDIR>/sdk/java-customcode/lib/papi-java-client.jar
Deploy a Custom Processor
1. Make a JAR containing the processor classes, for example, custom-processor.jar .
2. Copy the JAR to: <DATADIR>/resource/all-arch/builtin_plugins_deployed/core-java-connectors-plugin/lib/
3. Restart the connector server process.
4. In the Administration Console , add it to the Custom processors by specifying its full class name in the Java class configuration entry, as shown in the following example.
Important: Repeat step 2 after migrating Exalead CloudView to a new version.
This site works best with JavaScript enabled