Package org.apache.ignite.services
Interface ServiceCallContext
-
public interface ServiceCallContextService call context.This context is implicitly passed to the service and can be retrieved inside the service using
ServiceContext.currentCallContext(). It is accessible only from the local thread during the execution of a service method.Use
builder()to create the context builder.Note: passing the context to the service may lead to performance overhead, so it should only be used for "middleware" tasks.
Usage example:
// Service implementation. class HelloServiceImpl implements HelloService { @ServiceContextResource ServiceContext ctx; public String call(Strig msg) { return msg + ctx.currentCallContext().attribute("user"); } ... } ... // Call this service with context. ServiceCallContext callCtx = ServiceCallContext.builder().put("user", "John").build(); HelloService helloSvc = ignite.services().serviceProxy("hello-service", HelloService.class, false, callCtx, 0); // Print "Hello John". System.out.println( helloSvc.call("Hello ") );
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Stringattribute(String name)Get the string attribute.byte[]binaryAttribute(String name)Get the binary attribute.static ServiceCallContextBuilderbuilder()Create a context builder.
-
-
-
Method Detail
-
builder
static ServiceCallContextBuilder builder()
Create a context builder.- Returns:
- Context builder.
-
attribute
String attribute(String name)
Get the string attribute.- Parameters:
name- Attribute name.- Returns:
- String attribute value.
-
binaryAttribute
byte[] binaryAttribute(String name)
Get the binary attribute.- Parameters:
name- Attribute name.- Returns:
- Binary attribute value.
-
-