Nobody seems to be willing to burn his finger on this topic,
nevertheless I try to jump in the hot pot...

> From: Carsten Ziegeler [mailto:[email protected]]
> Hi,
>
> I've been thinking lately about identity of our objects, especially
> resource objects and adaptables.
>
> Without thinking about how this is implemented at the moment
> and without
> thinking if/how this could be implemented, what would you
> expect for the
> following: We simply get the same resource twice from the
> same resource
> resolver:
>
> ResourceResolver resolver;
>
> Resource a = resolver.getResource("/a/b");
> Resource b = resolver.getResource("/a/b");
>
> What should be true? a == b, a.equals(b) ?

If the following is given and we talk about the same request

Resource a = resolver.getResource("/a/b");
Resource b = resolver.getResource("/a/b");

I would expect
a.equals(b) = true
but a == b does not have to be true (but could be)

as of the JCR spec, even if in the same session between
retrieving a and b "/a/b" is changed, both a and b have to
reflect these changes.


> Next question: We get the same adaptable from a resource:
>
> Node n1 = a.adaptTo(Node.class);
> Node n2 = a.adaptTo(Node.class);
>
> Again: n1 == n2? n1.equals(n2)?

In this case I think we're not allowed to make any assumptions
about the returned instance, so I would expect also

n1.equals(n2) = true
n1 == n2 does not have to be true (but could be)


> While these questions seem to be trivial (more or less), it
> can get more
> subtle. Think about a resource resolver being used for a
> single request
> and getting the same resource during the request several times. Should
> it be possible to return different resources because the
> repository has
> changed during the request?

In the case of the JCR as backend (which maybe hasn't to be the case
in the future if we introduce ResourceResolverFactoriy etc.) the
JCR spec says
"However, the state reflected by the object must at all times be
consistent with any other Item object (associated with the same
Session) representing the same actual item entity"
That means that even if the resource resolver returns an other
resource on the second call the first should return the same
(changed) properties, which means a.equals(b) should return true
even in this case.

The question is here if we should specify this behavour for a
resource resolver in sling or not.

> Or the other way round. Think about an admin resource resolver running
> forever in the background.
>
> Before I post my answers I would like to get some other input? :)

best regards
mike

Reply via email to