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

define a bean alias with annotations (similar to @Component but just defining an alias) [SPR-6736] #11402

Open
spring-projects-issues opened this issue Jan 20, 2010 · 7 comments

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jan 20, 2010

adrian opened SPR-6736 and commented

I'm using Struts 1 with the Spring DelegatingTilesRequestProcessor plugin.
I define my actions as spring beans and would like to use @Component annotation and no XML configuration.

My problem is that an action path must correspond to the same Spring bean id.

And I can have the same spring bean used for multiple actions.

i.e /charge/view and /charge/save should map to the same bean.

I cannot do it with @Component annotation alone, and would need a @Alias or @Role annotation.

For instance something like :

@Component("/charge/view")
@Roles({`@Role`("/charge/remove"),
    @Role("/charge/edit"),
    @Role("/charge/save")})
public class EditChargeClienteleAction extends MappingDispatchAction {

Affects: 3.0 GA

Reference URL: http://forum.springsource.org/showthread.php?t=83133

16 votes, 12 watchers

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 21, 2013

Gergő Takács commented

It would be great for me too

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 21, 2013

Stevo Slavić commented

This is already supported outside of XML, albeit not with @Role/@Roles but with Spring Java @Configuration and bean aliasing (see here for more).

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 31, 2013

Hendy Irawan commented

+1 for this. outside Spring MVC bean aliasing is also useful.

@Configuration is a workaround, the same aliasing mechanism should be supported by @Component/@Service etc. (by accepting String[] instead of just String, or adding 'aliases')

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 12, 2016

M. Justin commented

Agreed that @Component/@Service, etc. beans should support defining the alias name without using @Configuration.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 12, 2019

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

@foal
Copy link

@foal foal commented Jan 15, 2019

Still relevant

@itsLucario
Copy link

@itsLucario itsLucario commented Oct 6, 2020

This issue is open from 2010. Spring must look into this feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants