jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1363688 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type: DefBuilderFactory.java ItemDefinitionImpl.java NodeDefinitionTemplateImpl.java NodeTypeTemplateImpl.java PropertyDefinitionTemplateImpl.java
Date Fri, 20 Jul 2012 09:08:36 GMT
Author: jukka
Date: Fri Jul 20 09:08:35 2012
New Revision: 1363688

URL: http://svn.apache.org/viewvc?rev=1363688&view=rev
Log:
OAK-66: JCR Node Type Management

Some cleanup and streamlining

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/DefBuilderFactory.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/ItemDefinitionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/DefBuilderFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/DefBuilderFactory.java?rev=1363688&r1=1363687&r2=1363688&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/DefBuilderFactory.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/DefBuilderFactory.java
Fri Jul 20 09:08:35 2012
@@ -19,9 +19,6 @@ package org.apache.jackrabbit.oak.plugin
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeTemplate;
 
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory;
@@ -32,21 +29,8 @@ class DefBuilderFactory extends
     private Map<String, String> namespaces = new HashMap<String, String>();
 
     @Override
-    public NodeTypeTemplateImpl newNodeTypeDefinitionBuilder()
-            throws RepositoryException {
-        return new NodeTypeTemplateImpl() {
-            @Override
-            protected NodeType getNodeType(String name) {
-                // TODO Auto-generated method stub
-                return null;
-            }
-            @Override
-            protected Value createValue(String value)
-                    throws RepositoryException {
-                // TODO Auto-generated method stub
-                return null;
-            }
-        };
+    public NodeTypeTemplateImpl newNodeTypeDefinitionBuilder() {
+        return new NodeTypeTemplateImpl();
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/ItemDefinitionImpl.java?rev=1363688&r1=1363687&r2=1363688&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/ItemDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/ItemDefinitionImpl.java
Fri Jul 20 09:08:35 2012
@@ -23,17 +23,10 @@ import static javax.jcr.version.OnParent
 import static javax.jcr.version.OnParentVersionAction.ACTIONNAME_INITIALIZE;
 import static javax.jcr.version.OnParentVersionAction.ACTIONNAME_VERSION;
 
-import java.util.List;
-
 import javax.jcr.nodetype.ItemDefinition;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.OnParentVersionAction;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.namepath.NameMapper;
-
 /**
  * <pre>
  * [nt:{propertyDefinition,childNodeDefinition}]
@@ -46,7 +39,6 @@ import org.apache.jackrabbit.oak.namepat
  *   ...
  * </pre>
  */
-
 class ItemDefinitionImpl implements ItemDefinition {
 
     private final NodeType type;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java?rev=1363688&r1=1363687&r2=1363688&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java
Fri Jul 20 09:08:35 2012
@@ -29,7 +29,7 @@ import org.apache.jackrabbit.commons.cnd
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-abstract class NodeDefinitionTemplateImpl
+class NodeDefinitionTemplateImpl
         extends AbstractNodeDefinitionBuilder<NodeTypeTemplate>
         implements NodeDefinitionTemplate {
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java?rev=1363688&r1=1363687&r2=1363688&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
Fri Jul 20 09:08:35 2012
@@ -21,20 +21,26 @@ import java.util.List;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeDefinitionTemplate;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeTemplate;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.nodetype.PropertyDefinitionTemplate;
 
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractNodeTypeDefinitionBuilder;
 
-abstract class NodeTypeTemplateImpl
+class NodeTypeTemplateImpl
     extends AbstractNodeTypeDefinitionBuilder<NodeTypeTemplate>
     implements NodeTypeTemplate {
 
+    private final NodeTypeManager manager;
+
+    private final ValueFactory factory;
+
     private String primaryItemName = null;
 
     private String[] superTypeNames = new String[0];
@@ -45,10 +51,20 @@ abstract class NodeTypeTemplateImpl
     private final List<NodeDefinitionTemplate> nodeDefinitionTemplates =
             new ArrayList<NodeDefinitionTemplate>();
 
+    private NodeTypeTemplateImpl(NodeTypeManager manager, ValueFactory factory) {
+        this.manager = manager;
+        this.factory = factory;
+    }
+
     public NodeTypeTemplateImpl() {
+        this(null, null);
     }
 
-    public NodeTypeTemplateImpl(NodeTypeDefinition ntd) {
+    public NodeTypeTemplateImpl(
+            NodeTypeManager manager, ValueFactory factory,
+            NodeTypeDefinition ntd) {
+        this(manager, factory);
+
         setName(ntd.getName());
         setAbstract(ntd.isAbstract());
         setMixin(ntd.isMixin());
@@ -90,11 +106,6 @@ abstract class NodeTypeTemplateImpl
         }
     }
 
-    protected abstract Value createValue(String value)
-            throws RepositoryException;
-
-    protected abstract NodeType getNodeType(String name);
-
     @Override
     public NodeTypeTemplate build() {
         return this;
@@ -106,11 +117,15 @@ abstract class NodeTypeTemplateImpl
             @Override
             protected Value createValue(String value)
                     throws RepositoryException {
-                return NodeTypeTemplateImpl.this.createValue(value);
+                if (factory != null) {
+                    return factory.createValue(value);
+                } else {
+                    return super.createValue(value);
+                }
             }
             @Override
             public void build() {
-                getPropertyDefinitionTemplates().add(this);
+                propertyDefinitionTemplates.add(this);
             }
         };
     }
@@ -119,12 +134,17 @@ abstract class NodeTypeTemplateImpl
     public NodeDefinitionTemplateImpl newNodeDefinitionBuilder() {
         return new NodeDefinitionTemplateImpl() {
             @Override
-            protected NodeType getNodeType(String name) {
-                return NodeTypeTemplateImpl.this.getNodeType(name);
+            protected NodeType getNodeType(String name)
+                    throws RepositoryException  {
+                if (manager != null) {
+                    return manager.getNodeType(name);
+                } else {
+                    return super.getNodeType(name);
+                }
             }
             @Override
             public void build() {
-                getNodeDefinitionTemplates().add(this);
+                nodeDefinitionTemplates.add(this);
             }
         };
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java?rev=1363688&r1=1363687&r2=1363688&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java
Fri Jul 20 09:08:35 2012
@@ -25,7 +25,7 @@ import javax.jcr.nodetype.PropertyDefini
 
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractPropertyDefinitionBuilder;
 
-abstract class PropertyDefinitionTemplateImpl
+class PropertyDefinitionTemplateImpl
         extends AbstractPropertyDefinitionBuilder<NodeTypeTemplate>
         implements PropertyDefinitionTemplate {
 



Mime
View raw message