Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Ability to pass custom context from caller to service (similar to HTTP request headers).
  2. Ability to define custom interceptors for service calls.

Public API

New public API entities.

  • ServiceCallContext -  immutable map of custom parameters to be implicitly passed to the service

    .
  • ServiceCallInterceptor  - intercepts service method calls.
  • ServiceInterceptorContext -  extended mutable version of caller context (interceptor obtains method call parameters from it and can use it to update the caller context).
  • Code Block
    languagejava
    themeRDark
    titleServiceCallContext
    linenumberstrue
    collapsetrue
    public interface ServiceCallContext {
        public String attribute(String name);
    
        public byte[] binaryAttribute(String name);
    }
    ServiceInterceptException - unchecked exception that is used to highlight the exception that occurred during method interception (not execution).


  • ServiceCallInterceptor  - intercepts service method calls.

    Code Block
    languagejava
    themeRDark
    titleServiceCallInterceptor
    linenumberstrue
    collapsetrue
    public interface ServiceCallInterceptor extends Serializable {
        public default void onInvoke(ServiceInterceptorContext ctx) throws ServiceInterceptException {
            // No-op.
        }
    
        public default void onComplete(@Nullable Object res, ServiceInterceptorContext ctx) throws ServiceInterceptException {
            // No-op.
        }
    
        public default void onError(Throwable err, ServiceInterceptorContext ctx) {
            // No-op.
        }
    }

...

ServiceCallContext -  immutable map of custom parameters to be implicitly passed to the service.

...

...

public interface ServiceCallContext {
    public String attribute(String name);

    public byte[] binaryAttribute(String name);
}

  • ServiceInterceptorContext -  extended mutable version of caller context (interceptor obtains method call parameters from it and can use it to update the caller context).

    Code Block
    languagejava
    themeRDark
    titleServiceInterceptorContext
    linenumberstrue
    collapsetrue
    public interface ServiceInterceptorContext extends ServiceCallContext {
        public String method();
    
        public @Nullable Object[] arguments();
    
        public void attribute(String name, String val);
    
        public void binaryAttribute(String name, byte[] val);
    }


  • ServiceInterceptException - unchecked exception that is used to highlight the exception that occurred during method interception (not execution).

Usage example

Diagram

draw.io Diagram
bordertrue
diagramNamemiddleware
simpleViewerfalse
width
linksauto
tbstyletop
lboxtrue
diagramWidth1001
revision13

...