jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1153452 - in /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel: RepositoryServiceImpl.java util/Paths.java
Date Wed, 03 Aug 2011 11:50:56 GMT
Author: mduerig
Date: Wed Aug  3 11:50:55 2011
New Revision: 1153452

URL: http://svn.apache.org/viewvc?rev=1153452&view=rev
Log:
spi2microkernel (WIP)
- better namespace compression

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1153452&r1=1153451&r2=1153452&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Wed Aug  3 11:50:55 2011
@@ -76,6 +76,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
@@ -139,6 +140,10 @@ public class RepositoryServiceImpl exten
 
             nodeTypeStore = NodeTypeStore.create(microKernel, systemWorkspace);
             nodeTypeStore.read(namespaces, nodeTypeDefs);
+
+            for (Entry<String, String> entry : namespaces.getPrefixToURIMapping().entrySet())
{
+                Paths.addKnownNamespace(entry.getKey(), entry.getValue());
+            }
         }
         catch (MicroKernelException e) {
             throw new RepositoryException(e.getMessage(), e);
@@ -396,6 +401,7 @@ public class RepositoryServiceImpl exten
 
     @Override
     public void registerNamespace(SessionInfo sessionInfo, String prefix, String uri) throws
RepositoryException {
+        Paths.addKnownNamespace(prefix, uri);
         namespaces.setMapping(prefix, uri);
         nodeTypeStore.write(namespaces, nodeTypeDefs);
     }

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java?rev=1153452&r1=1153451&r2=1153452&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Paths.java
Wed Aug  3 11:50:55 2011
@@ -19,8 +19,6 @@
 
 package org.apache.jackrabbit.spi2microkernel.util;
 
-import org.apache.commons.collections.BidiMap;
-import org.apache.commons.collections.bidimap.DualHashBidiMap;
 import org.apache.jackrabbit.mk.util.PathUtils;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NameFactory;
@@ -32,12 +30,16 @@ import org.apache.jackrabbit.spi.commons
 
 import javax.jcr.RepositoryException;
 import java.util.LinkedList;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import static org.apache.jackrabbit.spi.Name.NS_DEFAULT_URI;
 
 public final class Paths {
     private static final NameFactory NAME_FACTORY = NameFactoryImpl.getInstance();
     private static final PathFactory PATH_FACTORY = PathFactoryImpl.getInstance();
+    private static final ConcurrentMap<String, String> KNOWN_NAME_SPACES = new ConcurrentHashMap<String,
String>();
+    private static final ConcurrentMap<String, String> KNOWN_PREFIXES = new ConcurrentHashMap<String,
String>();
 
     private Paths() {}
 
@@ -96,26 +98,22 @@ public final class Paths {
             : wspPath + translateQPath(absPath);
     }
 
-    //------------------------------------------< private >---
+    public static void addKnownNamespace(String prefix, String uri) {
+        KNOWN_NAME_SPACES.putIfAbsent(prefix, uri);
+        KNOWN_PREFIXES.putIfAbsent(uri, prefix);
+    }
 
-    private static final BidiMap KNOWN_NAME_SPACES = new DualHashBidiMap() {{
-        put("jcr", "http://www.jcp.org/jcr/1.0");
-        put("xs", "http://www.w3.org/2001/XMLSchema");
-        put("nt", "http://www.jcp.org/jcr/nt/1.0");
-        put("mix", "http://www.jcp.org/jcr/mix/1.0");
-        put("sv", "http://www.jcp.org/jcr/sv/1.0");
-        put("xml", "http://www.w3.org/XML/1998/namespace");
-    }};
+    //------------------------------------------< private >---
 
     private static String escapeNameSpaceURI(String nameSpaceURI) {
-        String prefix = (String) KNOWN_NAME_SPACES.getKey(nameSpaceURI);
+        String prefix = KNOWN_PREFIXES.get(nameSpaceURI);
         return prefix == null
             ? nameSpaceURI.replace('/', '\\')
             : prefix;
     }
 
     private static String unescapeNameSpaceURI(String nameSpaceURI) {
-        String nsUri = (String) KNOWN_NAME_SPACES.get(nameSpaceURI);
+        String nsUri = KNOWN_NAME_SPACES.get(nameSpaceURI);
         return nsUri == null
             ? nameSpaceURI.replace('\\', '/')
             : nsUri;



Mime
View raw message