Class GetGlobalConfigurationContribution
- All Implemented Interfaces:
ResourceRequest<Optional<Configuration>>,Callable<Optional<Configuration>>
Contributions are inspected in the order defined by the oslc_config:contributionOrder property.
Hierarchies of Global Configurations are supported.
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 and this class will throw an
OslcWebApplicationException (404).
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.
- Since:
- 1.10.0
-
Constructor Summary
ConstructorsConstructorDescriptionGetGlobalConfigurationContribution(Configuration globalConfiguration, Function<URI, Optional<Configuration>> getConfiguration, Predicate<Configuration> acceptConfiguration) Same asGetGlobalConfigurationContribution(HttpServletRequest, URI, Function, Predicate), except the global configuration instance if known beforehand and no HTTP request is required.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. -
Method Summary
Modifier and TypeMethodDescriptioncall()Executes the request and parse the response content in the specified format.Extracts the best suited configurations with all its parent GCs.
-
Constructor Details
-
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.- Parameters:
request- the HTTP requestglobalConfiguration- the global configuration to extract the local configuration fromgetConfiguration- 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)
-
GetGlobalConfigurationContribution
public GetGlobalConfigurationContribution(Configuration globalConfiguration, Function<URI, Optional<Configuration>> getConfiguration, Predicate<Configuration> acceptConfiguration) Same asGetGlobalConfigurationContribution(HttpServletRequest, URI, Function, Predicate), except the global configuration instance if known beforehand and no HTTP request is required.When using this constructor, the requirement is that all contributions of the GC must be obtainable with the given
getConfigurationfunction, whether they belong to the local server or not.- Parameters:
globalConfiguration- the global configuration to extract the local configuration fromgetConfiguration- 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)- Since:
- 3.12.0
-
-
Method Details
-
call
Description copied from interface:ResourceRequestExecutes the request and parse the response content in the specified format. Throws aClientWebExceptionin case the HTTP response status is not20x.- Specified by:
callin interfaceCallable<Optional<Configuration>>- Specified by:
callin interfaceResourceRequest<Optional<Configuration>>
-
callHierarchy
Extracts the best suited configurations with all its parent GCs. Ifcall()would returnOptional.empty()then an empty Deque is returned.- Returns:
- a Deque which first element is the top level Global Contribution and last element is the matching configuration (result of
call()). - Since:
- 3.13.0
- See Also:
-