Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Page properties
Target release6.2.0
EpicLink to related JIRA epic or feature
Document status
Status
titleDRAFT
Document owner

James Bognar

Designer

James Bognar

Steve Blackmon

Developers

James Bognar

Steve Blackmon

QALead tester

Goals:

  • Simplify how remoteable interface proxies are exposed in the server and used in the clients.

User interaction and design

The goal on the server side is to simply map a method URL to a method using the existing @RestMethod annotation.  A new "PROXY" method name is used in place of the usual GET/PUT/POST/DELETE... 

...

@Remoteable(path="/proxy/*") 
public IAddressBook getProxy() {
return addressBookImpl;
}

...

  • Allow interface proxies to be defined against 3rd-party REST interfaces.
  • Allow interface proxies to pass Java method parameters as GET parameters.

New annotations:

  • @Remotable
    Annotation applied to interface proxy classes. 
  • path(String), optional 
    The absolute or relative path to the REST service.
    When relative path is specified, it's relative to the root-url defined on the RestClient.
     
  • expose(String), optional
    Defines the methods on the interface that are visible.
    Possible values:
    • "ALL" (default) - All methods defined on the interface are visible.
    • "REMOTEABLE" - Only methods marked with the @RemoteableMethod annotation are visible.

  • @RemoteableMethod
    Annotation applied to Java methods on interface proxy classes. 

    • path(String), optional
      The path to the REST service for this Java method.
      The default value is the Java method name itself.

    • httpMethod(String), optional
      Defines whether to use GET or POST for the method call.
      Possible values:
      • "POST" (default) - Parameters are serialized using the serializer registered with the RestClient.
      • "GET" - Parameters are serialized using the UrlEncodingSerializer registered with the RestClient.

Example:

@Remoteable(url="/myremoteableinterface")
public interface MyRemoteableInterface {

@RemoteableMethod(httpMethod="GET", path="/method1")
public Foo callMyMethod(@Param("bar") int bar, @Param("baz") String baz, @Param("qux") Bean qux);
}

RestClient client = RestClientBuilder().rootUrl("http://hostname").build();
MyRemoteableInterface i = client.getRemoteableProxy(MyRemoteInterface.class);
Foo f = i.callMyMethod(123,"foo",new Bean()); 

The code above causes the following HTTP request:

HTTP GET http://hostname/myremoteableinterface/method1?bar=123&baz=foo&qux=(...) 

 

...

On the client side, the proxy is retrieved using the RestClient class:

IAddressBook ab = 
new RestClientBuilder()
.rootUrl(microserviceURI)
.getRemoteableProxy(IAddressBook.class, "/addressBook/proxy");

 

Optionally, the @Remoteable annotation can be used to specify the URL on the client side....

@Remoteable(path="/addressBook/proxy")
public interface IAddressBook {
...

...

// or a new @RestProxy annotation with no path?
@RestProxy 
public IAddressBook getProxy() {
...
}
 
IAddressBook ab = 
new RestClientBuilder()
.rootUrl(microserviceURI)
.getRemoteableProxy(IAddressBook.class);

 

Questions...

...