Class XpathMetadataService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.metadata.MetadataServiceImpl
-
- com.adaptris.core.services.metadata.XpathMetadataService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Extract data via XPath and store it as metadata", tag="service,metadata,xml,xpath") public class XpathMetadataService extends MetadataServiceImpl
Store values extracted from message payload usingXpathQuery
as metadata.This service will support XPath 2.0+ features, but in order to use XPath 2.0 features you must use Saxon as your XPath provider. This means either explicitly removing all
DocumentBuilderFactoryBuilder
configuration, or ensuring thatnamespace-aware
is set to 'true' in theDocumentBuilderFactoryBuilder
configuration.If the
DocumentBuilderFactoryBuilder
has 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//NonNamespaceXpath
doesn'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-metadata-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
MetadataServiceImpl.LogWrapper
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
DEBUG, ERROR, INFO, TRACE, WARN
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description XpathMetadataService()
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addXpathQuery(XpathQuery query)
void
doService(AdaptrisMessage msg)
Apply the service to the message.KeyValuePairSet
getNamespaceContext()
DocumentBuilderFactoryBuilder
getXmlDocumentFactoryConfig()
java.util.List<XpathQuery>
getXpathQueries()
protected void
initService()
void
setNamespaceContext(KeyValuePairSet namespaceContext)
Set the namespace context for resolving namespaces.void
setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
void
setXpathQueries(java.util.List<XpathQuery> xql)
Set the list of XpathQuery instances that will be executed.-
Methods inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
closeService, getMetadataLogger, logMetadata, logMetadata, logMetadata, logMetadata, prepare, setMetadataLogger, withMetadataLogger
-
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
- Overrides:
initService
in classMetadataServiceImpl
- Throws:
CoreException
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
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<XpathQuery> getXpathQueries()
-
setXpathQueries
public void setXpathQueries(java.util.List<XpathQuery> xql)
Set the list of XpathQuery instances that will be executed.- Parameters:
xql
-
-
addXpathQuery
public void addXpathQuery(XpathQuery query)
-
getXmlDocumentFactoryConfig
public DocumentBuilderFactoryBuilder getXmlDocumentFactoryConfig()
-
setXmlDocumentFactoryConfig
public void setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
-
-