public interface RestProxy extends ViewBindable
@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(@PathParamString 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.
| Modifier and Type | Interface and Description |
|---|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
setEndpoint(String address)
Set base endpoint address for rest services calls made by this proxy
|
bindCruxViewgetBoundCruxView, getBoundCruxViewIdvoid setEndpoint(String address)
address - endpoint addressCopyright © 2015. All rights reserved.