if you had a Container and Element resources like this... (please
excuse the scala syntax...)
class Container extends Foo {
@GET
@Path("{id}")
def getElement(@PathParam("id") key : String) = {
doSomething
new Element(key)
}
...
}
class Element(key: String) extends Foo {
@GET
def index = {
// this will fail here...
doSomething
}
...
}
abstract class Foo {
@Context
protected var servletContext: ServletContext = _
def doSomething: Unit = {
if (servletContext == null) throw IllegalArgumentException("no
servletContext injected! Probably a sub resource :)")
}
}
Using @Context injection is very handy; however right now only root
resources get injected causing code like above to barf.
Is there any way to get Jersey to do injection of user created sub
resources (e.g. the Element instance) after its been created, but
before its methods have been invoked.
e.g. after the Container.getElement is invoked and an Element
created, but before the Element.index method is invoked?
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/