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.

((VaandroidOsgiPluginImpl))

  • static, private, instance

  • public, context

  • plugin

  • activates this plugin

  • deactivates this plugin

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

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

  • changes the label of the application

((Creating A Vaandroid Plugin))

Code {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);
}

} {CODE}