THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
...
...
...
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
/** * Service method call interceptor. */ public interface ServiceCallInterceptor { extends Serializable /** * Executes before service method invocation.{ public * default void onInvoke(ServiceInterceptorContext ctx) throws * @param mtdName Method name.ServiceInterceptException { * @param args Method arguments. * @param ctx Service request context. * @return Listener of the call result or {@code null}. */// No-op. } public @Nullabledefault ServiceCallListenervoid interceptonComplete(String@Nullable mtdName, Object[] argsres, ServiceRequestContextServiceInterceptorContext ctx); } | ||||||||
Code Block | ||||||||
| ||||||||
/** * Listener of the service method invocation. */ public interface ServiceCallListener { throws ServiceInterceptException { /**/ No-op. *} public *default @paramvoid res Service method call result, if any.onError(Throwable err, ServiceInterceptorContext ctx) { * @param t Error, if any// No-op. */ public void onComplete(@Nullable Object res, @Nullable Throwable t);} } |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
ServiceCallInterceptor security = (mtd, args,new ServiceCallInterceptor() { @Override public void onInvoke(ServiceInterceptorContext ctx) ->throws ServiceInterceptException { // Check permission before execution of the method. if (!CustomSecurityProvider.get().access(mtdctx.method(), ctx.valueattribute("sessionId"))) throw new SecurityException("Method invocation is not permitted"); return null;} } ServiceCallInterceptor audit = (mtd, args,new ServiceCallInterceptor() { @Override public void onInvoke(ServiceInterceptorContext ctx) -> { // Record an event before execution of the method. AuditProvider.get().recordStartEvent(mtdctx.method(), ctx.valueattribute("sessionId")); } return ( @Override public void onComplete(@Nullable Object res, err) -> { ServiceInterceptorContext ctx) { AuditProvider.get().recordFinishEvent(ctx.method(), ctx.attribute("sessionId")); } // Record an@Override eventpublic aftervoid the execution of the method. onError(Throwable err, ServiceInterceptorContext ctx) { AuditProvider.get().recordFinishEvent(mtdrecordError(ctx.method(), ctx.valueattribute("sessionId"), err != null.getMessage()); } } // Set context parameters for service proxy. ServiceCallContext ctx = ServiceCallContext.builder().put("sessionId", sessionId).build(); ServiceConfiguration svcCfg = new ServiceConfiguration() .setName("service") .setService(new MyServiceImpl()) .setMaxPerNodeCount(1) .setInterceptors(Arrays.asList(security, audit)); // Deploy service. ignite.services().deploy(svcCfg); ... // Set context parameters for service proxy. MyService proxy = ignite.services().serviceProxy("service", MyService.class, false, Collections.singletonMap("sessionId"ctx, sessionId), 0); // A business method call to be intercepted. proxy.placeOrder(order1); proxy.placeOrder(order2); |
// Describe project risks, such as API or binary compatibility issues, major protocol changes, etc.
...