jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r555290 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ nodetype/
Date Wed, 11 Jul 2007 14:45:04 GMT
Author: mreutegg
Date: Wed Jul 11 07:45:03 2007
New Revision: 555290

URL: http://svn.apache.org/viewvc?view=rev&rev=555290
Log:
JCR-1024: Only load root node definition when required

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?view=diff&rev=555290&r1=555289&r2=555290
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Wed Jul 11 07:45:03 2007
@@ -72,7 +72,6 @@
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.spi.LockInfo;
 import org.apache.jackrabbit.spi.QueryInfo;
-import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.Batch;
@@ -159,10 +158,9 @@
         this.cacheBehaviour = cacheBehaviour;
 
         nsRegistry = createNamespaceRegistry(NamespaceCache.getInstance(service));
-        QNodeDefinition rootNodeDef = service.getNodeDefinition(sessionInfo, service.getRootId(sessionInfo));
-        ntRegistry = createNodeTypeRegistry(rootNodeDef, nsRegistry);
+        ntRegistry = createNodeTypeRegistry(nsRegistry);
         changeFeed = createChangeFeed(pollTimeout, enableObservation);
-        definitionProvider = createDefinitionProvider(rootNodeDef, getEffectiveNodeTypeProvider());
+        definitionProvider = createDefinitionProvider(getEffectiveNodeTypeProvider());
 
         TransientItemStateFactory stateFactory = createItemStateFactory();
         this.isf = stateFactory;
@@ -380,11 +378,9 @@
     /**
      *
      * @param nsRegistry
-     * @param descriptors
      * @return
-     * @throws RepositoryException
      */
