Class RemoteClient

java.lang.Object
org.apache.juneau.rest.client.remote.RemoteClient

public final class RemoteClient extends Object
Creates Java proxy instances for Remote-annotated interfaces, backed by an RestClient.

Each interface method call translates to an HTTP request via the client.

Obtain instances via RestClient.remote(Class).

@Remote(path="/api/users") public interface UserService {{ @RemoteGet("/{id}") String getUser(@Path("id") String id); }} UserService svc = client.remote(UserService.class); String user = svc.getUser("42");

See Also:
Since:
9.2.1
  • Constructor Details

    • RemoteClient

      public RemoteClient(RestClient client)
      Constructor.
      Parameters:
      client - The underlying REST client. Must not be null.
  • Method Details

    • create

      public <T> T create(Class<T> iface)
      Creates a Java proxy for the given Remote-annotated interface.
      Type Parameters:
      T - The interface type.
      Parameters:
      iface - The interface class. Must be annotated with Remote. Must not be null.
      Returns:
      A proxy instance. Never null.
      Throws:
      IllegalArgumentException - If iface is not an interface or not annotated with Remote.