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
          Preference<MediaType>(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() {
      ArrayList<Operation> result = new Operations(opeDao.getAll()) ;
      return new Operations(result) ;
    }
    
    @Get("json")
    public JsonRepresentation retrieveJson() {
      ArrayList<Operation> 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(Result<Operations> 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=4447&dsMessageId=2699162

Reply via email to