Implicit Request Contexts

2 min read

2 min read

An implicit request context belongs to a communicator: Ice sends it with each invocation made through the proxies of this communicator, unless the invocation has an explicit context.

The Ice.ImplicitContext property specifies whether the communicator has an implicit context:

  • None (the default): the communicator has no implicit context.
  • Shared: the communicator has one implicit context, which all threads can use concurrently.
  • PerThread: the communicator has a separate implicit context for each thread.
  • None (the default): the communicator has no implicit context.
  • Shared: the communicator has one implicit context.

getImplicitContext on the communicator returns its implicit context, an object with methods to read and update the context's entries. With PerThread, call getImplicitContext and update the context on the thread that makes the invocations.

C++
Ice::ImplicitContextPtr implicitContext = communicator->getImplicitContext();
implicitContext->put("language", "fr");
// This invocation sends the "language" entry of the implicit context.
string greeting = greeter->greet(name);
C#
Ice.ImplicitContext implicitContext = communicator.getImplicitContext();
implicitContext.put("language", "fr");
// This invocation sends the "language" entry of the implicit context.
string greeting = await greeter.GreetAsync(name);
Java
ImplicitContext implicitContext = communicator.getImplicitContext();
implicitContext.put("language", "fr");
// This invocation sends the "language" entry of the implicit context.
String greeting = greeter.greet(name);
JavaScript
const implicitContext = communicator.getImplicitContext();
implicitContext.put("language", "fr");
// This invocation sends the "language" entry of the implicit context.
const greeting = await greeter.greet(name);
MATLAB
implicitContext = communicator.getImplicitContext();
implicitContext.put('language', 'fr');
% This invocation sends the 'language' entry of the implicit context.
greeting = greeter.greet(name);
Python
implicitContext = communicator.getImplicitContext()
implicitContext.put("language", "fr")
# This invocation sends the "language" entry of the implicit context.
greeting = await greeter.greetAsync(name)
Ruby
implicitContext = communicator.getImplicitContext()
implicitContext.put("language", "fr")
# This invocation sends the "language" entry of the implicit context.
greeting = greeter.greet(name)
Swift
let implicitContext = communicator.getImplicitContext()!
implicitContext.put(key: "language", value: "fr")
// This invocation sends the "language" entry of the implicit context.
let greeting = try await greeter.greet(name)