Use of Restlet 'Client' class inside a Servlet does not work

2007-06-30 Thread Philip Johnson
Greetings, all,

I'm a bit confused about what happens when Restlet Client instances are embedded
within Servlets.

I've built a small standalone HTTP client using Restlet that makes simple HTTP
requests of an HTTP server called (let's say) Foo. This client  works fine when
you run it independently from the command line.

A student of mine is now trying to use the Restlet client code within a servlet
for a webapp called (let's say) Bar, and the Restlet Client instance now returns
a 403 error when it makes an HTTP request to Foo. He extracted his code, ran it
as an independent application, and everything once again worked fine. 

I know there is a Servlet adapter in Restlet, but I figured this was for
server side integration of Restlet with web servers---i.e. allowing you to do
Restlet style Resource/Representation processing. 

In my case, we're not trying to do that: what we're trying to do is embed a
Client inside a Servlet and make calls to an external server. 

Does anyone have any ideas about why embedding a Restlet Client inside a Servlet
wouldn't work, and what I should do about it? 

If there isn't any obvious reason why I'm having this problem, I can put
together a small test case to illustrate the issue. 

Thanks very much for your help.

Philip


RE: client perfomance question

2007-06-30 Thread Jerome Louvel

Hi Evgeny,

  Inside a Restlet Application, the best is to
  leverage the Context.dispatcher mechanism which allows the 
  sharing of client connectors between several applications.
 
 If you have some possibilities and free time could you 
 describe this more detailly.

There is a diagram in the tutorial that provides an overview of the sharing
of client connectors between several applications:
http://www.restlet.org/documentation/1.0/tutorial#part05

Then, inside a Restlet or a Resource, you can invoke the
getContext().getDispatcher() method to get an instance of the Uniform
interface. This dispatcher will automatically route the request to the most
appropriate client connector, taking into account the Request.protocol
property or the Request.resourceRef's scheme.

Best regards,
Jerome  


RE: client perfomance question

2007-06-30 Thread Jerome Louvel

Evgeny,

 Maybe i will try to describe my situation more detailly to 
 explain what issues i'm facing.
 
 I have restlet-based serivce that exposes some XML documents.
 It's perfomance is tested with ab and satisfies my needs :)

Cool :)

 At client side i have some JSP that are using my service. In 
 JSP code i'm writing smth like.
 
 Client client = new Client(Protocol.HTTP);
 client.getContext()
 Response resp = client.get(..);
 
 XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
 XmlPullParser xpp = factory.newPullParser();
 xpp.setInput(resp.getEntity().getStream(), UTF-8);
   
 And as a result i'm having huge delays for getting the XML text. I've
 discovered it with tests that measures delays of ccertain operation.
 My client uses java.net.HttpURLConnection-based connector class.
 
 Then i decided to try use simple URLConnection approach.
 
 URLConnection con = new URL().openConnection();
 ((HttpURLConnection)con).setRequestMethod(GET);
 con.setDoOutput(true);
 
 XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
 XmlPullParser xpp = factory.newPullParser();
 xpp.setInput(con.getInputStream(), UTF-8);
 
 And according to timing delays for getting XML reduced 4-5 times.
 So i'm not thinking that restlet client is workign so slow 
 and wanted someone
 to advice if i'm usign Client instances incorrectly.

Thanks for sharing this experience. The observed performance is very
surprising to me, there is really no technical reason for such an overhead,
the code inside the connector should be straightforward and cause no
noticeable delay.

Could you drill down the Restlet source code to give us indication of where
this time is spent, maybe using a profiling tool?

Best regards,
Jerome  


Re: JXTA support?

2007-06-30 Thread Jerome Louvel

Hi James,

No worry, we are getting there :)

I have just updated the wiki page with current design discussion:
http://wiki.java.net/bin/view/Javawsxml/RestletDiscussionsJXTA

Best regards,
Jerome


James Todd wrote :

just got my rma number to return the video card.

short having that dev box back i can u/d the wiki w/ my thoughts and 
continue to get the standalone code working

as we discussed.