Interface ContextualRegistry

  • All Superinterfaces:

    public interface ContextualRegistry
    extends Context
    This class will be replaced with Context in future Helidon versions
    A registry for context objects. Enables instance localization between several services / components / ... integrated in a particular known scope. ContextualRegistry instance is intended to be associated with a scope aware object such as WebServer, ServerRequest or ClientRequest.

    Context contains also a notion of classifiers. Classifier is any object defining additional key for registered objects. To obtain such registered object, the same classifier (precisely, any equal object) has to be used.

    Classifiers can be used as follows:

    1. As an additional identifier for registered objects of common types, like a String, ...
       // User detail provider service
       registry.register("NAME_PARAM_ID", "Smith");
       registry.register("GENDER_PARAM_ID", "male");
       // User consumer service
       String name = registry.get("name", String.class);
    2. As an access control mechanism where only owners of the classifier can retrieve such contextual instance.
       // In some central security service.
       registry.register(securityFrameworkInternalInstance, new AuthenticatedInternalIdentity(...));
       // In some authorization filter known by a central security service
       AuthenticatedInternalIdentity auth = registry.get(securityFrameworkInternalInstance, AuthenticatedInternalIdentity.class);