RE: Re: Re: restlet-gwt serialization performance

2011-01-30 Thread Benibur
Well, in fact the problem was ... the development mode of GWT. 
As I could not understand the problem, I tried to deploy the web app on tomcat 
and then the performances were almost the same for json and gwt serialization...
Strange ...

But the performance remains surprising : in speed tracer I compared the 
performance of the json and GWT, and surprisingly the GWT request is bigger (I 
expected it would be smaller since there is less data to transmit) but it is 
faster (?)

Mime-type   application/json
Total Bytes 6924 bytes
Request Timing  @1009ms for 33ms
Response Timing @1042ms for 11ms
Total Timing@1009ms for 44ms

Mime-type   application/x-java-serialized-object+gwt
Total Bytes 13491 bytes
Request Timing  @6297ms for 17ms
Response Timing @6314ms for 17ms
Total Timing@6297ms for 34ms

Bigger ? but still faster ? where is the logic ? I must be missing something ...

Ben

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


RE: Re: restlet-gwt serialization performance

2011-01-20 Thread Benibur
Hello, thank's for the quick answer !
I tried with IE, FF and Chrome. The result is the same.
I profiled the client with the Chrome plugin Speed Tracer : I thought there was 
no ambiguity. But I had a doubt because chrome is working strangely on my pc.
I then created a simple restlet client in order to test : 
ClientResource resource = new 
ClientResource(http://127.0.0.1:/restlet/operations/byAccDate/start01102010/end10102010;);
resource.get(MediaType.APPLICATION_JAVA_OBJECT_GWT).write(System.out);

There is no doubt : if i don't de-serialize, the performance is very good...

The pb is on the client side...

my first tests will be :
1/ desactivate every graphical update on the client side : done, no significant 
result (13s)
2/ de-serialize the json string result in gwt
3/ try the Google Chrome Frame you mentionned
4/ ? any suggestion ?

Is there a way to improve the de-serialization with GWT ? 
Should I modify my objects ?
Should I store the data corresponding to the Operations in tables / array 
(not very familiar with javascript...)

Thank's !

Ben

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


restlet-gwt serialization performance

2011-01-19 Thread Benibur
Hello,

I encounter problem of performance in the serialization of an object by 
restlet-gwt : the json version takes 24ms whereas the gwt version takes 18s  ...

ON THE CLIENT SIDE :
 
  // JSON Button :
  requestButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
  ClientResource r = new 
ClientResource(/restlet/operations/byAccDate/start01102010/end10102010);
  r.setOnResponse(new Uniform() {
public void handle(Request request, Response response) {
  try {
respAreaLabel.setText(response.getEntity().getText());
  } catch (IOException e) {
e.printStackTrace();
  }
}
  });
  r.get(MediaType.APPLICATION_JSON);
}
  });

  // GWT Button :
  btReqAllOpe.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
  OperationsProxy orp = GWT.create(OperationsProxy.class);
  
orp.getClientResource().setReference(/restlet/operations/byAccDate/start01102010/end10102010);
  orp.getClientResource().getClientInfo().getAcceptedMediaTypes().add(new
  PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT_GWT));
  orp.retrieve(new Result Operations () {
public void onFailure(Throwable caught) {
  String st = error: + caught.getMessage();
  respAreaLabel.setText(st);
}
@Override
public void onSuccess(Operations opeList) {
  for (Operation ope : opeList) {
addRowOpe(ft , ope);
  }
}
  });
  
}
  });
  
ON THE SERVER SIDE :
  public class CopyOfOperationsServerRessource extends ServerResource 
