This thread has got me worried about the lifespan of my resolvers,
especially when the methods return resources. I understand how important it
is to keep the lifespans short, but if I were to close in that case at the
end of my method, I'd probably get something like "This session has already
been closed." I'm probably done with those resources a few function calls
later. Is it a good pattern to have a method in each service that I can
call to explicitly close the resolver?

Thanks,
Ben

On Wed, Jun 15, 2016 at 8:35 AM, Carsten Ziegeler <cziege...@apache.org>
wrote:

> Good catch, yes the javadocs is not precise. I'll update it
>
> Thanks
> Carsten
>
> Roy Teeuwen wrote
> > Hey Carsten,
> >
> > Then the javadocs seem a bit wrong to me, no?:
> >
> >
> https://sling.apache.org/apidocs/sling8/org/apache/sling/api/resource/ResourceResolver.html#isLive--
> <
> https://sling.apache.org/apidocs/sling8/org/apache/sling/api/resource/ResourceResolver.html#isLive--
> >
> >
> > boolean isLive()
> >
> > Returns true if this resource resolver has not been closed yet.
> > Unlike the other methods defined in this interface, this method will
> never throw an exception even after the resource resolver has been closed.
> >
> > Greetings,
> > Roy
> >
> >> On 15 Jun 2016, at 13:55, Carsten Ziegeler <cziege...@apache.org>
> wrote:
> >>
> >> Roy Teeuwen wrote
> >>> Hey,
> >>>
> >>> Thanks all for the responses.
> >>>
> >>> @Paul I would indeed ideally use the HTTP request, but there is no
> http request for the service that I am creating, but indeed that would be
> the best option.
> >>>
> >>> @Jason Yeah, I am still using the getAdminResourceResolver because it
> is for AEM 5.6.1. When the upgrade is done, these will be removed ;)
> >>>
> >>> @Carsten Wow, didn’t know about that last thing, then what is the use
> case of the isLive function? Where would you use it then?
> >>>
> >>
> >> The isLive is there to check whether you can still use the resource
> >> resolver, for example you got a resource resolver and while you're using
> >> it, the JCR provider is removed (or updated). In that case your resolver
> >> is not live anymore as one provider is not live anymore.
> >>
> >> Regards
> >> Carsten
> >> --
> >> Carsten Ziegeler
> >> Adobe Research Switzerland
> >> cziege...@apache.org
> >
> >
>
>
>
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org
>

Reply via email to