You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2022/08/08 08:36:28 UTC
[sling-org-apache-sling-jcr-resource] branch master updated: SLING-11516 add metadata for adaptable JcrResourceProvider and ResourceResolver (#34)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git
The following commit(s) were added to refs/heads/master by this push:
new 05e7c60 SLING-11516 add metadata for adaptable JcrResourceProvider and ResourceResolver (#34)
05e7c60 is described below
commit 05e7c605fbb453eb7f75a6f863ac36f3c281f9bf
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Aug 8 10:36:24 2022 +0200
SLING-11516 add metadata for adaptable JcrResourceProvider and ResourceResolver (#34)
The latter is provided via delegation from ResourceResolverImpl
---
.../jcr/resource/internal/helper/jcr/JcrResourceProvider.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
index 389baed..1022a7f 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
@@ -44,10 +44,13 @@ import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.api.JackrabbitSession;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.sling.adapter.annotations.Adaptable;
+import org.apache.sling.adapter.annotations.Adapter;
import org.apache.sling.api.SlingException;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.external.URIProvider;
@@ -79,6 +82,7 @@ import static org.apache.sling.jcr.resource.internal.helper.jcr.ContextUtil.getH
import static org.apache.sling.jcr.resource.internal.helper.jcr.ContextUtil.getResourceFactory;
import static org.apache.sling.jcr.resource.internal.helper.jcr.ContextUtil.getSession;
+@Adaptable(adaptableClass = ResourceProvider.class, adapters = { @Adapter(value=Session.class, condition="If the JcrResourceProvider is loaded"), @Adapter(value=Principal.class, condition="If the underlying java.jcr.Session implements JackrabbitSession") })
@Component(name="org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory",
service = ResourceProvider.class,
property = {
@@ -93,6 +97,11 @@ import static org.apache.sling.jcr.resource.internal.helper.jcr.ContextUtil.getS
})
public class JcrResourceProvider extends ResourceProvider<JcrProviderState> {
+ // due to https://issues.apache.org/jira/browse/SLING-11517 a dedicated class is necessary
+ @Adaptable(adaptableClass = ResourceResolver.class, adapters = { @Adapter(value=Session.class, condition="If the JcrResourceProvider is loaded"), @Adapter(value=Principal.class, condition="If the underlying java.jcr.Session implements JackrabbitSession") })
+ private static final class EmptyAdaptableAnnotationCarryingClass {
+ // just to carry the annotation
+ }
/** Logger */
private final Logger logger = LoggerFactory.getLogger(JcrResourceProvider.class);