Posts

Showing posts from October, 2021

Set OSGi Component properties dynamically using OCD - Use case with Sling ResourceChangeListener

Image
This post demonstrates the use of Object Class Definition(OCD) in setting the OSGi component properties. In general, per OSGi R6 annotations and above, we can set OSGi component properties via property attribute of @Component annotation (Static values) or Dynamically using @ ObjectClassDefinition together with  @ AttributeDefinition     (property amends in run time via Config Admin or /system/console/configMgr ) AttributeDefinition should be framed such that it evaluates to the property name correctly (underscores are converted to dots/period) Association of OCD with OSGi component happens via annotation named @Designate Example : Component properties like service.ranking  and in case of specific implementations like say WorkflowProcess , we set property named process.label  and for EventHandler, it is  EventConstants.EVENT_TOPIC  and examples add on in a similar fashion for any OSGi Component for that matter.   In order to illustrate this, I would like to consider Sling ResourceChang