public interface HelloPlugin {
void sayHello();
}
public class HelloPluginImpl implements HelloPlugin {
@Override
public void sayHello() {
System.out.println("Hello from HelloPlugin!");
}
}
BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
ServiceRegistration<HelloPlugin> registration = bundleContext.registerService(HelloPlugin.class, new HelloPluginImpl(), null);
ServiceReference<HelloPlugin> reference = bundleContext.getServiceReference(HelloPlugin.class);
HelloPlugin plugin = bundleContext.getService(reference);
plugin.sayHello();