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:22:24 UTC

[sling-org-apache-sling-jcr-resource] branch feature/more-adapter-metadata created (now 48b315c)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a change to branch feature/more-adapter-metadata
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git


      at 48b315c  SLING-11516 add metadata for adaptapte JcrResourceProvider and ResourceResolver (via delegation)

This branch includes the following new commits:

     new 48b315c  SLING-11516 add metadata for adaptapte JcrResourceProvider and ResourceResolver (via delegation)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-org-apache-sling-jcr-resource] 01/01: SLING-11516 add metadata for adaptapte JcrResourceProvider and ResourceResolver (via delegation)

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch feature/more-adapter-metadata
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git

commit 48b315ccf958a76d6d8b4aaa1a9375ceefe0e6d9
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Aug 8 10:22:18 2022 +0200

    SLING-11516 add metadata for adaptapte JcrResourceProvider and
    ResourceResolver (via delegation)
---
 .../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);