}
*/
public void testBindAll() throws Throwable
{
final KernelController controller = getController();
try
{
BeanMetaData singleton = new AbstractBeanMetaData("singleton", Singleton.class.getName());
controller.install(singleton);
installFactory(controller, "prototype", Prototype.class);
AbstractBeanMetaData injectorBean = new AbstractBeanMetaData("injector", GuiceInjectorFactory.class.getName());
AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
constructor.setFactoryClass(GuiceInjectorFactory.class.getName());
constructor.setFactoryMethod("createInjector");
List<ParameterMetaData> parameters = new ArrayList<ParameterMetaData>();
parameters.add(new AbstractParameterMetaData(new AbstractDependencyValueMetaData(KernelConstants.KERNEL_NAME)));
AbstractArrayMetaData array = new AbstractArrayMetaData();
array.add(new AbstractValueMetaData(GuiceObject.ALL));
parameters.add(new AbstractParameterMetaData(array));
constructor.setParameters(parameters);
injectorBean.setConstructor(constructor);
controller.install(injectorBean);
Key<Singleton> singletonKey = Key.get(Singleton.class, Names.named("singleton"));
Key<Prototype> prototypeKey = Key.get(Prototype.class, Names.named("prototype"));
ControllerContext injectorContext = controller.getInstalledContext("injector");
assertNotNull(injectorContext);
Injector injector = (Injector)injectorContext.getTarget();
assertNotNull(injector.getInstance(singletonKey));
assertSame(injector.getInstance(singletonKey), injector.getInstance(singletonKey));
assertNotNull(injector.getInstance(prototypeKey));
assertNotSame(injector.getInstance(prototypeKey), injector.getInstance(prototypeKey));
}
finally
{
controller.shutdown();
}
}