Skip to content

Instantly share code, notes, and snippets.

@andytill
Created September 4, 2012 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andytill/3620548 to your computer and use it in GitHub Desktop.
Save andytill/3620548 to your computer and use it in GitHub Desktop.
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