Node type registration extension is declared in org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager interface
Your custom service can register some neccessary predefined node types at the start-up time. The node definition should be placed in a special XML file (see DTD below) and declared in the service's configuration file thanks to eXo component plugin mechanism, described as follows:
<external-component-plugins>
<target-component>org.exoplatform.services.jcr.RepositoryService</target-component>
<component-plugin>
<name>add.nodeType</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
<init-params>
<values-param>
<name>autoCreatedInNewRepository</name>
<description>Node types configuration file</description>
<value>jar:/conf/test/nodetypes-tck.xml</value>
<value>jar:/conf/test/nodetypes-impl.xml</value>
</values-param>
<values-param>
<name>repo1</name>
<description>Node types configuration file for repository with name repo1</description>
<value>jar:/conf/test/nodetypes-test.xml</value>
</values-param>
<values-param>
<name>repo2</name>
<description>Node types configuration file for repository with name repo2</description>
<value>jar:/conf/test/nodetypes-test2.xml</value>
</values-param>
</init-params>
</component-plugin>
There are two types of registration. The first type is the registration of node types in all created repositories, it is configured in values-param with the name autoCreatedInNewRepository. The second type is registration of node types in specified repository and it is configured in values-param with the name of repository.
Node type definition file format:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE nodeTypes [
<!ELEMENT nodeTypes (nodeType)*>
<!ELEMENT nodeType (supertypes?|propertyDefinitions?|childNodeDefinitions?)>
<!ATTLIST nodeType
name CDATA #REQUIRED
isMixin (true|false) #REQUIRED
hasOrderableChildNodes (true|false)
primaryItemName CDATA
>
<!ELEMENT supertypes (supertype*)>
<!ELEMENT supertype (CDATA)>
<!ELEMENT propertyDefinitions (propertyDefinition*)>
<!ELEMENT propertyDefinition (valueConstraints?|defaultValues?)>
<!ATTLIST propertyDefinition
name CDATA #REQUIRED
requiredType (String|Date|Path|Name|Reference|Binary|Double|Long|Boolean|undefined) #REQUIRED
autoCreated (true|false) #REQUIRED
mandatory (true|false) #REQUIRED
onParentVersion (COPY|VERSION|INITIALIZE|COMPUTE|IGNORE|ABORT) #REQUIRED
protected (true|false) #REQUIRED
multiple (true|false) #REQUIRED
>
<!-- For example if you need to set ValueConstraints [],
you have to add an empty element <valueConstraints/>.
The same order is for other properties like defaultValues, requiredPrimaryTypes etc.
-->
<!ELEMENT valueConstraints (valueConstraint*)>
<!ELEMENT valueConstraint (CDATA)>
<!ELEMENT defaultValues (defaultValue*)>
<!ELEMENT defaultValue (CDATA)>
<!ELEMENT childNodeDefinitions (childNodeDefinition*)>
<!ELEMENT childNodeDefinition (requiredPrimaryTypes)>
<!ATTLIST childNodeDefinition
name CDATA #REQUIRED
defaultPrimaryType CDATA #REQUIRED
autoCreated (true|false) #REQUIRED
mandatory (true|false) #REQUIRED
onParentVersion (COPY|VERSION|INITIALIZE|COMPUTE|IGNORE|ABORT) #REQUIRED
protected (true|false) #REQUIRED
sameNameSiblings (true|false) #REQUIRED
>
<!ELEMENT requiredPrimaryTypes (requiredPrimaryType+)>
<!ELEMENT requiredPrimaryType (CDATA)>
]>