I have been working on spring based server that has few 
servlets [DWR, OpenAmf, Spring's MVC and Hibernate]. 
I needed to use Rest for providing API functionality.
Problem:
The examples in Wiki demonstrate loading spring beans 
and accessing them using Spring Extension and Spring context. 
When I started working, I missed it andeventually got it working
and it works fine. 

I have few questions / doubts though. 

What I do?
I am using spring's 
WebApplicationContextUtils.getWebApplicationContext() 
to get the spring context (hence I am using already 
available functionality and do not
need Spring extension). For this to work, I just made 
2 minor changes:
1. Added ServletContext attribute to Application class.
2. In ServerServlet class, I simply do
application.setServletContext(getServletContext()).
3. In my RestApplication extends Application createRoot(), 
I simply do getSpringContext() and pass it to 
WebApplicationContextUtils.

I would like to know, if this approach is good? 
It helps me in a huge way, as I was able to wire 
Targets in my application.xml, which directly 
reference beans in appServices. All these XMLs as 
listed in web.xml context-param <contextConfigLocation>.
It provides me uniform wiring, as previous contexts.
Furthermore, following spring's philosophy, the 
application.xml is now in web.xml, instead of 
hard-coded in the RestApplication class.

I am not sure which is better approach? Is having 
ServletContext in Application ok?
All in all, Restlet is a wonderful framework, thanks a lot Jerome.

Reply via email to