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

Reply via email to