Interface ContextService


  • public interface ContextService
    A service that provides shared context calculation functionality for any services that may wish to use contexts.

    When functionality is provided to query data based upon a given Set of Contexts, the querying code must consider which of the underlying data is "applicable" to the contexts specified in the query request. It is expected that implementations will deem entries of underlying data to be applicable if the Set of contexts defined in the query contain all of the Contexts required by the data entry. Mathematically, an underlying data entry is "applicable" if [the context of the entry] is a subset of [the context provided in the query], or programmatically if [the context provided in the query] Set.containsAll(Collection) of [the context of the entry].

    • Method Detail

      • contexts

        java.util.Set<Context> contexts()
        Get the active contexts from the current cause.
        Returns:
        an immutable set of contexts
      • contextsFor

        java.util.Set<Context> contextsFor​(Cause cause)
        Extract applicable contexts from the provided Cause.
        Parameters:
        cause - source cause
        Returns:
        immutable set of extracted contexts
      • registerContextCalculator

        void registerContextCalculator​(ContextCalculator calculator)
        Registers a ContextCalculator for use by this service.
        Parameters:
        calculator - The context calculator to register