Ask is moving to Stack Overflow and Serverfault.com! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

Revision history [back]

click to hide/show revision 1
initial version

How does a bundle start ?start(),Activator,ComponentActivatorAbstractBase,BundleActivator

Hello everyone, I have common question that almost all of the new developers may be puzzling. How does a bundle start ?If you know OSGi,It is may be easier,but the class ComponentActivatorAbstractBase stops me from go forwarding.In the class,there is method,named start(),implementions for BundleActivator's start().In the start() method of ComponentActivatorAbstractBase, as below: public void start(BundleContext context) { try { this.dm = new DependencyManager(context);

        logger.trace("Activating");

        // Now create Global components
        Object[] imps = ***getGlobalImplementations()***;
        if (imps != null) {
            for (int i = 0; i < imps.length; i++) {
                Object key = imps[i];
                Component c = this.dbGlobalInstances.get(key);
                if (c == null) {
                    try {
                        c = this.dm.createComponent();
                        c.addStateListener(new ListenerComponentStates());
                        // Now let the derived class to configure the
                        // dependencies it wants
                        configureGlobalInstance(c, imps[i]);
                        // Set the implementation so the component
                        // can manage its lifesycle
                        if (c.getService() == null) {
                            logger.trace("Setting implementation to: {}",
                                    imps[i]);
                            c.setImplementation(imps[i]);
                        }

                        // Now add the component to the dependency
                        // Manager which will immediately start
                        // tracking the dependencies
                        this.dm.add(c);
                    } catch (Exception nex) {
                        logger.error("During creation of a Global "
                                + "instance caught exception: " + nex
                                + "\nStacktrace:"
                                + stackToString(nex.getStackTrace()));
                    }

                    //Now lets keep track in our shadow database of the
                    //association
                    if (c != null)
                        this.dbGlobalInstances.put(key, c);
                } else {
                    logger.error("I have been asked again to create an "
                            + "instance " + " Global for object: "
                            + imps[i] + "when i already have it!!");
                }
            }
        }

