Package com.google.inject

Examples of com.google.inject.Binder.bind()


  {
    Binder binder = binder();

    JsonConfigProvider.bind(binder, "druid.server.http", ServerConfig.class);

    binder.bind(GuiceContainer.class).to(DruidGuiceContainer.class);
    binder.bind(DruidGuiceContainer.class).in(Scopes.SINGLETON);
    serve("/*").with(DruidGuiceContainer.class);

    Jerseys.addResource(binder, StatusResource.class);
    binder.bind(StatusResource.class).in(LazySingleton.class);
View Full Code Here


    Binder binder = binder();

    JsonConfigProvider.bind(binder, "druid.server.http", ServerConfig.class);

    binder.bind(GuiceContainer.class).to(DruidGuiceContainer.class);
    binder.bind(DruidGuiceContainer.class).in(Scopes.SINGLETON);
    serve("/*").with(DruidGuiceContainer.class);

    Jerseys.addResource(binder, StatusResource.class);
    binder.bind(StatusResource.class).in(LazySingleton.class);
  }
View Full Code Here

    binder.bind(GuiceContainer.class).to(DruidGuiceContainer.class);
    binder.bind(DruidGuiceContainer.class).in(Scopes.SINGLETON);
    serve("/*").with(DruidGuiceContainer.class);

    Jerseys.addResource(binder, StatusResource.class);
    binder.bind(StatusResource.class).in(LazySingleton.class);
  }

  public static class DruidGuiceContainer extends GuiceContainer
  {
    private final Set<Class<?>> resources;
View Full Code Here

    AnnotatedBindingBuilder<LangFactory> bindLangFactory = createMock(AnnotatedBindingBuilder.class);
    AnnotatedBindingBuilder<ILinkingDiagnosticMessageProvider.Extended> bindLinkingDMP = createMock(AnnotatedBindingBuilder.class);
    AnnotatedBindingBuilder<ILaunchManager> bindLaunchManager = createMock(AnnotatedBindingBuilder.class);
    final ILaunchManager launchManager = createMock(ILaunchManager.class);

    expect(binder.bind(LangFactory.class)).andReturn(bindLangFactory);
    expect(binder.bind(ILinkingDiagnosticMessageProvider.Extended.class)).andReturn(bindLinkingDMP);
    expect(binder.bind(ILaunchManager.class)).andReturn(bindLaunchManager);

    bindLangFactory.toInstance(LangFactory.eINSTANCE);
View Full Code Here

    AnnotatedBindingBuilder<ILinkingDiagnosticMessageProvider.Extended> bindLinkingDMP = createMock(AnnotatedBindingBuilder.class);
    AnnotatedBindingBuilder<ILaunchManager> bindLaunchManager = createMock(AnnotatedBindingBuilder.class);
    final ILaunchManager launchManager = createMock(ILaunchManager.class);

    expect(binder.bind(LangFactory.class)).andReturn(bindLangFactory);
    expect(binder.bind(ILinkingDiagnosticMessageProvider.Extended.class)).andReturn(bindLinkingDMP);
    expect(binder.bind(ILaunchManager.class)).andReturn(bindLaunchManager);

    bindLangFactory.toInstance(LangFactory.eINSTANCE);

    expect(bindLinkingDMP.to(Antlr4MissingReferenceMessageProvider.class)).andReturn(null);
View Full Code Here

    AnnotatedBindingBuilder<ILaunchManager> bindLaunchManager = createMock(AnnotatedBindingBuilder.class);
    final ILaunchManager launchManager = createMock(ILaunchManager.class);

    expect(binder.bind(LangFactory.class)).andReturn(bindLangFactory);
    expect(binder.bind(ILinkingDiagnosticMessageProvider.Extended.class)).andReturn(bindLinkingDMP);
    expect(binder.bind(ILaunchManager.class)).andReturn(bindLaunchManager);

    bindLangFactory.toInstance(LangFactory.eINSTANCE);

    expect(bindLinkingDMP.to(Antlr4MissingReferenceMessageProvider.class)).andReturn(null);
View Full Code Here

        Binder binder = binder().withSource(method);

        int p = 0;
        for (Key<?> paramKey : paramTypes.get(method)) {
          // Wrap in a Provider to cover null, and to prevent Guice from injecting the parameter
          binder.bind((Key) paramKey).toProvider(Providers.of(args[p++]));
        }

        if (producedType != null && !returnType.equals(producedType)) {
          binder.bind(returnType).to((Key) producedType);
        } else {
View Full Code Here

          // Wrap in a Provider to cover null, and to prevent Guice from injecting the parameter
          binder.bind((Key) paramKey).toProvider(Providers.of(args[p++]));
        }

        if (producedType != null && !returnType.equals(producedType)) {
          binder.bind(returnType).to((Key) producedType);
        } else {
          binder.bind(returnType);
        }
      }
    };
View Full Code Here

        }

        if (producedType != null && !returnType.equals(producedType)) {
          binder.bind(returnType).to((Key) producedType);
        } else {
          binder.bind(returnType);
        }
      }
    };

    Injector forCreate = injector.createChildInjector(assistedModule);
View Full Code Here

                     }
                     type = adapter.getComponentImplementation();
                  }
                  if (annotation == null && annotationType == null)
                  {
                     binder.bind(type).toProvider(new ComponentAdapterProvider(type, adapter));
                  }
                  else
                  {
                     // As we don't know the type, we will bind it for each super classes and interfaces too
                     ComponentAdapterProvider provider = new ComponentAdapterProvider(type, adapter);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.