users@jersey.java.net

Embedding Jersey

From: Aaron Anderson <nickmalthus_at_yahoo.com>
Date: Mon, 16 Jul 2007 10:40:11 -0700 (PDT)

I am attempting to see if I can embed Jersey into a pre-existing application framework. The framework would be responsible for instantiating the resource class, populating the @Resource annotated fields and methods, and invoking the @PostConstruct and @PreDestory methods. I am now researching how I could dynamically register these instances with the Jersey JSR311 implementation.

I have examined the Jersey SPI and noted the WebApplication and WebResourceResolver interfaces. I have observed that one can obtain an instance to a Jersey webapplication by invoking WebApplicationFactory .createWebApplication(). I believe I can implement the WebResourceResolverFactory and WebResourceResolver interfaces to return resource instances from the application framework to the Jersey WebApplication. However, the application framework needs to register the resource classes one at a time and not as a group as required by the ResourceConfig passed into WebApplication.initiate().

Question: What would happen if every time the application framework created a new resource instance and needed to register it with the Jersey WebApplication it added it to the set of Resources declared in the ResourceConfig class and then re-ran WebApplication.initiate()? Is the WebApplication.initate() method only supposed to be invoked once? Is there any other approach that I could use to dynamically register resource classes with a Jersey WebApplication when all of the resource classes are not known in advanced?

Thanks!




       
____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433