You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2015/09/27 11:04:14 UTC

svn commit: r1705517 - /sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/NodeTypeDefinitionScanner.java

Author: sseifert
Date: Sun Sep 27 09:04:13 2015
New Revision: 1705517

URL: http://svn.apache.org/viewvc?rev=1705517&view=rev
Log:
SLING-5064 sling-mock: Register JCR node types for OSGi bundles in class path

Modified:
    sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/NodeTypeDefinitionScanner.java

Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/NodeTypeDefinitionScanner.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/NodeTypeDefinitionScanner.java?rev=1705517&r1=1705516&r2=1705517&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/NodeTypeDefinitionScanner.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/NodeTypeDefinitionScanner.java Sun Sep 27 09:04:13 2015
@@ -44,6 +44,11 @@ import org.apache.jackrabbit.commons.cnd
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * Singleton class that fetches all node type definitions from OSGi bundle MANIFEST.MF files
+ * with "Sling-Nodetypes" definitions in the classpath.
+ * Additionally it support registering them to a JCR repository. 
+ */
 public final class NodeTypeDefinitionScanner {
     
     private static final NodeTypeDefinitionScanner SINGLETON = new NodeTypeDefinitionScanner();
@@ -101,6 +106,15 @@ public final class NodeTypeDefinitionSca
       }
     }
     
+    /**
+     * Register node types found in classpath in JCR repository, and remove those that succeeded to register from the list.
+     * @param nodeTypeResources List of nodetype classpath resources
+     * @param classLoader
+     * @param nodeTypeManager
+     * @param namespaceRegistry
+     * @param valueFactory
+     * @param logError if true, and error is logged if node type registration failed. Otherwise it is ignored.
+     */
     private void registerAndRemoveSucceeds(List<String> nodeTypeResources, ClassLoader classLoader,
             NodeTypeManager nodeTypeManager, NamespaceRegistry namespaceRegistry, ValueFactory valueFactory,
             boolean logError) {
@@ -127,6 +141,13 @@ public final class NodeTypeDefinitionSca
         }
     }
     
+    /**
+     * Find all node type definition classpath paths by searching all MANIFEST.MF files in the classpath and reading
+     * the paths from the "Sling-Nodetypes" entry.
+     * The order of the paths from each entry is preserved, but the overall order when multiple bundles define such an entry
+     * is not deterministic and may not be correct according to the dependencies between the node type definitions.
+     * @return List of node type definition class paths
+     */
     private static List<String> findeNodeTypeDefinitions() {
         List<String> nodeTypeDefinitions = new ArrayList<String>();
         try {