public interface ServiceCallContext extends Externalizable
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 ") );
ServiceContext
,
ServiceCallContextBuilder
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.
|
readExternal, writeExternal
static ServiceCallContextBuilder builder()
String attribute(String name)
name
- Attribute name.byte[] binaryAttribute(String name)
name
- Attribute name.
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024