Created
June 8, 2014 15:10
-
-
Save Romain-P/cf4985edb861589b4d91 to your computer and use it in GitHub Desktop.
better
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 TestImpl test; | |
@Override | |
public void start(BundleContext context) throws Exception { | |
Hashtable<String, String> properties = new Hashtable<>(); | |
properties.put("Plugin", "Test"); | |
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