OCM Node Definitions

5 messages Options
Embed this post
Permalink
Juan Pereyra

OCM Node Definitions

Reply Threaded More More options
Print post
Permalink
Hi all,

Here goes another question about the OCM. According to the documentation, one would define new namespaces and new nodetypes as part of an CND configuration. However, I noticed that most things that you define on the CND file, you could define them as annotations (i.e. jcrSuperTypes, etc.). Trying to get OCM to load the new types from annotations I got to the AnnotationDescriptorReader class, which JavaDoc is this:

<code>
/**
 * Helper class that reads the xml mapping file and load all class descriptors into memory (object graph)
 *
 * @author <a href="mailto:[hidden email]">Lombart Christophe </a>
 * @author : <a href="mailto:[hidden email]">Boni Gopalan</a>
 *
 */
public class AnnotationDescriptorReader implements DescriptorReader
</code>

However, the class reads annotation descriptors, not an XML, and interestingly enough, the JavaDoc is identical to the one in the class DigesterDescriptorReader.

So, summarizing, is it possible to load namespace definitions without the CND or an XML? just with annotations? Everything that's needed seems to be there already.

Many thanks guys!
Juan
Matthew Short-2

Re: OCM Node Definitions

Reply Threaded More More options
Print post
Permalink

Hrm.  I think an analogy/metaphor might help understand the CND vs OCM
annotation issue.

The CND specification and language allows for specifying constraints and
relationships between 'stuff' in the JCR.  Its a bit like throwing a
constraint on an RDBMS table with DDL, although a better idea would be
to create a  class of tables that share the same constraints and foreign
keys.

OCM operates at a level or tier above the JCR, similar to ORM tools.  Of
course, all the varied ways of defining and typing objects apply, with
much more flexibility than the JCR specs.  But you don't get the
namespace enforcement at the storage layer - which means a second tool
that doesnt use your OCM implementation could violate constraints and
namespaces established in your OCM implementation.

One of the questions I like to ask teams when starting projects is:
Should we handle constraints at the storage layer or persistence layer?  
And which constraints where?


Juan Pereyra wrote:

> Hi all,
>
> Here goes another question about the OCM. According to the documentation, one would define new namespaces and new nodetypes as part of an CND configuration. However, I noticed that most things that you define on the CND file, you could define them as annotations (i.e. jcrSuperTypes, etc.). Trying to get OCM to load the new types from annotations I got to the AnnotationDescriptorReader class, which JavaDoc is this:
>
> <code>
> /**
>  * Helper class that reads the xml mapping file and load all class descriptors into memory (object graph)
>  *
>  * @author <a href="mailto:[hidden email]">Lombart Christophe </a>
>  * @author : <a href="mailto:[hidden email]">Boni Gopalan</a>
>  *
>  */
> public class AnnotationDescriptorReader implements DescriptorReader
> </code>
>
> However, the class reads annotation descriptors, not an XML, and interestingly enough, the JavaDoc is identical to the one in the class DigesterDescriptorReader.
>
> So, summarizing, is it possible to load namespace definitions without the CND or an XML? just with annotations? Everything that's needed seems to be there already.
>
> Many thanks guys!
> Juan
>  

Christophe Lombart

Re: OCM Node Definitions

Reply Threaded More More options
Print post
Permalink
In reply to this post by Juan Pereyra
>
>
> So, summarizing, is it possible to load namespace definitions without the
> CND or an XML? just with annotations? Everything that's needed seems to be
> there already.
>

If you map some java classes to custom jcr node types, you have to register
those types into your repository with CND or XML JCR type def.

OCM Annotations (or the OCM xml mapping file) are just there to describe how
to map your java classes into JCR node types. This is not possible to load
new JCR node types or namespace with the OCM annotations (or the OCM xml
mapping file).

Let me know if you need more info.


Christophe
Juan Pereyra

Re: OCM Node Definitions

Reply Threaded More More options
Print post
Permalink
Ok, thanks guys. I just thought that the OCM would use the annotations data to sort of generate a CND on the fly and apply it to the repository. It's much clearer now.

Thanks!
Juan

----- Original Message -----
From: "Christophe Lombart" <[hidden email]>
To: [hidden email]
Sent: Thursday, July 2, 2009 6:59:12 AM GMT -03:00 Argentina
Subject: Re: OCM Node Definitions

>
>
> So, summarizing, is it possible to load namespace definitions without the
> CND or an XML? just with annotations? Everything that's needed seems to be
> there already.
>

If you map some java classes to custom jcr node types, you have to register
those types into your repository with CND or XML JCR type def.

OCM Annotations (or the OCM xml mapping file) are just there to describe how
to map your java classes into JCR node types. This is not possible to load
new JCR node types or namespace with the OCM annotations (or the OCM xml
mapping file).

Let me know if you need more info.


Christophe
Christophe Lombart

Re: OCM Node Definitions

Reply Threaded More More options
Print post
Permalink
You can also reviewed the component NodeTypeManager which can help to create
node types from the OCM mapping definitions but this component has to be
reviewed.
Christophe


2009/7/2 Juan Pereyra <[hidden email]>

> Ok, thanks guys. I just thought that the OCM would use the annotations data
> to sort of generate a CND on the fly and apply it to the repository. It's
> much clearer now.
>
> Thanks!
> Juan
>
> ----- Original Message -----
> From: "Christophe Lombart" <[hidden email]>
> To: [hidden email]
> Sent: Thursday, July 2, 2009 6:59:12 AM GMT -03:00 Argentina
> Subject: Re: OCM Node Definitions
>
> >
> >
> > So, summarizing, is it possible to load namespace definitions without the
> > CND or an XML? just with annotations? Everything that's needed seems to
> be
> > there already.
> >
>
> If you map some java classes to custom jcr node types, you have to register
> those types into your repository with CND or XML JCR type def.
>
> OCM Annotations (or the OCM xml mapping file) are just there to describe
> how
> to map your java classes into JCR node types. This is not possible to load
> new JCR node types or namespace with the OCM annotations (or the OCM xml
> mapping file).
>
> Let me know if you need more info.
>
>
> Christophe
>