Package io.wcm.sling.commons.caservice
Interface ContextAwareServiceResolver
-
@ProviderType public interface ContextAwareServiceResolverResolves the best-matching context-aware service implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceContextAwareServiceResolver.ResolveAllResult<T extends ContextAwareService>Result of theresolveAll(Class, Adaptable)method.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends ContextAwareService>
Tresolve(@NotNull java.lang.Class<T> serviceClass, @NotNull org.apache.sling.api.adapter.Adaptable adaptable)Resolves the best-matching service implementation for the given resource context.<T extends ContextAwareService>
@NotNull ContextAwareServiceResolver.ResolveAllResult<T>resolveAll(@NotNull java.lang.Class<T> serviceClass, @NotNull org.apache.sling.api.adapter.Adaptable adaptable)Resolves all matching service implementations for the given resource context.
-
-
-
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 inContextAwareService) 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 classadaptable- Adaptable which is either aResourceorSlingHttpServletRequest. 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 inContextAwareService) 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 classadaptable- Adaptable which is either aResourceorSlingHttpServletRequest. 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
-
-