You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2019/12/09 08:28:27 UTC

[GitHub] [sling-org-apache-sling-caconfig-spi] henrykuijpers commented on a change in pull request #1: Added a ConfigurationBindingsResourceDetectionStrategy that can be used to detect a Resource based on the provided bindings

henrykuijpers commented on a change in pull request #1: Added a ConfigurationBindingsResourceDetectionStrategy that can be used to detect a Resource based on the provided bindings
URL: https://github.com/apache/sling-org-apache-sling-caconfig-spi/pull/1#discussion_r355313665
 
 

 ##########
 File path: src/main/java/org/apache/sling/caconfig/resource/spi/ConfigurationBindingsResourceDetectionStrategy.java
 ##########
 @@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.caconfig.resource.spi;
+
+import org.apache.sling.api.resource.Resource;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.osgi.annotation.versioning.ConsumerType;
+
+import javax.script.Bindings;
+
+@ConsumerType
+public interface ConfigurationBindingsResourceDetectionStrategy {
+    /**
+     * Detects the resource by looking at the available bindings.
+     * @param bindings Bindings object to use for detecting the correct Resource.
+     * @return Detected Resource or {@code null} if this strategy did not detect an applicable resource.
+     */
+    @Nullable Resource detectResource(@NotNull Bindings bindings);
 
 Review comment:
   Hi @stefanseifert , in our case we're trying to solve another issue here as well: In an AEM context, it could be that the resource on the current request (or request.getResource(), if that's passed in this method), points to a node in /conf. 
   
   We're using the Bindings to obtain the current page, so that it will always point to /content (and never to /conf). 
   
   See also the other PR in the wcm.io extensions project. 
   
   Any suggestion on how to tackle this problem?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services