incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r889561 - in /sling/trunk/bundles/jcr/resource/src/main: java/org/apache/sling/jcr/resource/internal/ java/org/apache/sling/jcr/resource/internal/helper/ resources/OSGI-INF/metatype/
Date Fri, 11 Dec 2009 10:35:35 GMT
Author: fmeschbe
Date: Fri Dec 11 10:35:34 2009
New Revision: 889561

URL: http://svn.apache.org/viewvc?rev=889561&view=rev
Log:
SLING-1232 Make the location of the mapping configuration root configurable defaulting it
to /etc/map

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
    sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java?rev=889561&r1=889560&r2=889561&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
Fri Dec 11 10:35:34 2009
@@ -143,6 +143,11 @@
      */
     private static final String PROP_MAPPING = "resource.resolver.mapping";
 
+    /**
+     * @scr.property valueRef="MapEntries.DEFAULT_MAP_ROOT"
+     */
+    private static final String PROP_MAP_LOCATION = "resource.resolver.map.location";
+
     /** default log */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -193,6 +198,9 @@
     // the search path for ResourceResolver.getResource(String)
     private String[] searchPath;
 
+    // the root location of the /etc/map entries
+    private String mapRoot;
+
     private ResourceProviderEntry rootProviderEntry;
 
     // whether to mangle paths with namespaces or not
@@ -223,7 +231,7 @@
     public ResourceResolver getResourceResolver(Session session) {
         JcrResourceProviderEntry sessionRoot = new JcrResourceProviderEntry(
             session, rootProviderEntry, getJcrResourceTypeProviders(),
-            this.getDynamicClassLoader());        
+            this.getDynamicClassLoader());
 
         return new JcrResourceResolver(sessionRoot, this, mapEntries);
     }
@@ -277,6 +285,10 @@
 
     }
 
+    public String getMapRoot() {
+        return mapRoot;
+    }
+
     MapEntries getMapEntries() {
         return mapEntries;
     }
@@ -354,6 +366,10 @@
         mangleNamespacePrefixes = OsgiUtil.toBoolean(
             properties.get(PROP_MANGLE_NAMESPACES), false);
 
+        // the root of the resolver mappings
+        mapRoot = OsgiUtil.toString(properties.get(PROP_MAP_LOCATION),
+            MapEntries.DEFAULT_MAP_ROOT);
+
         // bind resource providers not bound yet
         for (ServiceReference reference : delayedResourceProviders) {
             bindResourceProvider(reference);
@@ -516,7 +532,7 @@
                if ( componentContext != null ) {
                 ResourceProvider provider = (ResourceProvider) componentContext.locateService(
                    "ResourceProvider", reference);
-                   
+
 
                 for (String root : roots) {
                     // cut off trailing slash
@@ -624,12 +640,12 @@
 
         return null;
     }
-    
-    
+
+
     public void run() {
         String stat = rootProviderEntry.getResolutionStats();
         if ( stat != null ) {
-            log.info(stat);   
+            log.info(stat);
         }
     }
 }

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java?rev=889561&r1=889560&r2=889561&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
Fri Dec 11 10:35:34 2009
@@ -51,11 +51,9 @@
 
     public static MapEntries EMPTY = new MapEntries();
 
-    private static final String ANY_SCHEME_HOST = "[^/]+/[^/]+";
-
-    private static final String MAP_ROOT = "/etc/map";
+    public static final String DEFAULT_MAP_ROOT = "/etc/map";
 
-    private static final String MAP_ROOT_PREFIX = MAP_ROOT + "/";
+    private static final String ANY_SCHEME_HOST = "[^/]+/[^/]+";
 
     /** default log */
     private final Logger log = LoggerFactory.getLogger(getClass());
@@ -66,6 +64,10 @@
 
     private Session session;
 
+    private final String mapRoot;
+
+    private final String mapRootPrefix;
+
     private List<MapEntry> resolveMaps;
 
     private Collection<MapEntry> mapMaps;
@@ -76,6 +78,8 @@
         session = null; // not needed
         factory = null;
         resolver = null;
+        mapRoot = DEFAULT_MAP_ROOT;
+        mapRootPrefix = mapRoot + "/";
 
         resolveMaps = Collections.<MapEntry> emptyList();
         mapMaps = Collections.<MapEntry> emptyList();
@@ -86,6 +90,8 @@
         this.factory = factory;
         this.session = repository.loginAdministrative(null);
         this.resolver = (JcrResourceResolver) factory.getResourceResolver(session);
+        this.mapRoot = factory.getMapRoot();
+        this.mapRootPrefix = this.mapRoot + "/";
 
         init();
 
@@ -200,8 +206,8 @@
             Event event = events.nextEvent();
             try {
                 String path = event.getPath();
-                handleEvent = MAP_ROOT.equals(path)
-                    || path.startsWith(MAP_ROOT_PREFIX)
+                handleEvent = mapRoot.equals(path)
+                    || path.startsWith(mapRootPrefix)
                     || path.endsWith("/sling:vanityPath")
                     || path.endsWith("/sling:vanityOrder")
                     || path.endsWith("/sling:redirect");
@@ -231,7 +237,7 @@
             Collection<MapEntry> resolveEntries,
             Map<String, MapEntry> mapEntries) {
         // the standard map configuration
-        Resource res = resolver.getResource(MAP_ROOT);
+        Resource res = resolver.getResource(mapRoot);
         if (res != null) {
             gather(resolver, resolveEntries, mapEntries, res, "");
         }

Modified: sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=889561&r1=889560&r2=889561&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties
Fri Dec 11 10:35:34 2009
@@ -29,6 +29,11 @@
 resource.resolver.description =  Configures the Resource Resolver for request \
  URL and resource path rewriting.
 
+resource.resolver.map.location.name = Mapping Location
+resource.resolver.map.location.description = The path to the root of the \
+ configuration to setup and configure the ResourceResolver mapping. The \
+ default value is /etc/map.
+
 resource.resolver.allowDirect.name = Allow Direct Mapping
 resource.resolver.allowDirect.description = Whether to add a direct URL \
  mapping to the front of the mapping list.



Mime
View raw message