-    private NodeTypeRegistry createNodeTypeRegistry(QNodeDefinition rootNodeDef, NamespaceRegistry
nsRegistry) {
+    private NodeTypeRegistry createNodeTypeRegistry(NamespaceRegistry nsRegistry) {
         NodeTypeStorage ntst = new NodeTypeStorage() {
             public Iterator getAllDefinitions() throws RepositoryException {
                 return service.getQNodeTypeDefinitions(sessionInfo);
@@ -402,17 +398,16 @@
                 throw new UnsupportedOperationException("NodeType registration not yet defined
by the SPI");
             }
         };
-        return NodeTypeRegistryImpl.create(ntst, rootNodeDef, nsRegistry);
+        return NodeTypeRegistryImpl.create(ntst, nsRegistry);
     }
 
     /**
      *
-     * @param rootDefinition
      * @param entProvider
      * @return
      */
-    private ItemDefinitionProvider createDefinitionProvider(QNodeDefinition rootDefinition,
EffectiveNodeTypeProvider entProvider) {
-        return new ItemDefinitionProviderImpl(rootDefinition, entProvider, service, sessionInfo);
+    private ItemDefinitionProvider createDefinitionProvider(EffectiveNodeTypeProvider entProvider)
{
+        return new ItemDefinitionProviderImpl(entProvider, service, sessionInfo);
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java?view=diff&rev=555290&r1=555289&r2=555290
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java
Wed Jul 11 07:45:03 2007
@@ -31,7 +31,7 @@
  */
 public interface ItemDefinitionProvider {
 
-    public QNodeDefinition getRootNodeDefinition();
+    public QNodeDefinition getRootNodeDefinition() throws RepositoryException;
 
     public QNodeDefinition getQNodeDefinition(NodeState nodeState) throws RepositoryException;
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java?view=diff&rev=555290&r1=555289&r2=555290
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
Wed Jul 11 07:45:03 2007
@@ -32,9 +32,6 @@
 import javax.jcr.PropertyType;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.ConstraintViolationException;
-import java.util.List;
-import java.util.Collections;
-import java.util.ArrayList;
 
 /**
  * <code>ItemDefinitionManagerImpl</code>...
@@ -43,16 +40,14 @@
 
     private static Logger log = LoggerFactory.getLogger(ItemDefinitionProviderImpl.class);
 
-    private final QNodeDefinition rootNodeDefintion;
     private final EffectiveNodeTypeProvider entProvider;
     private final RepositoryService service;
     private final SessionInfo sessionInfo;
+    private QNodeDefinition rootNodeDefinition;
 
-    public ItemDefinitionProviderImpl(QNodeDefinition rootNodeDefintion, 
-                                      EffectiveNodeTypeProvider entProvider,
+    public ItemDefinitionProviderImpl(EffectiveNodeTypeProvider entProvider,
                                       RepositoryService service,
                                       SessionInfo sessionInfo) {
-        this.rootNodeDefintion = rootNodeDefintion;
         this.entProvider = entProvider;
         this.service = service;
         this.sessionInfo = sessionInfo;
@@ -61,14 +56,21 @@
     /**
      * @inheritDoc
      */
-    public QNodeDefinition getRootNodeDefinition() {
-        return rootNodeDefintion;
+    public QNodeDefinition getRootNodeDefinition() throws RepositoryException {
+        if (rootNodeDefinition == null) {
+            rootNodeDefinition = service.getNodeDefinition(
+                    sessionInfo, service.getRootId(sessionInfo));
+        }
+        return rootNodeDefinition;
     }
 
     /**
      * @inheritDoc
      */
     public QNodeDefinition getQNodeDefinition(NodeState nodeState) throws RepositoryException
{
+        if (nodeState.getHierarchyEntry().getParent() == null) {
+            return getRootNodeDefinition();
+        }
         QNodeDefinition definition;
         try {
             /*
@@ -235,42 +237,6 @@
         throw new ConstraintViolationException("no matching child node definition found for
" + name);
     }
 
-    /**
-     * Returns all applicable property definitions for a property with the
-     * specified name, type and multiValued characteristics.
-     *
-     * @param ent
-     * @param name
-     * @param type
-     * @param multiValued
-     * @return
-     * @throws ConstraintViolationException
-     */
-    private static QPropertyDefinition[] getQPropertyDefinitions(EffectiveNodeType ent,
-                                                                 QName name, int type,
-                                                                 boolean multiValued)
-            throws ConstraintViolationException {
-        QPropertyDefinition named[] = ent.getNamedQPropertyDefinitions(name);
-        QPropertyDefinition unnamed[] = ent.getUnnamedQPropertyDefinitions();
-        QPropertyDefinition all[] = new QPropertyDefinition[named.length + unnamed.length];
-        for (int i = 0; i < all.length; i++) {
-            if (i < named.length) {
-                all[i] = named[i];
-            }
-            else {
-                all[i] = unnamed[i - named.length];
-            }
-        }
-
-        QPropertyDefinition result[] = getMatchingPropDefs(all, type, multiValued);
-        if (result.length == 0) {
-            throw new ConstraintViolationException("no matching property definition found
for " + name);
-        }
-        else {
-            return result;
-        }
-    }
-
    /**
      *
      * @param ent
@@ -400,34 +366,5 @@
             }
         }
         return match;
-    }
-
-    private static QPropertyDefinition[] getMatchingPropDefs(QPropertyDefinition[] defs,
int type, boolean multiValued) {
-        List result = Collections.EMPTY_LIST;
-
-        for (int i = 0; i < defs.length; i++) {
-            QItemDefinition qDef = defs[i];
-            if (!qDef.definesNode()) {
-                QPropertyDefinition pd = (QPropertyDefinition)qDef;
-                int reqType = pd.getRequiredType();
-                // match type
-                if (reqType == PropertyType.UNDEFINED || type == PropertyType.UNDEFINED ||
reqType == type) {
-                    // match multiValued flag
-                    if (multiValued == pd.isMultiple()) {
-                        // found match
-                        if (result.isEmpty()) {
-                            result = Collections.singletonList(pd);
-                        }
-                        else {
-                            if (result.size() == 1) {
-                                result = new ArrayList(result);
-                            }
-                            result.add(pd);
-                        }
-                    }
-                }
-            }
-        }
-        return (QPropertyDefinition[])result.toArray(QPropertyDefinition.EMPTY_ARRAY);
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java?view=diff&rev=555290&r1=555289&r2=555290
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
Wed Jul 11 07:45:03 2007
@@ -96,10 +96,12 @@
     /**
      * Creates a new <code>NodeTypeManagerImpl</code> instance.
      *
-     * @param ntReg      node type registry
-     * @param nsResolver namespace resolver
+     * @param ntReg        node type registry
+     * @param mgrProvider  the manager provider
+     * @param valueFactory the JCR value factory
      */
-    public NodeTypeManagerImpl(NodeTypeRegistry ntReg, ManagerProvider mgrProvider,
+    public NodeTypeManagerImpl(NodeTypeRegistry ntReg,
+                               ManagerProvider mgrProvider,
                                ValueFactory valueFactory) {
         this.mgrProvider = mgrProvider;
         this.ntReg = ntReg;
@@ -110,19 +112,10 @@
         ntCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
         pdCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
         ndCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
-
-        // setup root definition and update cache
-        QNodeDefinition rootDef = defProvider().getRootNodeDefinition();
-        NodeDefinition rootNodeDefinition = new NodeDefinitionImpl(rootDef, this, nsResolver());
-        ndCache.put(rootDef, rootNodeDefinition);
     }
 
     private NamespaceResolver nsResolver() {
         return mgrProvider.getNamespaceResolver();
-    }
-
-    private ItemDefinitionProvider defProvider() {
-        return mgrProvider.getItemDefinitionProvider();
     }
 
     private EffectiveNodeTypeProvider entProvider() {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?view=diff&rev=555290&r1=555289&r2=555290
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
Wed Jul 11 07:45:03 2007
@@ -82,24 +82,22 @@
     /**
      * Create a new <code>NodeTypeRegistry</codes>
      *
-     * @param nodeTypeDefs
+     * @param storage
      * @param nsRegistry
      * @return <code>NodeTypeRegistry</codes> object
-     * @throws RepositoryException
      */
-    public static NodeTypeRegistryImpl create(NodeTypeStorage storage, QNodeDefinition rootNodeDef,
NamespaceRegistry nsRegistry) {
-        NodeTypeRegistryImpl ntRegistry = new NodeTypeRegistryImpl(storage, rootNodeDef,
nsRegistry);
+    public static NodeTypeRegistryImpl create(NodeTypeStorage storage, NamespaceRegistry
nsRegistry) {
+        NodeTypeRegistryImpl ntRegistry = new NodeTypeRegistryImpl(storage, nsRegistry);
         return ntRegistry;
     }
 
     /**
      * Private constructor
      *
-     * @param nodeTypeDefs
+     * @param storage
      * @param nsRegistry
-     * @throws RepositoryException
      */
-    private NodeTypeRegistryImpl(NodeTypeStorage storage, QNodeDefinition rootNodeDef, NamespaceRegistry
nsRegistry) {
+    private NodeTypeRegistryImpl(NodeTypeStorage storage, NamespaceRegistry nsRegistry) {
         this.storage = storage;
         this.validator = new DefinitionValidator(this, nsRegistry);
 
@@ -109,11 +107,6 @@
 
         propDefs = new HashSet();
         nodeDefs = new HashSet();
-
-        // setup definition of root node
-        synchronized (nodeDefs) {
-            nodeDefs.add(rootNodeDef);
-        }
     }
 
     //---------------------------------------------------< NodeTypeRegistry >---



Mime
View raw message