[
https://issues.apache.org/jira/browse/SLING-2630?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Will McGauley updated SLING-2630:
---------------------------------
Attachment: SLING-2630.patch
Please find attached a patch which addresses this issue. The basic idea behind
the patch is to store a List of AdapterFactoryDescriptors for each combination
instead of a single one - and to call all adapterFactories in order based on
service ranking until the adapted value is not null.
There are tests included that cover this concept.
As an aside I also found a bug with respect to ranking AdapterFactories based
on service ranking which I fixed --> around line 365 in AdapterManagerImpl.java
the AdapterFactoryDescriptor classes are loaded into a HashSet, which loses all
ordering of the descriptors. I changed it to use an ArrayList which will
preserve the order.
> Cannot have multiple Adapter Factories configured to have same adapter /
> adaptable combination
> ----------------------------------------------------------------------------------------------
>
> Key: SLING-2630
> URL: https://issues.apache.org/jira/browse/SLING-2630
> Project: Sling
> Issue Type: Bug
> Components: Extensions
> Affects Versions: Adapter 2.0.16
> Reporter: Will McGauley
> Labels: AdapterManager
> Fix For: Adapter 2.0.18
>
> Attachments: SLING-2630.patch
>
>
> If you configure more than one AdapterFactory in the system which bears the
> same adapter / adaptable combinations only the AdapterFactory with the
> highest ranking is used.
> Example:
> ClassA extends MyInterface
> classB extends MyInterface
> AdapterFactoryA adapts Node to MyInterface (hoping to return implementation
> ClassA under some circumstances)
> AdapterFactoryB adapts Node to MyInterface (hoping to return implementation
> ClassA under some other circumstances)
> when adapting Node to MyInterface, only AdapterFactoryA is ever used, even if
> it returns null for a particular Node.
> Expected: If AdapterFactoryA returns null then any remaining
> AdapterFactories configured with that combination (in this case
> AdapterFactoryB) should be allowed the chance to adapt
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira