Annotation Interface MatsMapping


A method annotated with this repeatable annotation directly becomes a 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 is void), 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 MatsFactorys, 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).
You cannot specify more than one qualification per @MatsMapping. As mentioned, @MatsMapping is repeatable, so you can specify multiple mappings on one method. However, the two first ways to qualify which MatsFactory to use (that is, by means of annotating the @MatsMapping-annotated method with the qualifier annotation) will then apply to all of the mappings, while the three annotation-value based qualifications applies to the specific mapping.
See Also:
  • Element Details

    • endpointId

      @AliasFor("value") String endpointId
      The Mats Endpoint Id that this endpoint should listen to.
      Returns:
      the Mats Endpoint Id which this endpoint listens to.
      Default:
      ""
    • value

      @AliasFor("endpointId") String 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 subscription
      If this MatsEndpoint is subscription based. Only Terminators can be that, so this can only be set to true 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> matsFactoryCustomQualifierType
      Specifies the MatsFactory to use by means of a specific qualifier annotation type (which thus must be meta-annotated with Qualifier). 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 matsFactoryQualifierValue
      Specified the MatsFactory 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 matsFactoryBeanName
      Specified the MatsFactory to use by means of specifying the bean name of the MatsFactory.
      Returns:
      the bean name of the wanted MatsFactory.
      Default:
      ""