Usually I prefer the "High Level" CAC API 
(https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html#context-aware-configurations)
 over the "Low-Level" one descriped at 
https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html#context-aware-resources.

Still sometimes I am interested to figure out in code, whether there is a CAC 
bound at all. Currently I fail to see a method within 
https://sling.apache.org/apidocs/sling11/org/apache/sling/caconfig/ConfigurationBuilder.html
 which allows to easily check that. The as... method always succeed (i.e. will 
never return null and will rather return the default values from the annotation 
type).
I have to go the "manual way" by explicitly calling 
ConfigurationResourceResolver.getResource() 
(https://sling.apache.org/apidocs/sling11/org/apache/sling/caconfig/resource/ConfigurationResourceResolver.html)
 but that also takes an explicit bucket name as argument, so I would always 
have to give "sling:configs" as parameter

IMHO it would be nice to add a method like boolean hasConfiguration() to the 
ConfigurationBuilder interface. WDYT?

Cheers,
Konrad

Reply via email to