Per-Proxy Request Contexts
2 min read
2 min read
2 min read
Each proxy stores a request context, empty by default. Ice sends this per-proxy context with each invocation made through the proxy, unless the invocation has an explicit context.
ice_context returns a new proxy that stores the given context, and ice_getContext returns the proxy's context:
auto greeterEs = greeter->ice_context({{"language", "es"}});var greeterEs = GreeterPrxHelper.uncheckedCast( greeter.ice_context(new Dictionary<string, string> { ["language"] = "es" }));var greeterEs = greeter.ice_context(Map.of("language", "es"));const greeterEs = greeter.ice_context(new Map([["language", "es"]]));context = configureDictionary('string', 'string');context('language') = 'es';greeterEs = greeter.ice_context(context);$context = ["language" => "es"];$greeterEs = $greeter->ice_context($context);greeterEs = greeter.ice_context({"language": "es"})greeterEs = greeter.ice_context({"language"=>"es"})let greeterEs = greeter.ice_context(["language": "es"])The per-proxy context is a local setting of the proxy: a stringified proxy cannot carry one, and Ice does not marshal it when it sends the proxy to another application.
Configuring a Per-Proxy Request Context with Properties
When you create a proxy with propertyToProxy, the Context properties of the proxy property set its per-proxy context:
Greeter.Proxy=greeter:tcp -h localhost -p 4061Greeter.Proxy.Context.language=esEach name.Context.key=value property adds the entry key with the value value. To change this context, call ice_context with an updated copy of the dictionary that ice_getContext returns.