jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r655569 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: SessionImpl.java name/LocalNamespaceMappings.java
Date Mon, 12 May 2008 17:23:47 GMT
Author: jukka
Date: Mon May 12 10:23:47 2008
New Revision: 655569

URL: http://svn.apache.org/viewvc?rev=655569&view=rev
Log:
JCR-1564: JSR 283 namespace handling
    - Use AbstractSession for namespace handling in jcr2spi
    - LocalNamespaceMappings is no longer needed

Removed:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/LocalNamespaceMappings.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=655569&r1=655568&r2=655569&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Mon May 12 10:23:47 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
+import org.apache.jackrabbit.commons.AbstractSession;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
@@ -38,7 +39,6 @@
 import org.apache.jackrabbit.jcr2spi.version.VersionManager;
 import org.apache.jackrabbit.jcr2spi.operation.Move;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
-import org.apache.jackrabbit.jcr2spi.name.LocalNamespaceMappings;
 import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
 import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
@@ -104,7 +104,8 @@
 /**
  * <code>SessionImpl</code>...
  */
-public class SessionImpl implements Session, ManagerProvider {
+public class SessionImpl extends AbstractSession
+        implements NamespaceResolver, ManagerProvider {
 
     private static Logger log = LoggerFactory.getLogger(SessionImpl.class);
 
@@ -121,8 +122,7 @@
 
     private final SessionInfo sessionInfo;
 
-    private final LocalNamespaceMappings nsMappings;
-    private final NamePathResolver npResolver;
+    private NamePathResolver npResolver;
     private final NodeTypeManagerImpl ntManager;
 
     private final ValueFactory valueFactory;
@@ -142,8 +142,7 @@
         workspace = createWorkspaceInstance(config, sessionInfo);
 
         // build local name-mapping
-        nsMappings = new LocalNamespaceMappings(workspace.getNamespaceRegistryImpl());
-        npResolver = new DefaultNamePathResolver(nsMappings, true);
+        npResolver = new DefaultNamePathResolver(this, true);
 
         // build ValueFactory
         valueFactory = new ValueFactoryQImpl(config.getRepositoryService().getQValueFactory(),
npResolver);
@@ -491,34 +490,12 @@
 
     /**
      * @see javax.jcr.Session#setNamespacePrefix(String, String)
-     * @see LocalNamespaceMappings#setNamespacePrefix(String, String)
      */
-    public void setNamespacePrefix(String prefix, String uri) throws NamespaceException,
RepositoryException {
-        nsMappings.setNamespacePrefix(prefix, uri);
-    }
-
-    /**
-     * @see javax.jcr.Session#getNamespacePrefixes()
-     * @see LocalNamespaceMappings#getPrefixes()
-     */
-    public String[] getNamespacePrefixes() throws RepositoryException {
-        return nsMappings.getPrefixes();
-    }
-
-    /**
-     * @see javax.jcr.Session#getNamespaceURI(String)
-     * @see NamespaceResolver#getURI(String)
-     */
-    public String getNamespaceURI(String prefix) throws NamespaceException, RepositoryException
{
-        return nsMappings.getURI(prefix);
-    }
-
-    /**
-     * @see javax.jcr.Session#getNamespacePrefix(String)
-     * @see NamespaceResolver#getPrefix(String)
-     */
-    public String getNamespacePrefix(String uri) throws NamespaceException, RepositoryException
{
-        return nsMappings.getPrefix(uri);
+    public void setNamespacePrefix(String prefix, String uri)
+            throws RepositoryException {
+        super.setNamespacePrefix(prefix, uri);
+        // Reset name and path caches
+        npResolver = new DefaultNamePathResolver(this, true);
     }
 
     /**
@@ -533,8 +510,6 @@
         // notify listeners that session is about to be closed
         notifyLoggingOut();
 
-        // dispose name nsResolver
-        nsMappings.dispose();
         // dispose session item state manager
         itemStateManager.dispose();
         // dispose item manager
@@ -584,6 +559,28 @@
         }
     }
 
+    //-------------------------------------------------< NamespaceResolver >--
+
+    public String getPrefix(String uri) throws NamespaceException {
+        try {
+            return getNamespacePrefix(uri);
+        } catch (NamespaceException e) {
+            throw e;
+        } catch (RepositoryException e) {
+            throw new NamespaceException("Namespace not found: " + uri, e);
+        }
+    }
+
+    public String getURI(String prefix) throws NamespaceException {
+        try {
+            return getNamespaceURI(prefix);
+        } catch (NamespaceException e) {
+            throw e;
+        } catch (RepositoryException e) {
+            throw new NamespaceException("Namespace not found: " + prefix, e);
+        }
+    }
+
     //--------------------------------------< register and inform listeners >---
     /**
      * Add a <code>SessionListener</code>
@@ -670,7 +667,7 @@
      * @see ManagerProvider#getNamespaceResolver()
      */
     public NamespaceResolver getNamespaceResolver() {
-        return nsMappings;
+        return this;
     }
 
     /**
@@ -731,10 +728,6 @@
 
     //--------------------------------------------------------------------------
 
-    LocalNamespaceMappings getLocalNamespaceMappings() {
-        return nsMappings;
-    }
-
     ItemManager getItemManager() {
         return itemManager;
     }



Mime
View raw message