Target release6.2.0
EpicLink to related JIRA epic or feature
Document statusDRAFT
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.
  • 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.
    When no path is specified, it's assumed to be the class name ("org.foo.MyInterface")

  • expose(String), optional
    Defines the methods on the interface that are visible.
    Possible values:
    • "ALL" (default) - All methods defined on the interface are visible.
    • "REMOTE" - Only methods marked with the @RemoteMethod annotation are visible.

  • @RemoteMethod
    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 signature (e.g. "myMethod(int,boolean,java.lang.String)").

    • 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.

  • @Query("name")
    Annotation applied to Java method arguments to denote that they are QUERY parameters on the request.
  • @FormData("name")
    Annotation applied to Java method arguments to denote that they are FORM post parameters on the request.

  • @Body
    Annotation applied to Java method arguments to denote that they are the HTTP body of the request. 

  • @Header("name")
    Annotation applied to Java method arguments to denote that they are serialized as an HTTP header value. 

Example:

// *** Server side ***
@Remoteable(url="/myremoteable")
public interface MyRemoteableInterface {

@RemoteMethod(httpMethod="GET", path="/method1")
public Foo callMyMethod(@Query("count") int count, @Header("E-Tag") String eTag, @Body Bean myBean);
}

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

 

Other changes:

  • Move @Remoteable annotation to a new package:  org.apache.juneau.remoteable.
    All new annotations shown above would be grouped in this package.