Java EE 6 WebService and CDI injection

假装没事ソ 提交于 2019-12-08 03:38:12

问题


This is a clarification question I've got from a Java EE 5 migration. I'm currently developing a Java EE 6 web service packed in a WAR file, and I would like to know if it's possible to use CDI on it. I've seen some examples using the @Stateless annotation, which it's not possible to do in a WAR (as far as I know).

Current implementation:

@WebService
public class MyService{

    @Inject 
    HelloTeller teller:

    @WebMethod
    public String sayHello(){
        teller.sayHello();
    }
}

Note: The other approach would be to create an ejbModule specifically for this web-service.


回答1:


In EE6, you should be able to use a SLSB as JAX-WS endpoint in a war. You can inject EJBs, request scoped and application scoped beans from CDI.



来源:https://stackoverflow.com/questions/9848549/java-ee-6-webservice-and-cdi-injection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!