Is it possible to do the same using annotation-driven injection:
<beans>
...
<bean id="interceptorsList" class="com.mytest.AnyAction">
<property name="interceptors">
<list>
<ref bean="validatorInteceptor"/>
<ref bean="profilingInterceptor"/>
</list>
</property>
</bean>
</beans>
Is it possible to do the same using annotation-driven injection?
Good question - I don't think so (assuming that by "annotation-driven injection" you're referring to annotations on AnyAction).
It's possible that the following might work, but I don't think Spring recognises the @Resources annotation:
@Resources({
@Resource(name="validatorInteceptor"),
@Resource(name="profilingInterceptor")
})
private List interceptors;
Give it a try anyway, you never know.
Other than, you can use @Configuration-style configuration instead of XML:
@Configuration
public class MyConfig {
private @Resource Interceptor profilingInterceptor;
private @Resource Interceptor validatorInteceptor;
@Bean
public AnyAction anyAction() {
AnyAction anyAction = new AnyAction();
anyAction.setInterceptors(Arrays.asList(
profilingInterceptor, validatorInteceptor
));
return anyAction;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With