Hi Aaron,
Can you subscribe to the user & dev email lists [1] ? Or i can subscribe
you if you like, let me know either way. That way you will receive
emails from other users/developers and they don't have to CC you.
Aaron Anderson wrote:
> 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.
Right, the servlet container is a good example to look at for the use of
WebResourceResolver/Factory.
> 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?
Yes, i will update the JavaDoc.
> 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?
>
How about i add the following methods to WebApplication:
/**
* Register resource classes to an initiated Web application.
* <p>
* This method enables a container to dynamically register
* further resource classes to those resource classes that
* were registered at initiation.
*/
register(Set<Class> resourceClasses)
register(Class... resourceClasses)
Will that work for you?
Any further feedback on the container SPI in general would be most
useful, thanks,
Paul.
[1]
https://jersey.dev.java.net/communicate/
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109