Search in sources :

Example 6 with Binding

use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.

the class BindingResolverTest method testResolveIndirectCycleThroughProvider.

public void testResolveIndirectCycleThroughProvider() throws Exception {
    // Foo -> Baz -> Provider<Bar> -> Bar -> Foo
    StandardTree tree = createExampleTree();
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), baz()));
    Binding bazBinding = expectCreateBinding(baz(), required(baz(), providerBar()));
    Binding providerBarBinding = expectCreateBinding(providerBar(), requiredLazy(providerBar(), bar()));
    Binding barBinding = expectCreateBinding(bar(), required(bar(), foo()));
    tree.root.addBinding(foo(), fooBinding);
    tree.root.addBinding(providerBar(), providerBarBinding);
    tree.root.addBinding(bar(), barBinding);
    tree.root.addBinding(baz(), bazBinding);
    expectParentBinding(foo(), tree.root, tree.childLL);
    replayAndResolve(tree.childLL, required(Dependency.GINJECTOR, foo()));
}
Also used : ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding) Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding)

Example 7 with Binding

use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.

the class BindingResolverTest method testOneNode.

public void testOneNode() throws Exception {
    GinjectorBindings root = createInjectorNode("root");
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), required(foo(), baz()));
    bind(bar(), root);
    bind(baz(), root);
    root.addBinding(foo(), fooBinding);
    replayAndResolve(root, required(Dependency.GINJECTOR, foo()));
}
Also used : ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding) Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding) GinjectorBindings(com.google.gwt.inject.rebind.GinjectorBindings)

Example 8 with Binding

use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.

the class BindingResolverTest method testResolveDependenciesResolveInOriginExposedToParent.

public void testResolveDependenciesResolveInOriginExposedToParent() throws Exception {
    StandardTree tree = createExampleTree();
    // Bar is bound in the child, but exposed to the root.  Foo should still be in root
    bindChild(bar(), tree.root, tree.childR);
    bind(baz(), tree.root);
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), required(foo(), baz()));
    Binding barBinding = expectCreateBinding(bar());
    tree.root.addBinding(foo(), fooBinding);
    tree.childR.addBinding(bar(), barBinding);
    expectParentBinding(foo(), tree.root, tree.childR);
    replayAndResolve(tree.childR, required(Dependency.GINJECTOR, foo()));
}
Also used : ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding) Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding)

Example 9 with Binding

use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.

the class BindingResolverTest method testResolveMultipleCycles.

public void testResolveMultipleCycles() throws Exception {
    // Foo -> Bar -> Provider<Baz> -> Baz -> {Provider<Foo>, Provider<Bar>, Provider<Baz>}
    // Resolves multiple cycles, including a cycle that starts with a Provider
    StandardTree tree = createExampleTree();
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()));
    Binding barBinding = expectCreateBinding(bar(), required(bar(), providerBaz()));
    Binding providerBazBinding = expectCreateBinding(providerBaz(), requiredLazy(providerBaz(), baz()));
    Binding bazBinding = expectCreateBinding(baz(), required(baz(), providerFoo()), required(baz(), providerFoo()), required(baz(), providerBar()));
    Binding providerFooBinding = expectCreateBinding(providerFoo(), requiredLazy(providerFoo(), foo()));
    Binding providerBarBinding = expectCreateBinding(providerBar(), requiredLazy(providerBar(), bar()));
    tree.root.addBinding(foo(), fooBinding);
    tree.root.addBinding(providerBar(), providerBarBinding);
    tree.root.addBinding(providerFoo(), providerFooBinding);
    tree.root.addBinding(providerBaz(), providerBazBinding);
    tree.root.addBinding(bar(), barBinding);
    tree.root.addBinding(baz(), bazBinding);
    expectParentBinding(foo(), tree.root, tree.childLL);
    replayAndResolve(tree.childLL, required(Dependency.GINJECTOR, foo()));
}
Also used : ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding) Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding)

Example 10 with Binding

use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.

the class BindingResolverTest method bind.

private void bind(Key<?> key, GinjectorBindings in) {
    Binding binding = control.createMock(Binding.class);
    expect(binding.getContext()).andReturn(Context.forText("")).anyTimes();
    expect(in.isBound(key)).andReturn(true).anyTimes();
    expect(in.getBinding(key)).andReturn(binding).anyTimes();
    bindings.add(binding);
}
Also used : ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding) Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding)

Aggregations

Binding (com.google.gwt.inject.rebind.binding.Binding)34 ParentBinding (com.google.gwt.inject.rebind.binding.ParentBinding)28 ExposedChildBinding (com.google.gwt.inject.rebind.binding.ExposedChildBinding)25 GinjectorBindings (com.google.gwt.inject.rebind.GinjectorBindings)10 Key (com.google.inject.Key)6 Dependency (com.google.gwt.inject.rebind.binding.Dependency)5 GinjectorNameGenerator (com.google.gwt.inject.rebind.GinjectorNameGenerator)4 NameGenerator (com.google.gwt.inject.rebind.util.NameGenerator)4 BindingCreationException (com.google.gwt.inject.rebind.resolution.ImplicitBindingCreator.BindingCreationException)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Context (com.google.gwt.inject.rebind.binding.Context)2 HashMap (java.util.HashMap)2 UnableToCompleteException (com.google.gwt.core.ext.UnableToCompleteException)1 GinScope (com.google.gwt.inject.rebind.GinScope)1 GinjectorBinding (com.google.gwt.inject.rebind.binding.GinjectorBinding)1 RemoteServiceProxyBinding (com.google.gwt.inject.rebind.binding.RemoteServiceProxyBinding)1 InjectorMethod (com.google.gwt.inject.rebind.util.InjectorMethod)1 SourceWriteUtil (com.google.gwt.inject.rebind.util.SourceWriteUtil)1 Singleton (com.google.inject.Singleton)1