@ComponentProfile(summary="Perform a branch based on a match of a metadata value", tag="service,branching", branchSelector=true) public class MetadataValueBranchingService extends MetadataBranchingServiceImp
Implementation of Service
which sets the unique ID of the next Service
to apply based on
values of AdaptrisMessage
metadata.
It concatenates the values stored against the keys in MetadataBranchingServiceImp.getMetadataKeys()
and uses this String as a key to look up the
Service
to apply in getMetadataToServiceIdMappings()
. In most use cases you would only
configure a single metadata key to branch on rather than multiple keys.
In the adapter configuration file this class is aliased as metadata-value-branching-service which is the preferred alternative to the fully qualified classname when building your configuration.
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
MetadataValueBranchingService() |
Modifier and Type | Method and Description |
---|---|
void |
doService(AdaptrisMessage msg)
Obtains the value associated with each configured metadata key, concatenates these keys, then looks up and sets the
Service unique ID associated with this concatenated key. |
KeyValuePairList |
getMetadataToServiceIdMappings() |
MetadataValueMatcher |
getValueMatcher() |
protected void |
initService() |
void |
setMetadataToServiceIdMappings(KeyValuePairList mappings)
Set the list of mappings between metadata / service-id
|
void |
setValueMatcher(MetadataValueMatcher mvm)
Set the matching implementation for matching metadata values.
|
addMetadataKey, closeService, getDefaultServiceId, getMetadataKeys, prepare, setDefaultServiceId, setMetadataKeys
isBranching
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setLookupName, setUniqueId, start, stop
protected void initService() throws CoreException
initService
in class MetadataBranchingServiceImp
CoreException
public void doService(AdaptrisMessage msg) throws ServiceException
Obtains the value associated with each configured metadata key, concatenates these keys, then looks up and sets the
Service
unique ID associated with this concatenated key.
If any of the configured keys return null, nothing is appended to the result key.
If no ID is stored against the created key, the default ID will be returned if one is configured. Otherwise a
ServiceException
is thrown
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
sService.doService(com.adaptris.core.AdaptrisMessage)
public KeyValuePairList getMetadataToServiceIdMappings()
public void setMetadataToServiceIdMappings(KeyValuePairList mappings)
mappings
- the mapping to addpublic MetadataValueMatcher getValueMatcher()
public void setValueMatcher(MetadataValueMatcher mvm)
mvm
- the valueMatcher implementation to use. Using EqualsValueMatcher
or IgnoresCaseValueMatcher
will
replicate the previous functionality