You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Costin Leau <co...@gmail.com> on 2005/09/07 10:24:42 UTC

decorator package enhancements

Hello.

I've been working lately with the decorator package existent inside
jcr-ext (contrib dir) and I've added some functionality in which you might be
interested.

1. I refactored RepositoryDecorator so that login methods variants don't call
the repository directly but they delegate everything to the 2 params
method i.e.:

    public Session login(Credentials credentials) throws LoginException,
            NoSuchWorkspaceException, RepositoryException {
        Session session = repository.login(credentials);
        return factory.getSessionDecorator(this, session); 
    }

    becomes
    
    public Session login(Credentials credentials) throws LoginException,
            NoSuchWorkspaceException, RepositoryException {
        Session session = login(credentials, null);
        return factory.getSessionDecorator(this, session); 
    }
    
This minor change makes any subclass of RepositoryDecorator to extend
only 1 method not the whole 3 variants of login.


2. I've added two DecoratorFactories for chaining decorators.

a. One simply does delegation to the next one in chain, allowing the
decorator to call the next one in line or skip it.

b. the second one always considers also the top of the chain. This is
useful if the decorator diverts the method call. For example the login
on the repositoryDecorator diverts the call to getSessionDecorator
(the Session decorator).
Inside a chain, this may lead to undesired effects because the
decorators before the current level inside the chain are not called
(in this example the decorators for the session).

On top of these classes I've added two decoratoring factories which
register session listeners (JackRabbit specific) and event listeners
inside the workflow in a transparent way.

What would be the procedure to review my code and maybe add this code to the JackRabbit
procedure?

-- 
Best regards,
 Costin Leau                         mailto:costin.leau@gmail.com


Re: decorator package enhancements

Posted by Jukka Zitting <jz...@yukatan.fi>.
Hi,

Costin Leau wrote:
> I've been working lately with the decorator package existent inside
> jcr-ext (contrib dir) and I've added some functionality in which you might be
> interested.

Cool! I've lately been too busy to actively work on the jcr-ext stuff, 
so it's nice to hear that someone is interested in extending it.

> 1. I refactored RepositoryDecorator so that login methods variants don't call
> the repository directly but they delegate everything to the 2 params
> method i.e.:

That's fine. I've had a bit mixed views on how to best handle the many 
method variants in JCR (especially the property accessors), but I see no 
problem with such delegation as long as the choise of the base method to 
call is clear (and it is possible to override this behaviour in a 
decorator subclass).

> 2. I've added two DecoratorFactories for chaining decorators.

Nice. I'd be happy to review and integrate your work!

> What would be the procedure to review my code and maybe add
> this code to the JackRabbit procedure?

Please post a Jira issue about your enhancements and attach your changes 
as a patch against the latest SVN sources. Remember to check the license 
grant option on the attachment upload form so we can include your changes.

BR,

Jukka Zitting