Class MetadataValueBranchingService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.BranchingServiceImp
-
- com.adaptris.core.services.metadata.MetadataBranchingServiceImp
-
- com.adaptris.core.services.metadata.MetadataValueBranchingService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@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 nextService
to apply based on values ofAdaptrisMessage
metadata.It concatenates the values stored against the keys in
MetadataBranchingServiceImp.getMetadataKeys()
and uses this String as a key to look up theService
to apply ingetMetadataToServiceIdMappings()
. 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.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description MetadataValueBranchingService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doService(AdaptrisMessage msg)
Obtains the value associated with each configured metadata key, concatenates these keys, then looks up and sets theService
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-idvoid
setValueMatcher(MetadataValueMatcher mvm)
Set the matching implementation for matching metadata values.-
Methods inherited from class com.adaptris.core.services.metadata.MetadataBranchingServiceImp
addMetadataKey, closeService, getDefaultServiceId, getMetadataKeys, prepare, setDefaultServiceId, setMetadataKeys
-
Methods inherited from class com.adaptris.core.BranchingServiceImp
isBranching
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
-
-
-
Method Detail
-
initService
protected void initService() throws CoreException
- Overrides:
initService
in classMetadataBranchingServiceImp
- Throws:
CoreException
-
doService
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- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s- See Also:
Service.doService(com.adaptris.core.AdaptrisMessage)
-
getMetadataToServiceIdMappings
public KeyValuePairList getMetadataToServiceIdMappings()
-
setMetadataToServiceIdMappings
public void setMetadataToServiceIdMappings(KeyValuePairList mappings)
Set the list of mappings between metadata / service-id- Parameters:
mappings
- the mapping to add
-
getValueMatcher
public MetadataValueMatcher getValueMatcher()
- Returns:
- the valueMatcher
-
setValueMatcher
public void setValueMatcher(MetadataValueMatcher mvm)
Set the matching implementation for matching metadata values.- Parameters:
mvm
- the valueMatcher implementation to use. UsingEqualsValueMatcher
orIgnoresCaseValueMatcher
will replicate the previous functionality
-
-