public interface ServiceCallContext
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 ") );
Modifier and Type | Method and Description |
---|---|
String |
attribute(String name)
Get the string attribute.
|
byte[] |
binaryAttribute(String name)
Get the binary attribute.
|
static ServiceCallContextBuilder |
builder()
Create a context builder.
|
static ServiceCallContextBuilder builder()
String attribute(String name)
name
- Attribute name.byte[] binaryAttribute(String name)
name
- Attribute name.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023