Tuesday 22 October 2013

OSGi framework and Open DayLight

The newest SDN controller OpenDayLight is made on OSGi architecture. It gives you flexibility to load various plugins without stopping complete controller, which is cool actually as you can upgrade your existing plugin without any restart. So service is not affected. OSGi has three variations, OpenDayLight is made on equinox. (FYI eclipse is also made on equinox). OSGi bundles are essentially jar files. its the META-INF file which differentiates them. It has all information about the project. Whenever a project is loaded firstly an Activator class is called. (Note: That's why we give its address in tag bundle-activator in pom.xml). When bundle is loaded Activator first calls init method, and when you remove the bundle destroy method is called. the Now lets build a basic java code for ODL.


package org.opendaylight.controller.samples.userinfo.internal;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;


public class Activator extends ComponentActivatorAbstractBase {
    protected static final Logger logger = LoggerFactory
            .getLogger(Activator.class);

    /**
     * Function called when the activator starts just after some
     * initializations are done by the
     * ComponentActivatorAbstractBase.
     *
     */
    public void init() {
       logger.info("I have started !!");
    }

    /**
     * Function called when the activator stops just before the
     * cleanup done by ComponentActivatorAbstractBase
     *
     */
    public void destroy() {
              logger.info("Over and out !!");
    }

 }


For more info on pom file click here.
To create a sample application click here


No comments:

Post a Comment