Created
September 4, 2012 11:51
-
-
Save andytill/3620548 to your computer and use it in GitHub Desktop.
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 projmon.guice; | |
import java.util.ArrayList; | |
import com.google.inject.Key; | |
import com.google.inject.Provider; | |
import com.google.inject.Singleton; | |
@Singleton | |
public class FXMLLoadingScope extends EnterableScope { | |
private ArrayList<IdentifiableController> identifiables; | |
@Override | |
public void enter() { | |
super.enter(); | |
identifiables = new ArrayList<IdentifiableController>(); | |
} | |
@Override | |
public void exit() { | |
super.exit(); | |
identifiables = null; | |
} | |
@Override | |
protected <T> Object provideObject(Key<T> key, Provider<T> unscoped) { | |
Object providedObject = unscoped.get(); | |
if(providedObject instanceof IdentifiableController) { | |
if(identifiables != null) { | |
identifiables.add((IdentifiableController) providedObject); | |
} | |
} | |
return providedObject; | |
} | |
public ArrayList<IdentifiableController> getControllers() { | |
return identifiables; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment