Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between jcr:primaryType and jcr:mixinTypes?

Tags:

jcr

aem

I am just curious to know what is the difference between jcr:primaryType and jcr:mixinTypes, and why exactly does jcr:mixinTypes is used ? what does it signifies ? If you check /content/dam folder in crx it shows jcr:primaryType property value as sling:OrderedFolder and jcr:mixinTypes as mix:lockable,rep:AccessControllable where jcr:primaryType means this a sling folder but why mixin type. Also went through these docs http://www.day.com/specs/jcr/1.0/6.7.4_Primary_and_Mixin_Node_Types.html http://www.day.com/specs/jcr/1.0/6.7.5_Special_Properties_jcr_primaryType_and_jcr_mixinTypes.html but yet doesn't gives much insight to the difference.

Thanks.

like image 776
yash ahuja Avatar asked Apr 15 '14 09:04

yash ahuja


People also ask

What is jcr mixinTypes?

The jcr:mixinTypes property is a multi-value one (not a single property value but can have a list) and basically talking can be empty at node's creation since it is not a mondatory property and a node can have no jcr:mixinType at all.

What is NT base in AEM?

The nt:base type is the base type of all primary node types. It is also the only node type that is required by the JSR 170 specification to be available in all content repositories. The defined jcr:primaryType and jcr:mixinTypes properties are protected and can only be read using the normal property access methods.

What are Mixins in AEM?

A mixin type is similar to a primary type in that its definition has the same parameters. It differs, though, in that it provides additional features to a node, beyond those defined in the node type proper.


2 Answers

A Node can have only one jcr:primaryType but it can have several jcr:mixinTypes, so it is correct to see the mixins as "traits" or additional aspects of a node.

While http://wiki.apache.org/jackrabbit/DavidsModel "Data First, Structure Later. Maybe" rule recommends using primary node types sparingly due to the strong constraints that they usually imply, mixins are much less constraining and very useful to identify nodes as having specific uses or properties.

The mix:lockable mixin that you mention, for example, is used to express that a node can be locked. As per http://www.day.com/specs/jcr/2.0/17_Locking.html, only nodes with mixin node type mix:lockable may hold locks. Any type of node can potentially be locked, so using a node type for that wouldn't work.

like image 87
Bertrand Delacretaz Avatar answered Oct 04 '22 00:10

Bertrand Delacretaz


First you should note that both properties jcr:primaryType and jcr:mixinTypes are defined in the super node nt:base then inherited by all other nodes.

The jcr:primaryType property specifies the base type of a node and will be assigned at node's creation time and you can think of it as the BASE class of an object in OO world. It can be done programatically with Node.setPrimaryType('some-primary-type') e.g: nt:file, nt:unstructured...

The jcr:mixinTypes property is a multi-value one (not a single property value but can have a list) and basically talking can be empty at node's creation since it is not a mondatory property and a node can have no jcr:mixinType at all. The node can get a mixin type added programatically with node.addMixin('some-mixin-type'). You can think of it as interfaces in OO 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

like image 35
tmarwen Avatar answered Oct 04 '22 01:10

tmarwen