A general service does imho not sense. That service has no knowledge
about where resources are coming from and how binaries a stored.
A resource provider does know these things.
This leaves us with two options: we allow multiple services to be
registered. Each service than has to check if it knows about the
resource implementation it gets and if it knows about it, it can handle
it. This makes handling this case unnecessarily complex. It also brings
us back to an ordering problem - what if that service is currently not
registered, but the resource provider is etc.
The other option is to let the resource provider implementation provide
this object. The only interface we have for this, is adaptTo. But as
pointed out, in this case it is super safe to call adaptTo as the
resource (or the backing resource provider) can implement it.
No need to ask N services to find out that none of them supports a
resource. No fear of services being temporarily unavailable etc.
AdaptTo makes both, implementation and usage much cleaner
Carsten
On 31.01.2020 04:15, Ian Boston wrote:
Hi,
I started with that service pattern, as you have suggested, but Carsten
asked we used a provider with the adaptTo pattern. He can explain. He does
that better. It made sense to me when he did.
Best Regards
Ian
On Fri, 31 Jan 2020 at 12:02, Radu Cotescu <r...@apache.org> wrote:
Hi Ian,
I posted a comment to your gist [2] where I just changed the pattern to
not use adaptTo. WDYT?
Thanks,
Radu
[2] -
https://gist.github.com/ieb/5f217e2c160afb7bb4098bca99896621#gistcomment-3162233
<
https://gist.github.com/ieb/5f217e2c160afb7bb4098bca99896621#gistcomment-3162233
--
--
Carsten Ziegeler
Adobe Research Switzerland
cziege...@apache.org