actions, boolean disableAutoBinding) {
this.scanner = scanner;
this.stage = stage;
this.mode = mode;
this.modules = modules;
this.actions = actions;
- this.transformers = transformers;
this.bootstrapModules = bootstrapModules;
this.disableAutoBinding = disableAutoBinding;
}
@@ -85,7 +83,7 @@ protected void configure()
bindScope(LazySingleton.class, LazySingletonScope.get());
bindScope(FineGrainedLazySingleton.class, FineGrainedLazySingletonScope.get());
- bootstrapBinder = new BootstrapBinder(binder(), stage, mode, modules, actions, transformers, disableAutoBinding);
+ bootstrapBinder = new BootstrapBinder(binder(), stage, mode, modules, actions, disableAutoBinding);
if ( bootstrapModules != null )
{
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjector.java b/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjector.java
index 0197d6b1..2014333a 100644
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjector.java
+++ b/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjector.java
@@ -16,22 +16,6 @@
package com.netflix.governator.guice;
-import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.annotation.Resource;
-import javax.annotation.Resources;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@@ -60,6 +44,22 @@
import com.netflix.governator.lifecycle.ClasspathScanner;
import com.netflix.governator.lifecycle.LifecycleManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+
/**
*
* When using Governator, do NOT create a Guice injector manually. Instead, use a LifecycleInjector to create a Guice injector.
@@ -91,7 +91,6 @@ public class LifecycleInjector
private final Stage stage;
private final LifecycleInjectorMode mode;
private Set actions;
- private Set transformers;
/**
* Create a new LifecycleInjector builder
@@ -318,9 +317,6 @@ public Injector createChildInjector(Collection modules)
Injector childInjector;
Collection localModules = modules;
- for (ModuleTransformer transformer : transformers) {
- localModules = transformer.call(localModules);
- }
//noinspection deprecation
if ( mode == LifecycleInjectorMode.REAL_CHILD_INJECTORS )
{
@@ -417,7 +413,6 @@ public Injector createInjector(Collection additionalModules)
builder.getLifecycleInjectorMode(),
builder.getModuleListBuilder(),
builder.getPostInjectorActions(),
- builder.getModuleTransformers(),
builder.isDisableAutoBinding());
injector = Guice.createInjector
@@ -433,7 +428,6 @@ public Injector createInjector(Collection additionalModules)
this.ignoreClasses = ImmutableList.copyOf(builder.getIgnoreClasses());
this.actions = injector.getInstance(Key.get(new TypeLiteral>() {}));
- this.transformers = injector.getInstance(Key.get(new TypeLiteral>() {}));
try {
this.modules = internalBootstrapModule.getModuleListBuilder().build(injector);
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjectorBuilder.java b/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjectorBuilder.java
index d4411b7c..1a5b6eac 100644
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjectorBuilder.java
+++ b/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjectorBuilder.java
@@ -21,6 +21,7 @@
import com.google.inject.Stage;
import com.netflix.governator.annotations.AutoBindSingleton;
import com.netflix.governator.lifecycle.ClasspathScanner;
+
import java.util.Collection;
/**
@@ -109,6 +110,7 @@ public interface LifecycleInjectorBuilder
* @param module root application module
* @return this
*/
+ @Deprecated
public LifecycleInjectorBuilder withModuleClass(Class extends Module> module);
/**
@@ -240,39 +242,6 @@ public interface LifecycleInjectorBuilder
*/
public LifecycleInjectorBuilder withMode(LifecycleInjectorMode mode);
- /**
- * Just before creating the injector all the modules will run through the transformer.
- * Transformers will be executed in the order in which withModuleTransformer
- * is called. Note that once the first filter is called subsequent calls will only be
- * given the previous set of filtered modules.
- *
- * @param transformer
- * @return this
- */
- public LifecycleInjectorBuilder withModuleTransformer(ModuleTransformer transformer);
-
- /**
- * Just before creating the injector all the modules will run through the filter.
- * Transformers will be executed in the order in which withModuleTransformer
- * is called. Note that once the first filter is called subsequent calls will only be
- * given the previous set of filtered modules.
- *
- * @param transformer
- * @return this
- */
- public LifecycleInjectorBuilder withModuleTransformer(Collection extends ModuleTransformer> transformer);
-
- /**
- * Just before creating the injector all the modules will run through the filter.
- * Transformers will be executed in the order in which withModuleTransformer
- * is called. Note that once the first filter is called subsequent calls will only be
- * given the previous set of filtered modules.
- *
- * @param transformer
- * @return this
- */
- public LifecycleInjectorBuilder withModuleTransformer(ModuleTransformer... transformer);
-
/**
* Action to perform after the injector is created. Note that post injection actions
* are performed in the same order as calls to withPostInjectorAction
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjectorBuilderImpl.java b/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjectorBuilderImpl.java
index c47897d0..58d39257 100644
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjectorBuilderImpl.java
+++ b/governator-legacy/src/main/java/com/netflix/governator/guice/LifecycleInjectorBuilderImpl.java
@@ -41,7 +41,6 @@ class LifecycleInjectorBuilderImpl implements LifecycleInjectorBuilder
@SuppressWarnings("deprecation")
private LifecycleInjectorMode lifecycleInjectorMode = LifecycleInjectorMode.REAL_CHILD_INJECTORS;
private List actions = ImmutableList.of();
- private List transformers = ImmutableList.of();
public LifecycleInjectorBuilder withBootstrapModule(BootstrapModule module)
{
@@ -236,39 +235,6 @@ public LifecycleInjectorBuilder inStage(Stage stage)
return this;
}
- @Override
- public LifecycleInjectorBuilder withModuleTransformer(ModuleTransformer filter) {
- if (filter != null) {
- this.transformers = ImmutableList.builder()
- .addAll(this.transformers)
- .add(filter)
- .build();
- }
- return this;
- }
-
- @Override
- public LifecycleInjectorBuilder withModuleTransformer(Collection extends ModuleTransformer> filters) {
- if (this.transformers != null) {
- this.transformers = ImmutableList.builder()
- .addAll(this.transformers)
- .addAll(filters)
- .build();
- }
- return this;
- }
-
- @Override
- public LifecycleInjectorBuilder withModuleTransformer(ModuleTransformer... filters) {
- if (this.transformers != null) {
- this.transformers = ImmutableList.builder()
- .addAll(this.transformers)
- .addAll(ImmutableList.copyOf(filters))
- .build();
- }
- return this;
- }
-
@Override
public LifecycleInjectorBuilder withPostInjectorAction(PostInjectorAction action) {
this.actions = ImmutableList.builder()
@@ -351,10 +317,6 @@ List getPostInjectorActions() {
return actions;
}
- List getModuleTransformers() {
- return transformers;
- }
-
boolean isDisableAutoBinding() {
return this.disableAutoBinding;
}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/ModuleTransformer.java b/governator-legacy/src/main/java/com/netflix/governator/guice/ModuleTransformer.java
deleted file mode 100644
index 8c8b6176..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/ModuleTransformer.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.netflix.governator.guice;
-
-import java.util.Collection;
-
-import com.google.inject.Module;
-
-/**
- * Before creating the injector the modules are passed through a collection
- * of filters that can filter out or modify bindings
- *
- * @author elandau
- *
- */
-public interface ModuleTransformer {
- public Collection call(Collection modules);
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/ModulesEx.java b/governator-legacy/src/main/java/com/netflix/governator/guice/ModulesEx.java
deleted file mode 100644
index e827aa45..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/ModulesEx.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.netflix.governator.guice;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-import com.netflix.governator.guice.annotations.Bootstrap;
-
-/**
- * Utility class similar to Guice's Modules that simplifies recipes for
- * combing Guice modules.
- *
- * @author elandau
- *
- */
-public class ModulesEx {
- private static final Logger LOG = LoggerFactory.getLogger(ModulesEx.class);
-
- public static Module combineAndOverride(Module ... modules) {
- return combineAndOverride(Arrays.asList(modules));
- }
-
- /**
- * Generate a single module that is produced by accumulating and overriding
- * each module with the next.
- *
- *
- * {@code
- * Guice.createInjector(ModuleUtils.combineAndOverride(moduleA, moduleAOverrides, moduleB));
- * }
- *
- *
- * @param modules
- * @return
- */
- public static Module combineAndOverride(List extends Module> modules) {
- Iterator extends Module> iter = modules.iterator();
- Module current = Modules.EMPTY_MODULE;
- if (iter.hasNext()) {
- current = iter.next();
- if (iter.hasNext()) {
- current = Modules.override(current).with(iter.next());
- }
- }
-
- return current;
- }
-
- public static Module fromClass(final Class> cls) {
- return fromClass(cls, true);
- }
-
- /**
- * Create a single module that derived from all bootstrap annotations
- * on a class, where that class itself is a module.
- *
- * For example,
- *
- * {@code
- * public class MainApplicationModule extends AbstractModule {
- * @Override
- * public void configure() {
- * // Application specific bindings here
- * }
- *
- * public static void main(String[] args) {
- * Guice.createInjector(ModulesEx.fromClass(MainApplicationModule.class));
- * }
- * }
- * }
- *
- * @author elandau
- */
- public static Module fromClass(final Class> cls, final boolean override) {
- List modules = new ArrayList<>();
- // Iterate through all annotations of the main class, create a binding for the annotation
- // and add the module to the list of modules to install
- for (final Annotation annot : cls.getDeclaredAnnotations()) {
- final Class extends Annotation> type = annot.annotationType();
- Bootstrap bootstrap = type.getAnnotation(Bootstrap.class);
- if (bootstrap != null) {
- LOG.info("Adding Module {}", bootstrap.module());
- try {
- modules.add(bootstrap.module().getConstructor(type).newInstance(annot));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- try {
- if (override) {
- return Modules.override(combineAndOverride(modules)).with((Module)cls.newInstance());
- }
- else {
- return Modules.combine(Modules.combine(modules), (Module)cls.newInstance());
- }
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/actions/GrapherAction.java b/governator-legacy/src/main/java/com/netflix/governator/guice/actions/GrapherAction.java
deleted file mode 100644
index 28194331..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/actions/GrapherAction.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.netflix.governator.guice.actions;
-
-import com.google.inject.Injector;
-import com.netflix.governator.guice.Grapher;
-import com.netflix.governator.guice.PostInjectorAction;
-
-public class GrapherAction implements PostInjectorAction {
- private String text;
-
- @Override
- public void call(Injector injector) {
- Grapher grapher = injector.getInstance(Grapher.class);
- try {
- text = grapher.graph();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public String getText() {
- return text;
- }
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/actions/LifecycleManagerStarter.java b/governator-legacy/src/main/java/com/netflix/governator/guice/actions/LifecycleManagerStarter.java
deleted file mode 100644
index 5b2ad58d..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/actions/LifecycleManagerStarter.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.netflix.governator.guice.actions;
-
-import com.google.inject.Injector;
-import com.netflix.governator.guice.PostInjectorAction;
-import com.netflix.governator.lifecycle.LifecycleManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LifecycleManagerStarter implements PostInjectorAction {
- private static final Logger log = LoggerFactory.getLogger(LifecycleManagerStarter.class);
-
- @Override
- public void call(Injector injector) {
- LifecycleManager manager = injector.getInstance(LifecycleManager.class);
- try {
- manager.start();
- } catch (Exception e) {
- log.error("Failed to start LifecycleManager", e);
- }
- }
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/annotations/Bootstrap.java b/governator-legacy/src/main/java/com/netflix/governator/guice/annotations/Bootstrap.java
index e4981a8e..ae9a0391 100644
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/annotations/Bootstrap.java
+++ b/governator-legacy/src/main/java/com/netflix/governator/guice/annotations/Bootstrap.java
@@ -12,6 +12,11 @@
import com.netflix.governator.guice.LifecycleInjectorBuilder;
import com.netflix.governator.guice.LifecycleInjectorBuilderSuite;
+/**
+ * @deprecated 2016-05-26 All annotation based module loading APIs are being removed in favor of
+ * pure Guice and InjectoBuilder
+ */
+@Deprecated
@Documented
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/annotations/GovernatorConfiguration.java b/governator-legacy/src/main/java/com/netflix/governator/guice/annotations/GovernatorConfiguration.java
index fb51159c..00246e64 100644
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/annotations/GovernatorConfiguration.java
+++ b/governator-legacy/src/main/java/com/netflix/governator/guice/annotations/GovernatorConfiguration.java
@@ -1,16 +1,15 @@
package com.netflix.governator.guice.annotations;
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
import com.google.inject.Stage;
import com.netflix.governator.guice.LifecycleInjectorMode;
-import com.netflix.governator.guice.ModuleTransformer;
import com.netflix.governator.guice.PostInjectorAction;
import com.netflix.governator.guice.bootstrap.GovernatorBootstrap;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
/**
* Governator configuration for the main bootstrap class with 'good' default
*/
@@ -45,10 +44,4 @@
* @return
*/
Class extends PostInjectorAction>[] actions() default {};
-
- /**
- * {@link ModuleTransform} operations to perform on the final list of modules
- * @return
- */
- Class extends ModuleTransformer>[] transformers() default {};
}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/bootstrap/GovernatorBootstrap.java b/governator-legacy/src/main/java/com/netflix/governator/guice/bootstrap/GovernatorBootstrap.java
index 7d194dc7..81e457ce 100644
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/bootstrap/GovernatorBootstrap.java
+++ b/governator-legacy/src/main/java/com/netflix/governator/guice/bootstrap/GovernatorBootstrap.java
@@ -4,7 +4,6 @@
import com.google.inject.ProvisionException;
import com.netflix.governator.guice.BootstrapBinder;
import com.netflix.governator.guice.BootstrapModule;
-import com.netflix.governator.guice.ModuleTransformer;
import com.netflix.governator.guice.PostInjectorAction;
import com.netflix.governator.guice.annotations.GovernatorConfiguration;
@@ -34,13 +33,5 @@ public void configure(BootstrapBinder binder) {
throw new ProvisionException("Error creating postInjectorAction '" + action.getName() + "'", e);
}
}
-
- for (Class extends ModuleTransformer> transformer : config.transformers()) {
- try {
- binder.bindModuleTransformer().to(transformer);
- } catch (Exception e) {
- throw new ProvisionException("Error creating postInjectorAction '" + transformer.getName() + "'", e);
- }
- }
}
}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/main/BootstrapMain.java b/governator-legacy/src/main/java/com/netflix/governator/guice/main/BootstrapMain.java
deleted file mode 100644
index 25e04018..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/main/BootstrapMain.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.netflix.governator.guice.main;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.ProvisionException;
-import com.netflix.governator.guice.LifecycleInjector;
-
-/**
- * Main class for loading a bootstrap configuration via main(). When running an application set
- * this to the main class and set the first argument to the name of the bootstrap'd class.
- *
- * java BootstrapMain com.org.MyApplicationBootstrap ...
- *
- * Where,
- *
- *
- * {@code
- * @GovernatorConfiguration
- * public class MyApplicationBootstrap extends AbstractModule {
- * public void configure() {
- * // your application bindings here
- * }
- * }
- * }
- *
- *
- * Note that any component in your application can gain access to the command line arguments by injecting
- * Arguments. Also, it is the responsibility of your application to parse the command line and manage
- * the application lifecycle. In the future there may be governator subprojects for various cli parsing
- * and command line processing libraries (such as apache commons cli)
- *
- *
- * {@code
- * @Singleton
- * public class MyApplication {
- * @Inject
- * MyApplication(Arguments args) {
- * }
- * }
- * }
- *
- * @author elandau
- */
-public class BootstrapMain {
- public static void main(final String args[]) {
- try {
- Class> mainClass = Class.forName(args[0]);
- LifecycleInjector.bootstrap(mainClass, new AbstractModule() {
- @Override
- protected void configure() {
- bind(Arguments.class).toInstance(new Arguments(args));
- }
- });
- } catch (Exception e) {
- throw new ProvisionException("Error instantiating main class", e);
- }
- }
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/LifecycleRunner.java b/governator-legacy/src/main/java/com/netflix/governator/guice/runner/LifecycleRunner.java
deleted file mode 100644
index a5b9d687..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/LifecycleRunner.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.netflix.governator.guice.runner;
-
-import com.netflix.governator.guice.runner.standalone.StandaloneRunnerModule;
-
-/**
- * Abstraction defining the application runtime framework for an application using
- * Governator. If a binding for ApplicationFramework exists Governator will
- * create the instance of the ApplicationFramework immediately after creating
- * the bootstrap module. It is the application framework's responsibility
- * to call {@link com.netflix.governator.lifecycle.LifecycleManager LifecycleManager}
- * start and stop as well as manage the application termination mechanism.
- *
- * A {@link StandaloneRunnerModule} is provided for simple command line
- * applications.
- *
- * Additional LifecycleRunner implementations may be provided for running
- * Jetty, Karyon, etc...
- *
- * @author elandau
- *
- */
-public interface LifecycleRunner {
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/TerminationEvent.java b/governator-legacy/src/main/java/com/netflix/governator/guice/runner/TerminationEvent.java
deleted file mode 100644
index 679bc5a5..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/TerminationEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.netflix.governator.guice.runner;
-
-/**
- * Abstraction for an event that when fired should tell the LifecycleRunner
- * to terminate. A concrete TerminatEvent type is normally paired with a
- * specific runner implementation.
- *
- * @author elandau
- *
- * TODO: Add additional listeners of the termination event
- */
-public interface TerminationEvent {
- /**
- * Block until the termination event is fired.
- *
- * @throws InterruptedException
- */
- public void await() throws InterruptedException;
-
- /**
- * Fire the termination event.
- */
- public void terminate();
-
- /**
- * @return True if the termination event was set.
- */
- public boolean isTerminated();
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/events/BlockingTerminationEvent.java b/governator-legacy/src/main/java/com/netflix/governator/guice/runner/events/BlockingTerminationEvent.java
deleted file mode 100644
index bf4081aa..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/events/BlockingTerminationEvent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.netflix.governator.guice.runner.events;
-
-import javax.inject.Singleton;
-
-import com.netflix.governator.guice.runner.TerminationEvent;
-
-/**
- * Simple TerminatEvent using a countdown latch as the termination signal.
- *
- * @author elandau
- */
-@Singleton
-public class BlockingTerminationEvent implements TerminationEvent {
- private volatile boolean isTerminated = false;
-
- @Override
- public synchronized void await() throws InterruptedException {
- while (!isTerminated) {
- this.wait();
- }
- }
-
- @Override
- public synchronized void terminate() {
- isTerminated = true;
- this.notifyAll();
- }
-
- @Override
- public boolean isTerminated() {
- return isTerminated;
- }
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/events/SelfDestructingTerminationEvent.java b/governator-legacy/src/main/java/com/netflix/governator/guice/runner/events/SelfDestructingTerminationEvent.java
deleted file mode 100644
index 9ff96ca1..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/events/SelfDestructingTerminationEvent.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.netflix.governator.guice.runner.events;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-/**
- * Used mainly for testing the SelfDestructingTerminationEvent will fire the main TerminateEvent
- * after a specified amount of time has elapsed, causing the application to exit.
- * @author elandau
- */
-public class SelfDestructingTerminationEvent extends BlockingTerminationEvent {
- public SelfDestructingTerminationEvent(final long timeout, final TimeUnit units) {
- Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setDaemon(true).build())
- .schedule(new Runnable() {
- @Override
- public void run() {
- terminate();
- }
- }, timeout, units);
- }
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/standalone/StandaloneRunnerModule.java b/governator-legacy/src/main/java/com/netflix/governator/guice/runner/standalone/StandaloneRunnerModule.java
deleted file mode 100644
index 329614db..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/runner/standalone/StandaloneRunnerModule.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package com.netflix.governator.guice.runner.standalone;
-
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Singleton;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.TypeLiteral;
-import com.netflix.governator.annotations.binding.Main;
-import com.netflix.governator.guice.BootstrapBinder;
-import com.netflix.governator.guice.BootstrapModule;
-import com.netflix.governator.guice.lazy.LazySingleton;
-import com.netflix.governator.guice.lazy.LazySingletonScope;
-import com.netflix.governator.guice.runner.LifecycleRunner;
-import com.netflix.governator.guice.runner.TerminationEvent;
-import com.netflix.governator.guice.runner.events.BlockingTerminationEvent;
-import com.netflix.governator.lifecycle.LifecycleManager;
-
-/**
- * Implementation of a Runner module that should be used for runtime applications.
- *
- * @author elandau
- */
-public class StandaloneRunnerModule implements BootstrapModule {
- private static Logger LOG = LoggerFactory.getLogger(StandaloneRunnerModule.class);
-
- /**
- * This builder simplifies creation of the module in main()
- */
- public static class Builder {
- private List args = Lists.newArrayList();
- private Class> main;
- private TerminationEvent terminateEvent;
-
- /**
- * Specify optional command line arguments to be injected. The arguments can be injected
- * as
- *
- *
- * @Main List
- *
- * @param args
- */
- public Builder withArgs(String[] args) {
- this.args.addAll(Lists.newArrayList(args));
- return this;
- }
-
- /**
- * Specify an optional main class to instantiate. Alternatively the
- * main class can be added as an eager singleton
- * @param main
- */
- public Builder withMainClass(Class> main) {
- this.main = main;
- return this;
- }
-
- /**
- * Specify an externally provided {@link TerminationEvent}. If not specified
- * the default {@link BlockingTerminationEvent} will be used.
- * @param event
- */
- public Builder withTerminateEvent(TerminationEvent event) {
- this.terminateEvent = event;
- return this;
- }
-
- public StandaloneRunnerModule build() {
- return new StandaloneRunnerModule(this);
- }
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- @LazySingleton
- public static class StandaloneFramework implements LifecycleRunner {
- @Inject
- private Injector injector ;
-
- @Inject
- private LifecycleManager manager;
-
- @Inject(optional=true)
- private @Main Class> mainClass;
-
- @Inject(optional=true)
- private @Main List args;
-
- @Inject
- private @Main TerminationEvent terminateEvent;
-
- /**
- * This is the application's main 'run' loop. which blocks on the termination event
- */
- @PostConstruct
- public void init() {
- try {
- LOG.info("Starting application");
- manager.start();
-
- if (mainClass != null)
- injector.getInstance(mainClass);
-
- final ExecutorService executor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("GovernatorStandaloneTerminator-%d").build());
- executor.execute(new Runnable() {
- @Override
- public void run() {
- LOG.info("Waiting for terminate event");
- try {
- terminateEvent.await();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- LOG.info("Terminating application");
- manager.close();
- executor.shutdown();
- }
- });
- }
- catch (Exception e) {
- LOG.error("Error executing application ", e);
- }
- }
- }
-
- private final List args;
- private final Class> main;
- private final TerminationEvent terminateEvent;
-
- public StandaloneRunnerModule(String[] args, Class> main) {
- this.args = ImmutableList.copyOf(args);
- this.main = main;
- this.terminateEvent = null;
- }
-
- private StandaloneRunnerModule(Builder builder) {
- this.args = builder.args;
- this.main = builder.main;
- this.terminateEvent = builder.terminateEvent;
- }
-
- @Singleton
- public static class MainInjectorModule extends AbstractModule {
- @Override
- protected void configure() {
- bind(LifecycleRunner.class).to(StandaloneFramework.class).asEagerSingleton();
- }
- }
-
- @Override
- public void configure(BootstrapBinder binder) {
- binder.bind(MainInjectorModule.class);
-
- if (main != null) {
- binder.bind(main).in(LazySingletonScope.get());
- binder.bind(new TypeLiteral>() {}).annotatedWith(Main.class).toInstance(main);
- }
- if (args != null) {
- binder.bind(new TypeLiteral>() {}).annotatedWith(Main.class).toInstance(args);
- }
-
- if (terminateEvent == null)
- binder.bind(TerminationEvent.class).annotatedWith(Main.class).to(BlockingTerminationEvent.class);
- else
- binder.bind(TerminationEvent.class).annotatedWith(Main.class).toInstance(terminateEvent);
- }
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/OverrideAllDuplicateBindings.java b/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/OverrideAllDuplicateBindings.java
deleted file mode 100644
index 0af70326..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/OverrideAllDuplicateBindings.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.netflix.governator.guice.transformer;
-
-import java.util.Collection;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-import com.netflix.governator.guice.ModuleTransformer;
-
-/**
- * Treat any binding in list order as an override for previous bindings.
- *
- * @author elandau
- */
-public class OverrideAllDuplicateBindings implements ModuleTransformer {
-
- @Override
- public Collection call(Collection modules) {
- // Starting point
- Module current = new AbstractModule() {
- @Override
- protected void configure() {
- }
- };
-
- // Accumulate bindings while allowing for each to override all
- // previous bindings
- for (Module module : modules) {
- current = Modules.override(current).with(module);
- }
- return ImmutableList.of(current);
- }
-
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/StripStaticInjections.java b/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/StripStaticInjections.java
deleted file mode 100644
index 2dc3ba05..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/StripStaticInjections.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.netflix.governator.guice.transformer;
-
-import java.util.Collection;
-import java.util.List;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.inject.Module;
-import com.google.inject.spi.DefaultElementVisitor;
-import com.google.inject.spi.Element;
-import com.google.inject.spi.Elements;
-import com.google.inject.spi.StaticInjectionRequest;
-import com.netflix.governator.guice.ModuleTransformer;
-
-public class StripStaticInjections implements ModuleTransformer {
- @Override
- public Collection call(Collection modules) {
- final List noStatics = Lists.newArrayList();
- for(Element element : Elements.getElements(modules)) {
- element.acceptVisitor(new DefaultElementVisitor() {
- @Override
- public Void visit(StaticInjectionRequest request) {
- // override to not call visitOther
- return null;
- }
-
- @Override
- public Void visitOther(Element element) {
- noStatics.add(element);
- return null;
- }
- });
- }
- return ImmutableList.of(Elements.getModule(noStatics));
- }
-}
diff --git a/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/WarnAboutStaticInjections.java b/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/WarnAboutStaticInjections.java
deleted file mode 100644
index 4da305bc..00000000
--- a/governator-legacy/src/main/java/com/netflix/governator/guice/transformer/WarnAboutStaticInjections.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.netflix.governator.guice.transformer;
-
-import java.util.Collection;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Module;
-import com.google.inject.spi.DefaultElementVisitor;
-import com.google.inject.spi.Element;
-import com.google.inject.spi.Elements;
-import com.google.inject.spi.StaticInjectionRequest;
-import com.netflix.governator.guice.ModuleTransformer;
-
-public class WarnAboutStaticInjections implements ModuleTransformer {
- private static Logger LOG = LoggerFactory.getLogger(WarnAboutStaticInjections.class);
-
- @Override
- public Collection call(Collection modules) {
- for(Element element : Elements.getElements(modules)) {
- element.acceptVisitor(new DefaultElementVisitor() {
- @Override
- public Void visit(StaticInjectionRequest request) {
- LOG.warn("You shouldn't be using static injection at: " + request.getSource());
- return null;
- }
- });
- }
- return modules;
- }
-
-}
diff --git a/governator-legacy/src/test/java/com/netflix/governator/BootstrapTest.java b/governator-legacy/src/test/java/com/netflix/governator/BootstrapTest.java
deleted file mode 100644
index 1fad5d51..00000000
--- a/governator-legacy/src/test/java/com/netflix/governator/BootstrapTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.netflix.governator;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.CreationException;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Stage;
-import com.netflix.governator.guice.ModulesEx;
-import com.netflix.governator.guice.annotations.Bootstrap;
-
-public class BootstrapTest {
-
- public static interface Foo {
- }
-
- public static class Foo1 implements Foo {
- }
-
- public static class Foo2 implements Foo {
- }
-
- @Documented
- @Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
- @Target({ElementType.TYPE})
- @Bootstrap(module=FooBootstrap.class)
- public static @interface FooConfiguration {
- Class extends Foo> foo() default Foo1.class;
- }
-
- public static class FooBootstrap extends AbstractModule {
- private FooConfiguration config;
- public FooBootstrap(FooConfiguration config) {
- this.config = config;
- }
-
- @Override
- protected void configure() {
- bind(Foo.class).to(config.foo());
- }
- }
-
- @FooConfiguration
- public static class MyApplication extends AbstractModule {
- @Override
- protected void configure() {
- }
- }
-
- @FooConfiguration
- public static class MyApplicationWithOverride extends AbstractModule {
- @Override
- protected void configure() {
- bind(Foo.class).to(Foo2.class);
- }
- }
-
- @Test
- public void testWithoutOverride() {
- Injector injector = Guice.createInjector(Stage.DEVELOPMENT, ModulesEx.fromClass(MyApplication.class));
- Assert.assertEquals(Foo1.class, injector.getInstance(Foo.class).getClass());
- }
-
- @Test(expectedExceptions=CreationException.class)
- public void testDuplicateWithoutOverride() {
- Injector injector = Guice.createInjector(Stage.DEVELOPMENT, ModulesEx.fromClass(MyApplicationWithOverride.class, false));
- Assert.fail("Should have failed with duplicate binding exception");
- }
-
- @Test
- public void testDuplicateWithOverride() {
- Injector injector = Guice.createInjector(Stage.DEVELOPMENT, ModulesEx.fromClass(MyApplicationWithOverride.class));
- Assert.assertEquals(Foo2.class, injector.getInstance(Foo.class).getClass());
- }
-
-}
diff --git a/governator-legacy/src/test/java/com/netflix/governator/autobind/TestAutoBind.java b/governator-legacy/src/test/java/com/netflix/governator/autobind/TestAutoBind.java
index 145a248c..30a9d21f 100644
--- a/governator-legacy/src/test/java/com/netflix/governator/autobind/TestAutoBind.java
+++ b/governator-legacy/src/test/java/com/netflix/governator/autobind/TestAutoBind.java
@@ -18,19 +18,18 @@
import com.google.common.collect.Lists;
import com.google.inject.Binder;
-import com.google.inject.Guice;
import com.google.inject.Injector;
-import com.google.inject.Module;
import com.google.inject.TypeLiteral;
import com.netflix.governator.LifecycleInjectorBuilderProvider;
import com.netflix.governator.annotations.AutoBind;
import com.netflix.governator.guice.AutoBindProvider;
-import com.netflix.governator.guice.AutoBinds;
import com.netflix.governator.guice.BootstrapBinder;
import com.netflix.governator.guice.BootstrapModule;
import com.netflix.governator.guice.LifecycleInjectorBuilder;
+
import org.testng.Assert;
import org.testng.annotations.Test;
+
import java.util.Collections;
public class TestAutoBind extends LifecycleInjectorBuilderProvider
@@ -190,24 +189,6 @@ public void configure(BootstrapBinder binder)
Assert.assertEquals(instance.getF2().getParameter(), "f2");
}
- @Test
- public void testNormally()
- {
- Injector injector = Guice.createInjector
- (
- new Module()
- {
- @Override
- public void configure(Binder binder)
- {
- binder.bind(String.class).annotatedWith(AutoBinds.withValue("foo")).toInstance("we are the music makers");
- }
- }
- );
-
- Assert.assertEquals(injector.getInstance(SimpleAutoBind.class).getString(), "we are the music makers");
- }
-
private static class CustomAutoBindProvider implements AutoBindProvider
{
@Override
diff --git a/governator-legacy/src/test/java/com/netflix/governator/guice/TestPostInjectAction.java b/governator-legacy/src/test/java/com/netflix/governator/guice/TestPostInjectAction.java
deleted file mode 100644
index f94962c6..00000000
--- a/governator-legacy/src/test/java/com/netflix/governator/guice/TestPostInjectAction.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package com.netflix.governator.guice;
-
-import java.lang.reflect.Method;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.inject.Inject;
-import javax.inject.Provider;
-
-import junit.framework.Assert;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
-import com.google.inject.Singleton;
-import com.google.inject.Stage;
-import com.netflix.governator.guice.actions.BindingReport;
-import com.netflix.governator.guice.actions.CreateAllBoundSingletons;
-import com.netflix.governator.guice.actions.GrapherAction;
-
-public class TestPostInjectAction {
- @Test
- public void testPostInjectReport() {
- GrapherAction action = new GrapherAction();
- LifecycleInjector.builder()
- .withPostInjectorAction(action)
- .build()
- .createInjector();
-
- Assert.assertNotNull(action.getText());
- }
-
- public static interface Foo {
-
- }
-
- private String testName;
-
- @BeforeMethod
- public void handleTestMethodName(Method method)
- {
- testName = method.getName();
- }
-
- @Singleton
- public static class Transitive {
- private static AtomicInteger counter = new AtomicInteger();
-
- public Transitive() {
- counter.incrementAndGet();
- }
- }
-
- @Singleton
- public static class FooImpl implements Foo {
- private static AtomicInteger counter = new AtomicInteger();
-
- @Inject
- public FooImpl(Provider transitive) {
- counter.incrementAndGet();
- }
- }
-
- public static class FooNotAnnotated implements Foo {
- private static AtomicInteger counter = new AtomicInteger();
-
- @Inject
- public FooNotAnnotated(Provider transitive) {
- counter.incrementAndGet();
- }
- }
-
- @BeforeMethod
- public void before() {
- FooImpl.counter.set(0);
- FooNotAnnotated.counter.set(0);
- Transitive.counter.set(0);
- }
-
- @Test
- public void testClassSingleton() {
- LifecycleInjector.builder()
- .inStage(Stage.DEVELOPMENT)
- .withMode(LifecycleInjectorMode.SIMULATED_CHILD_INJECTORS)
- .withPostInjectorAction(new BindingReport(testName))
- .withPostInjectorAction(new CreateAllBoundSingletons())
- .withModules(new AbstractModule() {
- @Override
- protected void configure() {
- bind(FooImpl.class);
- }
- })
- .build()
- .createInjector();
-
- Assert.assertEquals(1, FooImpl.counter.get());
- Assert.assertEquals(0, Transitive.counter.get());
- }
-
- @Test
- public void testInterfaceSingleton() {
- LifecycleInjector.builder()
- .withPostInjectorAction(new BindingReport(testName))
- .withPostInjectorAction(new CreateAllBoundSingletons())
- .inStage(Stage.DEVELOPMENT)
- .withMode(LifecycleInjectorMode.SIMULATED_CHILD_INJECTORS)
- .withModules(new AbstractModule() {
- @Override
- protected void configure() {
- bind(Foo.class).to(FooImpl.class);
- }
- })
- .build()
- .createInjector();
-
- Assert.assertEquals(1, FooImpl.counter.get());
- Assert.assertEquals(0, Transitive.counter.get());
- }
-
- @Test
- public void testInterfaceSingletonProductionStage() {
- LifecycleInjector.builder()
- .withPostInjectorAction(new BindingReport(testName))
- .withPostInjectorAction(new CreateAllBoundSingletons())
- .withModules(new AbstractModule() {
- @Override
- protected void configure() {
- bind(Foo.class).to(FooImpl.class);
- }
- })
- .build()
- .createInjector();
-
- Assert.assertEquals(1, FooImpl.counter.get());
- Assert.assertEquals(0, Transitive.counter.get());
- }
-
- @Test
- public void testScopedSingleton() {
- LifecycleInjector.builder()
- .withPostInjectorAction(new BindingReport(testName))
- .withPostInjectorAction(new CreateAllBoundSingletons())
- .inStage(Stage.DEVELOPMENT)
- .withMode(LifecycleInjectorMode.SIMULATED_CHILD_INJECTORS)
- .withModules(new AbstractModule() {
- @Override
- protected void configure() {
- bind(Foo.class).to(FooNotAnnotated.class).in(Scopes.SINGLETON);
- }
- })
- .build()
- .createInjector();
-
- Assert.assertEquals(1, FooNotAnnotated.counter.get());
- Assert.assertEquals(0, Transitive.counter.get());
- }
-
-
-
-}
diff --git a/governator-legacy/src/test/java/com/netflix/governator/guice/TestStandaloneApplication.java b/governator-legacy/src/test/java/com/netflix/governator/guice/TestStandaloneApplication.java
deleted file mode 100644
index 958d4d76..00000000
--- a/governator-legacy/src/test/java/com/netflix/governator/guice/TestStandaloneApplication.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package com.netflix.governator.guice;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-
-import junit.framework.Assert;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Stopwatch;
-import com.google.inject.AbstractModule;
-import com.netflix.governator.guice.runner.TerminationEvent;
-import com.netflix.governator.guice.runner.events.SelfDestructingTerminationEvent;
-import com.netflix.governator.guice.runner.standalone.StandaloneRunnerModule;
-
-public class TestStandaloneApplication {
- private static Logger LOG = LoggerFactory.getLogger(TestStandaloneApplication.class);
-
- private final static AtomicBoolean initCalled = new AtomicBoolean();
- private final static AtomicBoolean shutdownCalled = new AtomicBoolean();
-
- public static class SomeSingleton {
- @PostConstruct
- public void init() {
- LOG.info("Init SomeSingleton()");
- initCalled.set(true);
- }
-
- @PreDestroy
- public void shutdown() {
- LOG.info("Shutdown SomeSingleton()");
- shutdownCalled.set(true);
- }
- }
-
- @BeforeTest
- public static void before() {
- initCalled.set(false);
- shutdownCalled.set(false);
- }
-
- @Test(enabled=false)
- public void shouldCreateSingletonAndExitAfter1Second() throws Exception {
- Stopwatch sw = new Stopwatch().start();
-
- final TerminationEvent event = new SelfDestructingTerminationEvent(1, TimeUnit.SECONDS);
- LifecycleInjector.builder()
- // Example of a singleton that will be created
- .withAdditionalModules(new AbstractModule() {
- @Override
- protected void configure() {
- bind(SomeSingleton.class).asEagerSingleton();
- }
- })
- .withAdditionalBootstrapModules(
- StandaloneRunnerModule.builder()
- .withTerminateEvent(event)
- .build())
- .build()
- .createInjector();
-
- event.await();
- long elapsed = sw.elapsed(TimeUnit.MILLISECONDS);
- LOG.info("Elapsed: " + elapsed);
- Assert.assertTrue(initCalled.get());
- Assert.assertTrue(shutdownCalled.get());
- Assert.assertTrue(elapsed > 1000);
-
- LOG.info("Exit main");
-
- }
-
- public static void main(String args[]) {
- final TerminationEvent event = new SelfDestructingTerminationEvent(1, TimeUnit.SECONDS);
- LifecycleInjector.builder()
- // Example of a singleton that will be created
- .withAdditionalModules(new AbstractModule() {
- @Override
- protected void configure() {
- bind(SomeSingleton.class).asEagerSingleton();
- }
- })
- .withAdditionalBootstrapModules(
- StandaloneRunnerModule.builder()
- .withTerminateEvent(event)
- .build())
- .build()
- .createInjector();
-
- }
-}
diff --git a/governator-legacy/src/test/java/com/netflix/governator/guice/transformer/OverrideAllDuplicateBindingsTest.java b/governator-legacy/src/test/java/com/netflix/governator/guice/transformer/OverrideAllDuplicateBindingsTest.java
deleted file mode 100644
index 11bf27a8..00000000
--- a/governator-legacy/src/test/java/com/netflix/governator/guice/transformer/OverrideAllDuplicateBindingsTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.netflix.governator.guice.transformer;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Injector;
-import com.netflix.governator.guice.LifecycleInjector;
-
-public class OverrideAllDuplicateBindingsTest {
- public static interface Foo {
-
- }
- public static class Foo1 implements Foo {
-
- }
- public static class Foo2 implements Foo {
-
- }
-
- public static class MyModule extends AbstractModule {
- @Override
- protected void configure() {
- bind(Foo.class).to(Foo1.class);
- }
- }
-
- public static class MyOverrideModule extends AbstractModule {
- @Override
- protected void configure() {
- bind(Foo.class).to(Foo2.class);
- }
- }
-
- @Test
- public void testShouldFailOnDuplicate() {
- try {
- LifecycleInjector.builder()
- .withModuleClasses(MyModule.class, MyOverrideModule.class)
- .build()
- .createInjector();
- Assert.fail("Should have failed with duplicate binding");
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testShouldInstallDuplicate() {
- Injector injector = LifecycleInjector.builder()
- .withModuleTransformer(new OverrideAllDuplicateBindings())
- .withModuleClasses(MyModule.class, MyOverrideModule.class)
- .build()
- .createInjector();
-
- Foo foo = injector.getInstance(Foo.class);
- Assert.assertTrue(foo.getClass().equals(Foo2.class));
- }
-}