Created
June 8, 2014 18:50
-
-
Save Romain-P/2f2be677ed4d222570e1 to your computer and use it in GitHub Desktop.
plugin manager
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.core.plugin; | |
import com.google.inject.AbstractModule; | |
import com.google.inject.multibindings.Multibinder; | |
import org.heater.api.HeaterActivator; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class PluginManager { | |
private List<HeaterActivator> instances; | |
private AbstractModule module; | |
public PluginManager() { | |
this.instances = new ArrayList<>(); | |
} | |
public PluginManager initialize() { | |
//TODO: insert modules main class | |
buildModule(); | |
return this; | |
} | |
private void buildModule() { | |
this.module = new AbstractModule() { | |
@Override | |
protected void configure() { | |
Multibinder<HeaterActivator> binder = Multibinder.newSetBinder(binder(), HeaterActivator.class); | |
for(HeaterActivator instance: instances) { | |
binder.addBinding().toInstance(instance); | |
install(instance.pluginModule()); | |
} | |
} | |
}; | |
} | |
public AbstractModule getModule() { | |
return this.module; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment