Hi,
Currently the ValidationModelProvider interface in 
https://github.com/apache/sling/blob/trunk/bundles/extensions/validation/api/src/main/java/org/apache/sling/validation/model/spi/ValidationModelProvider.java#L55
 contains a resource resolver as parameter which should be used by the 
according ValidationModelProvider implementation. 
Currently there is only one, namely 
https://github.com/apache/sling/blob/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/resourcemodel/ResourceValidationModelProviderImpl.java

This is not a good design choice, because IMHO the different 
ValidationModelProviders should be decoupled as much as possible, and it might 
even be that some providers don't rely on Resources at all (and then don't need 
the resource resolver) or want to use dedicated service resource resolvers. 
This was initially done to prevent the resource resolver from being opened for 
each individually requested model. 

Is there maybe some other pattern which prevents the resource resolver from 
being shared among multiple different model providers while still preventing 
from opening/closing the resource resolver for each model individually? Opening 
the resource resolver once in the activate() and then reuse it from multiple 
different threads is not recommended either. Or is opening/closing so cheap 
that I should not care (even if this is done multiple times per request?)

Thanks for your opinions.
Konrad

Reply via email to