org.apache.jackrabbit.jcr2spi.nodetype
Class NodeTypeRegistryImpl

java.lang.Object
  extended by org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistryImpl
All Implemented Interfaces:
EffectiveNodeTypeProvider, NodeTypeRegistry, Dumpable

public class NodeTypeRegistryImpl
extends Object
implements Dumpable, NodeTypeRegistry, EffectiveNodeTypeProvider

A NodeTypeRegistry ...


Method Summary
 void addListener(NodeTypeRegistryListener listener)
          Add a NodeTypeRegistryListener
static NodeTypeRegistryImpl create(NodeTypeStorage storage, NamespaceRegistry nsRegistry)
          Create a new NodeTypeRegistry
 void dispose()
          Clears all caches.
 void dump(PrintStream ps)
          Dumps the state of this instance in a human readable format for diagnostic purposes.
 EffectiveNodeType getEffectiveNodeType(Name ntName)
          Build the EffectiveNodeType from the given qualified NodeType name.
 EffectiveNodeType getEffectiveNodeType(Name[] ntNames)
          Build the EffectiveNodeType from the given qualified NodeType names.
 EffectiveNodeType getEffectiveNodeType(Name[] ntNames, Map ntdMap)
           
 EffectiveNodeType getEffectiveNodeType(QNodeTypeDefinition ntd, Map ntdMap)
          Builds an effective node type representation from the given node type definition.
 QNodeTypeDefinition getNodeTypeDefinition(Name nodeTypeName)
          Returns the node type definition of the node type with the given name.
 Name[] getRegisteredNodeTypes()
          Returns the names of all registered node types.
 boolean isRegistered(Name nodeTypeName)
           
 EffectiveNodeType registerNodeType(QNodeTypeDefinition ntDef)
          Validates the NodeTypeDef and returns a registered EffectiveNodeType instance.
 void registerNodeTypes(Collection ntDefs)
          Same as NodeTypeRegistry.registerNodeType(QNodeTypeDefinition) except that a collection of NodeTypeDefs is registered instead of just one.
 void removeListener(NodeTypeRegistryListener listener)
          Remove a NodeTypeRegistryListener
 EffectiveNodeType reregisterNodeType(QNodeTypeDefinition ntd)
           
 void unregisterNodeType(Name nodeTypeName)
           
 void unregisterNodeTypes(Collection nodeTypeNames)
          Same as NodeTypeRegistry.unregisterNodeType(Name) except that a set of node types is unregistered instead of just one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static NodeTypeRegistryImpl create(NodeTypeStorage storage,
                                          NamespaceRegistry nsRegistry)
Create a new NodeTypeRegistry

Parameters:
storage -
nsRegistry -
Returns:
NodeTypeRegistry object

dispose

public void dispose()
Clears all caches.


addListener

public void addListener(NodeTypeRegistryListener listener)
Description copied from interface: NodeTypeRegistry
Add a NodeTypeRegistryListener

Specified by:
addListener in interface NodeTypeRegistry
Parameters:
listener - the new listener to be informed on (un)registration of node types
See Also:
NodeTypeRegistry.addListener(NodeTypeRegistryListener)

removeListener

public void removeListener(NodeTypeRegistryListener listener)
Description copied from interface: NodeTypeRegistry
Remove a NodeTypeRegistryListener

Specified by:
removeListener in interface NodeTypeRegistry
Parameters:
listener - an existing listener
See Also:
NodeTypeRegistry.removeListener(NodeTypeRegistryListener)

getRegisteredNodeTypes

public Name[] getRegisteredNodeTypes()
                              throws RepositoryException
Description copied from interface: NodeTypeRegistry
Returns the names of all registered node types. That includes primary and mixin node types.

Specified by:
getRegisteredNodeTypes in interface NodeTypeRegistry
Returns:
the names of all registered node types.
Throws:
RepositoryException
See Also:
NodeTypeRegistry.getRegisteredNodeTypes()

isRegistered

public boolean isRegistered(Name nodeTypeName)
Specified by:
isRegistered in interface NodeTypeRegistry
Returns:
See Also:
NodeTypeRegistry.isRegistered(Name)

registerNodeType

public EffectiveNodeType registerNodeType(QNodeTypeDefinition ntDef)
                                   throws InvalidNodeTypeDefException,
                                          RepositoryException
Description copied from interface: NodeTypeRegistry
Validates the NodeTypeDef and returns a registered EffectiveNodeType instance.

The validation includes the following checks:

  • Supertypes must exist and be registered
  • Inheritance graph must not be circular
  • Aggregation of supertypes must not result in name conflicts, ambiguities, etc.
  • Definitions of auto-created properties must specify a name
  • Default values in property definitions must satisfy value constraints specified in the same property definition
  • Definitions of auto-created child-nodes must specify a name
  • Default node type in child-node definitions must exist and be registered
  • The aggregation of the default node types in child-node definitions must not result in name conflicts, ambiguities, etc.
  • Definitions of auto-created child-nodes must not specify default node types which would lead to infinite child node creation (e.g. node type 'A' defines auto-created child node with default node type 'A' ...)
  • Node types specified as constraints in child-node definitions must exist and be registered
  • The aggregation of the node types specified as constraints in child-node definitions must not result in name conflicts, ambiguities, etc.
  • Default node types in child-node definitions must satisfy node type constraints specified in the same child-node definition

Specified by:
registerNodeType in interface NodeTypeRegistry
Parameters:
ntDef - the definition of the new node type
Returns:
an EffectiveNodeType instance
Throws:
InvalidNodeTypeDefException
RepositoryException
See Also:
NodeTypeRegistry.registerNodeType(QNodeTypeDefinition)

