You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2008/05/12 19:32:25 UTC

svn commit: r655573 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: WorkspaceManager.java name/NamespaceCache.java name/NamespaceRegistryImpl.java

Author: jukka
Date: Mon May 12 10:32:25 2008
New Revision: 655573

URL: http://svn.apache.org/viewvc?rev=655573&view=rev
Log:
JCR-1564: JSR 283 namespace handling
    - Removed caching and listening of namespace registry in jcr2spi
      as AbstractSession already caches namespaces and JSR 283 removes
      the need to notify sessions about global namespace remappings

Removed:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceCache.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=655573&r1=655572&r2=655573&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java Mon May 12 10:32:25 2008
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeCache;
 import org.apache.jackrabbit.jcr2spi.name.NamespaceStorage;
 import org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryImpl;
-import org.apache.jackrabbit.jcr2spi.name.NamespaceCache;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.ChangeLog;
 import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager;
@@ -173,7 +172,7 @@
         this.pathFactory = service.getPathFactory();
 
         idFactory = service.getIdFactory();
-        nsRegistry = createNamespaceRegistry(NamespaceCache.getInstance(service));
+        nsRegistry = new NamespaceRegistryImpl(this);
         ntRegistry = createNodeTypeRegistry(nsRegistry);
         changeFeed = createChangeFeed(pollTimeout, enableObservation);
         definitionProvider = createDefinitionProvider(getEffectiveNodeTypeProvider());
@@ -434,15 +433,6 @@
 
     /**
      *
-     * @param nsCache the namespace cache.
-     * @return
-     */
-    private NamespaceRegistryImpl createNamespaceRegistry(NamespaceCache nsCache) throws RepositoryException {
-        return new NamespaceRegistryImpl(this, nsCache);
-    }
-
-    /**
-     *
      * @param nsRegistry
      * @return
      */

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java?rev=655573&r1=655572&r2=655573&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java Mon May 12 10:32:25 2008
@@ -16,8 +16,8 @@
  */
 package org.apache.jackrabbit.jcr2spi.name;
 
-import org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceListener;
+import java.util.Collection;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -30,56 +30,51 @@
  * <code>NamespaceRegistryImpl</code> implements the JCR client facing
  * NamespaceRegistry.
  */
