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

Add support for meta tags to annotation based context configuration [SPR-9382] #14018

Closed
spring-projects-issues opened this issue May 6, 2012 · 2 comments
Assignees
Labels
in: core status: declined type: enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 6, 2012

Radim Kolar opened SPR-9382 and commented

It seems that there is no way to do equivalent of including meta tags in java annotation based container configuration. Our project is using meta tags extensively for example:

<bean id="urlfilter2"
     class="org.apache.nutch.filter.TestingURLFilter" scope="prototype">
     <meta key="after" value="urlfilter1" />
     <property name="name" value="class2"></property>
</bean>

and for writing testcases, Java context configuration is preferred over XML configuration.


Affects: 3.1.1

Reference URL: http://forum.springsource.org/showthread.php?126082-Meta-tags-in-Annotation-context-configuration

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 7, 2012

Radim Kolar commented

Add anotation like
@Meta(name="xxx", value="xxx")

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 15, 2012

Chris Beams commented

Hi Radim,

It's interesting that you're the first (to my recollection) to request @Meta support since we've introduced annotation-based configuration some years ago. We actually did include a @Meta annotation in the standalone "JavaConfig" project, but decided not to include this support when that work was ported to the core framework in Spring 3.0. So far, that seems to have been a good decision, because no one has asked for it!

I'm putting this in the General Backlog for now, meaning that it's a totally reasonable idea, but doesn't have much priority at the moment basically because there's very little demand. If folks vote this up and add comments about their use cases, of course we'll reconsider.

If you're feeling a bit more ambitious, feel free to take a shot at implementing this support yourself. You can see how to do this in the contributor guidelines document. Keep in mind a few things:

  • @Meta should be supported at both the @Bean method level and at the @Component class level for feature parity between these two styles.
  • In XML, one may have 0..* <meta> elements associated with a given <bean>. To achieve this in Java, we need not only a @Meta(name="key", value="value"), but also a "meta collection" annotation to accommodate the case of multiple @Meta annotations. This is always a bit awkward, but would look something like the following:
@Metadata(
    @Meta(key="k1", value="v1"),
    @Meta(key="k2", value="v2"))
@Bean
public MyBean myBean() { ... }

You might look to the implementation of the @Primary annotation for inspiration. It behaves just like the primary attribute in XML.

@spring-projects-issues spring-projects-issues added status: declined type: enhancement in: core labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: declined type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants