FYI, I've made a synthesis of this thread into an RFE: "Add lighter Spring integration" http://restlet.tigris.org/issues/show_bug.cgi?id=278
Best regards, Jerome > -----Message d'origine----- > De : Jerome Louvel [mailto:[EMAIL PROTECTED] > Envoyé : lundi 12 mars 2007 10:37 > À : [email protected] > Objet : RE: Using SpringFinder > > > Hi Ryan, > > Thanks sounds excellent. I would like to either provide a new > Servlet or > facilitate the subclassing of the current one to provide > lighter adaptation > for cases where the container is not the Restlet framework. > It will be up to > developer to decide which integration mode is the best for them: > - standalone Restlet application > - Servlet-embedded Restlet application > - IoC usage without Restlet application > > Best regards, > Jerome > > > -----Message d'origine----- > > De : Ryan Daum [mailto:[EMAIL PROTECTED] > > Envoyé : dimanche 11 mars 2007 16:57 > > À : [email protected] > > Objet : Re: Using SpringFinder > > > > Hi Jerome, thanks for the tip; I will try writing something > > like this up tomorrow or the day after, and I'll send you the > > source one I'm done. > > Ryan > > > > > > -- > > Ryan Daum > > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > > Technical Lead, Toronto > > 647.724.5232 x 2073 > > > > > > On 3/9/07, Jerome Louvel <[EMAIL PROTECTED]> wrote: > > > > > > Rian, > > > > The regression concerning the access to ServletContext > > is now fixed (see > > other email). Sorry for the inconvenience. > > > > Now, I'd like to address your more general concerns > > with the container > > services provided by the concepts of > > Component/VirtualHost/Application. > > Those concepts are especially useful for people looking > > for portability of > > their application code, in standalone or in > > Servlet-embedded mode. As we aim > > to provide a full alternative to Servlets, it is > > important for us to have > > this support for portable and deployable applications. > > > > However, if you don't share these requirements, and > > don't need the services > > provided to Applications (like access logging, > > decompression, etc.), then > > nothing prevents you from directly using the "lower > > level" classes directly. > > > > For example, you could create a custom Servlet fully > > aware of your Spring > > application/context (maybe using HttpServletBean as > > pointed to by Michael). > > This Servlet could directly create a Router and attach > > Resource classes to > > it. > > > > Here is some sample code: > > > > In the Servlet's initialization code (on first request > > for example): > > // Create your context, tunneling log entries > > to the Servlet's log > > Context context = new Context(new > > ServletLogger(servlet.getServletConfig().getServletContext())); > > > > // Create a Server connector converting Servlet > > calls into Restlets > > calls > > Server server = new Server(context, null, > > request.getLocalAddr(), > > request.getLocalPort(), component); > > HttpServerHelper helper = new HttpServerHelper(server); > > > > // Attach your Router or Finder directly to the Server > > server.setTarget(myRouterConfiguredBySpring); > > > > In the Servlet's service method: > > public void service(HttpServletRequest request, > > HttpServletResponse > > response){ > > helper.handle (new ServletCall(server, > > request, response)); > > } > > > > Let me know if this lighter Servlet adapter would > > better suit you. If so, it > > could make its way in the Servlet extension. > > > > Best regards, > > Jerome > > > > > -----Message d'origine----- > > > De : Ryan Daum [mailto:[EMAIL PROTECTED] > > > Envoyé : vendredi 9 mars 2007 20:38 > > > À : [email protected] > > <mailto:[email protected]> > > > Objet : Re: Using SpringFinder > > > > > > Yeah, I was thinking/doing something similar; > > > > > > But as of RC4 I seem to have no way of getting access to my > > > Spring application context without using the "SpringContext" > > > packaged with Restlet. There is no longer access to the > > > ServletContext from Application ... since it turns out my > > > Context is not a ServletContextAdapter (with its > > > getServletContext method) but an "ApplicationContext", I seem > > > to have no access to the underlying servlet context from the > > > Application, which was my last resort for getting access at > > > _least_ to Spring. (I might be missing something subtle > > > here, but the examples for RC4 no longer work.) > > > > > > It seems like I may have to abandon my experiment with > > > Restlet. It seems its philosophy and mine do not jive -- > > > like many Java frameworks past it wants to own the entire > > > stack; it wants to be my object factory instead of the > > > container I already chose, and it seems to want to be my web > > > server and application server instead of the one I already > > > chose (for many reasons); hell, it even wants to manage > > > logging as well. > > > > > > The value proposition of something like Restlet I thought > > > would be a simple clean way of mapping URIs to REST concepts, > > > but I think it may have taken on way too much beyond that for > > > my comfort. If I can't find a simple clean way of making > > > Restlet cooperate with an existing application code base I > > > will just go back to using URLRewrite and my own custom > > > resource mapping. > > > > > > Thanks anyways, > > > Ryan > > > -- > > > Ryan Daum > > > [EMAIL PROTECTED] > > > Technical Lead, Toronto > > > 647.724.5232 x 2073 > > > > > > > > > On 3/9/07, Makunas, Michael < > > [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > wrote: > > > > > > > > > I understand your frustration with having to create the > > > application outside of Spring. One potential solution I've > > > thought might work is to have a version of restlet's > > > ServerServlet that extends Springs HttpServletBean. In the > > > meantime, we've been able to get everything except the > > > application managed by Spring by doing something like this: > > > > > > Within your class that extends Application: > > > > > > Map<String, Finder> resourceMap = (Map<String, > > > Finder>) springContext .getBean(RESOURCE_MAP); > > > for (String key : resourceMap.keySet()) { > > > router.attach(key, resourceMap.get(key)); > > > } > > > > > > And in you ApplicatonContext.xml: > > > > > > <bean id="resourceMap" class="java.util.HashMap"> > > > <constructor-arg> > > > <map> > > > <entry key="/foos/{foo}"><ref > > > bean="fooFinder"/></entry> > > > <entry key="/bars/{bar}"><ref > > > bean="barFinder"/></entry> > > > </map> > > > </constructor-arg> > > > </bean> > > > > > > <bean id="fooFinder" > > > class="org.restlet.ext.spring.SpringFinder"> > > > <lookup-method name="createResource" > > > bean="fooResource"/> > > > </bean> > > > > > > <bean id="barFinder" > > > class="org.restlet.ext.spring.SpringFinder"> > > > <lookup-method name="createResource" > > > bean="barResource"/> > > > </bean> > > > > > > <bean id="fooResource" > > > class="com.example.resource.FooResource" scope="prototype" > > > parent="baseResourceBean" /> > > > > > > <bean id="barResource" class=" > > > com.example.resource.BarResource" scope="prototype" > > > parent="baseResourceBean" /> > > > > > > > > > Hope that helps... > > > > > > -Michael > > > > > > ________________________________________ > > > From: Ryan Daum [mailto: [EMAIL PROTECTED] > > > Sent: 09 March 2007 16:22 > > > To: [email protected] > > > Subject: Using SpringFinder > > > > > > I'm trying to use the new SpringFinder class, but I'm > > > unsure about one thing. > > > > > > I see from the example in the Javadoc for configuring > > > the resource using SpringFinder, but I do not see an example > > > about how to register the SpringFinder from the application. > > > In particular, how can the application "know" about my > > > SpringFinder instance given that the RESTlet framework > > > insists on creating the application; it is not injectable, > > > since there doesn't appear to be a way to have Spring manage > > > the application instance. > > > > > > Keep in mind that I cannot use the SpringContext stuff > > > included in the extension package since I am using Restlet in > > > an existing Spring application invoked from a WAR, and it > > > uses the traditional WebApplicationContext stuff from Spring > > > which is initialized from a servlet. > > > > > > Unfortunately it seems (hope I'm wrong) that Restlet is > > > still vaguely competing with Spring and other IOC systems > > > rather than cooperating with them. > > > > > > Ryan > > > > > > -- > > > Ryan Daum > > > [EMAIL PROTECTED] <mailto: > > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > > > > Senior Developer, Toronto > > > 647.724.5232 x 2073 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

