cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sbery...@progress.com>
Subject Re: ServletContext in an inherited class
Date Wed, 13 May 2009 10:07:46 GMT
Hi,

it might be that a JAX-RS runtime does not introspect the parent classes yet, as far as the
injection of contexts is concerned.
The workaround is to add a method to the very top (concrete) subclass :

@Context
public void setServletContext(ServletContext jaxrsThreadLocalContext) {
    super.setJaxrsServletContext(jaxrsThreadLocalContext);
}

In meantime, I will work on ensuring contexts can be injected into super class fields directly...
Cheers, Sergey



----- Original Message ----- 
From: "Tom" <tbee@tbee.org>
To: <users@cxf.apache.org>
Sent: Tuesday, May 12, 2009 9:33 AM
Subject: ServletContext in an inherited class


>I have copied the code from the CXF manual to get access to the 
> ServletContext of either the SOAP or REST call and it works ok. However, 
> I naturally have more that one Service to implement, so I wanted to move 
> this code to an abstract parent class. When the code is there, only the 
> SOAP resource is injected, the REST variable is NULL.
> 
> Is there any reason why REST does not work in an inherited class?
> 
> 
>    // Get the ServletContext for SOAP and REST
>    @javax.annotation.Resource private javax.xml.ws.WebServiceContext 
> iSoapWebServiceContext;
>    @javax.ws.rs.core.Context private javax.servlet.ServletContext 
> iServletContext;
>  
>    private ServletContext getServletContext()
>    throws javax.ws.rs.WebApplicationException
>    {
>        if (iSoapWebServiceContext != null)
>        {
>            // soap invocation
>            return 
> (ServletContext)iSoapWebServiceContext.getMessageContext().get(javax.xml.ws.handler.MessageContext.SERVLET_CONTEXT);
>        }
>        else
>        {
>            // http-only jaxrs one
>            return 
> iServletContext;//(ServletContext)iRestMessageContext.get(MessageContext.SERVLET_CONTEXT);
>        } 
>    }
> 
>

Mime
View raw message