0

I've seen Configurations in aem which has two parts, first one is a static final String with whose name i'll access the configuration property and another one is an instance variable, whose value i'll get from properties Dictionary object.

For eg in Sling's own code,

public class ResourceResolverFactoryActivator implements Runnable {
...
@Property(
        boolValue = {true},
        label = "Namespace Mangling",
        description = ".."
    )
private static final String PROP_MANGLE_NAMESPACES = "resource.resolver.manglenamespaces";
... // other code in between

private boolean mangleNamespacePrefixes;

protected void activate(ComponentContext componentContext){
...
this.mangleNamespacePrefixes = PropertiesUtil.toBoolean(properties.get("resource.resolver.manglenamespaces"), false);
...
}  

what is the significance of final String PROP_MANGLE_NAMESPACES and instance boolean mangleNamespacePrefixes here. Why two different variables to represent only one @Property ?

Shashi
  • 746
  • 10
  • 39

1 Answers1

2

PROP_MANGLE_NAMESPACES is to store the property name (that would be used by felix to persist the property). mangleNamespacePrefixes is to store value of that property.

It is not mandatory to define mangleNamespacePrefixes, if you are willing to use PropertiesUtil.toBoolean(properties.get(PROP_MANGLE_NAMESPACES), false) everywhere its needed.

awd
  • 2,302
  • 1
  • 22
  • 29