implements OperationsServerRessource_Int {

private OperationDaoInterface opeDao;

public void setOpeDao(OperationDaoInterface opeDao) {
  this.opeDao = opeDao;
}

public OperationDaoInterface getOpeDao() {
  return opeDao;
}

@Get
public Operations retrieve() {
  ArrayListOperation result = new Operations(opeDao.getAll()) ;
  return new Operations(result) ;
}

@Get(json)
public JsonRepresentation retrieveJson() {
  ArrayListOperation result = new Operations(opeDao.getAll()) ;
  XStream xstream = new XStream(new JsonHierarchicalStreamDriver());
  xstream.setMode(XStream.NO_REFERENCES);
  xstream.alias(operation, Operation.class);
  return new JsonRepresentation( xstream.toXML(result) );
}
  }

  public interface OperationsProxy extends ClientProxy {

@Get
public void retrieve(ResultOperations callback);

  }
  
I thought I correctly use the gwt plugin, but the performance gap with the json 
version seems just too huge : I must have missed something : any idea ?

regards !

Ben

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


RE: GWT demo project with R2.0.0

2010-08-23 Thread Benibur
well, I made the test, with both the snapshot and the 2.0 stable release.
I always have the same behaviour as with the project dowloaded and run without 
any modification...
I think this is a problem with the tutorial, but i should not be the only one 
with this pb (the warnings are the same on my different computers...).

any idea ?

regards,

Ben

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


RE: GWT demo project with R2.0.0

2010-08-13 Thread Benibur
Hello,

Point 1 solved : I think I made a mistake : now my tests work with the jar of 
the lastest release. 
The bug was between the chair and the keyboard !  
:-) 
Good.

Point 2 : the given demo in the wiki continues to send warnings even if 
everything seems to work... If some one can correct it (but seems minor).

see you,

Ben

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


how to send an array of json objects to a GWT client ?

2010-08-13 Thread Benibur
Hello,

I need to send an ordered lit of objects to a GWT client.
Here is the solution I found, it works, but I am prety sure that tere is a more 
efficient solution :

My code on the server side :

public class TestArrayOfjObjectRessource extends ServerResource {
@Get(json)
public Representation toJson() throws ResourceException {
ListObject list = new ArrayListObject();
MyClass myObject_1 = new MyClass;
MyClass myObject_2 = new MyClass;
list.add( new JsonRepresentation(myObject_1).getJsonObject());
list.add( new JsonRepresentation(myObject_2).getJsonObject());
JsonRepresentation jr = new JsonRepresentation(new 
JSONArray(list));
return jr;
}
}

On client side :
jsonButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
 ClientResource r = new 
ClientResource(/restlet/simpleTestRessource);
 r.setOnResponse(new Uniform() {
  public void handle(Request request, Response 
response) {
Representation myEntity = response.getEntity();
JsonRepresentation jRep = new 
JsonRepresentation(myEntity);
try {
JSONObject jsonObject = 
jRep.getValue().isObject();

respAreaLabel.setText(jsonObject.toString());
} catch (IOException e) {
 e.printStackTrace();
}
}
 });
 // Indicates the client preferences and let the server handle
 // the best representation with content negotiation.
 r.get(MediaType.APPLICATION_JSON);
}
});

== the displayed result is [{...},{...}] what is the expected result.

does anyone have an idea if my solution can be improved.

thanks !

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


GWT demo project with R2.0.0

2010-08-07 Thread Benibur
Hello,

I continue my investigations of Restlet : it sounds very promising but I 
encounter few problems with the demo project of the GWT edition : 
http://wiki.restlet.org/docs_2.0/13-restlet/275-restlet/144-restlet/188-restlet.html
It is not possible to propose this framework in a professional project if we do 
not manage to put on the demo, i really hope that someone has a suggestion. 

Here are the 2 points : 

1/ if you replace the R2.0rc3 Restlet server jar located in war/WEB-INF/lib 
with R2.0.0 ones, then the json test no longer works (and work again if the jar 
are downgraded to 2.0rc3)
The warning are at the end of the post [1]


2/ when running the application (with R2.0rc3 jar), everything works fine, 
nonetheless there is a warning about the WAR connector : ATTENTION: No 
available client connector supports the required protocols: 'WAR' . 
Complete warning further [2]


Any idea ? 
Incompatibility between the demo project (testGwtRestlet-2.0) and R2.0.0 ?

