Hi, I am currently looking into CXF-437
http://issues.apache.org/jira/browse/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 javax.xml.ws.WebServiceContext. 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 javax.xml.ws.WebServiceContext, 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 javax.xml.ws.WebServiceProvider 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]. http://forums.java.net/jive/thread.jspa?messageID=131230&tstart=0