You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Sabyasachi Mukherjee <sa...@gmail.com> on 2017/08/24 20:51:18 UTC

Resource Resolver in SlingPostProcessor

Hi All,

I was playing around with SlingPostProcessor and found an use case where I
am getting the ResourceResolver from the request in process() method of my
custom implementation of SlingPostProcessor and using it for some API calls.

I am curious to know if we should close the RR if its alive?

As the documentation[0] says, "After the operation has performed its
changes but before the changes are persistet, all post processors are
called." , will there be any problem while persisting changes if I close
the RR in my custom PostProcessor and what is the best practice?


[0]
https://sling.apache.org/apidocs/sling7/org/apache/sling/servlets/post/SlingPostProcessor.html

Thanks,
Sabya

Re: Resource Resolver in SlingPostProcessor

Posted by Sabyasachi Mukherjee <sa...@gmail.com>.
That makes sense. Thanks Jörg !

- Sabya



On Thu, Aug 24, 2017 at 11:14 PM, Jörg Hoh <jh...@googlemail.com> wrote:

> Hi,
>
> do not close it. This basic rule of thumb applies here as well: "If you
> open a ResourceResolver, you close it". And the contrary as well: "If you
> get passed an already open ResourceResolver, do not close it".
>
>
> 2017-08-24 22:51 GMT+02:00 Sabyasachi Mukherjee <sa...@gmail.com>:
>
> > Hi All,
> >
> > I was playing around with SlingPostProcessor and found an use case where
> I
> > am getting the ResourceResolver from the request in process() method of
> my
> > custom implementation of SlingPostProcessor and using it for some API
> > calls.
> >
> > I am curious to know if we should close the RR if its alive?
> >
> > As the documentation[0] says, "After the operation has performed its
> > changes but before the changes are persistet, all post processors are
> > called." , will there be any problem while persisting changes if I close
> > the RR in my custom PostProcessor and what is the best practice?
> >
> >
> > [0]
> > https://sling.apache.org/apidocs/sling7/org/apache/sling/servlets/post/
> > SlingPostProcessor.html
> >
> > Thanks,
> > Sabya
> >
>
>
>
> --
> Cheers,
> Jörg Hoh,
>
> http://cqdump.wordpress.com
> Twitter: @joerghoh
>

Re: Resource Resolver in SlingPostProcessor

Posted by Jörg Hoh <jh...@googlemail.com>.
Hi,

do not close it. This basic rule of thumb applies here as well: "If you
open a ResourceResolver, you close it". And the contrary as well: "If you
get passed an already open ResourceResolver, do not close it".


2017-08-24 22:51 GMT+02:00 Sabyasachi Mukherjee <sa...@gmail.com>:

> Hi All,
>
> I was playing around with SlingPostProcessor and found an use case where I
> am getting the ResourceResolver from the request in process() method of my
> custom implementation of SlingPostProcessor and using it for some API
> calls.
>
> I am curious to know if we should close the RR if its alive?
>
> As the documentation[0] says, "After the operation has performed its
> changes but before the changes are persistet, all post processors are
> called." , will there be any problem while persisting changes if I close
> the RR in my custom PostProcessor and what is the best practice?
>
>
> [0]
> https://sling.apache.org/apidocs/sling7/org/apache/sling/servlets/post/
> SlingPostProcessor.html
>
> Thanks,
> Sabya
>



-- 
Cheers,
Jörg Hoh,

http://cqdump.wordpress.com
Twitter: @joerghoh