Hi David, I now consider this issue fixed. See my comments in the issue opened by Thierry for details. 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 : Thierry Boileau [mailto:[email protected]] Envoyé : jeudi 26 février 2009 12:39 À : [email protected] Objet : Re: DirectoryResource, the "clap://class/" scheme, and custom Classloaders - doesn't work? (OSGi- related) Hi Davd, nice shoot again :) I've entered a new RFC for that => http://restlet.tigris.org/issues/show_bug.cgi?id=740 best regards, Thierry Boileau > We tried to configure a Directory instance to serve out static > resources from a particular classloader (in our case we must do this > to access the resource files stored inside an OSGi bundle, each bundle > has it's own classloader). > > We set the directory's root reference to be something like > "clap://class/path/to/resource", following the instructions in the > Restlet docs. > > Additionally, we made sure to set the custom class loader Request > attribtue, also as documented: > > request.getAttributes().put("org.restlet.clap.classloader", > bundleClassLoader); > > However the Directory failed to serve out resources from the custom > classloader, and instead served resources from the classloader which > was providing the restlet classes. > > In looking at the code, it seems that the > org.restlet.engine.local.DirectoryResource class is the culprit. It > ignores everything in the incoming Request object except for the > target URI of the resource, and passes that URI to a call to > getClientDispatcher.get(targetURI). Therefor the request attribute > for "org.restlet.clap.classloader" is ignored, and the > ClapClientHelper code never sees it. > > As a work-around, we created a Directory subclass which uses the > "clap://thread/path/to/resource" strategy, and, on each request, > stores the current Thread's context class loader, replaces it with the > bundleClassLoader, and calls super.handle(), and then finally replaces > the original context class loader. > > any thoughts? > -Dave Fogel > > ------------------------------------------------------ > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId > =1231570 > > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=12325 59 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1278011

