jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jukka Zitting <jukka.zitt...@gmail.com>
Subject enter() method for JCR implementation classes
Date Tue, 19 Feb 2013 15:51:38 GMT
Hi,

The current boilerplate for most of the methods in our JCR
implementation classes looks something like this:

    public Something getSomething() {
        checkStatus();
        return sessionDelegate.perform(
            new SessionOperation<PropertyImpl>() {
                @Override
                public Something perform() throws RepositoryException {
                    return ...;
                }
            });
    }

That's quite verbose and also troublesome from a performance
perspective as even basic operations require multiple method calls and
the instantiation of at least one extra object.

The purpose of the above boilerplate is first to check the state of
the current object (and the session responsible for it) and to take
care of the auto-refresh logic. Later on we might want to attach more
functionality to this pattern.

Originally the perform() pattern comes from JCR-890, where we had to
add it to prevent concurrent clients from messing up with repository
internals. In Oak I believe we could do with a lot lighter-weight
approach since we have better decoupling between the different layers
of the system.

So, to simplify things I propose that we refactor the above code to
something like this:

    public Something getSomething() {
        enter("doSomething");
        return ...;
    }

The enter() method should take care of all the tasks outlined above,
and with the given argument constant could also emit a debug log of
all JCR method calls. Variants like enterOrThrowSomeException() could
be used in cases where special exceptions are required for specific
states.

WDYT?

PS. I wonder if we could use some aspect-tool to automatically inject
such enter() calls to our code as a part of the compilation process...

BR,

Jukka Zitting

Mime
View raw message