jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1335556 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/
Date Tue, 08 May 2012 14:55:49 GMT
Author: reschke
Date: Tue May  8 14:55:48 2012
New Revision: 1335556

URL: http://svn.apache.org/viewvc?rev=1335556&view=rev
Log:
OAK-66: refactor classes into session-aware parts and core parts (WIP)

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionDelegate.java?rev=1335556&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionDelegate.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionDelegate.java
Tue May  8 14:55:48 2012
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.jcr.nodetype;
+
+public class ItemDefinitionDelegate {
+
+    private String name;
+    private boolean autoCreated;
+    private boolean mandatory;
+    private int onParentVersion;
+    private boolean isProtected;
+
+    protected ItemDefinitionDelegate(String name, boolean autoCreated, boolean mandatory,
int onParentVersion, boolean isProtected) {
+        this.name = name;
+        this.autoCreated = autoCreated;
+        this.mandatory = mandatory;
+        this.onParentVersion = onParentVersion;
+        this.isProtected = isProtected;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getOnParentVersion() {
+        return onParentVersion;
+    }
+
+    public boolean isAutoCreated() {
+        return autoCreated;
+    }
+
+    public boolean isMandatory() {
+        return mandatory;
+    }
+
+    public boolean isProtected() {
+        return isProtected;
+    }
+}

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionImpl.java?rev=1335556&r1=1335555&r2=1335556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/ItemDefinitionImpl.java
Tue May  8 14:55:48 2012
@@ -23,30 +23,16 @@ import org.apache.jackrabbit.oak.namepat
 
 class ItemDefinitionImpl implements ItemDefinition {
 
+    private final ItemDefinitionDelegate dlg;
+
     private final NodeType type;
 
     protected final NameMapper mapper;
 
-    private final String name;
-
-    private final boolean autoCreated;
-
-    private final boolean mandatory;
-
-    private final int onParentRevision;
-
-    private final boolean isProtected;
-
-    protected ItemDefinitionImpl(
-            NodeType type, NameMapper mapper, String name, boolean autoCreated,
-            boolean mandatory, int onParentRevision, boolean isProtected) {
+    protected ItemDefinitionImpl(NodeType type, NameMapper mapper, ItemDefinitionDelegate
delegate) {
+        this.dlg = delegate;
         this.type = type;
         this.mapper = mapper;
-        this.name = name;
-        this.autoCreated = autoCreated;
-        this.mandatory = mandatory;
-        this.onParentRevision = onParentRevision;
-        this.isProtected = isProtected;
     }
 
     @Override
@@ -56,28 +42,26 @@ class ItemDefinitionImpl implements Item
 
     @Override
     public String getName() {
-        return mapper.getJcrName(name);
+        return mapper.getJcrName(dlg.getName());
     }
 
     @Override
     public boolean isAutoCreated() {
-        return autoCreated;
+        return dlg.isAutoCreated();
     }
 
     @Override
     public boolean isMandatory() {
-        return mandatory;
+        return dlg.isMandatory();
     }
 
     @Override
     public int getOnParentVersion() {
-        return onParentRevision;
+        return dlg.getOnParentVersion();
     }
 
     @Override
     public boolean isProtected() {
-        return isProtected;
+        return dlg.isProtected();
     }
-
-
 }

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionDelegate.java?rev=1335556&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionDelegate.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionDelegate.java
Tue May  8 14:55:48 2012
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.jcr.nodetype;
+
+public class NodeDefinitionDelegate extends ItemDefinitionDelegate {
+
+    private final String[] requiredPrimaryTypeNames;
+    private final String defaultPrimaryTypeName;
+    private final boolean allowsSameNameSiblings;
+
+    protected NodeDefinitionDelegate(String name, boolean autoCreated, boolean mandatory,
int onParentVersion, boolean isProtected,
+            String[] requiredPrimaryTypeNames, String defaultPrimaryTypeName, boolean allowsSameNameSiblings)
{
+        super(name, autoCreated, mandatory, onParentVersion, isProtected);
+        this.requiredPrimaryTypeNames = requiredPrimaryTypeNames;
+        this.defaultPrimaryTypeName = defaultPrimaryTypeName;
+        this.allowsSameNameSiblings = allowsSameNameSiblings;
+    }
+
+    public boolean allowsSameNameSiblings() {
+        return allowsSameNameSiblings;
+    }
+
+    public String getDefaultPrimaryTypeName() {
+        return defaultPrimaryTypeName;
+    }
+
+    public String[] getRequiredPrimaryTypeNames() {
+        return requiredPrimaryTypeNames;
+    }
+}

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionImpl.java?rev=1335556&r1=1335555&r2=1335556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeDefinitionImpl.java
Tue May  8 14:55:48 2012
@@ -27,20 +27,12 @@ class NodeDefinitionImpl extends ItemDef
 
     private final NodeTypeManager manager;
 
-    private final String[] requiredPrimaryTypeNames;
+    private final NodeDefinitionDelegate dlg;
 
-    private final String defaultPrimaryTypeName;
-
-    private final boolean allowsSameNameSiblings;
-
-    protected NodeDefinitionImpl(NodeTypeManager manager, NodeType type, NameMapper mapper,
String name, boolean autoCreated,
-            boolean mandatory, int onParentRevision, boolean isProtected, String[] requiredPrimaryTypeNames,
-            String defaultPrimaryTypeName, boolean allowsSameNameSiblings) {
-        super(type, mapper, name, autoCreated, mandatory, onParentRevision, isProtected);
+    protected NodeDefinitionImpl(NodeTypeManager manager, NodeType type, NameMapper mapper,
NodeDefinitionDelegate delegate) {
+        super(type, mapper, delegate);
         this.manager = manager;
-        this.requiredPrimaryTypeNames = requiredPrimaryTypeNames;
-        this.defaultPrimaryTypeName = defaultPrimaryTypeName;
-        this.allowsSameNameSiblings = allowsSameNameSiblings;
+        this.dlg = delegate;
     }
 
     @Override
@@ -51,8 +43,7 @@ class NodeDefinitionImpl extends ItemDef
             try {
                 types[i] = manager.getNodeType(names[i]);
             } catch (RepositoryException e) {
-                throw new IllegalStateException(
-                        "Inconsistent node definition: " + this, e);
+                throw new IllegalStateException("Inconsistent node definition: " + this,
e);
             }
         }
         return types;
@@ -60,11 +51,12 @@ class NodeDefinitionImpl extends ItemDef
 
     @Override
     public String[] getRequiredPrimaryTypeNames() {
-        String[] names = new String[requiredPrimaryTypeNames.length];
-        for (int i = 0; i < names.length; i++) {
-            names[i] = mapper.getJcrName(requiredPrimaryTypeNames[i]);
+        String[] requiredPrimaryTypeNames = dlg.getRequiredPrimaryTypeNames();
+        String[] result = new String[requiredPrimaryTypeNames.length];
+        for (int i = 0; i < result.length; i++) {
+            result[i] = mapper.getJcrName(requiredPrimaryTypeNames[i]);
         }
-        return names;
+        return result;
     }
 
     @Override
@@ -79,12 +71,13 @@ class NodeDefinitionImpl extends ItemDef
 
     @Override
     public String getDefaultPrimaryTypeName() {
+        String defaultPrimaryTypeName = dlg.getDefaultPrimaryTypeName();
         return defaultPrimaryTypeName == null ? null : mapper.getJcrName(defaultPrimaryTypeName);
     }
 
     @Override
     public boolean allowsSameNameSiblings() {
-        return allowsSameNameSiblings;
+        return dlg.allowsSameNameSiblings();
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java?rev=1335556&r1=1335555&r2=1335556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
Tue May  8 14:55:48 2012
@@ -291,8 +291,9 @@ public class NodeTypeManagerImpl impleme
         }
 
         public NodeDefinition getNodeDefinition(NodeTypeManager ntm, NodeType nt, NameMapper
mapper) {
-            return new NodeDefinitionImpl(ntm, nt, mapper, name, autocreate, isMandatory,
onParent, isProtected,
-                    requiredPrimaryTypes.toArray(new String[requiredPrimaryTypes.size()]),
defaultPrimaryType, allowSns);
+            return new NodeDefinitionImpl(ntm, nt, mapper, new NodeDefinitionDelegate(name,
autocreate, isMandatory, onParent,
+                    isProtected, requiredPrimaryTypes.toArray(new String[requiredPrimaryTypes.size()]),
defaultPrimaryType,
+                    allowSns));
         };
 
         @Override
@@ -336,8 +337,8 @@ public class NodeTypeManagerImpl impleme
                 defaultCoreValues[i] = vf.getCoreValueFactory().createValue(defaultValues.get(i),
requiredType);
             }
             
-            return new PropertyDefinitionImpl(nt, mapper, vf, name, autocreate, isMandatory,
onParent, isProtected, requiredType,
-                    isMultiple, defaultCoreValues);
+            return new PropertyDefinitionImpl(nt, mapper, vf, new PropertyDefinitionDelegate(name,
autocreate, isMandatory,
+                    onParent, isProtected, requiredType, isMultiple, defaultCoreValues));
         }
 
         @Override

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java?rev=1335556&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java
Tue May  8 14:55:48 2012
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.jcr.nodetype;
+
+import org.apache.jackrabbit.oak.api.CoreValue;
+
+public class PropertyDefinitionDelegate extends ItemDefinitionDelegate {
+
+    private final int requiredType;
+    private final boolean multiple;
+    private final CoreValue[] defaultCoreValues;
+
+    protected PropertyDefinitionDelegate(String name, boolean autoCreated, boolean mandatory,
int onParentVersion,
+            boolean isProtected, int requiredType, boolean multiple, CoreValue[] defaultCoreValues)
{
+        super(name, autoCreated, mandatory, onParentVersion, isProtected);
+        this.requiredType = requiredType;
+        this.multiple = multiple;
+        this.defaultCoreValues = defaultCoreValues;
+    }
+
+    public CoreValue[] getDefaultCoreValues() {
+        return defaultCoreValues;
+    }
+
+    public int getRequiredType() {
+        return requiredType;
+    }
+
+    public boolean isMultiple() {
+        return multiple;
+    }
+}

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java?rev=1335556&r1=1335555&r2=1335556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java
Tue May  8 14:55:48 2012
@@ -24,30 +24,21 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.jcr.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
 
-class PropertyDefinitionImpl
-        extends ItemDefinitionImpl implements PropertyDefinition {
+class PropertyDefinitionImpl extends ItemDefinitionImpl implements PropertyDefinition {
 
-    private final int requiredType;
-    private final boolean multiple;
-    private final CoreValue[] defaultCoreValues;
+    private final PropertyDefinitionDelegate dlg;
 
     private final ValueFactoryImpl vfac;
-    
-    public PropertyDefinitionImpl(
-            NodeType type, NameMapper mapper, ValueFactoryImpl vfac, String name, boolean
autoCreated,
-            boolean mandatory, int onParentRevision, boolean isProtected,
-            int requiredType, boolean multiple, CoreValue[] defaultCoreValues) {
-        super(type, mapper, name, autoCreated,
-                mandatory, onParentRevision, isProtected);
+
+    public PropertyDefinitionImpl(NodeType type, NameMapper mapper, ValueFactoryImpl vfac,
PropertyDefinitionDelegate delegate) {
+        super(type, mapper, delegate);
         this.vfac = vfac;
-        this.requiredType = requiredType;
-        this.multiple = multiple;
-        this.defaultCoreValues = defaultCoreValues;
+        this.dlg = delegate;
     }
 
     @Override
     public int getRequiredType() {
-        return requiredType;
+        return dlg.getRequiredType();
     }
 
     @Override
@@ -57,16 +48,17 @@ class PropertyDefinitionImpl
 
     @Override
     public Value[] getDefaultValues() {
-        Value[] defaults = new Value[defaultCoreValues.length];
+        CoreValue[] defaults = dlg.getDefaultCoreValues();
+        Value[] result = new Value[defaults.length];
         for (int i = 0; i < defaults.length; i++) {
-            defaults[i] = vfac.createValue(defaultCoreValues[i]);
+            result[i] = vfac.createValue(defaults[i]);
         }
-        return defaults;
+        return result;
     }
 
     @Override
     public boolean isMultiple() {
-        return multiple;
+        return dlg.isMultiple();
     }
 
     @Override



Mime
View raw message