Dave, Were you able to fix or workaround this issue? If not, you should enter a defect report (a patch would be nice). Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com
-----Message d'origine----- De : David Fogel [mailto:[email protected]] Envoyé : vendredi 20 mars 2009 04:55 À : [email protected] Objet : Re: Re: Restlet Jax-RS extension and OSGi Hi Stephan- I've been experimenting with the restlet.ext.jaxrs support, trying to get a small test project working, and I've run into what seems like a pretty big problem. While I am fairly new to JAX-RS, it is my understanding that the suggested way of giving your Resource classes access to other things in their environment (such as a persistence service, a ServletContext, an osgi BundleContext, etc) is by creating classes that extend javax.ws.rs.ext.ContextResolver, annotating them with @Provider, and registering instances of them with the jax-rs implementation. The container should then be able to inject these custom objects into Resource classes that annotate a parameter or field type with @Context. For example, if I have a service class called StorageService, I would create a ContextResolver like this: @Provider public class StorageServiceResolver extends ContextResolver<StorageService> { private StorageService service; public StorageServiceResolver(StorageService service) { this.service = service; } public StorageService getContext(Class<?> type) { return service; } } I would then be able to access the StorageService object within my Resource classes like this: @Path("path/to/root/resource") public class MyResource { // should be able to do annotate a field: @Context private StorageService service; // OR should be able to annotate a constructor param: public MyResource(@Context StorageService service) { this.service = service; } @GET @Produces("text/plain") public String getStoredThing(@QueryParam("id") String id) { // and then access the service here: return service.getValueForID(id); } } But when I create such classes, and register them with your JaxRsRestlet, the JaxRsRestlet refuses to accept the Resource classes, claiming that they are missing any valid constructor or that a field can not be injected with that type. The problem may be that the methods in WrapperUtil.java don't make use of the current set of "providers", but instead expect only the minimal set of predefined context types. Is there some other way I'm missing to give my Resource classes access to my application environment? thanks, -Dave Fogel ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=13610 04 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1522529

