I\'d like to have some init params in my web.xml and retrieve them later in the application, I know I can do this when I have a normal servlet. However with resteasy I confi
Use the @Context annotation to inject whatever you want into your method:
@GET
public Response getWhatever(@Context ServletContext servletContext) {
String myParm = servletContext.getInitParameter("parmName");
}
With @Context you can inject HttpHeaders, UriInfo, Request, HttpServletRequest, HttpServletResponse, ServletConvig, ServletContext, SecurityContext.
Or anything else if you use this code:
public class MyApplication extends Application {
public MyApplication(@Context Dispatcher dispatcher) {
MyClass myInstance = new MyClass();
dispatcher.getDefautlContextObjects().
put(MyClass.class, myInstance);
}
}
@GET
public Response getWhatever(@Context MyClass myInstance) {
myInstance.doWhatever();
}