THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
ServiceCallInterceptor security = (mtd, args, ctx, svcCall) -> { if (!CustomSecurityProvider.get().access(mtd, ctx.currentCallContext().attribute("sessionId"))) throw new SecurityException("Method invocation is not permitted"); // Execute remaining interceptors and service method. return svcCall.call(); }; ServiceCallInterceptor audit = (mtd, args, ctx, svcCall) -> { String sessionId = ctx.currentCallContext().attribute("sessionId"); AuditProvider prov = AuditProvider.get(); // Record an event before execution of the method. prov.recordStartEvent(ctx.name(), mtd, sessionId); try { // Execute service method. svcCall.call(); } catch (Exception e) { // Record error. prov.recordError(ctx.name(), mtd, sessionId), e.getMessage()); // Re-throw exception to initiator. throw e; } finally { // Record finish event after execution of the service method. prov.recordFinishEvent(ctx.name(), mtd, sessionId); } } ServiceConfiguration svcCfg = new ServiceConfiguration() .setName("service") .setService(new MyServiceImpl()) .setMaxPerNodeCount(1) .setInterceptors(security, audit); // Deploy service. ignite.services().deploy(svcCfg); // Set context parameters for the service proxy. ServiceCallContext callCtx = ServiceCallContext.builder().put("sessionId", sessionId).build(); // Make service proxy. MyService proxy = ignite.services().serviceProxy("service", MyService.class, false, callCtx, 0); // A Makebusiness servicemethod call to be intercepted. proxy.placeOrder(order1); proxy.placeOrder(order2); |
...