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 MetadataServiceImplStore values extracted from message payload usingXpathQueryas 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
DocumentBuilderFactoryBuilderconfiguration, or ensuring thatnamespace-awareis set to 'true' in theDocumentBuilderFactoryBuilderconfiguration.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-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 voidaddXpathQuery(XpathQuery query)voiddoService(AdaptrisMessage msg)Apply the service to the message.KeyValuePairSetgetNamespaceContext()DocumentBuilderFactoryBuildergetXmlDocumentFactoryConfig()java.util.List<XpathQuery>getXpathQueries()protected voidinitService()voidsetNamespaceContext(KeyValuePairSet namespaceContext)Set the namespace context for resolving namespaces.voidsetXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)voidsetXpathQueries(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:
initServicein classMetadataServiceImpl- Throws:
CoreException
-
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<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)
-
-