jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r681132 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/ j...
Date Wed, 30 Jul 2008 17:23:48 GMT
Author: jukka
Date: Wed Jul 30 10:23:47 2008
New Revision: 681132

URL: http://svn.apache.org/viewvc?rev=681132&view=rev
Log:
JCR-1612: Reintroduce NamespaceStorage and namespace-caching

Continuing to simplify NamespaceRegistryImpl: No need for it to implement NamePathResolver.

Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/RegistryNamespaceResolver.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/DefaultNamePathResolver.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/lock/Locked.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java?rev=681132&r1=681131&r2=681132&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
Wed Jul 30 10:23:47 2008
@@ -21,7 +21,6 @@
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.util.StringIndex;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.util.XMLChar;
 import org.slf4j.Logger;
@@ -44,8 +43,7 @@
  * A <code>NamespaceRegistryImpl</code> ...
  */
 public class NamespaceRegistryImpl implements
-        NamespaceRegistry, NamespaceResolver,
-        NamespaceEventListener, StringIndex {
+        NamespaceRegistry, NamespaceEventListener, StringIndex {
 
     private static Logger log = LoggerFactory.getLogger(NamespaceRegistryImpl.class);
 
@@ -421,7 +419,7 @@
         return (String[]) uriToPrefix.keySet().toArray(new String[uriToPrefix.keySet().size()]);
     }
 
-    //--------------------------------< NamespaceRegistry & NamespaceResolver >
+    //---------------------------------------------------< NamespaceRegistry >
     /**
      * {@inheritDoc}
      */

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=681132&r1=681131&r2=681132&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Wed Jul 30 10:23:47 2008
@@ -67,6 +67,7 @@
 import org.apache.jackrabbit.core.version.VersionManagerImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.namespace.RegistryNamespaceResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.InputSource;
@@ -2149,8 +2150,8 @@
         /**
          * {@inheritDoc}
          */
-        public NamespaceResolver getNamespaceResovler() {
-            return getNamespaceRegistry();
+        public NamespaceResolver getNamespaceResolver() {
+            return new RegistryNamespaceResolver(getNamespaceRegistry());
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterContext.java?rev=681132&r1=681131&r2=681132&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterContext.java
Wed Jul 30 10:23:47 2008
@@ -38,7 +38,7 @@
      *
      * @return namespace resolver
      */
-    NamespaceResolver getNamespaceResovler();
+    NamespaceResolver getNamespaceResolver();
 
     /**
      * Notifies the cluster context that some workspace update events are available

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=681132&r1=681131&r2=681132&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
Wed Jul 30 10:23:47 2008
@@ -216,7 +216,7 @@
         try {
             JournalConfig jc = cc.getJournalConfig();
             journal = (Journal) jc.newInstance();
-            journal.init(clusterNodeId, clusterContext.getNamespaceResovler());
+            journal.init(clusterNodeId, clusterContext.getNamespaceResolver());
             instanceRevision = journal.getInstanceRevision();
             journal.register(this);
         } catch (ConfigurationException e) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/DefaultNamePathResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/DefaultNamePathResolver.java?rev=681132&r1=681131&r2=681132&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/DefaultNamePathResolver.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/DefaultNamePathResolver.java
Wed Jul 30 10:23:47 2008
@@ -16,30 +16,39 @@
  */
 package org.apache.jackrabbit.spi.commons.conversion;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Session;
+
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
-
-import javax.jcr.NamespaceException;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.namespace.RegistryNamespaceResolver;
+import org.apache.jackrabbit.spi.commons.namespace.SessionNamespaceResolver;
 
 /**
  * <code>DefaultNamePathResolver</code>...
  */
 public class DefaultNamePathResolver implements NamePathResolver {
 
-    private static Logger log = LoggerFactory.getLogger(DefaultNamePathResolver.class);
-
     private final NameResolver nResolver;
+
     private final PathResolver pResolver;
 
     public DefaultNamePathResolver(NamespaceResolver nsResolver) {
         this(nsResolver, false);
     }
 
+    public DefaultNamePathResolver(Session session) {
+        this(new SessionNamespaceResolver(session));
+    }
+
+    public DefaultNamePathResolver(NamespaceRegistry registry) {
+        this(new RegistryNamespaceResolver(registry));
+    }
+
     public DefaultNamePathResolver(NamespaceResolver nsResolver, boolean enableCaching) {
         NameResolver nr = new ParsingNameResolver(NameFactoryImpl.getInstance(), nsResolver);
         PathResolver pr = new ParsingPathResolver(PathFactoryImpl.getInstance(), nr);

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/lock/Locked.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/lock/Locked.java?rev=681132&r1=681131&r2=681132&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/lock/Locked.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/lock/Locked.java
Wed Jul 30 10:23:47 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.spi.commons.lock;
 
-import org.apache.jackrabbit.spi.commons.namespace.SessionNamespaceResolver;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
@@ -134,7 +133,7 @@
         }
 
         Session session = lockable.getSession();
-        NamePathResolver resolver = new DefaultNamePathResolver(new SessionNamespaceResolver(session));
+        NamePathResolver resolver = new DefaultNamePathResolver(session);
 
         Lock lock;
         EventListener listener = null;

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/RegistryNamespaceResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/RegistryNamespaceResolver.java?rev=681132&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/RegistryNamespaceResolver.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/RegistryNamespaceResolver.java
Wed Jul 30 10:23:47 2008
@@ -0,0 +1,66 @@
+/*
+ * 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.jackrabbit.spi.commons.namespace;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+
+/**
+ * Namespace resolver based on the repository-wide namespace mappings
+ * stored in a namespace registry.
+ */
+public class RegistryNamespaceResolver implements NamespaceResolver {
+
+    /**
+     * Namespace registry
+     */
+    private final NamespaceRegistry registry;
+
+    /**
+     * Creates a new namespace resolver based on the given namespace registry.
+     * 
+     * @param registry namespace registry
+     */
+    public RegistryNamespaceResolver(NamespaceRegistry registry) {
+        this.registry = registry;
+    }
+
+    public String getPrefix(String uri) throws NamespaceException {
+        try {
+            return registry.getPrefix(uri);
+        } catch (RepositoryException e) {
+            if (!(e instanceof NamespaceException)) {
+                e = new NamespaceException(
+                        "Failed to resolve namespace URI: " + uri, e);
+            }
+            throw (NamespaceException) e;
+        }
+    }
+
+    public String getURI(String prefix) throws NamespaceException {
+        try {
+            return registry.getURI(prefix);
+        } catch (RepositoryException e) {
+            if (!(e instanceof NamespaceException)) {
+                e = new NamespaceException(
+                        "Failed to resolve namespace prefix: " + prefix, e);
+            }
+            throw (NamespaceException) e;
+        }
+    }
+}



Mime
View raw message