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 givenMap
into an instance ofMongoTransactionOptions
.Obtain the defaultMongoTransactionOptionsResolver
implementation using a mongo:prefix
.Get the prefix used to filter applicablelabels
.default MongoTransactionOptions
resolve
(TransactionDefinition definition) ResolveMongoTransactionOptions
from a givenTransactionDefinition
by evaluatingTransactionAttribute.getLabels()
labels if possible.
-
Method Details
-
defaultResolver
Obtain the defaultMongoTransactionOptionsResolver
implementation using a mongo:prefix
.- Returns:
- instance of default
MongoTransactionOptionsResolver
implementation.
-
getLabelPrefix
Get the prefix used to filter applicablelabels
.- Returns:
- null if no label defined.
-
resolve
ResolveMongoTransactionOptions
from a givenTransactionDefinition
by evaluatingTransactionAttribute.getLabels()
labels if possible.Splits applicable labels property style using = as deliminator and removes a potential
prefix
before callingconvert(Map)
with filtered label values.- Parameters:
definition
-- Returns:
MongoTransactionOptions.NONE
in case the givenTransactionDefinition
is not aTransactionAttribute
if no matchinglabels
could be found.- Throws:
IllegalArgumentException
- for options that do not map to valid transactions options or malformatted labels.
-
convert
Convert the givenMap
into an instance ofMongoTransactionOptions
.- Parameters:
options
- never null.- Returns:
- never null.
- Throws:
IllegalArgumentException
- for invalid options.
-