Skip to content

db.custom_action_java_class (collection.cfg setting)

Description

⚠ This is deprecated. Use the filter framework instead.

This configuration parameter allows a class to be selected which will be given the opportunity to perform custom actions with each database record before they are written to disk. The default empty setting causes no such class to be used. If set, the value must be the fully qualified class name of the desired class.

The specified class must implement the com.funnelback.common.workflow.Workflow interface (included in the $SEARCH_HOME/lib/java/common/funnelback-common.jar), which defines a single process method which accepts a single org.w3c.dom.Document object, and returns a org.w3c.dom.Document to be indexed by Funnelback. The process method may return null rather than a Document object, which causes the record to be excluded from indexing entirely.

Custom action java class example

The ExampleWorkflow class below provides a simple example of a workflow class which performs the following two actions:

  • Adds a new 'example' element containing the text content of all children of the root node.
  • Excludes from indexing any records where the above text contains the string 'exclude-me'.
    package com.mycompany.workflows;
    
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.funnelback.common.workflow.Workflow;
    
    public class ExampleWorkflow implements Workflow {
    
    	public Document process(Document document) {
    		if (document == null) {
    			return document;
    		}
    		StringBuffer exampleContent = new StringBuffer();
    		Node rootNode = document.getFirstChild();
    		NodeList children = rootNode.getChildNodes();
    
    		String separator = "";
    		for (int i = 1; i < children.getLength(); i++) {
    			Node child = children.item(i);
    
    			if (child.getNodeType() == Node.ELEMENT_NODE) {
    				String content = child.getTextContent();
    				
    				if (content.contains("exclude-me")) {
    					return null;
    				}
    				
    				exampleContent.append(separator + content);
    				separator = ", ";
    			}
    		}
    
    		Node exampleNode = document.createElement("example");
    		exampleNode.setTextContent(exampleContent.toString());
    
    		rootNode.appendChild(exampleNode);
    
    		return document;
    	}
    
    }

Installing your own class

Funnelback must be able to find your custom java class when gathering data from a database. If the driver is packaged in a jar file, it should be placed in <install_root>/lib/java/dbgather. If a simple class file is used, it should be placed in an appropriate directory hierarchy under <install_root>/lib/java/dbgather. For example, if the fully qualified class name is com.foocorp.funnelback.CustomWorkflow, the class file should be placed at <install_root>/lib/java/dbgather/com/foocorp/funnelback/CustomWorkflow.class.

Default value

(none)

Example

db.custom_action_java_class=com.funnelback.dbgather.ExampleWorkflow

See also

top

Funnelback logo
v15.16.0