Created JIRA TUSCANY-2919 (https://issues.apache.org/jira/browse/TUSCANY-2919)
I'll post the code in a week. Need to do some refactoring to remove stuff not pertaining to the JAX-RS extension. thnx, -Prateek Temkar -------------------------------------------------------------------------------------------------------------------------------------- On Tue, Mar 17, 2009 at 3:22 PM, Luciano Resende <[email protected]> wrote: > On Tue, Mar 17, 2009 at 3:08 PM, Prateek Temkar <[email protected]> wrote: >> Hello All, >> >> We have been working on a REST binding in Tuscany and have been >> able to implement one. It lets the Tuscany components expose RESTful >> services in addition to other services they can already expose. We >> have used Jersey, the JAX-RS Reference implementation developed by >> Sun. >> > > Great, Jersey is licensed under CDDL and we would be able to use it > based on Apache Third-Party Licensing Policy. > > [1] http://www.apache.org/legal/3party.html > >> I came across >> http://www.mail-archive.com/[email protected]/msg05857.html >> where Tuscany devs have expressed interest in implementing JAX-RS >> support and figured that I'd share what we have done. (Unfortunately, >> I could not reply to that thread and had to start a new one as I had >> not subscribed to the dev mailer) >> >> At a high level, what we do is, after Tuscany identifies that the >> binding involved is the REST-binding, we transfer the request to >> Jersey's ServletContainer. Jersey facilitates the addition of runtime >> annotations to Java programming language class files to define >> resources and the actions that can be performed on those resources. >> Plain Jersey would identify the method (and the arguments )to be >> invoked on a root resource class instance given the URI; Instead, we >> invoke a method in our binding (Tuscany), details below, and return >> the result to Jersey which forms and returns the Http response. >> >> Here is what we have done in detail: >> >> - Tuscany ships with the JSON RPC binding. We replicated the JSONRPC >> binding and made the ServiceServlet forward all REST-requests to >> Jersey's servlet engine. >> >> -We have modified Jersey source code. >> When Jersey is done mapping the URI to the resource and interpreting >> all the annotations in the resource, it transfers control to Tuscany >> (rest-runtime-binding) by invoking a method in our binding. Jersey has >> the following information: - The resource instance on which the method >> is to be invoked, - The Method object corresponding to the method to >> be invoked, - The arguments to the method. >> >> - We pass the Method object and the arguments to Tuscany by invoking >> a method. We don't pass the instance right away but save it in a >> static map with the thread id as the key (it is a single thread of >> execution). This method creates an instance of Operation using the >> method information and calls wire.invoke() with the Operation and the >> method arguments. >> >> - Inside the ReflectiveInstanceFactory, in the newInstance() method, >> we get the instance that Jersey has stored in its map (using the >> thread id) and let Tuscany's Injectors operate on it.The result is >> returned by the same chain back to Jersey which eventually returns the >> http response. >> >> We are aware that there are better ways to officially extend Tuscany >> like how Raymond mentioned at >> http://www.mail-archive.com/[email protected]/msg05857.html but >> nevertheless thought we'd share our experience. We would be more than >> happy to discuss contributing our code back to Tuscany if there is >> enough interest. >> > > This is really good, please raise a JIRA and provide the extension so > we can provide any feedback and get it applied to Tuscany svn. > >> thnx, >> >> - Prateek Temkar >> > > > > -- > Luciano Resende > Apache Tuscany, Apache PhotArk > http://people.apache.org/~lresende > http://lresende.blogspot.com/ >
