Package edu.iu.client

Class RemoteInvocationHandler

java.lang.Object
edu.iu.client.RemoteInvocationHandler
All Implemented Interfaces:
InvocationHandler

public abstract class RemoteInvocationHandler extends Object implements InvocationHandler
May be extended for synchronous client=side remote invocation of a Java interface via HTTP POST.
  • Constructor Details

    • RemoteInvocationHandler

      protected RemoteInvocationHandler()
      Default constructor.
  • Method Details

    • uri

      protected abstract URI uri(Method method)
      Supplies the remote invocation URI.
      Parameters:
      method - remote method
      Returns:
      URI
    • authorize

      protected abstract void authorize(HttpRequest.Builder requestBuilder)
      Adds authorization headers to a pending remote call request
      Parameters:
      requestBuilder - pending remote call request
    • payload

      protected void payload(HttpRequest.Builder requestBuilder, Method method, Object[] args)
      Adds request payload to a pending remote call request.

      Default behavior is to POST arguments as a JSON array, using adapt(Type) for conversion.

      Parameters:
      requestBuilder - pending remote call request
      method - method
      args - arguments
    • adapt

      protected <T> IuJsonAdapter<T> adapt(Type type)
      Get a IuJsonAdapter for converting to a generic type.
      Type Parameters:
      T - Java type
      Parameters:
      type - Java type
      Returns:
      IuJsonAdapter
    • invoke

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      Specified by:
      invoke in interface InvocationHandler
      Throws:
      Throwable