Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Dec 17, 2015 · 5 comments
Closed
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: duplicate A duplicate of another issue type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Dec 17, 2015

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:

@spring-projects-issues
Copy link
Collaborator Author

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

@spring-projects-issues
Copy link
Collaborator Author

Grzegorz Poznachowski commented

The thing is that overriding is not working.

@spring-projects-issues
Copy link
Collaborator Author

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

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 25, 2016

Sam Brannen commented

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

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 26, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant