Skip to content

Support @AliasFor for @JmsListener attributes [SPR-13803] #18376

Closed

Description

@spring-projects-issues

Grzegorz Poznachowski opened SPR-13803 and commented

I want to wrap @JmsListener annotation with a custom one (to avoid providing containerFactory attribute):

@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@JmsListener(containerFactory = "customJmsContainerFactory", destination = "")
public @interface CustomJmsListener {

    @AliasFor(annotation = JmsListener.class, attribute = "destination")
    String destination();

    @AliasFor(annotation = JmsListener.class, attribute = "selector")
    String selector() default "";

    @AliasFor(annotation = JmsListener.class, attribute = "concurrency")
    String concurrency() default "";
}

As destination is a required attribute I need to provide its value: destination = "". I would expect that it would be overridden by specifying destination attribute on @CustomJmsListener, however the @JmsListener value is being used.


Affects: 4.2.3

Issue Links:

Activity

  1. spring-projects-issues commented on Dec 17, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    I'm not sure there's much we can do about this: According to Java annotation declaration rules, required attributes have to be specified, even when used as meta-annotations.

    So I suppose that's just a nuisance (having to specify empty String there on the meta-annotation declaration) but the overriding actually works at runtime?

    Juergen

  2. spring-projects-issues commented on Dec 17, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Grzegorz Poznachowski commented

    The thing is that overriding is not working.

  3. spring-projects-issues commented on Dec 17, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    On review, I'm afraid that @JmsListener is one of the few places where we do not actually support alias declarations yet, due to the repeatable annotation lookup there. We intend to close such gaps in 4.3.

    Juergen

  4. spring-projects-issues commented on Feb 25, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Please note that this issue has been superseded by #18545.

  5. spring-projects-issues commented on Mar 26, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    FYI: this has been addressed in #18545, which is now resolved.

    For an example of this support in action, consult the following commit:

    4742aa0

    Just search for ComposedJmsListenersBean in the test class.

  6. added
    type: enhancement
    in: core
    status: duplicate
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: corestatus: duplicatetype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions