Running Business Processes and Composite Applications : webMethods Integration Server Administrator’s Guide : Configuring Ehcache on Integration Server : Making a Cache Searchable : Defining Attributes : Extracting Attributes by Class
Extracting Attributes by Class
To extract attributes by class, the extractor must be an implementation of net.sf.ehcache.search.attribute.AttributeExtractor. For more information about attribute extractors, see Ehcache product documentation for 2.8 at http://ehcache.org/documentation.
You must create an extractor similar to the sample given below and create a jar file containing this extractor. This jar file must be placed in the Integration Server_directory \instances\instance_name \lib\jars\custom directory or the Integration Server_directory \instances\instance_name \packages\packageName \code\jars directory.
The following sample shows how to extract an attribute that has a document as the element value in the key/value pair:
package com.softwareag.cache.sample;
import com.wm.data.IData;
import com.wm.data.IDataCursor;
import com.wm.data.IDataUtil;
import java.io.PrintStream;
import java.util.Properties;
import net.sf.ehcache.Element;
import net.sf.ehcache.search.attribute.AttributeExtractor;
import net.sf.ehcache.search.attribute.AttributeExtractorException;
public class IDataAttributeExtractor
implements AttributeExtractor
{
public IDataAttributeExtractor(Properties prop)
{
System.out.println(prop);
}

public Object attributeFor(Element element, String attributeName)
throws AttributeExtractorException
{
IDataCursor iData = ((IData)element.getValue()).getCursor();
String value = null;
if (("categoryName".equals(attributeName)) || ("categoryId".
equals(attributeName)))
{
IDataCursor category = IDataUtil.getIData(iData, "productCategory").
getCursor();
value = IDataUtil.getString(category, attributeName);
}
else
{
value = (String)IDataUtil.get(iData, attributeName);
}
System.out.println("Extracting...................." + attributeName +
"....." + value);
return value;
}
}
Copyright © 2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback