Package io.mats3.spring
Annotation Interface MatsMapping
@Documented
@Retention(RUNTIME)
@Target({METHOD,ANNOTATION_TYPE})
@Repeatable(MatsMappings.class)
public @interface MatsMapping
A method annotated with this repeatable annotation directly becomes a
Which
If you have a setup with multiple
Mats Single-stage
Endpoint
or a
Mats
Terminator Endpoint
, depending on whether the method specifies a return type, or is void.
Single-stage (service) endpoint
For the Single-Stage endpoint (where the return type is set), one method parameter should be annotated with@Dto
: When the endpoint is invoked, it will be set to the incoming
(request) Data Transfer Object - and the argument's type thus also specifies its expected deserialization class. The
method's return type represent the outgoing reply Data Transfer Object.
Terminator endpoint
For the Terminator endpoint (where the return type isvoid
), one method
parameter should be annotated with @Dto
: When the endpoint is invoked, it will be set to the incoming
(typically request - or just "message") Data Transfer Object - and the argument's type thus also specifies its
expected deserialization class. The method's return type represent the outgoing reply Data Transfer Object. In
addition, another method parameter can be annotated with @Sto
, which will be the "State Transfer Object"
- this is the object which an initiator supplied to the
initiate call
when it set this
Terminator endpoint as the replyTo
endpointId.
Which MatsFactory
the endpoint is created on
If you have a setup with multiple MatsFactory
s,
you must either have one (and only one) of the factories denoted as @Primary
, or you must qualify
which MatsFactory to use. This can be done by the following means:
- Add a
@Qualifier(qualifiervalue)
annotation to the @MatsMapping-annotated method - this both matches a MatsFactory with the same@Qualifier(qualifiervalue)
-annotation, and a MatsFactory whose bean name is the 'qualifierValue' (this dual-logic is Spring's standard). - Add a custom qualifier annotation, e.g.
@SpecialMatsFactory
, or you can make a custom qualification taking parameters like@SpecialMatsFactory(location="somevalue")
. Whether a qualification matches or not is evaluated by .equals(..)-semantics. - Use the
matsFactoryBeanName()
annotation value - Use the
matsFactoryQualifierValue()
annotation value - Use the
matsFactoryCustomQualifierType()
annotation value (please read the JavaDoc for special considerations with this).
- See Also:
-
Nested Class Summary
Nested Classes -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe Mats Endpoint Id that this endpoint should listen to.Specified theMatsFactory
to use by means of specifying the bean name of theMatsFactory
.Class<? extends Annotation>
Specifies theMatsFactory
to use by means of a specific qualifier annotation type (which thus must be meta-annotated withQualifier
).Specified theMatsFactory
to use by means of specifying the@Qualifier
value.boolean
If this MatsEndpoint is subscription based.Alias for "endpointId", so that if you only need to set the endpointId, you can do so directly:@MatsMapping("endpointId")
-
Element Details
-
endpointId
The Mats Endpoint Id that this endpoint should listen to.- Returns:
- the Mats Endpoint Id which this endpoint listens to.
- Default:
- ""
-
value
Alias for "endpointId", so that if you only need to set the endpointId, you can do so directly:@MatsMapping("endpointId")
- Returns:
- the endpointId.
- Default:
- ""
-
subscription
boolean subscriptionIf this MatsEndpoint is subscription based. Only Terminators can be that, so this can only be set totrue
on methods that have 'void' as the return type.- Returns:
- whether the Mats Endpoint should be subscription-based - and only Terminators are allowed to be that (i.e. the method must not return anything, i.e. "void").
- Default:
- false
-
matsFactoryCustomQualifierType
Class<? extends Annotation> matsFactoryCustomQualifierTypeSpecifies theMatsFactory
to use by means of a specific qualifier annotation type (which thus must be meta-annotated withQualifier
). Notice that this will search for the custom qualifier annotation type, as opposed to if you add the annotation to the @MatsMapped-annotated method directly, in which case it "equals" the annotation instance (as Spring also does when performing injection with such qualifiers). The difference comes into play if the annotation has values, where e.g. a@SpecialMatsFactory(location="central")
is not equal to@SpecialMatsFactory(location="region_west")
- but they are equal when comparing types, as the qualification here does. Thus, if using this qualifier-approach, you should probably not use values on your custom qualifier annotations (instead make separate custom qualifier annotations, e.g.@MatsFactoryCentral
and@MatsFactoryRegionWest
for the example).- Returns:
- the custom qualifier type which the wanted
MatsFactory
is qualified with.
- Default:
- java.lang.annotation.Annotation.class
-
matsFactoryQualifierValue
String matsFactoryQualifierValueSpecified theMatsFactory
to use by means of specifying the@Qualifier
value. Spring performs such lookup by first looking for actual qualifiers with the specified value, e.g.@Qualifier(value="the_value")
. If this does not produce a result, it will try to find a bean with this value as the bean name.- Returns:
- the qualifier value which the wanted
MatsFactory
is qualified with.
- Default:
- ""
-
matsFactoryBeanName
String matsFactoryBeanNameSpecified theMatsFactory
to use by means of specifying the bean name of theMatsFactory
.- Returns:
- the bean name of the wanted
MatsFactory
.
- Default:
- ""
-