Adds a custom context (arbitrary object) to this container.
This context will be passed for all outbound service calls made by RxClient.
Serialization/de-serialization mechanism for this context will be delegated to {@code serializer}. Serialization will be done when an outbound service call is made, to send this context on the wire.
De-serialization will be done in the outbound service for the above call,
if and only if, a client invokes {@link ContextsContainer#getContext(String)} for the same context name.
This method overwrites any existing value with the passed context name. Context updates:
If the context is mutable, then every mutation should add the context back here otherwise, the mutation will be lost when the context gets passed to a remote application.
Bi-directional contexts:
The following scenario counts as an update to a bi-directional context:
- The added context is bi-directional.
- There already is a value associated with this context name.
- The associated value is of the same class as the new value.
- The associated value is not equal to the new value as indicated by {@link Object#equals(Object)}
In case this is actually an update, any subsequent calls to {@link #getModifiedBidirectionalContexts()} will alsoinclude this context.
@param contextName Name of the context.
@param context Context instance.
@param serializer Serializer for the context.
@param < T> Type of the context.
@throws IllegalArgumentException If any of the arguments are null.