org.cruxframework.crux.core.client.rest
Interface RestProxy

All Superinterfaces:
ViewAware, ViewBindable

public interface RestProxy
extends ViewBindable

Base interface to define REST clients. It can be used to invoke services defined with @RestService annotation or external services.

For example, see the following rest service defined on application's server side:

 @RestService("myService")
 @Editor.Path("test")
 public class MyRestService
 {
    @GET
    @Editor.Path("hello/{userName}")
    public String sayHello(@PathParam("userName") String userName)
    {
        return "Hello "+userName+"!";
    }
 }
 

It could be called from application's client side with the following rest proxy:

 @TargetRestService("myService")
 public interface MyRestServiceProxy extends RestProxy
 {
    void sayHello(String userName, Callback<String> callback);
 }
 

It is possible also to create a rest proxy to invoke external services that are not necessarily defined using Crux at the server side. When Crux does not find the annotation @TargetRestService on the proxy interface, it searches for rest annotations on proxy methods to realize how to build the requests to rest services.

For example, see the following client rest proxy:

 @TargetEndPoint("http://targethost/rest")
 @Editor.Path("test")
 public interface MyRestServiceProxy extends RestProxy
 {
    @GET
    @Editor.Path("hello/${userName}")
    void sayHello(@PathParam String userName, Callback<String> callback);
 }
 

It Could be used to call a rest service located on http://targethost/rest/. Calling MyRestServiceProxy.sayHello("Thiago") would make a request to http://targethost/rest/test/hello/Thiago URI and expect to receive an String as result.

Author:
Thiago da Rosa de Bustamante

Nested Class Summary
static interface RestProxy.TargetEndPoint
          Annotation used to associate an end point address to the current proxy.
static interface RestProxy.TargetRestService
          Annotation used to associate a server side Rest service to the current proxy.
static interface RestProxy.UseJsonP
          A marker interface to specify that the calls made to the service must be made through jsonP.
 
Method Summary
 void setEndpoint(String address)
          Set base endpoint address for rest services calls made by this proxy
 
Methods inherited from interface org.cruxframework.crux.core.client.screen.views.ViewBindable
bindCruxView
 
Methods inherited from interface org.cruxframework.crux.core.client.screen.views.ViewAware
getBoundCruxView, getBoundCruxViewId
 

Method Detail

setEndpoint

void setEndpoint(String address)
Set base endpoint address for rest services calls made by this proxy

Parameters:
address - endpoint address


Copyright © 2014. All rights reserved.