On May 17, 2009, at 12:04 PM, Vincent Massol wrote: >> To install it, web.xml must be modified: >> <!-- RESTful API Restlet servlet --> >> <servlet> >> <servlet-name>RestletServlet</servlet-name> >> <servlet-class> >> org.xwiki.rest.XWikiRestletServlet >> </servlet-class> >> <init-param> >> <param-name>resources</param-name> >> <param-value> >> ... >> com.xpn.xwiki.rest.annotation.AnnotationService; >> </param-value> >> </init-param> >> ... > > It's too complex for the users and not dynamic enough IMO. I suggest > you work with Fabio to provide a generic REST servlet that can be > extended internally using components when we need to add new REST > APIs. >>
Currently this is the way for adding a "rest resource" to the system: drop a jar with your code and declare the resources in the web.xml so that they can be found and registered. The question about "being dynamic" is indeed central and should be addressed wrt the whole Rest subsystem. I am spending some time on it and currently I am exploring the following solution: declare every resource as a @Component and use the component manager for discovering resources (via the lookupList method). This will solve the problem of modifying the web.xml and adding a set of resources will be just a matter of dropping a jar in WEB-INF/lib. The difficult part here is making the Restlet/JAXRS and Component Manager logics to co-exist. So far things seem to work but I am having some initialization problems and, moreover, with this approach components cannot be singletons so I will need to handle with care component deallocation. I hope to have a working thing by the end of the day. Should I find some blocking problem another approach could be the one used by Jersey (the other JAXRS implementation) Basically this approach would consist in looking for every class in every jar that is annotated with a JAXRS annotation. Or alternatively "duplicate" the component manager lookup code in order to load classes declared in a "resources.txt" file. Of course I think that the @Component way is better (you have automatic injection) and I would proceed on this path in order to make it work. If you have any comment don't hesitate. Cheers, Fabio _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

