You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Jukka Zitting <ju...@gmail.com> on 2007/10/23 12:14:22 UTC

[OCM] DynaBean support

Hi,

The current OCM require existing Java classes when mapping JCR content
to Java objects. This introduces a relatively high entry barrier for
various scripting environments, where you just want access to JavaBean
properties as name-value pairs without having to set up explicit
content mappings.

To make life easier for such environments I'd like to propose
implementing a JCR binding for the DynaBean concept [1] in Commons
BeanUtils.

[1] http://commons.apache.org/beanutils/commons-beanutils-1.7.0/docs/api/org/apache/commons/beanutils/package-summary.html#dynamic

BR,

Jukka Zitting

Re: [OCM] DynaBean support

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 10/23/07, Christophe Lombart <ch...@gmail.com> wrote:
> Why not to create a new jackrabbit contrib ?

Probably makes sense, the Map/DynaBean approach is a bit different in
nature from the OCM approach.

> Concerning OCM, I would like to implement an implicit mapping which will not
> require annotation or mapping file.

Nice :-)

BR,

jukka Zitting

Re: [OCM] DynaBean support

Posted by Christophe Lombart <ch...@gmail.com>.
Why not to create a new jackrabbit contrib ?
Concerning OCM, I would like to implement an implicit mapping which will not
require annotation or mapping file.

Christophe



On 10/23/07, Jukka Zitting <ju...@gmail.com> wrote:
>
> Hi,
>
> The current OCM require existing Java classes when mapping JCR content
> to Java objects. This introduces a relatively high entry barrier for
> various scripting environments, where you just want access to JavaBean
> properties as name-value pairs without having to set up explicit
> content mappings.
>
> To make life easier for such environments I'd like to propose
> implementing a JCR binding for the DynaBean concept [1] in Commons
> BeanUtils.
>
> [1]
> http://commons.apache.org/beanutils/commons-beanutils-1.7.0/docs/api/org/apache/commons/beanutils/package-summary.html#dynamic
>
> BR,
>
> Jukka Zitting
>

Re: [OCM] DynaBean support

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 10/23/07, Carsten Ziegeler <cz...@apache.org> wrote:
> I'm not against support for DynaBeans but what about an even easier
> approach like for example Apache iBatis is doing? In iBatis you can just
> use java.util.Map (or an implementation of it if you want to read stuff).

We could do that as well. In fact if we have a "NodeMap"
implementation, we can add DynaBean support simply by wrapping the map
in a LazyDynaMap adapter.

BR,

Jukka Zitting

Re: [OCM] DynaBean support

Posted by "Padraic I. Hannon" <pi...@wasabicowboy.com>.
Let me know what you think I would love to collaborate with you, or 
anyone else, to make this a better system. I would love to make it work 
with pojo's and not require interfaces. This would, however, take more 
cglib skills than I currently have. I have a long plane ride from Zurich 
to Los Angeles coming up soon, perhaps I will be able to work something 
out during that time.

-paddy

Re: [OCM] DynaBean support

Posted by Christophe Lombart <ch...@gmail.com>.
Oopps I forgot this issue. sorry.
I will look at it .



On 10/23/07, Padraic I. Hannon <pi...@wasabicowboy.com> wrote:
>
> I placed the code in jira:
> https://issues.apache.org/jira/browse/JCR-1100. I think there is a lot
> of room to make this better. Here is an example test case I wrote with
> our data:
>
>         JcrRepository repo = getRepository();
>         Feature feature = new FeatureImpl("test feature mixin");
>         feature = (Feature)repo.add(feature);
>
>         feature = (Feature)feature.addMixin(new EngineImpl());
>         Engine engine = (Engine)feature;
>         engine.setConfiguration(Engine.V_CONFIGURATION);
>         engine.setFuelType(Engine.UNLEADED_FUEL);
>         engine.setHorsePower(200);
>         engine.setHorsePowerRPM(10);
>         repo.save(feature);
>
>         Object obj = repo.forPath(feature.getPath());
>         assert obj instanceof Engine;
>
> Note in this example there are four java files: Feature (interface),
> FeatureImpl (class), Engine (interface), Engine (class)...
>
> -paddy
>
> Christophe Lombart wrote:
> > Hi Paddy,
> >
> > It should be nice if you can donnate the code
> >
> > Christophe
> >
> > On 10/23/07, Padraic I. Hannon <pi...@wasabicowboy.com> wrote:
> >
> >> I think this would be a great idea, I implemented something similar for
> >> OCM using cglib mixin proxies to provide mixin support at run time.
> >>
> >> -paddy
> >>
> >>
> >
> >
>
>

Re: [OCM] DynaBean support

Posted by "Padraic I. Hannon" <pi...@wasabicowboy.com>.
I placed the code in jira: 
https://issues.apache.org/jira/browse/JCR-1100. I think there is a lot 
of room to make this better. Here is an example test case I wrote with 
our data:

        JcrRepository repo = getRepository();
        Feature feature = new FeatureImpl("test feature mixin");
        feature = (Feature)repo.add(feature);

        feature = (Feature)feature.addMixin(new EngineImpl());
        Engine engine = (Engine)feature;
        engine.setConfiguration(Engine.V_CONFIGURATION);
        engine.setFuelType(Engine.UNLEADED_FUEL);
        engine.setHorsePower(200);
        engine.setHorsePowerRPM(10);
        repo.save(feature);

        Object obj = repo.forPath(feature.getPath());
        assert obj instanceof Engine;

Note in this example there are four java files: Feature (interface), 
FeatureImpl (class), Engine (interface), Engine (class)...

-paddy

Christophe Lombart wrote:
> Hi Paddy,
>
> It should be nice if you can donnate the code
>
> Christophe
>
> On 10/23/07, Padraic I. Hannon <pi...@wasabicowboy.com> wrote:
>   
>> I think this would be a great idea, I implemented something similar for
>> OCM using cglib mixin proxies to provide mixin support at run time.
>>
>> -paddy
>>
>>     
>
>   


Re: [OCM] DynaBean support

Posted by Christophe Lombart <ch...@gmail.com>.
Hi Paddy,

It should be nice if you can donnate the code

Christophe

On 10/23/07, Padraic I. Hannon <pi...@wasabicowboy.com> wrote:
>
> I think this would be a great idea, I implemented something similar for
> OCM using cglib mixin proxies to provide mixin support at run time.
>
> -paddy
>

Re: [OCM] DynaBean support

Posted by "Padraic I. Hannon" <pi...@wasabicowboy.com>.
I think this would be a great idea, I implemented something similar for 
OCM using cglib mixin proxies to provide mixin support at run time.

-paddy

Re: [OCM] DynaBean support

Posted by Carsten Ziegeler <cz...@apache.org>.
Jukka Zitting wrote:
> Hi,
> 
> The current OCM require existing Java classes when mapping JCR content
> to Java objects. This introduces a relatively high entry barrier for
> various scripting environments, where you just want access to JavaBean
> properties as name-value pairs without having to set up explicit
> content mappings.
> 
> To make life easier for such environments I'd like to propose
> implementing a JCR binding for the DynaBean concept [1] in Commons
> BeanUtils.
> 
> [1] http://commons.apache.org/beanutils/commons-beanutils-1.7.0/docs/api/org/apache/commons/beanutils/package-summary.html#dynamic
> 
I'm not against support for DynaBeans but what about an even easier
approach like for example Apache iBatis is doing? In iBatis you can just
 use java.util.Map (or an implementation of it if you want to read stuff).

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org