jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1170225 - in /jackrabbit/sandbox/jackrabbit-mk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit...
Date Tue, 13 Sep 2011 16:13:18 GMT
Author: mduerig
Date: Tue Sep 13 16:13:17 2011
New Revision: 1170225

URL: http://svn.apache.org/viewvc?rev=1170225&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
refactor: consolidate ManagerProvider

Added:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeResolver.java
Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ManagerProvider.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ManagerProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ManagerProvider.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ManagerProvider.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ManagerProvider.java
Tue Sep 13 16:13:17 2011
@@ -26,10 +26,12 @@ import org.apache.jackrabbit.jcr2spi.ver
 import org.apache.jackrabbit.spi.PathFactory;
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeResolver;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeTypeManager;
 
 /**
  * {@code ManagerProvider}...
@@ -68,6 +70,10 @@ public interface ManagerProvider {
 
     NodeTypeDefinitionProvider getNodeTypeDefinitionProvider();
 
+    NodeTypeResolver getNodeTypeResolver();
+
+    NodeTypeManager getNodeTypeManager();
+
     EffectiveNodeTypeProvider getEffectiveNodeTypeProvider();
 
     /**
@@ -79,9 +85,9 @@ public interface ManagerProvider {
      * @return
      * @throws RepositoryException
      */
-    ValueFactory getJcrValueFactory() throws RepositoryException;
+    ValueFactory getJcrValueFactory();
 
-    QValueFactory getQValueFactory() throws RepositoryException;
+    QValueFactory getQValueFactory();
 
     PathFactory getPathFactory();
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Tue Sep 13 16:13:17 2011
@@ -20,8 +20,6 @@ import org.apache.jackrabbit.jcr2spi.hie
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.lock.LockStateManager;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeImpl;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.jcr2spi.operation.AddNode;
 import org.apache.jackrabbit.jcr2spi.operation.AddProperty;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
@@ -92,14 +90,18 @@ public class NodeImpl extends ItemImpl i
 
     protected NodeImpl(SessionImpl session, NodeState state, ItemLifeCycleListener listener)
{
         super(session, state, listener);
-        Name nodeTypeName = state.getNodeTypeName();
+
         // make sure the nodetype name is valid
-        if (!session.getNodeTypeManager().hasNodeType(nodeTypeName)) {
+        Name ntName = state.getNodeTypeName();
+        try {
+            session.getNodeTypeResolver().getNodeType(ntName);
+        }
+        catch (NoSuchNodeTypeException e) {
             // should not occur. Since nodetypes are defined by the 'server'
             // its not possible to determine a fallback nodetype that is
             // always available.
             throw new IllegalArgumentException("Unknown nodetype " +
-                    LogUtil.saveGetJCRName(nodeTypeName, session.getNamePathResolver()));
+                    LogUtil.saveGetJCRName(ntName, session.getNamePathResolver()));
         }
     }
 
@@ -578,7 +580,7 @@ public class NodeImpl extends ItemImpl i
     @Override
     public NodeType getPrimaryNodeType() throws RepositoryException {
         checkStatus();
-        return session.getNodeTypeManager().getNodeType(getPrimaryNodeTypeName());
+        return session.getNodeTypeResolver().getNodeType(getPrimaryNodeTypeName());
     }
 
     @Override
@@ -597,8 +599,7 @@ public class NodeImpl extends ItemImpl i
             return;
         }
 
-        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
-        NodeType nt = ntMgr.getNodeType(ntName);
+        NodeType nt = session.getNodeTypeResolver().getNodeType(ntName);
         if (nt.isMixin() || nt.isAbstract()) {
             throw new ConstraintViolationException("Cannot change the primary type: '" +
nodeTypeName +
                     "' is a mixin type or abstract.");
@@ -615,7 +616,7 @@ public class NodeImpl extends ItemImpl i
         Name[] mixinNames = getNodeState().getMixinTypeNames();
         NodeType[] nta = new NodeType[mixinNames.length];
         for (int i = 0; i < mixinNames.length; i++) {
-            nta[i] = session.getNodeTypeManager().getNodeType(mixinNames[i]);
+            nta[i] = session.getNodeTypeResolver().getNodeType(mixinNames[i]);
         }
         return nta;
     }
