Hi Jonathan,

For this use case, couldn't you leverage the SpringContext class in the
org.restlet.ext.spring extension?

Best regards,
Jerome  

> -----Message d'origine-----
> De : Jonathan Hall [mailto:[EMAIL PROTECTED] 
> Envoyé : mardi 6 mars 2007 22:27
> À : [email protected]
> Objet : Re: Servlet Context
> 
> Hi Jerome,
> 
> Thankyou for responding.
> 
> The use case I had in mind was for creating a springContext without 
> hardcoding the configuration xml locations:
> 
> WebApplicationContext springContext = 
> WebApplicationContextUtils.getWebApplicationContext(getServlet
> Context());
> 
> This requires a ServletContext and I couldn't find another way to 
> access/cast it.
> I haven't looked into it, so I shouldn't really comment if other IoC 
> frameworks use this or not.
> 
> If you don't believe this should be added, it is fair enough. It is 
> trivial to extend ServerServlet myself and use that. I just 
> thought it 
> might be useful to have.
> 
> Best Regards,
> Jonathan
> 
> 
> 
> Jerome Louvel wrote:
> > Hi Jonathan,
> >
> > When using the ServerServlet, the Restlet's context already 
> wraps the
> > Servlet's context (logging, resource loading, parameters, 
> etc.). Why would
> > you need a direct access to the Servlet context?
> >
> > Best regards,
> > Jerome  
> >
> >   
> >> -----Message d'origine-----
> >> De : Jonathan Hall [mailto:[EMAIL PROTECTED] 
> >> Envoyé : mardi 6 mars 2007 20:27
> >> À : [email protected]
> >> Objet : Servlet Context
> >>
> >> Hi,
> >>
> >> I was wondering if a way to access the ServletContext could 
> >> be added to 
> >> the code. This would be useful for Spring and I presume other IoC 
> >> frameworks.
> >> It would not tie Restlet to any other libraries or harm it as 
> >> far as I 
> >> can see.
> >>
> >> As per shloks example, it would require changes to 
> >> com.noelios.restlet.ext.servlet.ServerServlet and 
> >> org.restlet.Application
> >>
> >> com.noelios.restlet.ext.servlet.ServerServlet 
> >>
> >>     public Application createApplication(Context context) {
> >> ...
> >>
> >>         if (application != null)
> >>             application.setServletContext(getServletContext());
> >>
> >> }
> >>
> >>
> >> org.restlet.Application.java
> >>
> >>     private ServletContext servletContext = null;
> >>
> >>     public ServletContext getServletContext() {
> >>         return servletContext;
> >>     }
> >>
> >>     public void setServletContext(ServletContext servletContext) {
> >>         this.servletContext = servletContext;
> >>     }
> >>
> >> Please let me know what you think,
> >>
> >> Best Regards,
> >> Jonathan
> >>
> >>     
> >
> >   

Reply via email to