Package org.springframework.data.mongodb
Interface MongoTransactionOptionsResolver
public interface MongoTransactionOptionsResolver
A
TransactionOptionResolver reading MongoDB specific transaction options from
a TransactionDefinition. Implementations of MongoTransactionOptions may choose a specific
prefix for transaction attribute labels to avoid
evaluating non-store specific ones.
TransactionAttribute.getLabels() evaluated by default should follow the property style using = to
separate key and value pairs.
By default resolve(TransactionDefinition) will filter labels by the prefix and
strip the prefix from the label before handing the pruned Map to the convert(Map) function.
A transaction definition with labels targeting MongoDB may look like the following:
@Transactional(label = { "mongo:readConcern=majority" })
- Since:
- 4.3
- Author:
- Christoph Strobl
-
Method Summary
Modifier and TypeMethodDescriptionConvert the givenMapinto an instance ofMongoTransactionOptions.Obtain the defaultMongoTransactionOptionsResolverimplementation using a mongo:prefix.Get the prefix used to filter applicablelabels.default MongoTransactionOptionsresolve(TransactionDefinition definition) ResolveMongoTransactionOptionsfrom a givenTransactionDefinitionby evaluatingTransactionAttribute.getLabels()labels if possible.
-
Method Details
-
defaultResolver
Obtain the defaultMongoTransactionOptionsResolverimplementation using a mongo:prefix.- Returns:
- instance of default
MongoTransactionOptionsResolverimplementation.
-
getLabelPrefix
Get the prefix used to filter applicablelabels.- Returns:
- null if no label defined.
-
resolve
ResolveMongoTransactionOptionsfrom a givenTransactionDefinitionby evaluatingTransactionAttribute.getLabels()labels if possible.Splits applicable labels property style using = as deliminator and removes a potential
prefixbefore callingconvert(Map)with filtered label values.- Parameters:
definition-- Returns:
MongoTransactionOptions.NONEin case the givenTransactionDefinitionis not aTransactionAttributeif no matchinglabelscould be found.- Throws:
IllegalArgumentException- for options that do not map to valid transactions options or malformatted labels.
-
convert
Convert the givenMapinto an instance ofMongoTransactionOptions.- Parameters:
options- never null.- Returns:
- never null.
- Throws:
IllegalArgumentException- for invalid options.
-