Question

I've noticed recently that spring can wire up my ejb's for me if I annotate the ejb with @Interceptors(SpringBeanAutowiringInterceptor.class). I've never actually done this so don't know the details.

I was wondering, is there a way to get this to work with other kinds of beans, for example, @WebService annotated ones as well.

At the moment in my web service classes (because the application server manages them) I have to load the dependencies from the BeanFactory and would thus prefer to have them autowired.

I know I could use the @Configurable annotation but am not particularly keen to have to specify and agent on the VM.

Is this possible?

Was it helpful?

Solution

Once again, spring has thought of this use case and catered for it!

The problem is that @WebService is not a spring annotation, it is a JAX-WS annotation and thus classes that are annotated with @WebService to be exposed as web services are not managed by spring, but their life cycle is managed by JAX-WS.

The way to handle this case is to have the JAX-WS managed bean extend org.springframework.web.context.support.SpringBeanAutowiringSupport - this will enable the @Autowire annotation, for example, to work in this bean. see here for more information

OTHER TIPS

Yes, of course. There's @WebService, @Repository, @Controller, @Service, @Endpoint, and other annotations in Spring. Here's an example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top