You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Carsten Ziegeler <cz...@apache.org> on 2007/11/30 00:54:06 UTC

Re: svn commit: r599405 - in /incubator/sling/trunk/api: ./ src/main/java/org/apache/sling/api/resource/

I'm a little bit unhappy that noone responded to my response in this
thread and now the code is already changed.

Creating all these one method interfaces really looks like FS and makes
imho the api much more complicated than it could be.

Carsten

fmeschbe@apache.org wrote:
> Author: fmeschbe
> Date: Thu Nov 29 04:14:53 2007
> New Revision: 599405
> 
> URL: http://svn.apache.org/viewvc?rev=599405&view=rev
> Log:
> SLING-109 Abstract Resource completely from internal data
>    - Remove getRawData and getObject methods
>    - Add Provider interfaces which may be implemented to
>      provide access to Resource as appropriate
> 



-- 
Carsten Ziegeler
cziegeler@apache.org

Re: svn commit: r599405 - in /incubator/sling/trunk/api: ./ src/main/java/org/apache/sling/api/resource/

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

Am Donnerstag, den 29.11.2007, 18:54 -0500 schrieb Carsten Ziegeler:
> I'm a little bit unhappy that noone responded to my response in this
> thread and now the code is already changed.

Sorry, but this code change showed the potential for an even better
solution based on an adapter pattern as described in the other mail
thread.

> Creating all these one method interfaces really looks like FS and makes
> imho the api much more complicated than it could be.

It has more interfaces, but using these interfaces makes using the API
much cleaner because there is much less wild guessing.

Before, you had to write:

    if (resource.getRawData() instanceof Node) {
        Node node = (Node) resource.getRawData();
        ...
    }

which looks like having some knowledge of a concrete implementation,
which is definitely not the sense of an interface. Compared to this, you
now do

    if (resource instanceof NodeProvider) {
        Node node = ((NodeProvider) resource).getNode();
        ...
    }

which is much more detached from the actual implementation. With the
adapter pattern, it becomes even nicer:

    Node node = resource.adaptTo(Node.class);
    if (node != null) {
        ....
    }

We could drop the NodeProvider interface and -- ta taa -- the dependency
on the JCR API is gone :-)

Regards
Felix


Re: svn commit: r599405 - in /incubator/sling/trunk/api: ./ src/main/java/org/apache/sling/api/resource/

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Nov 30, 2007 12:54 AM, Carsten Ziegeler <cz...@apache.org> wrote:
> ...I'm a little bit unhappy that noone responded to my response in this
> thread and now the code is already changed....

Sorry about that - I have replied in the API thread, let's make sure
we agree (although I think we shouldn't put too much energy in what
are mostly API details), and revert if needed.

-Bertrand