On Fri, 2015-02-06 at 00:45 +0000, Alexander Klimetschek wrote: > Let me recap: > 0. adaptTo was invented for jsp scripts > 1. we are now using adaptTo() everywhere because of convenience and we > don't want to depend on a service > 2. we figure out it doesn't work in some startup cases > 3. we add a new mock adapter service and depend on that in our code > > Isn't it simpler to use a proper service in the first place then?
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. Sometimes you don't want to add new API just for getting a service. Cheers, Robert
