Yes, that can be great, but I don't want to change Sling sources, only reuse them, that's why I asked about best practices.
On Wed, Apr 7, 2010 at 9:58 PM, Justin Edelson <[email protected]>wrote: > We should probably just support jsonp natively in these servlets. > > > On 4/7/10 2:05 PM, Luca Masini wrote: > > Hi guys, I need an advice from Sling experts. > > > > I need a JSONP renderer for Sling, initially I thought I had to develop > only > > one, but after I discovered that in effect Sling has two renderer for > JSON, > > one for plain resources and one for query. > > > > These two renderer are in private packages in a Sling Bundle, and because > > JSONP and JSON are quite equals and I wanted to reuse as much as > possible, I > > started thinking about strategies to call them. > > > > The JsonQueryServlet is deployed as an OSGi Component, so I was able to > > inject it using Felix SCR Annotation (querying for his properties), and > then > > I called his service() method inside my doGet: > > > > servlet.service(req, resp); > > > > For the JsonRendererServlet instead I used another strategy. > > > > I extracted the RequestPathInfo from the SlingHttpServletRequest and the > I > > included it using RequestDispatcher: > > > > String jsonPath = calculateIt(req); > > > > req.getRequestDispatcher(jsonPath).include(req, resp); > > > > Now both of these two are working, but I have a bad taste. > > > > Which of this is the best approach ?? The first ?? The second ?? None of > > them ??? > > > > > > -- **************************************** http://www.lucamasini.net http://twitter.com/lmasini http://www.linkedin.com/pub/luca-masini/7/10/2b9 ****************************************