Thank you, my analyse is stuck by sand dust and this is quite frustrating since 
I have great expectation for this framework.

Ben

WARNINGS :

[1]

14:03:08.218 [ERROR] [testgwtrestlet_2_0] Uncaught exception escaped
com.google.gwt.json.client.JSONException: 
com.google.gwt.core.client.JavaScriptException: (SyntaxError): invalid regular 
expression flag a
 fileName: 
http://127.0.0.1:1212/testgwtrestlet_2_0/hosted.html?testgwtrestlet_2_0
 lineNumber: 54
 stack: eval((?xml version=\1.0\ 
encoding=\UTF-8\?mainkey2value2/key2key1value1/key1/main))@:0
((?xml version=\1.0\ 
encoding=\UTF-8\?mainkey2value2/key2key1value1/key1/main))@http://127.0.0.1:1212/testgwtrestlet_2_0/hosted.html?testgwtrestlet_2_0:54
(?xml version=\1.0\ 
encoding=\UTF-8\?mainkey2value2/key2key1value1/key1/main)@http://127.0.0.1:1212:27
@:0
([object GWTJavaObject],786433,[object 
XMLHttpRequest])@http://127.0.0.1:1212/testgwtrestlet_2_0/hosted.html?testgwtrestlet_2_0:56
([object Event])@http://127.0.0.1:1212:80
((function () {__gwt_makeJavaInvoke(1)(handler, 786433, _this);}),[object 
XMLHttpRequest],[object Object])@http://127.0.0.1:1212:60
@:0
(null,65560,(function () {__gwt_makeJavaInvoke(1)(handler, 786433, 
_this);}),[object XMLHttpRequest],[object 
Object])@http://127.0.0.1:1212/testgwtrestlet_2_0/hosted.html?testgwtrestlet_2_0:56
([object Event])@http://127.0.0.1:1212:48
at com.google.gwt.json.client.JSONParser.parse(JSONParser.java:53)
at 
org.restlet.client.ext.json.JsonRepresentation.getValue(JsonRepresentation.java:160)
at 
org.restlet.example.gwt.client.SimpleExample$3$1.handle(SimpleExample.java:170)
at 
org.restlet.client.engine.http.adapter.ClientAdapter$1.handle(ClientAdapter.java:102)
at 
org.restlet.client.engine.http.GwtClientCall$2.onResponseReceived(GwtClientCall.java:245)
at 
com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at 
com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at 
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at 
com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714)
at 
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
at 
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at 
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
at 
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at 
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at 
com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669)
at 
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
at 
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Unknown Source)
Caused by: com.google.gwt.core.client.JavaScriptException: 

Restlet 2.0 gwt : where are server class packages ?

2010-08-06 Thread Benibur
Hello,

My first steps with restlet gwt  2.0 were very promising.
The exemple project works fine.

Then I tried to set up my own project : I put on the class path the 3 jar given 
with the gwt edition 2.0.0 :
 - org.restlet.jar
 - org.restlet.ext.json.jar
 - org.restlet.ext.xml.jar

But none of these jar contains server side classes such as 
 - org.restlet.Application 
or 
 - org.restlet.ressource.ServerRessource

== where should i find these classes ?

I can't use org.restlet.jar from another edition otherwise gwt classes will be 
missing ...

many thanks,

ben

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


RE: Restlet 2.0 gwt : where are server class packages ?

2010-08-06 Thread Benibur
Ok thank you, with your informations and by digging the documentation, I 
understood :

1/ The 3 jar given with the gwt edition 2.0.0 (client side) :
 - org.restlet.jar
 - org.restlet.ext.json.jar
 - org.restlet.ext.xml.jar
must be in the class path of the project (file can be where ever we want, just 
add it to the class path).

2/ The jar given with the edition corresponding to the server side used (jee in 
my case), must be placed in :
war/WEB-INF/lib and then added to the classpath.

When reading the doc it is not said clearly, i hope this post will help other 
people with the same misunderstanding.

anyway, it work's well, thank you for your help !

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