Hi Marcel,

Great to hear that it works well!

Best regards,
Jerome  

> -----Message d'origine-----
> De : Marcel Schepers [mailto:[EMAIL PROTECTED] 
> Envoyé : mercredi 22 novembre 2006 08:13
> À : [email protected]
> Objet : Re: New Spring extension
> 
> Hello Jerome,
>  
> Yesterday I have played around with the new Spring 
> extensions. It seems you are on the right track, it worked 
> like a charm. I'll vote to keep this extension in 1.0. 
>  
> Keep up the good work,
> Marcel
> 
>  
> On 11/20/06, Jerome Louvel <[EMAIL PROTECTED]> wrote: 
> 
> 
>       Hi again,
>       
>       After investigating this Spring integration issue in 
> more depth, I've
>       decided to provide a new Restlet extension for Spring 
> 2.0. I've created two
>       classes SpringContext and SpringResource in an 
> org.restlet.ext.spring
>       package that should let you create Spring-based Restlet 
> Application in any
>       mode (Servlet and standalone).
>       
>       The SpringContext is a subclass of Spring's 
> GenericApplicationContext that 
>       can take a list of property config URIs and XML config 
> URIs. I think this
>       will be flexible enough for most uses. The URIs are 
> resolved by the
>       Application's context dispatcher, so you need to have 
> the proper client 
>       connectors set-up in order to get the local representations.
>       
>       I haven't done testing so far, so I welcome anyone who 
> has Spring knowledge
>       to play with this extension and report any issue. If 
> the solution is
>       satisfactory enough, it will stay in 1.0 final.
>       
>       Best regards,
>       Jerome
>       
>       > -----Message d'origine-----
>       > De : Jerome Louvel
>       > Envoyé : lundi 20 novembre 2006 15:23
>       > À : [email protected] 
> <mailto:[email protected]> 
>       > Objet : RE: getServlet
>       >
>       >
>       > Hi Marcel,
>       >
>       > You are correct, the previous solution didn't help in your
>       > case. I've removed it and also made those changes: 
>       >  - renamed NRE's ServletContext into ServletContextAdapter
>       >  - replaced the private getServlet() method by a public
>       > getServletContext() one
>       >
>       > I totally agree that the definitive Spring integration must 
>       > be usable in all usage modes. As I noted in the RFE#200, I
>       > think this will go through the direct implementation of the
>       > Spring ApplicationContext interface.
>       >
>       > Any help on this front is welcome! AJ Barnes (via Spring's 
>       > ClassPathXmlApplicationContext) and Manohar Viswanathan (via
>       > Spring's WebApplicationContextUtils) already worked on
>       > integrating Restlet and Spring, see Sample code section at:
>       > http://wiki.java.net/bin/view/Javawsxml/Restlet 
> <http://wiki.java.net/bin/view/Javawsxml/Restlet> 
>       >
>       > Probably a good starting point would be the Spring's
>       > AbstractXmlApplicationContext class.
>       >
>       > Best regards,
>       > Jerome
>       >
>       > > -----Message d'origine-----
>       > > De : Marcel Schepers [mailto:[EMAIL PROTECTED]
>       > > Envoyé : lundi 20 novembre 2006 14:47
>       > > À : [email protected]
>       > > Objet : Re: getServlet
>       > >
>       > > Sorry, the last sentence should be:
>       > >
>       > > It should be possible to deploy handlers standalone or with 
>       > > the aid of the Servlet API without changes in Java code.
>       > >
>       > >
>       > > Marcel
>       > >
>       > >
>       > > On 11/20/06, Marcel Schepers < 
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote:
>       > >
>       > >     Hi Jerome,
>       > >
>       > >     I do not think portability is a big issue: integrating
>       > > the Restlet API with servlets already requires the use of 
>       > > NRE. On the other hand, I agree that it should be 
> possible to
>       > > use Spring without the servlet API. I do have some thoughts
>       > > about this issue and I will get back to this list within a
>       > few days.
>       > >
>       > >     The added attribute does not provide access to the
>       > > servlet's context during the 'createRoot' method of an
>       > > Application. It is my understanding that the createRoot 
>       > > method creates the router along with all handlers and their
>       > > URL mappings. Please correct me if I am wrong. I have
>       > > attached a snippet of my createRoot method
>       > >
>       > >     public Restlet createRoot() { 
>       > >             if (this.webAapplicationContext == null) {
>       > >                 // webApplicationContext provides access to
>       > > all Spring beans.
>       > >                 throw new IllegalStateException("no Spring 
>       > > web application context");
>       > >             }
>       > >
>       > >             Context context = getContext();
>       > >
>       > >             // get a handler as Spring bean
>       > >             Handler handler = (Handler) 
>       > > this.webAapplicationContext.getBean("versionHandler");
>       > >             handler.setContext(context);
>       > >
>       > >             Router router = new Router(getContext());
>       > > 
>       > >             router.attach("/version$", handler);
>       > >
>       > >             return router;
>       > >         }
>       > >
>       > >     During the createRoot method I do not have a Restlet 
>       > > request, so the newly introduced attribute does not 
> solve the
>       > > problem to configure handlers as Spring beans.
>       > >
>       > >     IMHO, a different method is needed to integrate Spring
>       > > with Restlet. Both methods (casting the context and 
> the newly
>       > > introduced attribute) have both some serious
>       > > limitations/consequences. Spring without servlets should be
>       > > possible as well as Spring during setup. Ideally handlers 
>       > > should not be access
>       > >     Marcel
>       > >
>       > >
>       > >
>       > >     On 11/20/06, Jerome Louvel < [EMAIL PROTECTED]
>       > > <mailto: [EMAIL PROTECTED]> > wrote:
>       > >
>       > >
>       > >             Hi Marcel,
>       > >
>       > >             Your technique requires a casting to
>       > > 
>       > > "com.noelios.restlet.ext.servlet.ServletContext" which is
>       > > specific to NRE.
>       > >             Thus, this solution won't allow applications to
>       > > be portable to another
>       > >             container.
>       > >
>       > >             I have changed the implementation to
>       > > automatically add an attribute named
>       > >             "org.restlet.http.servlet.context " to each
>       > > Restlet request. It contains the
>       > >             instance of javax.servlet.ServletContext that
>       > > you need and won't require any
>       > >             casting to NRE classes. 
>       > >
>       > >             However, we should think about providing a
>       > > custom Spring ApplicationContext
>       > >             that would work in all situations (Servlet-mode
>       > > or standalone-mode). I've 
>       > >             added a new RFE to keep track of this
>       > > (scheduled for 1.1):
>       > >             
> http://restlet.tigris.org/issues/show_bug.cgi?id=200 
>       > >
>       > >             Best regards,
>       > >             Jerome
>       > >
>       > >             > -----Message d'origine-----
>       > >             > De : Marcel Schepers
>       > > [mailto: [EMAIL PROTECTED]
>       > >             > Envoyé : dimanche 19 novembre 2006 09:56
>       > >             > À : [email protected] 
> <mailto:[email protected]> 
>       > > <mailto:[email protected]>
>       > >             > Objet : getServlet
>       > >             >
>       > >             > Hello, 
>       > >             >
>       > >             > I am busy integrating the Restlet API with
>       > > servlets and
>       > >             > Spring. For the Spring part access to a
>       > > servlet's context 
>       > >             > (javax.servlet.ServletContext) is required.
>       > > Using the Restlet
>       > >             > extension ServletContext
>       > >             >
>       > > (com.noelios.restlet.ext.servlet.ServletContext ) the code
>       > >             > would look like:
>       > >             >
>       > >             > public void setContext(Context context) {
>       > >             >         super.setContext(context); 
>       > >             >
>       > >             >         if (context instanceof
>       > >             > 
> com.noelios.restlet.ext.servlet.ServletContext) {
>       > >             >
>       > > com.noelios.restlet.ext.servlet.ServletContext 
>       > >             > tmpContext =
>       > >             >
>       > >             >
>       > > (com.noelios.restlet.ext.servlet.ServletContext) context;
>       > >             >
>       > >             >             Servlet servlet = 
> tmpContext.getServlet();
>       > >             >
>       > >             >             javax.servlet.ServletContext
>       > > servletContext =
>       > >             > 
> servlet.getServletConfig().getServletContext(); 
>       > >             >             WebApplicationContext tmp =
>       > >             > (WebApplicationContext)
>       > > servletContext.getAttribute(contextAttribute);
>       > >             >         } 
>       > >             >     }
>       > >             >
>       > >             > However, the 'getServlet()' method in
>       > >             >
>       > > com.noelios.restlet.ext.servlet.ServletContext is 
> private. In
>       > >             > order to make this work I've changed the
>       > > access modifier to
>       > >             > public. Is it possible to change the
>       > > signature to public
>       > >             > permanently? If not, what would be the
>       > > preferred way to get a
>       > >             > reference to the javax.servlet.ServletContext?
>       > >             >
>       > >             > Have a nice day, 
>       > >             > Marcel
>       > >             >
>       > >             > BTW, a full description of the 
> Restlet-Servlet-Spring
>       > >             > integration will follow as soon as possible. 
>       > >             >
>       > >             >
>       > >             >
>       > >             >
>       > >
>       > >
>       > >
>       > >
>       > >
>       
> 
> 
> 

Reply via email to