On 13.02.2015, at 01:55, Robert Munteanu <[email protected]> wrote: > Coming back to this , I think that there's a scenario where actually > adaptTo makes a lot of sense outside of scripts - components which must > be backed by the caller's session / resource resolver. > > When looking up an OSGi service you can't pass in your own resource > resolver. So if you want to get a component backed by your own resource > resolver, you either use resourceResolver.adaptTo(...) or add new API > which takes a resource resolver as an argument.
Such a service is exactly what I am talking about - and I don't think it's a problem. In many cases you end up having more optional arguments to get this, say some ThatService.getObject(ResourceResolver resolver, String option, ...) method (and the adaptTo is only kept for the simple/default way). Here you need the service anyway. > Sometimes you don't want > to add new API just for getting a service. You are adding a new API anyway for the object you adaptTo. Cheers, Alex
