jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1461231 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/
Date Tue, 26 Mar 2013 17:17:36 GMT
Author: mduerig
Date: Tue Mar 26 17:17:36 2013
New Revision: 1461231

URL: http://svn.apache.org/r1461231
Log:
OAK-702: Optimize access to node type information  Use Trees instead of Nodes when accessing
node definitions

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java?rev=1461231&r1=1461230&r2=1461231&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/DefinitionProvider.java
Tue Mar 26 17:17:36 2013
@@ -17,8 +17,6 @@
 package org.apache.jackrabbit.oak.plugins.nodetype;
 
 import javax.annotation.Nonnull;
-import javax.jcr.Node;
-import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NodeDefinition;
@@ -41,7 +39,6 @@ public interface DefinitionProvider {
      * child node definitions of {@code parent} are checked matching the
      * given node name. Then the residual definitions are checked.
      *
-     *
      * @param parent   the parent node.
      * @param nodeName The internal oak name of the child node.
      * @return the applicable node definition.
@@ -49,7 +46,7 @@ public interface DefinitionProvider {
      * @throws RepositoryException If another error occurs.
      */
     @Nonnull
-    NodeDefinition getDefinition(@Nonnull Node parent, @Nonnull String nodeName)
+    NodeDefinition getDefinition(@Nonnull Tree parent, @Nonnull String nodeName)
             throws ConstraintViolationException, RepositoryException;
 
     /**
@@ -67,20 +64,6 @@ public interface DefinitionProvider {
             throws ConstraintViolationException, RepositoryException;
 
     /**
-     * Calculates the definition of the specified property.
-     *
-     * @param parent The parent node.
-     * @param targetProperty The target property.
-     * @return The definition of the specified property.
-     * @throws ConstraintViolationException If no matching definition can be
-     * found.
-     * @throws RepositoryException If another error occurs.
-     */
-    @Nonnull
-    PropertyDefinition getDefinition(Node parent, Property targetProperty)
-            throws ConstraintViolationException, RepositoryException;
-
-    /**
      * Calculates the applicable definition for the property state under the
      * given parent tree.
      *
@@ -93,6 +76,6 @@ public interface DefinitionProvider {
     @Nonnull
     PropertyDefinition getDefinition(
             Tree parent, PropertyState propertyState, boolean exactTypeMatch)
-            throws ConstraintViolationException,RepositoryException;
+            throws ConstraintViolationException, RepositoryException;
 
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java?rev=1461231&r1=1461230&r2=1461231&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java
Tue Mar 26 17:17:36 2013
@@ -16,6 +16,13 @@
  */
 package org.apache.jackrabbit.oak.plugins.nodetype;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
+import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.NODE_TYPES_PATH;
+
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
@@ -23,10 +30,8 @@ import java.util.Set;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.Node;
-import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
@@ -41,7 +46,6 @@ import javax.jcr.nodetype.PropertyDefini
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
 import org.apache.jackrabbit.oak.api.PropertyState;
@@ -54,14 +58,6 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.jcr.PropertyType.UNDEFINED;
-import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
-import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
-import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.NODE_TYPES_PATH;
-
 /**
  * Base implementation of a {@link NodeTypeManager} with support for reading
  * node types from the {@link Tree} returned by {@link #getTypes()}. Methods
@@ -354,7 +350,6 @@ public abstract class ReadOnlyNodeTypeMa
 
     @Override
     public EffectiveNodeType getEffectiveNodeType(Tree tree) throws RepositoryException {
-
         NodeTypeImpl primaryType;
         PropertyState jcrPrimaryType = tree.getProperty(JCR_PRIMARYTYPE);
         if (jcrPrimaryType != null) {
@@ -385,7 +380,7 @@ public abstract class ReadOnlyNodeTypeMa
 
     @Nonnull
     @Override
-    public NodeDefinition getDefinition(@Nonnull Node parent, @Nonnull String nodeName)
+    public NodeDefinition getDefinition(@Nonnull Tree parent, @Nonnull String nodeName)
             throws RepositoryException {
         checkNotNull(parent);
         checkNotNull(nodeName);
@@ -405,24 +400,6 @@ public abstract class ReadOnlyNodeTypeMa
         return eff.getNodeDefinition(name, getEffectiveNodeType(targetNode));
     }
 
-    @Override
-    public PropertyDefinition getDefinition(Node parent, Property targetProperty) throws
RepositoryException {
-        String name = targetProperty.getName();
-        boolean isMultiple = targetProperty.isMultiple();
-        int type = UNDEFINED;
-        if (isMultiple) {
-            Value[] values = targetProperty.getValues();
-            if (values.length > 0) {
-                type = values[0].getType();
-            }
-        } else {
-            type = targetProperty.getValue().getType();
-        }
-
-        EffectiveNodeType effective = getEffectiveNodeType(parent);
-        return effective.getPropertyDefinition(name, isMultiple, type, true);
-    }
-
     @Nonnull
     @Override
     public PropertyDefinition getDefinition(

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1461231&r1=1461230&r2=1461231&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Tue Mar 26 17:17:36 2013
@@ -242,7 +242,7 @@ public class NodeImpl<T extends NodeDele
                 if (ntName == null) {
                     DefinitionProvider dp = getDefinitionProvider();
                     String childName = getOakName(PathUtils.getName(relPath));
-                    NodeDefinition def = dp.getDefinition(new NodeImpl<NodeDelegate>(parent,
sessionContext), childName);
+                    NodeDefinition def = dp.getDefinition(parent.getTree(), childName);
                     ntName = def.getDefaultPrimaryTypeName();
                     if (ntName == null) {
                         throw new ConstraintViolationException(

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1461231&r1=1461230&r2=1461231&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Tue Mar 26 17:17:36 2013
@@ -532,7 +532,8 @@ public class PropertyImpl extends ItemIm
         return perform(new ItemReadOperation<PropertyDefinition>() {
             @Override
             protected PropertyDefinition perform() throws RepositoryException {
-                return getDefinitionProvider().getDefinition(getParent(), PropertyImpl.this);
+                return getDefinitionProvider().getDefinition(
+                        dlg.getParent().getTree(), dlg.getPropertyState(), true);
             }
         });
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java?rev=1461231&r1=1461230&r2=1461231&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PropertyDelegate.java
Tue Mar 26 17:17:36 2013
@@ -37,7 +37,7 @@ public class PropertyDelegate extends It
     }
 
     @Nonnull
-    private PropertyState getPropertyState() throws InvalidItemStateException {
+    public PropertyState getPropertyState() throws InvalidItemStateException {
         PropertyState p = getLocation().getProperty();
         if (p == null) {
             throw new InvalidItemStateException();



Mime
View raw message