类似于Spring中针对非EJB的EJB连接 [英] Something like EJB wiring in Spring for non EJB's

查看:197
本文介绍了类似于Spring中针对非EJB的EJB连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近注意到,如果我使用@Interceptors(SpringBeanAutowiringInterceptor.class)注释ejb,那么spring可以为我连接我的ejb。我从来没有真正这样做过,所以不知道细节。

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.

我想知道,有没有办法让它与其他种类的bean一起使用,例如,@ WebService也注明了。

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

目前在我的Web服务类中(因为应用程序服务器管理它们)我必须从BeanFactory加载依赖项并且因此,我们更愿意让它们自动装配。

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.

我知道我可以使用@Configurable注释但不是特别热衷于必须在VM上指定和代理。

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

这可能吗?

推荐答案

再一次,春天想到了这个用途案例并且照顾它!

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

问题是@WebService不是 spring 注释,它是 JAX-WS 注释,因此使用@WebService注释以作为Web服务公开的类不由spring管理,但它们的生命周期由JAX-WS管理。

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.

哇要处理这种情况,就是让JAX-WS托管bean扩展org.springframework.web.context.support.SpringBeanAutowiringSupport - 这将使@Autowire注释能够在这个bean中工作。请参阅此处了解更多信息

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

这篇关于类似于Spring中针对非EJB的EJB连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