7

I have a component with properties as follows.

@Component(immediate = true, metatype = true, label = "Conf Details")
@Service(value = { LocationConfigurationUtil.class })
@Properties({
        @Property(label = "location blueprint", name = "locationPath", value = "", description = "..."),
        @Property(label = "location page template", name = "locationTemplate", value = "", description = "..."),
        @Property(label = "basepath live copies", name = "liveCopyRoot", value = "/content/WebRoot", description = "...") })
public class LocationConfigurationUtil {
@Activate
    protected void activate(Map<String, Object> mapCreated) {
          // some code
    }
}

To make it editable properties in a jcr node, I used a non-standard method. I created sling:OsgiConfig in path /apps/system/config having properties declared in java code, which is working fine.

screen shot

But if I just have the same sling:OsgiConfig inside /etc/myapp/myconfig, it does not work.

Dileepa
  • 1,019
  • 1
  • 15
  • 40

2 Answers2

10

With default settings, JCR Installer Provider does not look for installable bundles and nodes (sling:OsgiConfig) in folders other than /libs and /apps. so any config in /etc will not be loaded.

If you want to change this behavior, make a search path entry in "Apache Sling JCR Installer" config in osgi configuration console. But be aware it is not recommended, you should not be putting any sling:osgiconfig node in /etc in the first place.

awd
  • 2,302
  • 1
  • 22
  • 29
5

Note that placing configuration nodes under /etc is a really bad idea.

From a security point of view, /libs and /apps are locked down, but with /etc/ you open yourself up to at least two major security holes:

  • OSGi configurations can be read by anonymous users
  • Code can be deployed by unprivileged users

Please reconsider adding the /etc path to the JCR Installers search path entries and instead deploy your configurations to /apps.

Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278