-public class NamespaceRegistryImpl extends AbstractNamespaceResolver
-    implements NamespaceRegistry {
+public class NamespaceRegistryImpl implements NamespaceRegistry {
 
     private static Logger log = LoggerFactory.getLogger(NamespaceRegistryImpl.class);
 
     private final NamespaceStorage storage;
-    private final NamespaceCache nsCache;
 
     /**
      * Create a new <code>NamespaceRegistryImpl</code>.
      *
      * @param storage
-     * @param nsCache
      */
-    public NamespaceRegistryImpl(NamespaceStorage storage,
-                                 NamespaceCache nsCache) {
-        // listener support in AbstractNamespaceResolver is not needed
-        // because we delegate listeners to NamespaceCache
-        super(false);
+    public NamespaceRegistryImpl(NamespaceStorage storage) {
         this.storage = storage;
-        this.nsCache = nsCache;
     }
 
     //--------------------------------------------------< NamespaceRegistry >---
+
     /**
      * @see NamespaceRegistry#registerNamespace(String, String)
      */
     public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException {
-        nsCache.registerNamespace(storage, prefix, uri);
+        storage.registerNamespace(prefix, uri);
     }
 
     /**
      * @see NamespaceRegistry#unregisterNamespace(String)
      */
     public void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException {
-        nsCache.unregisterNamespace(storage, prefix);
+        storage.unregisterNamespace(prefix);
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getPrefixes()
      */
     public String[] getPrefixes() throws RepositoryException {
-        return nsCache.getPrefixes(storage);
+        Collection prefixes = storage.getRegisteredNamespaces().keySet();
+        return (String[]) prefixes.toArray(new String[prefixes.size()]);
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getURIs()
      */
     public String[] getURIs() throws RepositoryException {
-        return nsCache.getURIs(storage);
+        Collection uris = storage.getRegisteredNamespaces().values();
+        return (String[]) uris.toArray(new String[uris.size()]);
     }
 
     /**
@@ -89,7 +84,7 @@
     public String getURI(String prefix) throws NamespaceException {
         // try to load the uri
         try {
-            return nsCache.getURI(storage, prefix);
+            return storage.getURI(prefix);
         } catch (RepositoryException ex) {
             log.debug("Internal error while loading registered namespaces.");
             throw new NamespaceException(prefix + ": is not a registered namespace prefix.");
@@ -103,28 +98,11 @@
     public String getPrefix(String uri) throws NamespaceException {
         // try to load the prefix
         try {
-            return nsCache.getPrefix(storage, uri);
+            return storage.getPrefix(uri);
         } catch (RepositoryException ex) {
             log.debug("Internal error while loading registered namespaces.");
             throw new NamespaceException(uri + ": is not a registered namespace uri.");
         }
     }
 
-    //-----------------------< AbstractNamespaceResolver >----------------------
-
-    /**
-     * Unregister on <code>NamespaceCache</code>.
-     * @param listener the namespace listener.
-     */
-    public void removeListener(NamespaceListener listener) {
-        nsCache.removeListener(listener);
-    }
-
-    /**
-     * Register on <code>NamespaceCache</code>.
-     * @param listener the namespace listener.
-     */
-    public void addListener(NamespaceListener listener) {
-        nsCache.addListener(listener);
-    }
 }



Discussions regarding svn commit: r655573, r655574 -> summary for the record

Posted by Angela Schreiber <an...@day.com>.
just for the record:

jukka, marcel and myself discussed the 2 threads yesterday
in basel and reached consensus as follows:

- keep a namespace caching in jcr2spi but replace the
   NamespaceCache by a simple map, that gets cleared
   if necessary.
- make jcr2spi and core use the same NamespaceRegistry
   with different storage impls.
- reintroduce the NamespaceStorage
- we didn't decide in which project the latter is going
   to live. spi-commons was one possibility discussed.
- jukka volunteered to provide a patch to have something
   concrete to look at.

regards
angela

Re: svn commit: r655573 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: WorkspaceManager.java name/NamespaceCache.java name/NamespaceRegistryImpl.java

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Tue, May 13, 2008 at 1:07 PM, Marcel Reutegger
<ma...@gmx.net> wrote:
> please note that NamespaceCache is not about caching namespace mappings in
> a session, but caching the mapping on a repository service level.
>
>  see: https://issues.apache.org/jira/browse/JCR-1020
>
> it was an attempt to reduce the cost of creating a session and to reduce
> the amount of redundant information that is transfered to a client.

Shouldn't that be a concern of a remoting layer instead of jcr2spi?

BR,

Jukka Zitting

Re: svn commit: r655573 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: WorkspaceManager.java name/NamespaceCache.java name/NamespaceRegistryImpl.java

Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Jukka,

please note that NamespaceCache is not about caching namespace mappings in a 
session, but caching the mapping on a repository service level.

see: https://issues.apache.org/jira/browse/JCR-1020

it was an attempt to reduce the cost of creating a session and to reduce the 
amount of redundant information that is transfered to a client.

regards
  marcel

jukka@apache.org wrote:
> Author: jukka
> Date: Mon May 12 10:32:25 2008
> New Revision: 655573
> 
> URL: http://svn.apache.org/viewvc?rev=655573&view=rev
> Log:
> JCR-1564: JSR 283 namespace handling
>     - Removed caching and listening of namespace registry in jcr2spi
>       as AbstractSession already caches namespaces and JSR 283 removes
>       the need to notify sessions about global namespace remappings
> 
> Removed:
>     jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceCache.java
> Modified:
>     jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
>     jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java