Created
May 22, 2015 15:01
-
-
Save roberto-filho/a4b95244d22b591e18ff to your computer and use it in GitHub Desktop.
Service creation with eclipse plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Para cadastrar um serviço, chame esse método no "start" da classe plugin | |
*/ | |
plugin.getBundle().getBundleContext().registerService(ExternalAPI.class, new ConcreteExternalAPI(), null); | |
/* | |
* Para obter o serviço registrado por outro plugin | |
*/ | |
BundleContext bundleContext = PluginActivator.getDefault().getBundle().getBundleContext(); | |
// Busca a referencia do service | |
ServiceReference<ExternalAPI> sr = bundleContext.getServiceReference(ExternalAPI.class); | |
// Busca o serviço concreto | |
ExternalAPI service = bundleContext.getService(sr); | |
// Roda o método do serviço | |
service.doSomething(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment