Hi Rahul,

 

In Restlet 2.0, the ServletContext is copied into an
"org.restlet.ext.servlet.ServletContext" attribute of the Restlet
application attached to the ServerServlet. You should be able to retrieve it
this way:

 

ServletContext sc = (ServletContext)
getContext().getAttributes().get(“org.restlet.ext.servlet.ServletContext”);

 

Let us know if it doesn’t work.

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~  <http://www.restlet.org/>
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  <http://www.noelios.com/>
http://www.noelios.com

 

 

 

 

De : Rahul Juneja [mailto:rahul.jun...@thoughtclicks.com] 
Envoyé : mercredi 16 septembre 2009 03:16
À : discuss@restlet.tigris.org
Objet : Re: spring context - webapplication context in restlet 2

 

Rhett,

 

But still i guess its good to have an interface or something which can have
an implementation in case we are running within the container. maybe inside
the jee version of the restlet.

 

Thanks,

Rahul

 

On Tue, Sep 15, 2009 at 2:32 PM, Rhett Sutphin <rh...@detailedbalance.net>
wrote:

Hi Rahul,


On Sep 15, 2009, at 8:54 AM, Rahul Juneja wrote:

> Rhett,
>
> I tried the following things in ServerResource File. anyways thats
> ok but i have a question about why Restlet doesn't expose the
> Servlet context which is one of the attributes added to the context
> of the application. "org.restlet.ext.servlet.ServletContext" ?

Do you mean "why doesn't Restlet expose the ServletContext in the
ServerResource API"?  Because that would create a dependency in
Restlet core on a JEE class.  Restlet core is designed to run without
JEE.

Rhett


>
> Thanks,
> Rahul
>
> On Mon, Sep 14, 2009 at 5:39 PM, Rhett Sutphin <rh...@detailedbalance.net
> > wrote:
> Hi Rahul,
>
> On Sep 13, 2009, at 11:39 AM, Rahul Juneja wrote:
>
> > I wanted to get some spring injected beans in my resource file. and
> > i have looked at the integration with spring in other ways but i
> > would not be very interested in that as i want to keep spring
> > separate from restlet. Also i am aware of the concern that this way
> > my application will be tied to Servlet api. but i think i am fine
> > with that as i will be running on tomcat only.
> >
> > I looked at "SpringServerServlet" and tried calling
> > getWebApplicationContext() or getServletContext() but in both the
> > cases i am getting exception. I did not do anything else. except
> > calling this method from the resource file. Is there any other steps
> > i need to follow to get the springContext or webappllication context
> > to get the beans from the spring.
>
> getServletContext() inside a servlet is provided by the JEE API.  If
> that's throwing an exception, you have a non-restlet-related problem.
>
> I'm not so familiar with SpringServerServlet, but it appears that it
> is loading the spring application context from the standard (for
> spring) JEE location.  Are you loading the application context using
> ContextLoaderListener?
>
> You might also try out RestletFrameworkServlet.  It allows you to
> configure restlet in approximately the same way you configure Spring
> MVC.
>
> Again, though, if you can't invoke getServletContext() from inside a
> servlet, none of these solutions are going to work for you.
>
> Rhett
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447
<http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2394
793> &dsMessageId=2394793
>
>
>
> --
> Rahul Juneja
> Phone : (631) 681-9996
> Fax :  (206) 339-9047
> http://techlabs.thoughtclicks.com
> http://finance.thoughtclicks.com
>
---------------------------------------------------------------------------
> The thing always happens that you really believe in;
> and the belief in a thing makes it happen.

------------------------------------------------------

http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447
<http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2395
203> &dsMessageId=2395203




-- 
Rahul Juneja
Phone : (631) 681-9996
Fax :  (206) 339-9047
http://techlabs.thoughtclicks.com
http://finance.thoughtclicks.com
---------------------------------------------------------------------------
The thing always happens that you really believe in;
and the belief in a thing makes it happen.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2402833

Reply via email to