You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Craig L. Ching" <cc...@mqsoftware.com> on 2008/07/21 21:44:21 UTC

Using OCM, can't adaptTo again

Hi all,

I had this problem back in mid-June and it's reared its head again.
Basically, in a JSP, I am trying to adapt an OCM mapped resource and I'm
getting null back.  Felix originally fixed this problem in [1]
but it's back and I'm having troubles again.  The easiest way to see
this is to deploy the samples/simple-demo bundle and go to
http://localhost:8080/sample/content/home.html.  You should get a null
pointer exception because this call:

    final SamplePage samplePage = resource.adaptTo(SamplePage.class);

in
samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/Samp
lePage/html.jsp returns null.  Any ideas what the problem might be this
time?  I'm finding it a bit tricky debugging the OCM mapped resources
;-)

As an aside, should I be staying away from OCM?  I like the idea and it
works great when it does work, but I don't want to be outside of the
norm here if it's not a good technology.  Or I could possibly supply
some tests given a little guidance to make sure it's breakage becomes
more obvious.

[1] https://issues.apache.org/jira/browse/SLING-546

Cheers,
Craig

RE: Using OCM, can't adaptTo again

Posted by "Craig L. Ching" <cc...@mqsoftware.com>.
Hi Felix, 

> -----Original Message-----
> From: Felix Meschberger [mailto:fmeschbe@gmail.com] 
> Sent: Thursday, July 24, 2008 5:51 AM
> To: sling-dev@incubator.apache.org
> Subject: Re: Using OCM, can't adaptTo again
> 
> Hi,
> 
> Craig L. Ching schrieb:

[snip]

> > As an aside, should I be staying away from OCM?  I like the 
> idea and 
> > it works great when it does work, but I don't want to be outside of 
> > the norm here if it's not a good technology.
> 
> I am also one of the OCM guys. Actually the first Sling 
> implementations exclusively built upon OCM...
> 
> Anyway, I like thinking in business object terms in contrast 
> to just nodes and properties terms (as if a business 
> application would just be built by static functions operation 
> on maps ;-) ). But YMMV. I would say, if you have a reason to 
> use OCM, use it.
> 

Yeah, I've been thinking about the alternatives and I think OCM is a
very nice fit for me.  As part of our app, I want people to provide
their own content (we'll have a library of objects that can be used in
our app and we want users to extend that library with their own objects)
that can be included with ours and, for us, that means at the JCR level.
I think it would be much easier to expose OCM to them than the whole of
the JCR API.  So, I think I'm sticking with OCM.

> >  Or I could possibly supply
> > some tests given a little guidance to make sure it's 
> breakage becomes 
> > more obvious.
> 
> As Bertrand already said, this would certainly be a nice 
> addition and be welcomed.
> 
Yeah, I haven't had much time to think about this, but I'll definitely
try to make some time.  On a side note, Rory Douglas posted this on
Tuesday:

>I think I figured this out:  I added @scr.service
interface="org.osgi.framework.SynchronousBundleListener" to
ObjectContentManagerFactoryImpl, and the component now activates
immediately (and registers mapped types from simple-demo)

I tried what he said and it didn't work for me.  I've got some time this
morning to look further into it, but thought I'd point that out in case
you missed it.


> Regards
> Felix
> 

Cheers,
Craig

Re: Using OCM, can't adaptTo again

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Craig L. Ching schrieb:
> Hi all,
> 
> I had this problem back in mid-June and it's reared its head again.
> Basically, in a JSP, I am trying to adapt an OCM mapped resource and I'm
> getting null back.  Felix originally fixed this problem in [1]
> but it's back and I'm having troubles again.  The easiest way to see
> this is to deploy the samples/simple-demo bundle and go to
> http://localhost:8080/sample/content/home.html.  You should get a null
> pointer exception because this call:
> 
>     final SamplePage samplePage = resource.adaptTo(SamplePage.class);
> 
> in
> samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/Samp
> lePage/html.jsp returns null.  Any ideas what the problem might be this
> time?  I'm finding it a bit tricky debugging the OCM mapped resources
> ;-)

Yeah, I fear problems reappeared. I will have to dig into this (again).

> 
> As an aside, should I be staying away from OCM?  I like the idea and it
> works great when it does work, but I don't want to be outside of the
> norm here if it's not a good technology.

I am also one of the OCM guys. Actually the first Sling implementations 
exclusively built upon OCM...

Anyway, I like thinking in business object terms in contrast to just 
nodes and properties terms (as if a business application would just be 
built by static functions operation on maps ;-) ). But YMMV. I would 
say, if you have a reason to use OCM, use it.

>  Or I could possibly supply
> some tests given a little guidance to make sure it's breakage becomes
> more obvious.

As Bertrand already said, this would certainly be a nice addition and be 
welcomed.

Regards
Felix

RE: Using OCM, can't adaptTo again

Posted by "Craig L. Ching" <cc...@mqsoftware.com>.
 

> -----Original Message-----
> From: bdelacretaz@gmail.com [mailto:bdelacretaz@gmail.com] On 
> Behalf Of Bertrand Delacretaz
> Sent: Tuesday, July 22, 2008 7:12 AM
> To: sling-dev@incubator.apache.org
> Subject: Re: Using OCM, can't adaptTo again
> 
> On Mon, Jul 21, 2008 at 9:44 PM, Craig L. Ching 
> <cc...@mqsoftware.com> wrote:
> 

[snip]

> > ...Or I could possibly supply
> > some tests given a little guidance to make sure it's 
> breakage becomes 
> > more obvious....
> 
> That would certainly help improve the current situation, at 
> least for test-infected people like me ;-)
> 

Yeah, I guess I need to dig into OCM then.  Last time I started in on
it, I got a bit lost, but Felix fixed the problem before I had to get my
hands too dirty ;-P  I'll have a look and see if I can figure out what
I'm doing wrong, otherwise I might just stay away from OCM.

> -Bertrand
> 

Cheers,
Craig

Re: Using OCM, can't adaptTo again

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Jul 21, 2008 at 9:44 PM, Craig L. Ching <cc...@mqsoftware.com> wrote:

> ...As an aside, should I be staying away from OCM?  I like the idea and it
> works great when it does work, but I don't want to be outside of the
> norm here if it's not a good technology.  ..

I'm not a big fan of OCM, as I like the JCR API very much and usually
don't find a need to hide it under additional layers...but OCM can
certainly be very useful in some cases, depending on your application
patterns.

I don't think there are any plans to put OCM in the "outside the norm"
category, even if within Day (who's certainly the heaviest user of
Sling today) we're using it less than we first thought we would.

> ...Or I could possibly supply
> some tests given a little guidance to make sure it's breakage becomes
> more obvious....

That would certainly help improve the current situation, at least for
test-infected people like me ;-)

-Bertrand