users@jersey.java.net

[Jersey] How to access spring context created by SpringServlet

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Thu, 13 Oct 2011 11:47:49 -0400

I am working on a java class that needs to expose a jersey server
endpoint for receiving callbacks from an external process. The class
needs to be usable in a standalone java app. I am therefor using an
embedded Grizzly HttpServer created using
com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory. I am using
com.sun.jersey.spi.spring.container.servlet.SpringServlet to deploy my
spring wired jersey server into the Grizzly HttpServer.

Is there a way to get access to spring application context created by
the SpringServlet (and beans it creates) from the container code that
creates the SpringServlet and Grizzly HttpServer after it starts the
Grizzly HttpServer?

I see that com.sun.jersey.spi.spring.container.servlet.SpringServlet has
protected methods |*getDefaultContext
<http://jersey.java.net/nonav/apidocs/1.9.1/contribs/jersey-spring/com/sun/jersey/spi/spring/container/servlet/SpringServlet.html#getDefaultContext%28%29>*()|and
|*getChildContext
<http://jersey.java.net/nonav/apidocs/1.9.1/contribs/jersey-spring/com/sun/jersey/spi/spring/container/servlet/SpringServlet.html#getChildContext%28java.lang.String%29>*|(java.lang.String contextConfigLocation).
Is there a reason these are protected and not public?

Right now I would have to derive a sub-class from SprinServlet and make
these methods public. Is there a better way?
Also should I file an RFE to make these methods public?

-- 
Regards,
Farrukh Najmi
Web:http://www.wellfleetsoftware.com