@@ -664,8 +665,9 @@ public class NodeImpl extends ItemImpl i
 
         // mix:referenceable needs additional assertion: the mixin cannot be
         // removed, if any references are left to this node.
-        NodeTypeImpl mixin = session.getNodeTypeManager().getNodeType(ntName);
-        if (mixin.isNodeType(NameConstants.MIX_REFERENCEABLE)) {
+        NodeType mixin = session.getNodeTypeResolver().getNodeType(ntName);
+        String mixReferenceable = session.getNamePathResolver().getJCRName(NameConstants.MIX_REFERENCEABLE);
+        if (mixin.isNodeType(mixReferenceable)) {
             EffectiveNodeType entRemaining = getRemainingENT(mixinValue);
             if (!entRemaining.includesNodeType(NameConstants.MIX_REFERENCEABLE)) {
                 if (getReferences().hasNext()) {
@@ -677,7 +679,8 @@ public class NodeImpl extends ItemImpl i
 
         // mix:lockable: the mixin cannot be removed if the node is currently
         // locked even if the editing session is the lock holder.
-        if (mixin.isNodeType(NameConstants.MIX_LOCKABLE)) {
+        String mixLockable = session.getNamePathResolver().getJCRName(NameConstants.MIX_LOCKABLE);
+        if (mixin.isNodeType(mixLockable)) {
             EffectiveNodeType entRemaining = getRemainingENT(mixinValue);
             if (!entRemaining.includesNodeType(NameConstants.MIX_LOCKABLE) && isLocked())
{
                 throw new ConstraintViolationException(mixinName + " can not be removed:
the node is locked.");
@@ -770,7 +773,7 @@ public class NodeImpl extends ItemImpl i
     public NodeDefinition getDefinition() throws RepositoryException {
         checkStatus();
         QNodeDefinition qnd = getNodeState().getDefinition();
-        return session.getNodeTypeManager().getNodeDefinition(qnd);
+        return session.getNodeTypeResolver().getNodeDefinition(qnd);
     }
 
     @Override
@@ -1183,7 +1186,7 @@ public class NodeImpl extends ItemImpl i
         }
         // NEW nodes with inherited-mixins -> mixin not yet active
         if (getNodeState().getStatus() == Status.NEW &&
-            session.getNodeTypeManager().getNodeType(qName).isMixin()) {
+            session.getNodeTypeResolver().getNodeType(qName).isMixin()) {
             return false;
         }
 
@@ -1487,12 +1490,9 @@ public class NodeImpl extends ItemImpl i
      * @throws NoSuchNodeTypeException
      * @throws ConstraintViolationException
      */
-    private boolean canAddMixin(Name mixinName) throws NoSuchNodeTypeException,
-        ConstraintViolationException {
-        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
-
+    private boolean canAddMixin(Name mixinName) throws NoSuchNodeTypeException, ConstraintViolationException
{
         // first check characteristics of each mixin
-        NodeType mixin = ntMgr.getNodeType(mixinName);
+        NodeType mixin = session.getNodeTypeResolver().getNodeType(mixinName);
         if (!mixin.isMixin()) {
             log.error(mixin.getName() + ": not a mixin node type");
             return false;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
Tue Sep 13 16:13:17 2011
@@ -405,7 +405,7 @@ public class PropertyImpl extends ItemIm
     public PropertyDefinition getDefinition() throws RepositoryException {
         checkStatus();
         QPropertyDefinition qpd = getPropertyState().getDefinition();
-        return session.getNodeTypeManager().getPropertyDefinition(qpd);
+        return session.getNodeTypeResolver().getPropertyDefinition(qpd);
     }
 
     @Override

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Tue Sep 13 16:13:17 2011
@@ -57,6 +57,7 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeResolver;
 import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -81,6 +82,7 @@ import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFactory;
 import javax.jcr.Workspace;
+import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.retention.RetentionManager;
 import javax.jcr.security.AccessControlManager;
 import javax.jcr.version.Version;
@@ -117,6 +119,7 @@ public class SessionImpl extends Abstrac
     private NamePathResolver npResolver;
     private final NodeTypeManagerImpl ntManager;
 
+    private final QValueFactory qValueFactory;
     private final ValueFactory valueFactory;
 
     private final SessionItemStateManager itemStateManager;
@@ -138,7 +141,8 @@ public class SessionImpl extends Abstrac
         npResolver = new DefaultNamePathResolver(this, idResolver, true);
 
         // build ValueFactory
-        valueFactory = new ValueFactoryQImpl(config.getRepositoryService().getQValueFactory(),
npResolver);
+        qValueFactory = config.getRepositoryService().getQValueFactory();
+        valueFactory = new ValueFactoryQImpl(qValueFactory, npResolver);
 
         // build nodetype manager
         ntManager = new NodeTypeManagerImpl(workspace.getNodeTypeRegistry(), this);
@@ -749,17 +753,27 @@ public class SessionImpl extends Abstrac
     }
 
     @Override
+    public NodeTypeResolver getNodeTypeResolver() {
+        return ntManager;
+    }
+
+    @Override
+    public NodeTypeManager getNodeTypeManager() {
+        return ntManager;
+    }
+
+    @Override
     public EffectiveNodeTypeProvider getEffectiveNodeTypeProvider() {
         return workspace.getEffectiveNodeTypeProvider();
     }
 
     @Override
-    public final QValueFactory getQValueFactory() throws RepositoryException {
-        return config.getRepositoryService().getQValueFactory();
+    public final QValueFactory getQValueFactory() {
+        return qValueFactory;
     }
 
     @Override
-    public ValueFactory getJcrValueFactory() throws RepositoryException {
+    public ValueFactory getJcrValueFactory() {
         return valueFactory;
     }
 
@@ -793,10 +807,6 @@ public class SessionImpl extends Abstrac
         return itemStateManager;
     }
 
-    NodeTypeManagerImpl getNodeTypeManager() {
-        return ntManager;
-    }
-
     CacheBehaviour getCacheBehaviour() {
         return config.getCacheBehaviour();
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Tue Sep 13 16:13:17 2011
@@ -47,6 +47,7 @@ import org.apache.jackrabbit.spi.PathFac
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
@@ -246,12 +247,6 @@ public class WorkspaceImpl implements Wo
     }
 
     @Override
-    public NodeTypeManager getNodeTypeManager() throws RepositoryException {
-        session.checkIsAlive();
-        return session.getNodeTypeManager();
-    }
-
-    @Override
     public ObservationManager getObservationManager() throws RepositoryException {
         session.checkSupportedOption(Repository.OPTION_OBSERVATION_SUPPORTED);
         session.checkIsAlive();
@@ -398,6 +393,16 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public NodeTypeDefinitionProvider getNodeTypeDefinitionProvider() {
+        return session.getNodeTypeDefinitionProvider();
+    }
+
+    @Override
+    public NodeTypeResolver getNodeTypeResolver() {
+        return session.getNodeTypeResolver();
+    }
+
+    @Override
+    public NodeTypeManager getNodeTypeManager() {
         return session.getNodeTypeManager();
     }
 
@@ -407,12 +412,12 @@ public class WorkspaceImpl implements Wo
     }
 
     @Override
-    public ValueFactory getJcrValueFactory() throws RepositoryException {
+    public ValueFactory getJcrValueFactory() {
         return session.getJcrValueFactory();
     }
 
     @Override
-    public QValueFactory getQValueFactory() throws RepositoryException {
+    public QValueFactory getQValueFactory() {
         return session.getQValueFactory();
     }
 

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
Tue Sep 13 16:13:17 2011
@@ -16,18 +16,6 @@
  */
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
-import java.util.ArrayList;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.NodeDefinition;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.NodeTypeDefinition;
-import javax.jcr.nodetype.PropertyDefinition;
-
 import org.apache.jackrabbit.jcr2spi.ManagerProvider;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeDefinition;
@@ -43,6 +31,16 @@ import org.apache.jackrabbit.value.Value
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+import java.util.ArrayList;
+
 /**
  * {@code NodeTypeImpl} ...
  */
@@ -50,7 +48,6 @@ public class NodeTypeImpl extends Abstra
     private static final Logger log = LoggerFactory.getLogger(NodeTypeImpl.class);
 
     private final EffectiveNodeType ent;
-    private final NodeTypeManagerImpl ntMgr;
     private final ManagerProvider mgrProvider;
 
     /**
@@ -62,13 +59,11 @@ public class NodeTypeImpl extends Abstra
      *
      * @param ent        the effective (i.e. merged and resolved) node type representation
      * @param ntd        the definition of this node type
-     * @param ntMgr      the node type manager associated with this node type
      * @param mgrProvider the manager provider
      */
-    NodeTypeImpl(EffectiveNodeType ent, QNodeTypeDefinition ntd, NodeTypeManagerImpl ntMgr,
ManagerProvider mgrProvider) {
-        super(ntd, ntMgr, mgrProvider.getNamePathResolver());
+    NodeTypeImpl(EffectiveNodeType ent, QNodeTypeDefinition ntd, ManagerProvider mgrProvider)
{
+        super(ntd, mgrProvider.getNamePathResolver(), mgrProvider.getNodeTypeResolver(),
mgrProvider.getNodeTypeManager());
         this.ent = ent;
-        this.ntMgr = ntMgr;
         this.mgrProvider = mgrProvider;
     }
 
@@ -142,7 +137,7 @@ public class NodeTypeImpl extends Abstra
         NodeType[] supertypes = new NodeType[ntNames.length];
         for (int i = 0; i < ntNames.length; i++) {
             try {
-                supertypes[i] = ntMgr.getNodeType(ntNames[i]);
+                supertypes[i] = mgrProvider.getNodeTypeResolver().getNodeType(ntNames[i]);
             } catch (NoSuchNodeTypeException e) {
                 // should never get here
                 log.error("undefined supertype", e);
@@ -160,7 +155,7 @@ public class NodeTypeImpl extends Abstra
         QNodeDefinition[] defs = ent.getAllQNodeDefinitions();
         NodeDefinition[] nodeDefs = new NodeDefinition[defs.length];
         for (int i = 0; i < defs.length; i++) {
-            nodeDefs[i] = ntMgr.getNodeDefinition(defs[i]);
+            nodeDefs[i] = mgrProvider.getNodeTypeResolver().getNodeDefinition(defs[i]);
         }
         return nodeDefs;
     }
@@ -173,7 +168,7 @@ public class NodeTypeImpl extends Abstra
         QPropertyDefinition[] pda = ent.getAllQPropertyDefinitions();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = ntMgr.getPropertyDefinition(pda[i]);
+            propDefs[i] = mgrProvider.getNodeTypeResolver().getPropertyDefinition(pda[i]);
         }
         return propDefs;
     }
@@ -320,7 +315,7 @@ public class NodeTypeImpl extends Abstra
     public boolean canAddChildNode(String childNodeName, String nodeTypeName) {
         try {
             Name ntName = resolver().getQName(nodeTypeName);
-            QNodeTypeDefinition def = ntMgr.getNodeTypeDefinition(ntName);
+            QNodeTypeDefinition def = mgrProvider.getNodeTypeDefinitionProvider().getNodeTypeDefinition(ntName);
             ent.checkAddNodeConstraints(resolver().getQName(childNodeName), def, definitionProvider());
             return true;
         } catch (NameException be) {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
Tue Sep 13 16:13:17 2011
@@ -24,7 +24,6 @@ import org.apache.jackrabbit.spi.QNodeDe
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
-import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeTypeManager;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl;
@@ -36,7 +35,6 @@ import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
@@ -77,11 +75,6 @@ public class NodeTypeManagerImpl extends
     private final NodeTypeRegistry ntReg;
 
     /**
-     * The ValueFactory used to build property definitions.
-     */
-    private final ValueFactory valueFactory;
-
-    /**
      * A cache for {@code NodeType} instances created by this
      * {@code NodeTypeManager}
      */
@@ -106,11 +99,10 @@ public class NodeTypeManagerImpl extends
      * @param mgrProvider  the manager provider
      * @throws RepositoryException If an error occurs.
      */
-    public NodeTypeManagerImpl(NodeTypeRegistry ntReg, ManagerProvider mgrProvider) throws
RepositoryException {
+    public NodeTypeManagerImpl(NodeTypeRegistry ntReg, ManagerProvider mgrProvider) {
         this.mgrProvider = mgrProvider;
         this.ntReg = ntReg;
         this.ntReg.addListener(this);
-        valueFactory = mgrProvider.getJcrValueFactory();
 
         // setup caches with soft references to node type
         ntCache = cast(new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT));
@@ -118,40 +110,27 @@ public class NodeTypeManagerImpl extends
         ndCache = cast(new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT));
     }
 
-    private EffectiveNodeTypeProvider entProvider() {
-        return mgrProvider.getEffectiveNodeTypeProvider();
-    }
-
-    //--------------------------------------------------------------------------
+    //------------------------------------------< AbstractNodeTypeManager >---
 
     @Override
-    public NodeTypeImpl getNodeType(Name name) throws NoSuchNodeTypeException {
+    public NodeTypeImpl getNodeType(Name ntName) throws NoSuchNodeTypeException {
         synchronized (ntCache) {
-            NodeTypeImpl nt = ntCache.get(name);
+            NodeTypeImpl nt = ntCache.get(ntName);
             if (nt == null) {
-                EffectiveNodeType ent = entProvider().getEffectiveNodeType(name);
-                QNodeTypeDefinition def = ntReg.getNodeTypeDefinition(name);
-                nt = new NodeTypeImpl(ent, def, this, mgrProvider);
-                ntCache.put(name, nt);
+                EffectiveNodeType ent = mgrProvider.getEffectiveNodeTypeProvider().getEffectiveNodeType(ntName);
+                QNodeTypeDefinition def = ntReg.getNodeTypeDefinition(ntName);
+                nt = new NodeTypeImpl(ent, def, mgrProvider);
+                ntCache.put(ntName, nt);
             }
             return nt;
         }
     }
 
     @Override
-    public NamePathResolver getNamePathResolver() {
-        return mgrProvider.getNamePathResolver();
-    }
-
-    /**
-     *
-     * @param nodeTypeName
-     * @return
-     */
-    public boolean hasNodeType(Name nodeTypeName) {
-        boolean isRegistered = ntCache.containsKey(nodeTypeName);
+    public boolean hasNodeType(Name ntName) {
+        boolean isRegistered = ntCache.containsKey(ntName);
         if (!isRegistered) {
-            isRegistered = ntReg.isRegistered(nodeTypeName);
+            isRegistered = ntReg.isRegistered(ntName);
         }
         return isRegistered;
     }
@@ -187,18 +166,16 @@ public class NodeTypeManagerImpl extends
         synchronized (pdCache) {
             PropertyDefinition pdi = pdCache.get(def);
             if (pdi == null) {
-                pdi = new PropertyDefinitionImpl(def, this, getNamePathResolver(), valueFactory);
+                pdi = new PropertyDefinitionImpl(def, this, getNamePathResolver(), mgrProvider.getJcrValueFactory());
                 pdCache.put(def, pdi);
             }
             return pdi;
         }
     }
 
-    /**
-     * @return the NodeTypeRegistry
-     */
-    NodeTypeRegistry getNodeTypeRegistry() {
-        return ntReg;
+    @Override
+    protected NamePathResolver getNamePathResolver() {
+        return mgrProvider.getNamePathResolver();
     }
 
     //-----------------------------------------< NodeTypeDefinitionProvider >---
@@ -324,40 +301,13 @@ public class NodeTypeManagerImpl extends
         return new NodeTypeIteratorAdapter(list);
     }
 
-    @Override
-    public NodeType getNodeType(String nodeTypeName)
-            throws NoSuchNodeTypeException {
-        try {
-            Name qName = getNamePathResolver().getQName(nodeTypeName);
-            return getNodeType(qName);
-        } catch (NamespaceException e) {
-            throw new NoSuchNodeTypeException(nodeTypeName, e);
-        } catch (NameException e) {
-            throw new NoSuchNodeTypeException(nodeTypeName, e);
-        }
-    }
-
-    /**
-     * @see NodeTypeManager#hasNodeType(String)
-     */
-    @Override
-    public boolean hasNodeType(String name) throws RepositoryException {
-        try {
-            Name qName = getNamePathResolver().getQName(name);
-            return hasNodeType(qName);
-        } catch (NamespaceException e) {
-            return false;
-        } catch (NameException e) {
-            return false;
-        }
-    }
-
     /**
      * @see NodeTypeManager#registerNodeTypes(javax.jcr.nodetype.NodeTypeDefinition[], boolean)
      */
     @Override
     public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntDefs, boolean allowUpdate)
             throws RepositoryException {
+        
         List<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>(ntDefs.length);
         for (NodeTypeDefinition definition : ntDefs) {
             QNodeTypeDefinition ntDef = new QNodeTypeDefinitionImpl(definition, getNamePathResolver(),
@@ -369,7 +319,7 @@ public class NodeTypeManagerImpl extends
             defs.add(ntDef);
         }
 
-        getNodeTypeRegistry().registerNodeTypes(defs, allowUpdate);
+        ntReg.registerNodeTypes(defs, allowUpdate);
 
         List<NodeType> nts = new ArrayList<NodeType>();
         for (QNodeTypeDefinition def : defs) {
@@ -388,7 +338,8 @@ public class NodeTypeManagerImpl extends
         for (String name : names) {
             ntNames.add(getNamePathResolver().getQName(name));
         }
-        getNodeTypeRegistry().unregisterNodeTypes(ntNames);
+        
+        ntReg.unregisterNodeTypes(ntNames);
     }
 
     //-------------------------------------------------------------< Object >---

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java
Tue Sep 13 16:13:17 2011
@@ -39,8 +39,7 @@ public interface NodeTypeRegistry {
      * @throws NoSuchNodeTypeException if a node type with the given name
      *                                 does not exist
      */
-    QNodeTypeDefinition getNodeTypeDefinition(Name nodeTypeName)
-            throws NoSuchNodeTypeException;
+    QNodeTypeDefinition getNodeTypeDefinition(Name nodeTypeName) throws NoSuchNodeTypeException;
 
     /**
      * Add a {@code NodeTypeRegistryListener}

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
Tue Sep 13 16:13:17 2011
@@ -16,18 +16,14 @@
  */
 package org.apache.jackrabbit.jcr2spi.operation;
 
-import javax.jcr.AccessDeniedException;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.version.VersionException;
-
 import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
+import javax.jcr.RepositoryException;
+
 /**
  * {@code SetMixin}...
  */
@@ -111,8 +107,7 @@ public class SetMixin extends TransientO
 
     //------------------------------------------------------------< Factory >---
 
-    public static Operation create(NodeState nodeState, Name[] mixinNames)
-            throws RepositoryException {
+    public static Operation create(NodeState nodeState, Name[] mixinNames) throws RepositoryException
{
         if (nodeState == null || mixinNames == null) {
             throw new IllegalArgumentException();
         }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
Tue Sep 13 16:13:17 2011
@@ -63,7 +63,7 @@ public class QueryManagerImpl implements
      * @throws RepositoryException if an error occurs while initializing this
      *                             query manager.
      */
-    public QueryManagerImpl(Session session, ManagerProvider mgrProvider) throws RepositoryException
{
+    public QueryManagerImpl(Session session, ManagerProvider mgrProvider) {
         this.session = session;
         valueFactory = mgrProvider.getJcrValueFactory();
         this.mgrProvider = mgrProvider;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeType.java
Tue Sep 13 16:13:17 2011
@@ -30,6 +30,7 @@ import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.RepositoryException;
 import javax.jcr.NamespaceException;
@@ -46,24 +47,25 @@ public abstract class AbstractNodeType i
      */
     private static final Logger log = LoggerFactory.getLogger(AbstractNodeType.class);
 
-    protected final AbstractNodeTypeManager ntMgr;
-
     protected final QNodeTypeDefinition ntd;
-
-    protected final NamePathResolver resolver;
+    private final NamePathResolver npResolver;
+    private final NodeTypeResolver nodeTypeResolver;
+    private final NodeTypeManager nodeTypeManager;
 
     /**
      * Create a new {@code AbstractNodeType}.
      *
      * @param ntd      the underlying node type definition.
-     * @param ntMgr    the node type manager.
-     * @param resolver the name/path resolver of the session that created this
+     * @param npResolver the name/path resolver of the session that created this
      *                 node type instance.
      */
-    protected AbstractNodeType(QNodeTypeDefinition ntd, AbstractNodeTypeManager ntMgr, NamePathResolver
resolver) {
+    protected AbstractNodeType(QNodeTypeDefinition ntd, NamePathResolver npResolver, NodeTypeResolver
nodeTypeResolver,
+            NodeTypeManager nodeTypeManager) {
+
         this.ntd = ntd;
-        this.ntMgr = ntMgr;
-        this.resolver = resolver;
+        this.npResolver = npResolver;
+        this.nodeTypeResolver = nodeTypeResolver;
+        this.nodeTypeManager = nodeTypeManager;
     }
 
     /**
@@ -80,7 +82,7 @@ public abstract class AbstractNodeType i
     @Override
     public String getName() {
         try {
-            return resolver.getJCRName(ntd.getName());
+            return npResolver.getJCRName(ntd.getName());
         } catch (NamespaceException e) {
             // should never get here
             log.error("encountered unregistered namespace in node type name", e);
@@ -109,7 +111,7 @@ public abstract class AbstractNodeType i
         String[] supertypes = new String[ntNames.length];
         for (int i = 0; i < ntNames.length; i++) {
             try {
-                supertypes[i] = resolver.getJCRName(ntNames[i]);
+                supertypes[i] = npResolver.getJCRName(ntNames[i]);
             } catch (NamespaceException e) {
                 // should never get here
                 log.error("encountered unregistered namespace in node type name", e);
@@ -125,7 +127,7 @@ public abstract class AbstractNodeType i
         NodeType[] supertypes = new NodeType[ntNames.length];
         for (int i = 0; i < ntNames.length; i++) {
             try {
-                supertypes[i] = ntMgr.getNodeType(ntNames[i]);
+                supertypes[i] = nodeTypeResolver.getNodeType(ntNames[i]);
             } catch (NoSuchNodeTypeException e) {
                 // should never get here
                 log.error("undefined supertype", e);
@@ -156,7 +158,7 @@ public abstract class AbstractNodeType i
         QNodeDefinition[] defs = ntd.getChildNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[defs.length];
         for (int i = 0; i < defs.length; i++) {
-            nodeDefs[i] = ntMgr.getNodeDefinition(defs[i]);
+            nodeDefs[i] = nodeTypeResolver.getNodeDefinition(defs[i]);
         }
         return nodeDefs;
     }
@@ -167,7 +169,7 @@ public abstract class AbstractNodeType i
         try {
             Name piName = ntd.getPrimaryItemName();
             if (piName != null) {
-                return resolver.getJCRName(piName);
+                return npResolver.getJCRName(piName);
             } else {
                 return null;
             }
@@ -186,7 +188,7 @@ public abstract class AbstractNodeType i
         QPropertyDefinition[] pda = ntd.getPropertyDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = ntMgr.getPropertyDefinition(pda[i]);
+            propDefs[i] = nodeTypeResolver.getPropertyDefinition(pda[i]);
         }
         return propDefs;
     }
@@ -195,7 +197,7 @@ public abstract class AbstractNodeType i
     public boolean isNodeType(String nodeTypeName) {
         Name ntName;
         try {
-            ntName = resolver.getQName(nodeTypeName);
+            ntName = npResolver.getQName(nodeTypeName);
         } catch (NamespaceException e) {
             log.warn("invalid node type name: " + nodeTypeName, e);
             return false;
@@ -233,7 +235,7 @@ public abstract class AbstractNodeType i
     public NodeTypeIterator getSubtypes(boolean directOnly) {
         NodeTypeIterator nts;
         try {
-            nts = ntMgr.getAllNodeTypes();
+            nts = nodeTypeManager.getAllNodeTypes();
         } catch (RepositoryException e) {
             // should never get here
             log.error("failed to retrieve registered node types", e);

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java?rev=1170225&r1=1170224&r2=1170225&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/AbstractNodeTypeManager.java
Tue Sep 13 16:13:17 2011
@@ -17,53 +17,40 @@
 package org.apache.jackrabbit.spi.commons.nodetype;
 
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.QNodeDefinition;
-import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
+import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
-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;
 
 /**
  * {@code AbstractNodeTypeManager} covers creation of node type templates
  * and definition templates.
  */
-public abstract class AbstractNodeTypeManager implements NodeTypeManager {
+public abstract class AbstractNodeTypeManager implements NodeTypeManager, NodeTypeResolver
{
 
     /**
-     * Return the node type with the specified {@code ntName}.
-     *
-     * @param ntName Name of the node type to be returned.
-     * @return the node type with the specified {@code ntName}.
-     * @throws NoSuchNodeTypeException If no such node type exists.
-     */
-    public abstract NodeType getNodeType(Name ntName) throws NoSuchNodeTypeException;
-
-    /**
-     * Retrieve the {@code NodeDefinition} for the given
-     * {@code QNodeDefinition}.
-     *
-     * @param nd the QNodeDefinition.
-     * @return the node definition.
-     */
-    public abstract NodeDefinition getNodeDefinition(QNodeDefinition nd);
+     * Determine whether a node type of the specified {@code ntName} exists.
 
-    /**
-     * Retrieve the {@code PropertyDefinition} for the given
-     * {@code QPropertyDefinition}.
-     *
-     * @param pd the QPropertyDefinition.
-     * @return the property definition.
+     * @param ntName
+     * @return
      */
-    public abstract PropertyDefinition getPropertyDefinition(QPropertyDefinition pd);
+    protected boolean hasNodeType(Name ntName) {
+        try {
+            getNodeType(ntName);
+            return true;
+        }
+        catch (NoSuchNodeTypeException e) {
+            return false;
+        }
+    }
 
     /**
      * Returns the NamePathResolver used to validate JCR names.
@@ -72,10 +59,37 @@ public abstract class AbstractNodeTypeMa
      * onces and vice versa. The resolver may also be used to validate names
      * passed to the various templates.
      */
-    public abstract NamePathResolver getNamePathResolver();
+    protected abstract NamePathResolver getNamePathResolver();
 
     //----------------------------------------------------< NodeTypeManager >---
 
+    @Override
+    public NodeType getNodeType(String ntName) throws NoSuchNodeTypeException {
+        try {
+            Name qName = getNamePathResolver().getQName(ntName);
+            return getNodeType(qName);
+        } catch (NamespaceException e) {
+            throw new NoSuchNodeTypeException(ntName, e);
+        } catch (NameException e) {
+            throw new NoSuchNodeTypeException(ntName, e);
+        }
+    }
+
+    /**
+     * @see NodeTypeManager#hasNodeType(String)
+     */
+    @Override
+    public boolean hasNodeType(String ntName) throws RepositoryException {
+        try {
+            Name qName = getNamePathResolver().getQName(ntName);
+            return hasNodeType(qName);
+        } catch (NamespaceException e) {
+            return false;
+        } catch (NameException e) {
+            return false;
+        }
+    }
+
     /**
      * @see javax.jcr.nodetype.NodeTypeManager#createNodeTypeTemplate()
      */

Added: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeResolver.java?rev=1170225&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeResolver.java
(added)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeResolver.java
Tue Sep 13 16:13:17 2011
@@ -0,0 +1,38 @@
+package org.apache.jackrabbit.spi.commons.nodetype;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+
+public interface NodeTypeResolver {
+
+    /**
+     * Return the node type with the specified {@code ntName}.
+     *
+     * @param ntName Name of the node type to be returned.
+     * @return the node type with the specified {@code ntName}.
+     * @throws javax.jcr.nodetype.NoSuchNodeTypeException If no such node type exists.
+     */
+    NodeType getNodeType(Name ntName) throws NoSuchNodeTypeException;
+
+    /**
+     * Retrieve the {@code NodeDefinition} for the given {@code QNodeDefinition}.
+     *
+     * @param nd the QNodeDefinition.
+     * @return the node definition.
+     */
+    NodeDefinition getNodeDefinition(QNodeDefinition nd);
+
+    /**
+     * Retrieve the {@code PropertyDefinition} for the given {@code QPropertyDefinition}.
+     *
+     * @param pd the QPropertyDefinition.
+     * @return the property definition.
+     */
+    PropertyDefinition getPropertyDefinition(QPropertyDefinition pd);
+}



Mime
View raw message