[dna-commits] DNA SVN: r1201 - in trunk: docs/reference/src/main/docbook/en-US and 1 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Sep 10 09:42:41 EDT 2009


Author: rhauch
Date: 2009-09-10 09:42:41 -0400 (Thu, 10 Sep 2009)
New Revision: 1201

Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java
   trunk/docs/reference/src/main/docbook/en-US/content/jcr/jcr.xml
   trunk/docs/reference/src/main/docbook/en-US/custom.dtd
Log:
DNA-516 Reference Guide example that defines node types programmatically has several typos

Corrected the faulty sections, and added a bit more detail to the same sections.

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java	2009-09-10 01:13:24 UTC (rev 1200)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java	2009-09-10 13:42:41 UTC (rev 1201)
@@ -40,7 +40,7 @@
 
 /**
  * Class to parse one or more Compact Node Definition (CND) files containing custom node type definitions into a format that can
- * be registered with the {@link RepositoryNodeTypeManager}.
+ * be registered with the {@link JcrNodeTypeManager}.
  * <p>
  * The class contains methods for determining whether the CND files were parsed successfully and what errors occurred. Typically,
  * the class will be used like this:
@@ -55,7 +55,7 @@
  *      // Report problems
  *  }
  *  else {
- *      repositoryNodeTypeManager.registerNodeTypes(nodeTypeSource);
+ *      jcrNodeTypeManager.registerNodeTypes(nodeTypeSource);
  *  }
  * }
  * catch (IOException ioe) {

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java	2009-09-10 01:13:24 UTC (rev 1200)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java	2009-09-10 13:42:41 UTC (rev 1201)
@@ -48,7 +48,7 @@
 
 /**
  * Class to convert one or more {@link NodeTypeTemplate node type templates} containing custom node type definitions into a format
- * that can be registered with the {@link RepositoryNodeTypeManager}.
+ * that can be registered with the {@link JcrNodeTypeManager}.
  * <p>
  * As the JSR-283 specification mandates that node type templates be the standard basis for custom type registration, the
  * {@link RepositoryNodeTypeManager#registerNodeTypes(java.util.Collection, boolean)} method should be used in preference to

Modified: trunk/docs/reference/src/main/docbook/en-US/content/jcr/jcr.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/jcr/jcr.xml	2009-09-10 01:13:24 UTC (rev 1200)
+++ trunk/docs/reference/src/main/docbook/en-US/content/jcr/jcr.xml	2009-09-10 13:42:41 UTC (rev 1201)
@@ -247,60 +247,66 @@
 				Both type registration mechanisms are supported equally within JBoss DNA, although the CND approach for defining node types is recommended.
 				<note>
 					<para>JBoss DNA also supports defining custom node types to load at startup.  This is discussed in more detail
-					in the next chapter.
+					in the <link linkend="programmatically_configuring_repositories">previous chapter</link>.
 					</para>
 				</note>
 			</para>
 			<para>
-				Although the JSR-283 specification is not yet final, it does provide a useful means of programatically defining JCR node types.  JBoss DNA supports a comparable
-				node type definition API that implements the functionality from the specification, albeit with classes in an <code>org.jboss.dna.jcr</code> package.  The intent
-				is to deprecate these classes and replace their usage with the JSR-283 equivalents after JBoss DNA fully supports in the JSR-283 specification in a future release.
+				Although the JSR-283 specification is not yet final, it does provide a useful means of programmatically defining JCR node types.  JBoss DNA supports a comparable
+				node type definition API that implements the functionality from the specification, albeit with interfaces in the <code>org.jboss.dna.jcr.nodetype</code> package.  
+				The intent is to deprecate these classes and replace their usage with the JSR-283 equivalents when JBoss DNA fully supports
+				the JSR-283 final adopted specification in a future release.
+			</para>
+			<para>
 				Node types can be defined like so:
 	    <programlisting>
 &Session; session = ... ;
-NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
 
+// Obtain the DNA-specific node type manager ...
+&JcrNodeTypeManager; nodeTypeManager = (JcrNodeTypeManager) session.getWorkspace().getNodeTypeManager();
+
 // Declare a mixin node type named "searchable" (with no namespace)
-NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate();
+&NodeTypeTemplate; nodeType = nodeTypeManager.createNodeTypeTemplate();
 nodeType.setName("searchable");
 nodeType.setMixin(true);
-nodeType.getNodeDefinitionTemplates().add(childNode);
 
 // Add a mandatory child named "source" with a required primary type of "nt:file" 
-NodeDefinitionTemplate childNode = nodeTypeManager.createNodeDefinitionTemplate();
+&NodeDefinitionTemplate; childNode = nodeTypeManager.createNodeDefinitionTemplate();
 childNode.setName("source");
 childNode.setMandatory(true);
-childNode.setRequiredPrimaryTypeNames(new String[] { "nt:file" });
+childNode.setRequiredPrimaryTypes(new String[] { "nt:file" });
 childNode.setDefaultPrimaryType("nt:file");
+nodeType.getNodeDefinitionTemplates().add(childNode);
 
 // Add a multi-valued STRING property named "keywords"
-PropertyDefinitionTemplate property = nodeTypeManager.createPropertyDefinitionTemplate();
+&PropertyDefinitionTemplate; property = nodeTypeManager.createPropertyDefinitionTemplate();
 property.setName("keywords");
 property.setMultiple(true);
 property.setRequiredType(PropertyType.STRING);
 nodeType.getPropertyDefinitionTemplates().add(property);
 
 // Register the custom node type
-nodeTypeManager.registerNodeType(nodeType);
+nodeTypeManager.registerNodeType(nodeType,false);
 </programlisting>	
 			Residual properties and child node definitions can also be defined simply by not calling <code>setName</code> on 
 			the template.
 			</para>
 			<para>
 			Custom node types can be defined more succinctly through the &CND; file format.  In fact, this is how JBoss
-			DNA defines its built-in node types.  An example CND file that declares the same node type as above would be:
+			DNA defines its built-in node types. An example CND file that declares the same node type as above would be:
 <programlisting>
 [searchable] mixin
 - keywords (string) multiple
 + source (nt:file) = nt:file
 </programlisting>	
-			This definition could then be registered with the following code snippet.
+			This definition could then be registered as part of the repository configuration, using the &JcrConfiguration; class
+			(see the <link linkend="programmatically_configuring_repositories">previous chapter</link>).  Or, you can also
+			use a Session to declare the node types in a CDN file, but this also requires DNA-specific interfaces and classes:
 <programlisting>
-
 String pathToCndFileInClassLoader = ...;
-CndNodeTypeSource nodeTypeSource = new CndNodeTypeSource(pathToCndFileInClassLoader);
+&CndNodeTypeSource; nodeTypeSource = new &CndNodeTypeSource;(pathToCndFileInClassLoader);
 
-for (Problem problem : nodeTypeSource.getProblems()) {
+for (&Problem; problem : nodeTypeSource.getProblems()) {
     System.err.println(problem);
 }
 if (!nodeTypeSource.isValid()) {
@@ -308,9 +314,12 @@
 }
 
 &Session; session = ... ;
-NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
+// Obtain the DNA-specific node type manager ...
+&JcrNodeTypeManager; nodeTypeManager = (JcrNodeTypeManager) session.getWorkspace().getNodeTypeManager();
 nodeTypeManager.registerNodeTypes(nodeTypeSource);
 </programlisting>
+    The &CndNodeTypeSource; class actually implements the &JcrNodeTypeSource; interface, so other implementations can actually be defined.
+    For more information, see the JavaDoc for &JcrNodeTypeSource;.
 				<note>
 					<para> JBoss DNA does not yet support a simple means of unregistering types at this time, so be careful before registering types outside of a 
 					sandboxed environment.

Modified: trunk/docs/reference/src/main/docbook/en-US/custom.dtd
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/custom.dtd	2009-09-10 01:13:24 UTC (rev 1200)
+++ trunk/docs/reference/src/main/docbook/en-US/custom.dtd	2009-09-10 13:42:41 UTC (rev 1201)
@@ -180,6 +180,13 @@
 <!ENTITY JcrRepository			       		"<ulink url='&API;jcr/JcrRepository.html'><classname>JcrRepository</classname></ulink>">
 <!ENTITY JcrSession					       		"<ulink url='&API;jcr/JcrSession.html'><classname>JcrSession</classname></ulink>">
 <!ENTITY SecurityContextCredentials   "<ulink url='&API;jcr/SecurityContextCredentials.html'><classname>SecurityContextCredentials</classname></ulink>">
+<!ENTITY JcrNodeTypeManager       		"<ulink url='&API;jcr/JcrNodeTypeManager.html'><classname>JcrNodeTypeManager</classname></ulink>">
+<!ENTITY NodeTypeTemplate          		"<ulink url='&API;jcr/nodetype/NodeTypeTemplate.html'><interface>NodeTypeTemplate</interface></ulink>">
+<!ENTITY PropertyDefinitionTemplate		"<ulink url='&API;jcr/nodetype/PropertyDefinitionTemplate.html'><interface>PropertyDefinitionTemplate</interface></ulink>">
+<!ENTITY NodeDefinitionTemplate    		"<ulink url='&API;jcr/nodetype/NodeDefinitionTemplate.html'><interface>NodeDefinitionTemplate</interface></ulink>">
+<!ENTITY NodeTypeDefinition        		"<ulink url='&API;jcr/nodetype/NodeTypeDefinition.html'><interface>NodeTypeDefinition</interface></ulink>">
+<!ENTITY JcrNodeTypeSource        		"<ulink url='&API;jcr/JcrNodeTypeSource.html'><interface>JcrNodeTypeSource</interface></ulink>">
+<!ENTITY CndNodeTypeSource        		"<ulink url='&API;jcr/CndNodeTypeSource.html'><classname>CndNodeTypeSource</classname></ulink>">
 
 <!-- Types in extensions/ -->
 



More information about the dna-commits mailing list