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
Comment From: spring-projects-issues
Gergő Takács commented
It would be great for me too
Comment From: spring-projects-issues
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).
Comment From: spring-projects-issues
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')
Comment From: spring-projects-issues
M. Justin commented
Agreed that @Component/@Service, etc. beans should support defining the alias name without using @Configuration.
Comment From: spring-projects-issues
Bulk closing outdated, unresolved issues. Please, reopen if still relevant.
Comment From: foal
Still relevant
Comment From: itsLucario
This issue is open from 2010. Spring must look into this feature request.
Comment From: mauromol
I also think this is a missing feature in Spring annotations. Probably an alias property of @Component or an @Alias annotation could do the trick?
Comment From: AdrianLopez1994
Still relevant.
Comment From: fibsifan
+1
Comment From: snicoll
Thanks for the suggestion but, after a careful consideration, we're going to decline this. @Component is a simple way of registering new beans in the bean factory that is decoupled from BeanDefinition. As such, adding an alias to it does not really make sense.
If you need to register a bean with multiple aliases, please use the @Configuration model with @Bean that provides a way for you to provide several bean names.