Created
June 8, 2014 15:07
-
-
Save Romain-P/a8497136c99762913cd1 to your computer and use it in GitHub Desktop.
like that ;)
This file contains 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
package org.heater.test.service; | |
import com.google.inject.AbstractModule; | |
import com.google.inject.Inject; | |
import com.google.inject.Injector; | |
import com.google.inject.Module; | |
import org.heater.api.HeaterActivator; | |
import org.osgi.framework.BundleActivator; | |
import org.osgi.framework.BundleContext; | |
import java.util.Hashtable; | |
public class Activator extends HeaterActivator { | |
@Inject Injector injector; | |
@Override | |
public void start(BundleContext context) throws Exception { | |
Hashtable<String, String> properties = new Hashtable<>(); | |
properties.put("Plugin", "Test"); | |
TestImpl test = injector.getInstance(TestImpl.class); | |
context.registerService(TestService.class, test, properties); | |
} | |
@Override | |
public void stop(BundleContext context) throws Exception { | |
//the context will automatically unregister services | |
} | |
@Override | |
public Module pluginModule() { | |
return new AbstractModule() { | |
@Override | |
protected void configure() { | |
bind(TestService.class).to(TestImpl.class).asEagerSingleton(); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment