Class GetGlobalConfigurationContribution

  • All Implemented Interfaces:
    ResourceRequest<Optional<Configuration>>, Callable<Optional<Configuration>>

    public class GetGlobalConfigurationContribution
    extends Object
    implements ResourceRequest<Optional<Configuration>>
    Inspects the contributions to a Global Configuration in order to extract the best suited Local Configuration.

    Contributions are inspected in the order defined by the oslc_config:contributionOrder property.

    Hierarchies of Global Configurations are supported, as long as they are all part of the same GC application.

    All contributions whose URI matches the context path of the current server are potential candidates. The chosen one is the first that can be obtained with the provided Function and that matches the acceptance criteria of the provided Predicate.

    The contract of the Function is to return a Configuration instance from its URI. If the configuration cannot be accessed (e.g: the configuration no longer exists, the user does not have the permission to access it...), return an empty Optional instead.

    The contract of the Predicate is to return true if the configuration matches the acceptance criteria (e.g: the configuration is part of the required Component), false otherwise.

    Note that configurations are cached for 10 seconds to avoid querying the GC and the local application too often.

    • Constructor Detail

      • GetGlobalConfigurationContribution

        public GetGlobalConfigurationContribution​(HttpServletRequest request,
                                                  URI globalConfiguration,
                                                  Function<URI,​Optional<Configuration>> getConfiguration,
                                                  Predicate<Configuration> acceptConfiguration)
        Creates a request to extract the best suited Local Configuration from the given Global Configuration.
        request - the HTTP request
        globalConfiguration - the global configuration to extract the local configuration from
        getConfiguration - the function to get a local configuration instance from its URI (see this class documentation for more details)
        acceptConfiguration - the predicate to determine whether or not a local configuration is acceptable for the current request (see this class documentation for more details)