The bold part getGlobalImplementations() will return a null value,whatever in the class ComponentActivatorAbstractBase or in the class Activator,as bellow: protected Object[] getGlobalImplementations() { return null; } How should I understand this? But in fact we usual override getImplementations(), public Object[] getImplementations() { Object[] res = { LoadBalancerService.class };//Here will return a non-null Object array return res; }

There is another question,in the start(),there is an invoking of init(),the init() method is required to be overriden by the derived class for customization,but in the Activator,this is not happen,however,it occurs in the main class(refer to the LoadBalanceService of sal),it's really right?

How does a bundle start ?start(),Activator,ComponentActivatorAbstractBase,BundleActivator

Hello everyone, I have common question that almost all of the new developers may be puzzling. How does a bundle start ?If you know OSGi,It is may be easier,but the class ComponentActivatorAbstractBase stops me from go forwarding.In the class,there is method,named start(),implementions for BundleActivator's start().In the start() method of ComponentActivatorAbstractBase, as below: below:

public void start(BundleContext context) { try { this.dm = new DependencyManager(context);

        logger.trace("Activating");

        // Now create Global components
        Object[] imps = ***getGlobalImplementations()***;
**getGlobalImplementations()**;
        if (imps != null) {
            for (int i = 0; i < imps.length; i++) {
                Object key = imps[i];
                Component c = this.dbGlobalInstances.get(key);
                if (c == null) {
                    try {
                        c = this.dm.createComponent();
                        c.addStateListener(new ListenerComponentStates());
                        // Now let the derived class to configure the
                        // dependencies it wants
                        configureGlobalInstance(c, imps[i]);
                        // Set the implementation so the component
                        // can manage its lifesycle
                        if (c.getService() == null) {
                            logger.trace("Setting implementation to: {}",
                                    imps[i]);
                            c.setImplementation(imps[i]);
                        }

                        // Now add the component to the dependency
                        // Manager which will immediately start
                        // tracking the dependencies
                        this.dm.add(c);
                    } catch (Exception nex) {
                        logger.error("During creation of a Global "
                                + "instance caught exception: " + nex
                                + "\nStacktrace:"
                                + stackToString(nex.getStackTrace()));
                    }

                    //Now lets keep track in our shadow database of the
                    //association
                    if (c != null)
                        this.dbGlobalInstances.put(key, c);
                } else {
                    logger.error("I have been asked again to create an "
                            + "instance " + " Global for object: "
                            + imps[i] + "when i already have it!!");
                }
            }
        }

The bold part getGlobalImplementations() will return a null value,whatever in the class ComponentActivatorAbstractBase or in the class Activator,as bellow: bellow:

protected Object[] getGlobalImplementations() {
     return null;
 }

How should I understand this? But in fact we usual override getImplementations(), getImplementations(),

public Object[] getImplementations() {
     Object[] res = { LoadBalancerService.class };//Here };//***Here will return a non-null Object array array***
    return res;
    }

}

There is another question,in the start(),there is an invoking of init(),the init() method is required to be overriden by the derived class for customization,but in the Activator,this is not happen,however,it occurs in the main class(refer to the LoadBalanceService of sal),it's really right?

How does a bundle start ?start(),Activator,ComponentActivatorAbstractBase,BundleActivator

Hello everyone, I have common question that almost all of the new developers may be puzzling. How does a bundle start ?If you know OSGi,It is may be easier,but the class ComponentActivatorAbstractBase stops me from go forwarding.In the class,there is method,named start(),implementions for BundleActivator's start().In the start() method of ComponentActivatorAbstractBase, as below:

public void start(BundleContext context) { try { this.dm = new DependencyManager(context);

        logger.trace("Activating");

        // Now create Global components
        Object[] imps = **getGlobalImplementations()**;
        if (imps != null) {
            for (int i = 0; i < imps.length; i++) {
                Object key = imps[i];
                Component c = this.dbGlobalInstances.get(key);
                if (c == null) {
                    try {
                        c = this.dm.createComponent();
                        c.addStateListener(new ListenerComponentStates());
                        // Now let the derived class to configure the
                        // dependencies it wants
                        configureGlobalInstance(c, imps[i]);
                        // Set the implementation so the component
                        // can manage its lifesycle
                        if (c.getService() == null) {
                            logger.trace("Setting implementation to: {}",
                                    imps[i]);
                            c.setImplementation(imps[i]);
                        }

                        // Now add the component to the dependency
                        // Manager which will immediately start
                        // tracking the dependencies
                        this.dm.add(c);
                    } catch (Exception nex) {
                        logger.error("During creation of a Global "
                                + "instance caught exception: " + nex
                                + "\nStacktrace:"
                                + stackToString(nex.getStackTrace()));
                    }

                    //Now lets keep track in our shadow database of the
                    //association
                    if (c != null)
                        this.dbGlobalInstances.put(key, c);
                } else {
                    logger.error("I have been asked again to create an "
                            + "instance " + " Global for object: "
                            + imps[i] + "when i already have it!!");
                }
            }
        }

The bold part getGlobalImplementations() will return a null value,whatever in the class ComponentActivatorAbstractBase or in the class Activator,as bellow:

protected Object[] getGlobalImplementations() {
    return null;
}

How should I understand this? But in fact we usual override getImplementations(),

public Object[] getImplementations() {
    Object[] res = { LoadBalancerService.class };//***Here will return a non-null Object array***
    return res;
}

There is another question,in the start(),there is an invoking of init(),the init() method is required to be overriden by the derived class for customization,but in the Activator,this is not happen,however,it occurs in the main class(refer to the LoadBalanceService of sal),it's really right?

How does a bundle start ?start(),Activator,ComponentActivatorAbstractBase,BundleActivator

Hello everyone, I have common question that almost all of the new developers may be puzzling. How does a bundle start ?If you know OSGi,It is may be easier,but the class ComponentActivatorAbstractBase stops me from go forwarding.In the class,there is method,named start(),implementions for BundleActivator's start().In the start() method of ComponentActivatorAbstractBase, as below:

 public void start(BundleContext context) {
     try {
         this.dm = new DependencyManager(context);

DependencyManager(context);

        logger.trace("Activating");

        // Now create Global components
        Object[] imps = **getGlobalImplementations()**;
        if (imps != null) {
            for (int i = 0; i < imps.length; i++) {
                Object key = imps[i];
                Component c = this.dbGlobalInstances.get(key);
                if (c == null) {
                    try {
                        c = this.dm.createComponent();
                        c.addStateListener(new ListenerComponentStates());
                        // Now let the derived class to configure the
                        // dependencies it wants
                        configureGlobalInstance(c, imps[i]);
                        // Set the implementation so the component
                        // can manage its lifesycle
                        if (c.getService() == null) {
                            logger.trace("Setting implementation to: {}",
                                    imps[i]);
                            c.setImplementation(imps[i]);
                        }

                        // Now add the component to the dependency
                        // Manager which will immediately start
                        // tracking the dependencies
                        this.dm.add(c);
                    } catch (Exception nex) {
                        logger.error("During creation of a Global "
                                + "instance caught exception: " + nex
                                + "\nStacktrace:"
                                + stackToString(nex.getStackTrace()));
                    }

                    //Now lets keep track in our shadow database of the
                    //association
                    if (c != null)
                        this.dbGlobalInstances.put(key, c);
                } else {
                    logger.error("I have been asked again to create an "
                            + "instance " + " Global for object: "
                            + imps[i] + "when i already have it!!");
                }
            }
        }

The bold part getGlobalImplementations() will return a null value,whatever in the class ComponentActivatorAbstractBase or in the class Activator,as bellow:

protected Object[] getGlobalImplementations() {
    return null;
}

How should I understand this? But in fact we usual override getImplementations(),

public Object[] getImplementations() {
    Object[] res = { LoadBalancerService.class };//***Here will return a non-null Object array***
    return res;
}

There is another question,in the start(),there is an invoking of init(),the init() method is required to be overriden by the derived class for customization,but in the Activator,this is not happen,however,it occurs in the main class(refer to the LoadBalanceService of sal),it's really right?