Class XpathObjectMetadataService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.metadata.XpathObjectMetadataService
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,MessageEventGenerator,Service,StateManagedComponent
@ComponentProfile(summary="Extract data via XPath and store it as object metadata", tag="service,metadata,xml,xpath") public class XpathObjectMetadataService extends ServiceImpStore values extracted from message payload usingXpathQueryas object metadata.If the
DocumentBuilderFactoryBuilderhas been explicitly set to be not namespace aware and the document does in fact contain namespaces, then Saxon can cause merry havoc in the sense that//NonNamespaceXpathdoesn't work if the document has namespaces in it. We have included a shim so that behaviour can be toggled based on what you have configured.- See Also:
XPath.newXPathInstance(DocumentBuilderFactoryBuilder, NamespaceContext)
In the adapter configuration file this class is aliased as xpath-object-metadata-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description XpathObjectMetadataService()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddXpathQuery(XpathQuery query)protected voidcloseService()voiddoService(AdaptrisMessage msg)Apply the service to the message.KeyValuePairSetgetNamespaceContext()DocumentBuilderFactoryBuildergetXmlDocumentFactoryConfig()java.util.List<XpathObjectQuery>getXpathQueries()protected voidinitService()voidprepare()Prepare for initialisation.voidsetNamespaceContext(KeyValuePairSet namespaceContext)Set the namespace context for resolving namespaces.voidsetXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)voidsetXpathQueries(java.util.List<XpathObjectQuery> xql)Set the list of XpathQuery instances that will be executed.-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
-
-
-
Method Detail
-
initService
protected void initService() throws CoreException- Specified by:
initServicein classServiceImp- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:ServiceApply the service to the message.
- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
getNamespaceContext
public KeyValuePairSet getNamespaceContext()
-
setNamespaceContext
public void setNamespaceContext(KeyValuePairSet namespaceContext)
Set the namespace context for resolving namespaces.- The key is the namespace prefix
- The value is the namespace uri
- Parameters:
namespaceContext-
-
getXpathQueries
public java.util.List<XpathObjectQuery> getXpathQueries()
-
setXpathQueries
public void setXpathQueries(java.util.List<XpathObjectQuery> xql)
Set the list of XpathQuery instances that will be executed.- Parameters:
xql-
-
addXpathQuery
public void addXpathQuery(XpathQuery query)
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Throws:
CoreException
-
getXmlDocumentFactoryConfig
public DocumentBuilderFactoryBuilder getXmlDocumentFactoryConfig()
-
setXmlDocumentFactoryConfig
public void setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
-
-