jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1461058 - 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/
Date Tue, 26 Mar 2013 10:56:06 GMT
Author: jukka
Date: Tue Mar 26 10:56:06 2013
New Revision: 1461058

URL: http://svn.apache.org/r1461058
Log:
OAK-702: Optimize access to node type information

Use the internal Tree insteance instead of NodeImpl for the
getDefinition() call in internalSetProperty(). Avoid the extra
check on whether a property already exists (see also JCR-3543).

Remove the now unused DefinitionProvider method signature.
Also remove the OAK-652 feature flag as we're getting closer to
resolving the issue.

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/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.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=1461058&r1=1461057&r2=1461058&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 10:56:06 2013
@@ -96,26 +96,6 @@ public interface DefinitionProvider {
 
     /**
      * Calculates the applicable definition for the property with the specified
-     * characteristics under the given parent node.
-     *
-     * @param parent The parent node.
-     * @param propertyName The internal oak name of the property for which the
-     * definition should be retrieved.
-     * @param isMultiple {@code true} if the target property is multi-valued.
-     * @param type The target type of the property.
-     * @param exactTypeMatch {@code true} if the required type of the definition
-     * must exactly match the type of the target property.
-     * @return the applicable definition for the target property.
-     * @throws ConstraintViolationException If no matching definition can be found.
-     * @throws RepositoryException If another error occurs.
-     */
-    @Nonnull
-    PropertyDefinition getDefinition(Node parent, String propertyName,
-                                     boolean isMultiple, int type, boolean exactTypeMatch)
-            throws ConstraintViolationException, RepositoryException;
-
-    /**
-     * Calculates the applicable definition for the property with the specified
      * characteristics under the given parent tree.
      *
      * @param parent The parent tree.

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=1461058&r1=1461057&r2=1461058&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 10:56:06 2013
@@ -430,13 +430,6 @@ public abstract class ReadOnlyNodeTypeMa
 
     @Nonnull
     @Override
-    public PropertyDefinition getDefinition(Node parent, String propertyName, boolean isMultiple,
int type, boolean exactTypeMatch) throws RepositoryException {
-        EffectiveNodeType effective = getEffectiveNodeType(parent);
-        return effective.getPropertyDefinition(propertyName, isMultiple, type, exactTypeMatch);
-    }
-
-    @Nonnull
-    @Override
     public PropertyDefinition getDefinition(Tree parent, String propertyName, boolean isMultiple,
int type, boolean exactTypeMatch) throws RepositoryException {
         EffectiveNodeType effective = getEffectiveNodeType(parent);
         return effective.getPropertyDefinition(propertyName, isMultiple, type, exactTypeMatch);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1461058&r1=1461057&r2=1461058&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Tue Mar 26 10:56:06 2013
@@ -40,13 +40,6 @@ import org.slf4j.LoggerFactory;
  */
 abstract class ItemImpl<T extends ItemDelegate> extends AbstractItem {
 
-    /**
-     * Flag to disable expensive transient item definition checks.
-     * FIXME: This flag should be removed once OAK-652 gets resolved.
-     */
-    protected static final boolean DISABLE_TRANSIENT_DEFINITION_CHECKS =
-            Boolean.getBoolean("OAK-652");
-
     protected final SessionContext sessionContext;
     protected final T dlg;
     protected final SessionDelegate sessionDelegate;
@@ -193,16 +186,12 @@ abstract class ItemImpl<T extends ItemDe
     protected abstract ItemDefinition getDefinition() throws RepositoryException;
 
     public void checkProtected() throws RepositoryException {
-        if (DISABLE_TRANSIENT_DEFINITION_CHECKS) {
-            return;
-        }
-
         ItemDefinition definition;
         try {
             definition = getDefinition();
-        }
-        catch (RepositoryException ignore) {
-            // No definition -> not protected but a different error which should be handled
else where
+        } catch (RepositoryException ignore) {
+            // FIXME: No definition -> not protected but a different error
+            // which should be handled else where
             return;
         }
         checkProtected(definition);

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=1461058&r1=1461057&r2=1461058&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 10:56:06 2013
@@ -1606,30 +1606,19 @@ public class NodeImpl<T extends NodeDele
 
             @Override
             public Property perform() throws RepositoryException {
-                Value targetValue;
-                if (DISABLE_TRANSIENT_DEFINITION_CHECKS) {
-                    targetValue = value;
-                } else {
-                    PropertyDefinition definition;
-                    // TODO: Avoid extra JCR method calls (OAK-672)
-                    if (hasProperty(jcrName)) {
-                        definition = getProperty(jcrName).getDefinition();
-                    } else {
-                        definition = getDefinitionProvider().getDefinition(
-                                NodeImpl.this, oakName, false, type,
-                                exactTypeMatch);
-                    }
-                    checkProtected(definition);
-                    if (definition.isMultiple()) {
-                        throw new ValueFormatException(
-                                "Cannot set single value to multivalued property");
-                    }
-
-                    int targetType = getTargetType(value, definition);
-                    targetValue = ValueHelper.convert(
-                            value, targetType, getValueFactory());
+                // TODO: Avoid extra JCR method calls (OAK-672)
+                PropertyDefinition definition = getDefinitionProvider().getDefinition(
+                        dlg.getTree(), oakName, false, type, exactTypeMatch);
+                checkProtected(definition);
+                if (definition.isMultiple()) {
+                    throw new ValueFormatException(
+                            "Cannot set single value to multivalued property");
                 }
 
+                int targetType = getTargetType(value, definition);
+                Value targetValue = ValueHelper.convert(
+                        value, targetType, getValueFactory());
+
                 PropertyState state =
                         PropertyStates.createProperty(oakName, targetValue);
                 return new PropertyImpl(dlg.setProperty(state), sessionContext);
@@ -1653,30 +1642,19 @@ public class NodeImpl<T extends NodeDele
 
             @Override
             public Property perform() throws RepositoryException {
-                Value[] targetValues;
-                if (DISABLE_TRANSIENT_DEFINITION_CHECKS) {
-                    targetValues = values;
-                } else {
-                    PropertyDefinition definition;
-                    // TODO: Avoid extra JCR method calls (OAK-672)
-                    if (hasProperty(jcrName)) {
-                        definition = getProperty(jcrName).getDefinition();
-                    } else {
-                        definition = getDefinitionProvider().getDefinition(
-                                NodeImpl.this, oakName, true, type,
-                                exactTypeMatch);
-                    }
-                    checkProtected(definition);
-                    if (!definition.isMultiple()) {
-                        throw new ValueFormatException(
-                                "Cannot set value array to single value property");
-                    }
-
-                    int targetType = getTargetType(values, definition);
-                    targetValues = ValueHelper.convert(
-                            values, targetType, getValueFactory());
+                // TODO: Avoid extra JCR method calls (OAK-672)
+                PropertyDefinition definition = getDefinitionProvider().getDefinition(
+                        dlg.getTree(), oakName, true, type, exactTypeMatch);
+                checkProtected(definition);
+                if (!definition.isMultiple()) {
+                    throw new ValueFormatException(
+                            "Cannot set value array to single value property");
                 }
 
+                int targetType = getTargetType(values, definition);
+                Value[] targetValues = ValueHelper.convert(
+                        values, targetType, getValueFactory());
+
                 Iterable<Value> nonNullValues = Iterables.filter(
                         Arrays.asList(targetValues), Predicates.notNull());
                 PropertyState state =



Mime
View raw message