ConfigurationAdmin – Access OSGi configuration of other services

In this article we will explore ConfigurationAdmin interface. Service for administering configuration data.

ConfigurationAdmin is a dictionary of properties. To identify a target service’s dictionary use its PID.

Sharing as code snippet that reads “” configuration of the OOTB “Day CQ Root Mapping” service.

package com.techrevel.dam.core.servlets;
import java.util.Dictionary;
import javax.servlet.Servlet;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(service = Servlet.class, property = { "sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths=" + "/apps/techrevel/accessserviceconfig" })
public class AccessServiceConfig extends SlingAllMethodsServlet {
private final Logger LOGGER = LoggerFactory.getLogger(getClass());
private ConfigurationAdmin configAdmin;
* The method fetches the Post Process Observation configuration
* @throws IOException
private void getConfigs() throws IOException {
Configuration taxonomyFeedConfig = configAdmin
Dictionary<String, Object> properties = taxonomyFeedConfig.getProperties();
LOGGER.debug("[getConfigs] – Root Mapping Target: {}",
PropertiesUtil.toString(properties.get(""), ""));
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {

When a target service’s configuration is updated, config details would also refresh in ConfigurationAdmin API. Thus, if you read configuration once updates are persisted, you would get the updated values. Example: if we access above servlet after updating the “”, we would receive the updated value in logs.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s