You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2016/02/02 16:12:53 UTC

An API to retrieve the search path?

Hi,

I was looking at a few cases where we use an administrative
ResourceResolver just to get the current search paths, for example in
ScriptCacheImpl [1], the (simplified) pattern is:

  ResourceResolver resolver = rrf.getAdministrativeResourceResolver(null);
  searchPaths = resolver.getSearchPath();
  resolver.close();

Conceptually there's no need to have a resource resolver to get the
search path, nor should it be necessary to login to anything - the
search path is just a configuration in
ResourceResolverFactoryActivator.

To avoid having to create service users just for this, I suggest
creating a service that provides the search path, and letting the
ResourceResolverFactoryActivator provide that service. We can then get
rid of a number of admin sessions and resolvers, in various places.

WDYT?

-Bertrand

[1] https://github.com/apache/sling/blob/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptCacheImpl.java

Re: An API to retrieve the search path?

Posted by Carsten Ziegeler <cz...@apache.org>.
Bertrand Delacretaz wrote
> Hi Carsten,
> 
> On Tue, Feb 2, 2016 at 4:24 PM, Carsten Ziegeler <cz...@apache.org> wrote:
>> ...With the new observation api we have a more
>> elegant solution: you can register the listener with a relative path and
>> the search paths are automatically added....
> 
> Do we have docs or examples that show how to adapt existing code?
> 

I don't think so.

Carsten

 
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: An API to retrieve the search path?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Carsten,

On Tue, Feb 2, 2016 at 4:24 PM, Carsten Ziegeler <cz...@apache.org> wrote:
> ...With the new observation api we have a more
> elegant solution: you can register the listener with a relative path and
> the search paths are automatically added....

Do we have docs or examples that show how to adapt existing code?

-Bertrand

Re: An API to retrieve the search path?

Posted by Carsten Ziegeler <cz...@apache.org>.
This pattern is usually used with registering event handlers as
observation listeners. With the new observation api we have a more
elegant solution: you can register the listener with a relative path and
the search paths are automatically added.

As all our event handlers should move to the new observation api, I
don't see a reason to add new api - unless there is another good use case.

Carsten

Bertrand Delacretaz wrote
> Hi,
> 
> I was looking at a few cases where we use an administrative
> ResourceResolver just to get the current search paths, for example in
> ScriptCacheImpl [1], the (simplified) pattern is:
> 
>   ResourceResolver resolver = rrf.getAdministrativeResourceResolver(null);
>   searchPaths = resolver.getSearchPath();
>   resolver.close();
> 
> Conceptually there's no need to have a resource resolver to get the
> search path, nor should it be necessary to login to anything - the
> search path is just a configuration in
> ResourceResolverFactoryActivator.
> 
> To avoid having to create service users just for this, I suggest
> creating a service that provides the search path, and letting the
> ResourceResolverFactoryActivator provide that service. We can then get
> rid of a number of admin sessions and resolvers, in various places.
> 
> WDYT?
> 
> -Bertrand
> 
> [1] https://github.com/apache/sling/blob/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptCacheImpl.java
> 


 
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org