Package io.mats3.spring
Annotation Type MatsMapping
-
@Documented @Retention(RUNTIME) @Target({METHOD,ANNOTATION_TYPE}) @Repeatable(MatsMappings.class) public @interface MatsMappingA method annotated with this repeatable annotation directly becomes aMats Single-stage Endpointor aMats 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 theinitiate callwhen it set this Terminator endpoint as thereplyToendpointId.Which
If you have a setup with multipleMatsFactorythe endpoint is created onMatsFactorys, 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:
MatsClassMapping
- Add a
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringconcurrencyA string representing theconcurrencyof the Endpoint.java.lang.StringendpointIdThe Mats Endpoint Id that this endpoint should listen to.java.lang.StringmatsFactoryBeanNameSpecified theMatsFactoryto use by means of specifying the bean name of theMatsFactory.java.lang.Class<? extends java.lang.annotation.Annotation>matsFactoryCustomQualifierTypeSpecifies theMatsFactoryto use by means of a specific qualifier annotation type (which thus must be meta-annotated withQualifier).java.lang.StringmatsFactoryQualifierValueSpecified theMatsFactoryto use by means of specifying the@Qualifiervalue.booleansubscriptionIf this MatsEndpoint is subscription based.java.lang.StringvalueAlias for "endpointId", so that if you only need to set the endpointId, you can do so directly:@MatsMapping("endpointId")
-
-
-
-
subscription
boolean subscription
If this MatsEndpoint is subscription based. Only Terminators can be that, so this can only be set totrueon 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
-
-
-
concurrency
java.lang.String concurrency
A string representing theconcurrencyof the Endpoint. Currently only digits are allowed, and the value is passed directly toInteger.parseInt(String). (In a future version it might be possible to specify a Spring SpEL expression, which would be evaluated against a context of the parent MatsFactory so that you could say "parentFactory * 2", and include the Spring Environment, so that you could say "env['mats.concurrency'] * 2" or similar constructs.)- Default:
- ""
-
-
-
matsFactoryCustomQualifierType
java.lang.Class<? extends java.lang.annotation.Annotation> matsFactoryCustomQualifierType
Specifies theMatsFactoryto 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.@MatsFactoryCentraland@MatsFactoryRegionWestfor the example).- Returns:
- the custom qualifier type which the wanted
MatsFactoryis qualified with.
- Default:
- java.lang.annotation.Annotation.class
-
-
-
matsFactoryQualifierValue
java.lang.String matsFactoryQualifierValue
Specified theMatsFactoryto use by means of specifying the@Qualifiervalue. 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
MatsFactoryis qualified with.
- Default:
- ""
-
-