Buuhuu opened a new pull request #35:
URL: https://github.com/apache/sling-org-apache-sling-models-impl/pull/35


   Currently the model caching works with the requested type. This does not 
support models that are registered with multiple adapter types. For example a 
model `ModelA` that is registered with `AdapterType1` and `AdapterType2` should 
be cached after being adapted using `AdapterType1` and can be returned from 
cache if adapted using `AdapterType2`. 
   
   ```
   interface AdapterType1 {}
   interface AdapterType2 {}
   
   @Model(adaptables = Resource.class, adapterType={AdapterType1.class, 
AdapterType2.class}, cache = true) 
   class Model implements AdapterType1, AdapterType2 {}
   
   assertSame(resource.adaptTo(AdapterType1), resouce.adaptTo(AdapterType2));
   ```
   
   With this change the models are cached with their implementation type as 
key, which preserves the existing behaviour but also supports the one described 
above. It should also behave as expected, when the implementation type for a 
given adapter type and adaptable changes during the lifetime of the cache, for 
example when a new implementation picker gets registered. 
   
   @raducotescu any thoughts? I saw you reviewing a previous PR in this area. 
@kwin maybe any thoughts? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to