Switching To Config Subsystem Aware Bundles In OpenDaylight Helium

In my previous posts we saw why config subsystem over osgi activator, this post provides a step by step guide to convert the existing osgi bundles which are using activators to config subsystem aware bundles.

Step 1: Write a YANG file that defines configuration of your module

We will be using the configuration subsystem to wire in the dependencies between our plugin and rest of the ODL e.g. MD-SAL infrastructure services. We need to define these dependencies i.e. the services which are required in a yang file. To do this, make the src/main/yang directory structure and create a new yang file e.g. shape-provider-impl.yang as given below:

We have defined three dependencies which are specified as an augment of the config:configuration i.e. our plugin will be using RPC, Notification and Data broker services provided by MD-SAL.

Note: We need to write this YANG module definition per plugin.

Step 2: Update pom.xml to auto-generate code

2.a) Using yang-maven-plugin and yang-jmx-generator-plugin

2.b) Deleting bundle activator specification

Ensure that existing bundle activator in pom.xml file is removed i.e. you need to delete following tags from your pom.xml:

2.c)  Updating export package specification

 2.d) Defining few more dependencies

Now run a build using mvn clean install.

This will generate Java files and place them in src/main/java folders.

  • The generated file to note, located under package “ org.opendaylight.shape.provider.shape_provider.impl” is ShapeProviderModule.java. It is initially generated but once manually edited it doesn’t get overwritten by the code generator.
  • The createInstance() method of the generated file is to be implemented manually.

Other auto generated files are placed under generated-sources/config folder.

Step 3: Define initial configuration values for the module in an XML file

Lets name this file as 04-shape.xml. This file needs to be placed in following directory:


 Step 4: Implement ShapeProviderModule

Now we need to wire our service into ShapeProviderModule.java class & for that we need to modify the createInstance method to create our ShapeImpl and wire it to the MD-SAL. Basically you need to do whatever you were doing in your activator class in createInstance method.

Now build the code by using “mvn clean install” and copy the jar file in ODL plugin directory.


  1. Vikram says

    Hi Kanika

    I am a opendaylight beginner and want to understand

    what is the difference in getting the DataBroker injected by ConfigSubsystem(as explained in the article by defining dependencies in YANG) and getting the DataBroker in “onSessionInitiated(ProviderContext pc)” of BindingAware component.

    we can use below statement to get DataBroker

    In the later approach, we do not need to define the dependencies in yang file, am I correct?

Leave a Reply

Your email address will not be published. Required fields are marked *