!--a11y-->
Configuring an Event Subscription 
1. Implement the interface IConfigEventListener
If you want to be notified about modifications to your configuration, you have to implement the interface IConfigEventListener.

public class HelloWorld extends AbstractPortalComponent implements IConfigEventListener { ... } |
a. Add the required methods
Two methods have to be implemented:
§ public String getConfigListenerId() - returns the ID of the listener

public String getConfigListenerId() { return "com.sap.portal.prt.config.prototype.HelloWorld"; } |
This will uniquely identify your listener throughout all the applications. It is a good idea to use a combination of the application name and the component name. In this case, com.sap.portal.prt.config.prototype is the application name and HelloWorld is the component name . Of course, if you need only one Config listener in your application, you can just use the application name.
§ public void configEvent(ConfigEvent event) – this is called when an action occurred on the specified Configuration

public void configEvent(ConfigEvent event) { if (event.getType() == ConfigEvent.CONFIGURABLE_ADDED) { ... } else if ( event.getType() == ConfigEvent.CONFIGURABLE_UPDATED) { ... } else if ( ... } |
b. List of events type:
Event |
Description |
CONFIGMANAGER_INITIALIZED |
A configmanager has been initialized |
CONFIGMANAGER_TERMINATED |
A configmanager has been terminated |
CONFIGURABLE_ADDED |
A new configurable has been added |
CONFIGURABLE_DELETED |
A configurable has been deleted |
CONFIGURABLE_LOADED |
A new configurable has been loaded from store |
CONFIGURABLE_UPDATED |
A configurable has been updated |
CONFIGURATION_UPDATED |
The configuration has been updated (by a queued update) |
2. Add a listener
To be notified about changes to your configuration data, you have to subscribe to the IConfigEventService. When you do this you can specify for which domains you want to receive notifications.
Specifying domains allows the configuration framework to perform preliminary filtering on the events that will be sent to your listener, so that your listener receives only the events that are relevant to your application.

try { // get Configuration Service IConfigurationService configurationService = Configuration.getInstance(); IConfigEventService eventService = configurationService.getConfigEventServiceInstance();
// add listener on domain String[] domains = { "/com.sap.portal.prt.config" }; eventService.addConfigEventListener(this, domains); } catch (InitialConfigException e) { e.printStackTrace(); } catch (InvalidEntryException e) { e.printStackTrace(); } |
Generally speaking, elements of domains can be plug-ins, configurables or config items. You can register the listener in the method init(IPortalComponentInitContext context) of your portal iView.
3. Remove the listener
At the end, you have to remove the listener of the IConfigEventService. The destroy method of your component is a good place to remove the listener:

try { // get Configuration Service IConfigurationService configurationService = Configuration.getInstance(); IConfigEventService eventService = configurationService.getConfigEventServiceInstance();
// remove listener eventService.removeConfigEventListener(this); } catch (InvalidEntryException e) { e.printStackTrace(); } catch (InitialConfigException e) { e.printStackTrace(); } |
