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 ServiceImp
Store values extracted from message payload usingXpathQuery
as object metadata.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-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 void
addXpathQuery(XpathQuery query)
protected void
closeService()
void
doService(AdaptrisMessage msg)
Apply the service to the message.KeyValuePairSet
getNamespaceContext()
DocumentBuilderFactoryBuilder
getXmlDocumentFactoryConfig()
java.util.List<XpathObjectQuery>
getXpathQueries()
protected void
initService()
void
prepare()
Prepare for initialisation.void
setNamespaceContext(KeyValuePairSet namespaceContext)
Set the namespace context for resolving namespaces.void
setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
void
setXpathQueries(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:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
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<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 CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
getXmlDocumentFactoryConfig
public DocumentBuilderFactoryBuilder getXmlDocumentFactoryConfig()
-
setXmlDocumentFactoryConfig
public void setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
-
-