Hello Sling Devs,

I've got a question about the sling models [FirstImplementationPicker][1]. This 
appears to essentially be a "default" implementation picker. It will be used in 
two situation: (1) my app doesn't provide any other ImplementationPickers; (2) 
all my app's ImplementationPickers returned null, declaring that they couldn't 
find an implementation.

The Second situation has caused me a bit of pain today, and I'm wondering 
FirstImplementationPicker was intended to act in that situation. Here's my 
thinking:

I have an interface which has multiple implementations. The correct 
implementation will be chosen based on a property of the Resource being 
adapted. If there is no Implementation found for one of the possible values of 
that property, I would like the resource to *not* be adapted (i.e. the 
adaptTo() returning null). So, I wrote a custom ImplementationPicker and 
returned null when there is no matching implementation, but then saw that one 
of my Impl's was chosen seemingly arbitrarily. 

I wonder if a "better" default implementation picker would return null if it is 
given multiple implementationTypes since it can't determine how one would want 
to choose one over the other, and only return the implementationType if there 
is only one to choose from.

WDYT? Do I just have bad expectations of this Interface?
 
[1]: 
https://github.com/apache/sling/blob/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/FirstImplementationPicker.java


Jordan Shurmer | Software Engineer | Scripps Lifestyle Studios

9721 Sherrill Blvd, Knoxville TN 37932
Office: 865-560-4887
jshur...@scrippsnetworks.com

SCRIPPS NETWORKS INTERACTIVE | the Leader in Lifestyle Media | 
scrippsnetworksinteractive.com
HGTV | Food Network | Travel Channel | DIY Network | Cooking Channel | Great 
American Country | TVN | Fine Living | Asian Food Channel

Reply via email to