Skip to content

Instantly share code, notes, and snippets.

@Romain-P
Created June 8, 2014 15:10
Show Gist options
  • Save Romain-P/cf4985edb861589b4d91 to your computer and use it in GitHub Desktop.
Save Romain-P/cf4985edb861589b4d91 to your computer and use it in GitHub Desktop.
better
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