Actually, you don't have to use "jaxrs.scope" parameter in this case, this 
injection should work wirth singletons too.

cheers, Sergey



Hi,


The only way to do it at the moment is to use a per-request resource class with @Context ServletContext being one of the constructor parameters

public class Resource {

private ServletContext  servletContext;

public Resource(@Context ServletContext servletContext) {}
}

and use CXFNonSpringJaxrsServlet :

http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-RegisteringendpointswithoutSpring

You'd need to add "jaxrs.scope" parameter with the value of "prototype".
We can't inject ServletContext/ServletConfig at initialization time yet with 
Spring - watch this JIRA please :

http://issues.apache.org/jira/browse/CXF-2197

cheers, Sergey


----- Original Message ----- From: "Vassilis Virvilis" <[email protected]>
To: <[email protected]>
Sent: Monday, June 22, 2009 3:21 PM
Subject: How to get servlet context at initialization time of a POJO


Halo,

The subject says it all

How to get servlet context at __initialization time__ of a POJO?

At initialization time
   @Context
   private javax.servlet.ServletContext  servletContext;

has not yet injected on the POJO.

Thank for any insight.


     Vassilis



Reply via email to