view dev/multi-module-plugin-archetype/src/main/resources/archetype-resources/client-cli/src/main/java/cli/internal/Activator.java @ 1383:21466861b0ef

Add thermostat multi-module plug-in archetype. Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-January/009130.html Reviewed-by: neugens PR1671
author Severin Gehwolf <sgehwolf@redhat.com>
date Tue, 21 Jan 2014 19:17:27 +0100
parents
children
line wrap: on
line source

package ${package}.cli.internal;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import com.redhat.thermostat.common.cli.CommandRegistry;
import com.redhat.thermostat.common.cli.CommandRegistryImpl;

/**
 * Registers the {@link ExampleCommand} with Thermostat.
 */
public class Activator implements BundleActivator {

    private CommandRegistry reg;
    
    @Override
    public void start(BundleContext context) throws Exception {    
        ExampleCommand cmd = new ExampleCommand(context);
        reg = new CommandRegistryImpl(context);
        reg.registerCommand(ExampleCommand.NAME, cmd);
    }

    @Override
    public void stop(BundleContext context) throws Exception {
        if (reg != null) {
            // unregisters commands which this registry registered
            reg.unregisterCommands();
        }
    }
}