You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Vidar Ramdal <vi...@idium.no> on 2010/02/04 11:40:39 UTC

Re: Registering an AccessManagerPlugin kills EventListeners

On Sun, Jan 31, 2010 at 5:18 PM, Vidar Ramdal <vi...@idium.no> wrote:
> While researching why domain mappings weren't being updated [1], I
> discovered that when an AccessManagerPlugin becomes available, the
> AccessManagerFactoryTracker closes all JCR sessions that have been
> created so far [2]. This seems to kill off any existing event
> listeners. I'm not that into the Jackrabbit internals (and maybe this
> is a question for the Jackrabbit list), but are EventListeners
> supposed to be killed when all sessions close?
>
> This, in effect, is causing the MapEntries to not become notified of
> new nodes under /etc/map, so that the domain mappings table is not
> being updated.
> To reproduce the problem, have a start a Sling instance that already
> have an active AccessManagerPlugin, and:
> 1. Go to http://localhost:8080/system/console/jcrresolver and note the
> domain mappings
> 2. Create a new node /etc/map/http/domain.com, with a
> sling:internalRedirect property set to /node
> 3. Refresh http://localhost:8080/system/console/jcrresolver
> Expected result:
> - The domain mappings table reflects the new mapping domain.com => /node
> Actual result:
> - The domain mappings table is unchanged
>
> If you restart the JcrResourceResolverFactory component, the domain
> mappings table is updated, and subsequent updates to /etc/map are
> reflected. This is because the MapEntries eventlistener is not being
> de-registered until a new AccessManagerPlugin is registered.
>
> Is there a reason for closing all sessions when an AMP is registered,
> or could we safely remove that code?

Any opinions on this?

There is a workaround: Make sure your AccessManagerPlugin starts
BEFORE the JcrResourceResolver, that is, the bundle containing your
AMP must have a lower start-level than the Apache Sling Resource
Resoulver bundle.
However, if you restart your AMP you'll have to restart the
JcrResourceResolver as well. Not a perfect solution, in other words.

If leaving sessions open when plugging in an AMP is not good practice,
the PluggableDefaultAccessManager should try to re-register all event
listeners with the new AMP.

> [1] http://markmail.org/thread/r4jzqd4pheelo6fq
> [2] http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/AccessManagerFactoryTracker.java?view=markup#l51
>
> --
> Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
> Sommerrogata 13-15, N-0255 Oslo, Norway
> + 47 22 00 84 00 / +47 21 531941, ext 2070
>



-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070