You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:59:54 UTC

[sling-org-apache-sling-resourceresolver] 24/47: SLING-2583 - introducing MapConfigurationProvider interface

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

rombert pushed a commit to annotated tag org.apache.sling.resourceresolver-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git

commit 1edd269b80536c81001255efcf8a374bdaf7b4e1
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Aug 28 18:34:48 2012 +0000

    SLING-2583 - introducing MapConfigurationProvider interface
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/resourceresolver@1378260 13f79535-47bb-0310-9956-ffa450edef68
---
 .../impl/ResourceResolverFactoryImpl.java          |  3 +-
 .../impl/mapping/MapConfigurationProvider.java     | 38 ++++++++++++++++++++++
 .../resourceresolver/impl/mapping/MapEntries.java  | 16 ++++-----
 3 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
index d5237e7..5565d72 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
@@ -27,6 +27,7 @@ import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.resourceresolver.impl.console.ResourceResolverWebConsolePlugin;
 import org.apache.sling.resourceresolver.impl.helper.ResourceDecoratorTracker;
 import org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext;
+import org.apache.sling.resourceresolver.impl.mapping.MapConfigurationProvider;
 import org.apache.sling.resourceresolver.impl.mapping.MapEntries;
 import org.apache.sling.resourceresolver.impl.mapping.Mapping;
 import org.apache.sling.resourceresolver.impl.tree.RootResourceProviderEntry;
@@ -44,7 +45,7 @@ import org.slf4j.LoggerFactory;
  * </ul>
  *
  */
-public class ResourceResolverFactoryImpl implements ResourceResolverFactory {
+public class ResourceResolverFactoryImpl implements ResourceResolverFactory, MapConfigurationProvider {
 
     /** Helper for the resource resolver. */
     private MapEntries mapEntries = MapEntries.EMPTY;
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java
new file mode 100644
index 0000000..28767e2
--- /dev/null
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java
@@ -0,0 +1,38 @@
+/*
+ * 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.resourceresolver.impl.mapping;
+
+import java.util.Map;
+
+import org.apache.sling.api.resource.ResourceResolverFactory;
+
+/**
+ * Internal interface representing the additional methods
+ * MapEntries needs from the ResourceResolverFactory.
+ * 
+ * Exists primarily to facilitate mocking of the ResourceResolverFactory
+ * when testing MapEntries.
+ */
+public interface MapConfigurationProvider extends ResourceResolverFactory {
+
+    String getMapRoot();
+
+    Map<?, ?> getVirtualURLMap();
+
+    Mapping[] getMappings();
+
+}
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
index dfe3c4b..29d9169 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
@@ -84,7 +84,7 @@ public class MapEntries implements EventHandler {
     /** default log */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private ResourceResolverFactoryImpl factory;
+    private MapConfigurationProvider factory;
 
     private volatile ResourceResolver resolver;
 
@@ -118,7 +118,7 @@ public class MapEntries implements EventHandler {
     }
 
     @SuppressWarnings("unchecked")
-    public MapEntries(final ResourceResolverFactoryImpl factory, final BundleContext bundleContext, final EventAdmin eventAdmin)
+    public MapEntries(final MapConfigurationProvider factory, final BundleContext bundleContext, final EventAdmin eventAdmin)
                     throws LoginException {
         this.resolver = factory.getAdministrativeResourceResolver(null);
         this.factory = factory;
@@ -162,7 +162,7 @@ public class MapEntries implements EventHandler {
      * to trigger a call to doInit. Terminates when the resolver has been
      * null-ed after having been triggered.
      */
-    void init() {
+    private void init() {
         while (this.resolver != null) {
             try {
                 this.initTrigger.acquire();
@@ -175,16 +175,16 @@ public class MapEntries implements EventHandler {
     }
 
     /**
-     * Actual initializer. Guards itself agains concurrent use by using a
+     * Actual initializer. Guards itself against concurrent use by using a
      * ReentrantLock. Does nothing if the resource resolver has already been
      * null-ed.
      */
-    private void doInit() {
+    protected void doInit() {
 
         this.initializing.lock();
         try {
             final ResourceResolver resolver = this.resolver;
-            final ResourceResolverFactoryImpl factory = this.factory;
+            final MapConfigurationProvider factory = this.factory;
             if (resolver == null || factory == null) {
                 return;
             }
@@ -551,7 +551,7 @@ public class MapEntries implements EventHandler {
         return result;
     }
 
-    private void loadConfiguration(final ResourceResolverFactoryImpl factory, final List<MapEntry> entries) {
+    private void loadConfiguration(final MapConfigurationProvider factory, final List<MapEntry> entries) {
         // virtual uris
         final Map<?, ?> virtuals = factory.getVirtualURLMap();
         if (virtuals != null) {
@@ -592,7 +592,7 @@ public class MapEntries implements EventHandler {
         }
     }
 
-    private void loadMapConfiguration(final ResourceResolverFactoryImpl factory, final Map<String, MapEntry> entries) {
+    private void loadMapConfiguration(final MapConfigurationProvider factory, final Map<String, MapEntry> entries) {
         // URL Mappings
         final Mapping[] mappings = factory.getMappings();
         if (mappings != null) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.