Interface ContextAwareServiceResolver


  • @ProviderType
    public interface ContextAwareServiceResolver
    Resolves the best-matching context-aware service implementation.
    • Method Detail

      • resolve

        @Nullable
        <T extends ContextAwareService> T resolve​(@NotNull
                                                  @NotNull java.lang.Class<T> serviceClass,
                                                  @NotNull
                                                  @NotNull org.apache.sling.api.adapter.Adaptable adaptable)
        Resolves the best-matching service implementation for the given resource context. Only implementations which accept the given context resource path (via the service properties defined in ContextAwareService) are considered as candidates. If multiple candidates exist the implementation with the highest service ranking is returned.
        Type Parameters:
        T - Service interface or class
        Parameters:
        serviceClass - Service interface or class
        adaptable - Adaptable which is either a Resource or SlingHttpServletRequest. A resource instance is used directly for matching, in case of request the associated resource is used. May be null if no context is available.
        Returns:
        Service implementation or null if no match found.
      • resolveAll

        @NotNull
        <T extends ContextAwareService> @NotNull ContextAwareServiceResolver.ResolveAllResult<T> resolveAll​(@NotNull
                                                                                                            @NotNull java.lang.Class<T> serviceClass,
                                                                                                            @NotNull
                                                                                                            @NotNull org.apache.sling.api.adapter.Adaptable adaptable)
        Resolves all matching service implementations for the given resource context. Only implementations which accept the given context resource path (via the service properties defined in ContextAwareService) are considered as candidates. The candidates are returned ordered descending by their service ranking.
        Type Parameters:
        T - Service interface or class
        Parameters:
        serviceClass - Service interface or class
        adaptable - Adaptable which is either a Resource or SlingHttpServletRequest. A resource instance is used directly for matching, in case of request the associated resource is used. May be null if no context is available.
        Returns:
        Collection of all matching services