Diff between jcr:primaryType and jcr:mixinTypes

There are two categories of node types, primary and mixin. Every node has a primary node type assigned to it upon creation. In addition, a mixin node type may be added to a node later in its lifecycle.

The primary node type of a node usually defines node structure (i.e., allowed and required child nodes and properties) & Mixin node types usually specify additional properties or child nodes related to a capability being added to the node.
These capabilities may include generic repository-level functions as in the case of the built-in mixins mix:versionable and mix:lockable, for example, or domain-level capabilities such as a (hypothetical) myapp:Emailable mixin type that adds the property myapp:emailAddress to a node.

Below are some noticeable differences in both.

1:- Mixin Types are similar to interfaces, one node could have multiple mixin types.You can think of it as interfaces in Object Oriented world since a node can have multiple ones and they aim
to add aditionnal properties (state/instance variable in OO world) to that node. e.g: mix:versionable, mix:referenceable
2:-The jcr:mixinTypes property is a multi-value one.
3:-The node can get a mixin type added programatically with node.addMixin('some-mixin-type').
4:-When a node is created, its jcr:primaryType property is automatically created and set to the name of the assigned primary node type. When a mixin type is assigned, its name is added to the multi-valued jcr:mixinTypes property, which is created if it does not yet exist.

Below is the /content/dam node under which all the aem assets resides. This node has jcr:primaryType as sling:Folder but jcr:mixinTypes as rep:AccessControllable.



Similarly when we create i18n language nodes we provide jcr:mixinTypes.


Comments

Popular posts from this blog

AEM Scheduler

AEM Sling Servlet

Event Handling in AEM