jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1461644 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemImpl.java NodeImpl.java PropertyImpl.java
Date Wed, 27 Mar 2013 15:22:21 GMT
Author: mduerig
Date: Wed Mar 27 15:22:21 2013
New Revision: 1461644

URL: http://svn.apache.org/r1461644
Log:
OAK-672: Avoid JCR APIs calling other JCR APIs
avoid extra call to perform() for getting ItemDefinition

Modified:
    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
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java

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=1461644&r1=1461643&r2=1461644&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
Wed Mar 27 15:22:21 2013
@@ -69,14 +69,14 @@ abstract class ItemImpl<T extends ItemDe
     protected abstract class ItemReadOperation<T> extends SessionOperation<T>
{
         @Override
         protected void checkPreconditions() throws RepositoryException {
-            checkStatus();
+            checkAlive();
         }
     }
 
     protected abstract class ItemWriteOperation<T> extends SessionOperation<T>
{
         @Override
         protected void checkPreconditions() throws RepositoryException {
-            checkStatus();
+            checkAlive();
             checkProtected();
         }
     }
@@ -267,17 +267,17 @@ abstract class ItemImpl<T extends ItemDe
      * @throws RepositoryException if this item has been rendered invalid for some reason
      * or the associated session has been logged out.
      */
-    void checkStatus() throws RepositoryException {
+    void checkAlive() throws RepositoryException {
         sessionDelegate.checkAlive();
         dlg.checkNotStale();
     }
 
-    protected abstract ItemDefinition getDefinition() throws RepositoryException;
+    protected abstract ItemDefinition internalGetDefinition() throws RepositoryException;
 
     void checkProtected() throws RepositoryException {
         ItemDefinition definition;
         try {
-            definition = getDefinition();
+            definition = internalGetDefinition();
         } catch (RepositoryException ignore) {
             // FIXME: No definition -> not protected but a different error
             // which should be handled else where

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=1461644&r1=1461643&r2=1461644&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
Wed Mar 27 15:22:21 2013
@@ -187,7 +187,7 @@ public class NodeImpl<T extends NodeDele
      */
     @Override
     public void accept(ItemVisitor visitor) throws RepositoryException {
-        checkStatus();
+        checkAlive();
         visitor.visit(this);
     }
 
@@ -944,13 +944,7 @@ public class NodeImpl<T extends NodeDele
         return perform(new ItemReadOperation<NodeDefinition>() {
             @Override
             protected NodeDefinition perform() throws RepositoryException {
-                NodeDelegate parent = dlg.getParent();
-                if (parent == null) {
-                    return getDefinitionProvider().getRootDefinition();
-                } else {
-                    return getDefinitionProvider().getDefinition(
-                            parent.getTree(), dlg.getTree());
-                }
+                return internalGetDefinition();
             }
         });
     }
@@ -958,7 +952,7 @@ public class NodeImpl<T extends NodeDele
     @Override
     @Nonnull
     public String getCorrespondingNodePath(String workspaceName) throws RepositoryException
{
-        checkStatus();
+        checkAlive();
         checkValidWorkspace(workspaceName);
         throw new UnsupportedRepositoryOperationException("TODO: Node.getCorrespondingNodePath");
     }
@@ -966,7 +960,7 @@ public class NodeImpl<T extends NodeDele
 
     @Override
     public void update(String srcWorkspace) throws RepositoryException {
-        checkStatus();
+        checkAlive();
         checkValidWorkspace(srcWorkspace);
 
         // check for pending changes
@@ -1300,7 +1294,18 @@ public class NodeImpl<T extends NodeDele
 
     }
 
-    //------------------------------------------------------------< private >---
+    //------------------------------------------------------------< internal >---
+
+    @Override
+    protected final NodeDefinition internalGetDefinition() throws RepositoryException {
+        NodeDelegate parent = dlg.getParent();
+        if (parent == null) {
+            return getDefinitionProvider().getRootDefinition();
+        } else {
+            return getDefinitionProvider().getDefinition(
+                    parent.getTree(), dlg.getTree());
+        }
+    }
 
     private EffectiveNodeType getEffectiveNodeType() throws RepositoryException {
         return getEffectiveNodeTypeProvider().getEffectiveNodeType(dlg.getTree());

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=1461644&r1=1461643&r2=1461644&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
Wed Mar 27 15:22:21 2013
@@ -115,7 +115,7 @@ public class PropertyImpl extends ItemIm
 
     @Override
     public void accept(ItemVisitor visitor) throws RepositoryException {
-        checkStatus();
+        checkAlive();
         visitor.visit(this);
     }
 
@@ -379,7 +379,7 @@ public class PropertyImpl extends ItemIm
         return perform(new ItemReadOperation<PropertyDefinition>() {
             @Override
             protected PropertyDefinition perform() throws RepositoryException {
-                return getPropertyDefinition();
+                return internalGetDefinition();
             }
         });
     }
@@ -393,7 +393,7 @@ public class PropertyImpl extends ItemIm
                     Value[] values = getValues();
                     if (values.length == 0) {
                         // retrieve the type from the property definition
-                        PropertyDefinition definition = getPropertyDefinition();
+                        PropertyDefinition definition = internalGetDefinition();
                         if (definition.getRequiredType() == PropertyType.UNDEFINED) {
                             return PropertyType.STRING;
                         } else {
@@ -421,6 +421,12 @@ public class PropertyImpl extends ItemIm
 
     //------------------------------------------------------------< internal >---
 
+    @Override
+    protected final PropertyDefinition internalGetDefinition() throws RepositoryException
{
+        return getDefinitionProvider().getDefinition(
+                dlg.getParent().getTree(), dlg.getPropertyState(), true);
+    }
+
     /**
      * Determine the {@link javax.jcr.PropertyType} of the passed values if all are of
      * the same type.
@@ -470,11 +476,6 @@ public class PropertyImpl extends ItemIm
         });
     }
 
-    private PropertyDefinition getPropertyDefinition() throws RepositoryException {
-        return getDefinitionProvider().getDefinition(
-                dlg.getParent().getTree(), dlg.getPropertyState(), true);
-    }
-
     private void internalSetValue(@Nonnull final Value value)
             throws RepositoryException {
         checkNotNull(value);
@@ -482,7 +483,7 @@ public class PropertyImpl extends ItemIm
             @Override
             protected Void perform() throws RepositoryException {
                 // TODO: Avoid extra JCR method calls (OAK-672)
-                PropertyDefinition definition = getPropertyDefinition();
+                PropertyDefinition definition = internalGetDefinition();
                 PropertyState state = createSingleState(dlg.getName(), value, definition);
                 dlg.setState(state);
                 return null;
@@ -496,7 +497,7 @@ public class PropertyImpl extends ItemIm
             @Override
             protected Void perform() throws RepositoryException {
                 // TODO: Avoid extra JCR method calls (OAK-672)
-                PropertyDefinition definition = getPropertyDefinition();
+                PropertyDefinition definition = internalGetDefinition();
                 PropertyState state = createMultiState(dlg.getName(), type, values, definition);
                 dlg.setState(state);
                 return null;



Mime
View raw message