Details

Description

I'd like to enable Spring's component scanner (<context:component-scan .../>) to look for all Interfaces annotated with the @Service annotation.

Then for remoting scenarios, the client tier Scanner could find all interfaces annotated with @Service and then auto-generate remoting proxy stubs. The server tier Scanner can find the same annotated interfaces and auto-generate the remoting exporters. All of this would be really slick and work based on just the @Service annotation on one or more interfaces.

The problem currently is that the @Service annotation is really expected to be used within Class definitions - not Interfaces (indeed the ClassPathScanningCandidateComponentProvider#isCandidateComponent(AnnotatedBeanDefinition beanDefinition) method explicitly discards Interfaces by default).

This is an important distinction because in most remoting environments, the actual business implementations of an Interface will not be shipped to the client VM, so annotating the implementation class won't work.

For example, in a business-tier environment using JMS remoting, 2 BeanDefinitions could be registered based on a single discovered @Service annotated Interface: an InvocationListener and a ServiceExporter. In the client-tier environment, a BeanDefinition that specifies some service ProxyFactoryBean would be registered.

Les Hazlewood
added a comment - 18/Mar/09 9:24 AM The default implementation of this factory interface would just return a Collection with a single ScannedGenericBeanDefinition instance to retain the current behavior.