how to read OSGI configuration via JAVA
so I have the code below
I have a breakpoint in this line 27 and another one in line 29.
when debugging my code (eclipse user here), the program stops at the first breakpoint. And when I resume (F8), it never stops in the second breakpoint. I suppose something happened to it (fatal error perhaps) and my page loads completely as if nothing happened.
This is how I call the JAVA code:
<sly data-sly-use.protectedflag="${'com.mycompany.core.impl.view.tools.checker' @ path=currentPage.path}"/>
Any ideas what I could be doing wrong? Thanks
package com.mycompany.core.impl.view.tools;
import com.adobe.cq.sightly.WCMUsePojo;
import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
public class checker extends WCMUsePojo {
private boolean protectedPage;
@Reference
private ConfigurationAdmin configAdmin;
@Override
public void activate() {
try {
Configuration conf = configAdmin.getConfiguration("org.apache.sling.engine.impl.auth.SlingAuthenticator");
String path = get("path", String.class);
@SuppressWarnings("unchecked")
Dictionary<String, Object> props = conf.getProperties();
protectedPage = false;
} catch (IOException e) {
protectedPage = false;
}
}
public boolean getProtectedPage() {
return protectedPage;
}
}

