Jukka Zitting schrieb:
> Hi,
> 
> On Wed, Jun 10, 2009 at 3:10 PM, Carsten Ziegeler<cziege...@apache.org> wrote:
>> While caching in the resource resolver might be a good idea anyway,
>> perhaps caching one layer above might give even more benefit. Instead
>> of querying the resource resolver a lot, caching above the resolver
>> would even avoid querying the resolver.
> 
> This turns out to be the best approach in my case. Especially since a
> new ResourceResolver gets instantiated for each new request, which
> makes it more difficult to add global caching.

Not sure, whether it really is the best approach. Though it is true,
that the ResourceResolver instance is created on each request, it is
still created from the JcrResourceResolverFactory, which might as well
be the holder of the cache and provide the user-specific subset of the
cache to the per-request-ResourceResolver.

> 
> However, since the resolution process depends on access rights, I
> currently need to do something like this to include the potential
> username in the cache key:
> 
>     String user = "";
>     Session session = resourceResolver.adaptTo(Session.class);
>     if (session != null) {
>         user = session.getUserId();
>     }
> 
> This seems a bit fragile, so I was wondering if getting the username
> from the request would work better:
> 
>     String user = "";
>     Principal principal = request.getUserPrincipal();
>     if (principal != null) {
>         user = principal.getName();
>     }
> 
> I guess there are cases where the JCR Session (or whatever is used for
> resource resolution) is authenticated using something else than the
> user principal associated with the HTTP request.

You might want to use request.getRemoteUser(), which is backed by
Session.getUserId().

> 
> Ultimately we should probably solve the performance issue on the
> repository layer by making path lookups (especially negative ones)
> blazingly fast. They're already pretty good in Jackrabbit, but for my
> use case I'd need about an order of magnitude more performance. With a
> simple high-level cache I was able to achieve this.

oh yeah ;-)

Regards
Felix

Reply via email to