001 package org.jboss.dna.jcr; 002 003 import javax.jcr.nodetype.NodeType; 004 import org.jboss.dna.graph.Graph; 005 006 /** 007 * Interface for any potential provider of {@link JcrNodeType} definitions, the DNA implementation of {@link NodeType}. Possible 008 * sources of node type definitions include CND files, repository metadata, and mock types for testing. 009 * 010 * @see JcrWorkspace#getNodeTypeManager() 011 */ 012 public interface JcrNodeTypeSource { 013 014 /** 015 * Returns the node type information to be registered in graph form. The graph has a very specific required format. 016 * <p> 017 * The root node of the graph should have zero or more children. Each child of the root node represents a type to be 018 * registered and the name of the node should be the name of the node type to be registered. Additionally, any facets of the 019 * node type that are specified should be set in a manner consistent with the JCR specification for the {@code nt:nodeType} 020 * built-in node type. The {@code jcr:primaryType} property does not need to be set on these nodes, but the nodes must be 021 * semantically valid as if the {@code jcr:primaryType} property was set. 022 * </p> 023 * <p> 024 * Each node type node may have zero or more children, each with the name {@code jcr:propertyDefinition} or {@code 025 * jcr:childNodeDefinition}, as per the definition of the {@code nt:nodeType} built-in type. Each property definition and 026 * child node definition must obey the semantics of {@code jcr:propertyDefinition} and {@code jcr:childNodeDefinition} 027 * respectively However these nodes also do not need to have the {@code jcr:primaryType} property set. 028 * </p> 029 * <p> 030 * For example, one valid graph is: 031 * 032 * <pre> 033 * <root> 034 * +---- test:testMixinType 035 * +--- jcr:nodeTypeName = test:testMixinType (PROPERTY) 036 * +--- jcr:isMixin = true (PROPERTY) 037 * +--- jcr:childNodeDefinition (CHILD NODE) 038 * | +--- jcr:name = test:childNodeA (PROPERTY) 039 * | +--- jcr:mandatory = true (PROPERTY) 040 * | +--- jcr:autoCreated = true (PROPERTY) 041 * | +--- jcr:defaultPrimaryType = nt:base (PROPERTY) 042 * | +--- jcr:requiredPrimaryTypes = nt:base (PROPERTY) 043 * +--- jcr:propertyDefinition (CHILD NODE) 044 * +--- jcr:name = test:propertyA (PROPERTY) 045 * +--- jcr:multiple = true (PROPERTY) 046 * +--- jcr:requiredType = String (PROPERTY) 047 * </pre> 048 * 049 * This graph (when registered) would create a mixin node named "test:testMixinType" with a mandatory, autocreated child node 050 * named "test:childNodeA" with a default and required primary type of "nt:base" and a multi-valued string property named 051 * "test:propertyA". 052 * </p> 053 * 054 * @return a graph with the semantics noted above 055 */ 056 Graph getNodeTypes(); 057 }