cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Liu, Jervis" <>
Subject RE: CXF-437: @Resources are not injected into Handlers
Date Fri, 02 Mar 2007 03:02:27 GMT
Hi, just had an online chat with DanK, he mentioned that the use case one is the problem he
noticed while fixing some stuff for Jarek, I will fix this first.


> -----Original Message-----
> From: Liu, Jervis []
> Sent: 2007?3?1? 17:10
> To:
> Subject: CXF-437: @Resources are not injected into Handlers
> Hi, I am currently looking into CXF-437 
> What I am 
> trying to figure out is what kind of @Resource are valid 
> resources that can be injected into handlers. Through a quick 
> search into JSR-109, as far as I can find, following resouces 
> are injectable into handlers:
> 1. When CXF is deployed into a servlet container, the 
> component's context and environment entries are injected into 
> handlers. JSR-109, section 6.2.3:
> With JAX-WS, the handler allows for resources to be injected, 
> typically by using the @Resource annotation. So
> a Handler.handle<action>() method may access the component's 
> context and environment entries by using any
> resources that were injected. It can also use JNDI lookup of 
> the "java:comp/env" context and accessing
> the env-entry-names defined in the deployment descriptor by 
> performing a JNDI lookup. See chapter 15
> of the Enterprise JavaBeans specification - Enterprise 
> JavaBeans Core Contracts and Requirements for details.
> The container may throw a java.lang.IllegalStateException if 
> the environment is accessed from
> any other Handler method and the environment is not 
> available. The element init-params in the
> deployment descriptors is no longer used for JAX-WS based 
> container. If needed, the developer should use the
> environment entry elements (<env-entry>) declared in the 
> application component's deployment descriptor for
> this purpose. These can be injected into the handler using 
> the @Resource annotation or looked up using JNDI.
> An example of this use case: [1]. As a side note, we also 
> need to support the JNDI look up of environment entries from 
> handlers in order to make CXF JAX-WS spec compliant. 
> 2. The injection of JSR-109, 
> section 6.2.4:
> A JAX-WS based container must carry out any injections (if 
> any) requested by the handler, typically via the
> @Resource annotation (see section 2.2 of JSR-250 Common 
> Annotations for Java Platform specification). A
> JAX-WS handler should use the, 
> which is an injectable resource,
> to access message context and security information relative 
> to the request being served. A unique Handler
> instance must be provided for each Port component declared in 
> the deployment descriptor or annotated by
> javax.jws.WebService or annotations.
> CXF does support the injection of WebServiceContext in 
> endpoint but not in handlers yet. I presume a code snippet 
> that has the injection of  WebServiceContext would look like below:
> public class MyHandler implements SOAPHandler<SOAPMessageContext> {
> ....
> @Resource
> WebServiceContext context
> ...
> }
> Am I reading the spec correctly? anything missing? I will 
> create two jiras to support case 1 and 2 if it looks ok.
> Thanks,
> Jervis
> [1].

View raw message