PluginImpl

This class is necessary to register a new plugin. After the plugin is installed, it advertises that is a plugin, registers plugin as a new plugin.

Superclass

VaandroidOsgiPluginImpl

Variables

PluginImpl

  • static, private, instance

BundleContext

  • public, context

VaandroidOsgiPluginImpl

  • plugin

Methods

@Activate activate

  • activates this plugin

@Deactivate deactivate

  • deactivates this plugin

getInstance()

  • returns the instance PluginImpl defined in the class
  • instance is used to....

getContext()

  • returns the context BundleContext defined in the class.
  • Context is used to....

@override getLabel

  • changes the label of the application

See also

Creating A Vaandroid Plugin

Code

package tv.twelvetone.vaandroid.plugin.project_name;

import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import tv.twelvetone.vaandroid.core.api.runtime.VaandroidOsgiPlugin;
import tv.twelvetone.vaandroid.plugin.osgi.api.VaandroidOsgiPluginImpl;

@Component(service = VaandroidOsgiPlugin.class)
public class PluginImpl extends VaandroidOsgiPluginImpl {
    static private PluginImpl instance;
    public BundleContext context;
    private VaandroidOsgiPluginImpl plugin;

    public PluginImpl() {
        instance = this;
    }

    @Activate
    protected void activate(ComponentContext componentContext) {
        context = componentContext.getBundleContext();
    }

    @Deactivate
    protected void deactivate(ComponentContext componentContext) {
        context = null;
    }

    public static PluginImpl getInstance() {
        return instance;
    }

    public static BundleContext getContext() {
        return instance != null ? instance.context : null;
    }

    @Override
    public String getLabel() {
        return R.getString(R.string.app_name);
    }
}