Re-added injection singleton properties.

This commit is contained in:
neviyn 2016-12-05 01:15:52 +00:00
parent 79ee3d3ff2
commit 1cd6bfccfc

View File

@ -22,14 +22,14 @@ class SwingUIModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
bind(IDatabase.class).to(HibernateDatabase.class).in(Singleton.class); bind(IDatabase.class).to(HibernateDatabase.class).in(Singleton.class);
bind(IPlaylist.class).to(TabbedJTablePlaylist.class); bind(IPlaylist.class).to(TabbedJTablePlaylist.class).in(Singleton.class);
bind(ILibrary.class).to(JTreeLibrary.class); bind(ILibrary.class).to(JTreeLibrary.class).in(Singleton.class);
bind(PlayerCallbackInterface.class).to(PlayerGUI.class); bind(PlayerCallbackInterface.class).to(PlayerGUI.class).in(Singleton.class);
String engineName = ConfigManager.getPlayerEngine(); String engineName = ConfigManager.getPlayerEngine();
boolean engineSet = false; boolean engineSet = false;
for(Engine engine : Engine.values()){ for(Engine engine : Engine.values()){
if(engineName.equals(engine.getEngineName()) && engine.isAvailable()){ if(engineName.equals(engine.getEngineName()) && engine.isAvailable()){
bind(IPlayer.class).to(engine.getEngineImplementation()); bind(IPlayer.class).to(engine.getEngineImplementation()).in(Singleton.class);
ConfigManager.setPlayerEngine(engine.getEngineName()); ConfigManager.setPlayerEngine(engine.getEngineName());
engineSet = true; engineSet = true;
} }
@ -37,7 +37,7 @@ class SwingUIModule extends AbstractModule {
if(!engineSet){ // If the user has set an invalid engine, try and set a usable one. if(!engineSet){ // If the user has set an invalid engine, try and set a usable one.
for(Engine engine : Engine.values()){ for(Engine engine : Engine.values()){
if(engine.isAvailable()){ if(engine.isAvailable()){
bind(IPlayer.class).to(engine.getEngineImplementation()); bind(IPlayer.class).to(engine.getEngineImplementation()).in(Singleton.class);
ConfigManager.setPlayerEngine(engine.getEngineName()); ConfigManager.setPlayerEngine(engine.getEngineName());
break; break;
} }