...
ServiceCallContext - immutable map of custom parameters to user parameter map that will be implicitly passed to the service (and interceptor) on every method call.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public interface ServiceCallContext { public String attribute(String name); public byte[] binaryAttribute(String name); } |
ServiceCallInterceptor - intercepts service method calls.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
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. } } |
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
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); } |
...
Interceptor only applies to user-defined business methods and does not apply to service lifecycle methods - init, execute andcancel,
Interceptor can modify ServiceCallContext, but Service methods can only read it.
If an interceptor has been specified, but the user has not passed the caller context through the proxy, it will be created dynamically.
One service can have several interceptors. They are defined using the service configuration and deployed with the service.
To add/remove interceptor - service should be redeployed.
Interceptor is located and executed where the service is implemented (for Java service - on Java side, for .NET-service on .NET side). Its execution should not cause additional serialization.To add/remove interceptor - service should be redeployed.
...
Interceptor should support LifeCycleAware
The user can create this context and bind it to the service proxy. After that, each call to the proxy method will also implicitly pass context parameters to the service.
Service method can read current context using ServiceContext#currentCallContext method. It is only accessible from the current thread during the execution of a service method.
Interceptor can read and update this parameters using ServiceInterceptorContext.
If an interceptor has been specified, but the user has not passed the caller context through the proxy, then for each call to the service method, an empty context will be dynamically created.
Interceptor can only throw unchecked exceptions.
...