registerNodeTypes

public void registerNodeTypes(Collection ntDefs)
                       throws InvalidNodeTypeDefException,
                              RepositoryException
Description copied from interface: NodeTypeRegistry
Same as NodeTypeRegistry.registerNodeType(QNodeTypeDefinition) except that a collection of NodeTypeDefs is registered instead of just one.

This method can be used to register a set of node types that have dependencies on each other.

Note that in the case an exception is thrown, some node types might have been nevertheless successfully registered.

Specified by:
registerNodeTypes in interface NodeTypeRegistry
Parameters:
ntDefs - a collection of NodeTypeDefs
Throws:
InvalidNodeTypeDefException
RepositoryException
See Also:
NodeTypeRegistry.registerNodeTypes(Collection)

unregisterNodeType

public void unregisterNodeType(Name nodeTypeName)
                        throws NoSuchNodeTypeException,
                               RepositoryException
Specified by:
unregisterNodeType in interface NodeTypeRegistry
Throws:
NoSuchNodeTypeException
RepositoryException
See Also:
NodeTypeRegistry.unregisterNodeType(Name)

unregisterNodeTypes

public void unregisterNodeTypes(Collection nodeTypeNames)
                         throws NoSuchNodeTypeException,
                                RepositoryException
Description copied from interface: NodeTypeRegistry
Same as NodeTypeRegistry.unregisterNodeType(Name) except that a set of node types is unregistered instead of just one.

This method can be used to unregister a set of node types that depend on each other.

Specified by:
unregisterNodeTypes in interface NodeTypeRegistry
Parameters:
nodeTypeNames - a collection of Name objects denoting the node types to be unregistered
Throws:
NoSuchNodeTypeException - if any of the specified names does not denote a registered node type.
RepositoryException - if another error occurs
See Also:
NodeTypeRegistry.unregisterNodeTypes(Collection)

reregisterNodeType

public EffectiveNodeType reregisterNodeType(QNodeTypeDefinition ntd)
                                     throws NoSuchNodeTypeException,
                                            InvalidNodeTypeDefException,
                                            RepositoryException
Specified by:
reregisterNodeType in interface NodeTypeRegistry
Returns:
Throws:
NoSuchNodeTypeException
InvalidNodeTypeDefException
RepositoryException
See Also:
NodeTypeRegistry.reregisterNodeType(QNodeTypeDefinition)

getNodeTypeDefinition

public QNodeTypeDefinition getNodeTypeDefinition(Name nodeTypeName)
                                          throws NoSuchNodeTypeException
Description copied from interface: NodeTypeRegistry
Returns the node type definition of the node type with the given name.

Specified by:
getNodeTypeDefinition in interface NodeTypeRegistry
Parameters:
nodeTypeName - name of node type whose definition should be returned.
Returns:
the node type definition of the node type with the given name.
Throws:
NoSuchNodeTypeException - if a node type with the given name does not exist
See Also:
NodeTypeRegistry.getNodeTypeDefinition(Name)

getEffectiveNodeType

public EffectiveNodeType getEffectiveNodeType(Name ntName)
                                       throws NoSuchNodeTypeException
Description copied from interface: EffectiveNodeTypeProvider
Build the EffectiveNodeType from the given qualified NodeType name.

Specified by:
getEffectiveNodeType in interface EffectiveNodeTypeProvider
Returns:
Throws:
NoSuchNodeTypeException
See Also:
EffectiveNodeTypeProvider.getEffectiveNodeType(Name)

getEffectiveNodeType

public EffectiveNodeType getEffectiveNodeType(Name[] ntNames)
                                       throws ConstraintViolationException,
                                              NoSuchNodeTypeException
Description copied from interface: EffectiveNodeTypeProvider
Build the EffectiveNodeType from the given qualified NodeType names.

Specified by:
getEffectiveNodeType in interface EffectiveNodeTypeProvider
Returns:
Throws:
ConstraintViolationException
NoSuchNodeTypeException
See Also:
EffectiveNodeTypeProvider.getEffectiveNodeType(Name[])

getEffectiveNodeType

public EffectiveNodeType getEffectiveNodeType(Name[] ntNames,
                                              Map ntdMap)
                                       throws ConstraintViolationException,
                                              NoSuchNodeTypeException
Specified by:
getEffectiveNodeType in interface EffectiveNodeTypeProvider
Returns:
Throws:
ConstraintViolationException
NoSuchNodeTypeException
See Also:
EffectiveNodeTypeProvider.getEffectiveNodeType(Name[], Map)

getEffectiveNodeType

public EffectiveNodeType getEffectiveNodeType(QNodeTypeDefinition ntd,
                                              Map ntdMap)
                                       throws ConstraintViolationException,
                                              NoSuchNodeTypeException
Description copied from interface: EffectiveNodeTypeProvider
Builds an effective node type representation from the given node type definition. Whereas all referenced node types must exist (i.e. must be present in the specified map), the definition itself is not required to be registered.

Specified by:
getEffectiveNodeType in interface EffectiveNodeTypeProvider
Returns:
Throws:
ConstraintViolationException
NoSuchNodeTypeException
See Also:
EffectiveNodeTypeProvider.getEffectiveNodeType(QNodeTypeDefinition, Map)

dump

public void dump(PrintStream ps)
Dumps the state of this instance in a human readable format for diagnostic purposes.

Specified by:
dump in interface Dumpable
Parameters:
ps - stream to dump state to


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.