You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by dan mcweeney <mc...@adobe.com> on 2013/10/03 20:51:40 UTC
ResourceProviderFactory vs. ResourceProvider Question
I've been implementing the ResourceProviderFactory and wanted to find
out if the providers that are returned from the factory are ever used by
different threads or ever dropped into a pool and reused. Are there any
differences between registering a Factory vs. just registering the
provider that I need to be aware of?
I did some testing and seems like they are never reused nor used by
multiple threads but, I just wanted to confirm my anecdotal testing.
-d
Re: ResourceProviderFactory vs. ResourceProvider Question
Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,
if you use a factory, once resources from this factory are hit, an instance
for the current resource resolver is created exclusively for this resource
resolver. As resource resolvers are not thread safe, they shouldn't be used
from different threads (at least not concurrently) and therefore the same
applies for resource provider instances created by a factory. These
instances are never pooled etc, once a resolver is closed, they are freed.
Whereas if you register a ResourceProvider directly, this is a singleton
which can be used concurrently.
In addition if you choose a RPFactory you can implement more functionality
as some of the extension interfaces of the RP interface are only used if
the instance is created via a factory.
Regards
Carsten
2013/10/3 dan mcweeney <mc...@adobe.com>
> I've been implementing the ResourceProviderFactory and wanted to find out
> if the providers that are returned from the factory are ever used by
> different threads or ever dropped into a pool and reused. Are there any
> differences between registering a Factory vs. just registering the provider
> that I need to be aware of?
>
> I did some testing and seems like they are never reused nor used by
> multiple threads but, I just wanted to confirm my anecdotal testing.
>
> -d
>
--
Carsten Ziegeler
cziegeler@apache.org