Java Code Examples for com.google.inject.Binder

The following examples show how to use com.google.inject.Binder. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public void configure(Binder binder) {
	binder.bind(IQualifiedNameConverter.class);
	
	binder.bind(BuilderDeltaConverter.class);
	binder.bind(DeltaConverter.class);
	binder.bind(TypeURIHelper.class);
	
	binder.bind(TypeResourceUnloader.class);
	binder.bind(JavaChangeQueueFiller.class);
	
	binder.bind(IEagerContribution.class).to(ListenerRegistrar.class);

	binder.bind(TraceRegionSerializer.class);
	binder.bind(ITraceForTypeRootProvider.class).to(TraceForTypeRootProvider.class);
	binder.bind(FolderAwareTrace.class);
	binder.bind(ZipFileAwareTrace.class);
	binder.bind(OppositeFileOpenerContributor.class).to(ClassFileBasedOpenerContributor.class);
}
 
Example 2
Source Project: seed   Source File: RestModuleTest.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void testBindProviders(@Mocked final Binder binder) {
    underTest.configure(binder);
    new Verifications() {{
        binder.bind(MyProvider1.class).in(Scopes.SINGLETON);
        binder.bind(MyProvider2.class).in(Scopes.SINGLETON);
    }};
}
 
Example 3
Source Project: presto-kinesis   Source File: JsonKinesisDecoderModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder)
{
    bindRowDecoder(binder, JsonKinesisRowDecoder.class);

    bindFieldDecoder(binder, JsonKinesisFieldDecoder.class);
    bindFieldDecoder(binder, RFC2822JsonKinesisFieldDecoder.class);
    bindFieldDecoder(binder, ISO8601JsonKinesisFieldDecoder.class);
    bindFieldDecoder(binder, SecondsSinceEpochJsonKinesisFieldDecoder.class);
    bindFieldDecoder(binder, MillisecondsSinceEpochJsonKinesisFieldDecoder.class);
    bindFieldDecoder(binder, CustomDateTimeJsonKinesisFieldDecoder.class);
}
 
Example 4
Source Project: digdag   Source File: CommandExecutorModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder)
{
    //binder.bind(CommandExecutor.class).to(SimpleCommandExecutor.class).in(Scopes.SINGLETON);
    binder.bind(CommandExecutor.class).to(DockerCommandExecutor.class).in(Scopes.SINGLETON);
    binder.bind(SimpleCommandExecutor.class).in(Scopes.SINGLETON);
}
 
Example 5
Source Project: statecharts   Source File: JavaGeneratorModule.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void configureGeneratorRoot(GeneratorEntry entry, Binder binder) {

	// TODO: replace binding with new to define JavaFlowConfiguration
	binder.bind(IFlowConfiguration.class).to(DefaultFlowConfiguration.AllFeaturesDisabled.class);
	
	binder.bind(IModelSequencer.class).to(ModelSequencer.class);
	binder.bind(BehaviorMapping.class).to(org.yakindu.sct.model.sexec.transformation.ng.BehaviorMapping.class);
	binder.bind(IExecutionFlowGenerator.class).to(JavaGenerator.class);
	binder.bind(GeneratorEntry.class).toInstance(entry);
}
 
Example 6
public <T> T getInstance(
        Class<T> clazz,
        Module[] overridableModules,
        Module[] sealedModules) throws XadesProfileResolutionException
{
    Module userBindingsModule = new Module()
    {
        @Override
        public void configure(Binder b)
        {
            for (BindingAction ba : bindings)
            {
                ba.bind(b);
            }
        }
    };
    Module overridesModule = Modules.override(overridableModules).with(userBindingsModule);
    // Concat sealed modules with overrides module
    Module[] finalModules = Arrays.copyOf(sealedModules, sealedModules.length + 1);
    finalModules[finalModules.length - 1] = overridesModule;
    try
    {
        return Guice.createInjector(finalModules).getInstance(clazz);
    }
    catch (RuntimeException ex)
    {
        throw new XadesProfileResolutionException(ex.getMessage(), ex);
    }
}
 
Example 7
Source Project: atlas   Source File: TestModules.java    License: Apache License 2.0 5 votes vote down vote up
protected void bindAuditRepository(Binder binder) {

            Class<? extends EntityAuditRepository> auditRepoImpl = AtlasRepositoryConfiguration.getAuditRepositoryImpl();

            //Map EntityAuditRepository interface to configured implementation
            binder.bind(EntityAuditRepository.class).to(auditRepoImpl).asEagerSingleton();

            if(Service.class.isAssignableFrom(auditRepoImpl)) {
                Class<? extends Service> auditRepoService = (Class<? extends Service>)auditRepoImpl;
                //if it's a service, make sure that it gets properly closed at shutdown
                Multibinder<Service> serviceBinder = Multibinder.newSetBinder(binder, Service.class);
                serviceBinder.addBinding().to(auditRepoService);
            }
        }
 
Example 8
Source Project: arcusplatform   Source File: Binders.java    License: Apache License 2.0 5 votes vote down vote up
public static <T> ScopedBindingBuilder bindMapToInstancesOf(Binder binder, TypeLiteral<Map<String, T>> type) {
  	return bindMapToInstancesOf(binder, type, new Function<T,String>() {
  	   @Override
  	   public String apply(T service) {
  	      return Injectors.getServiceName(service);
  	   }
  	});
}
 
Example 9
Source Project: sarl   Source File: ExtendedSARLInjectorProvider.java    License: Apache License 2.0 5 votes vote down vote up
/** Create the module for tests of the runtime libraries.
 *
 * @return the module.
 */
@SuppressWarnings("static-method")
protected Module createRuntimeTestModule() {
	return new Module() {

		@Override
		public void configure(Binder binder) {
			binder.bind(OnTheFlyJavaCompiler2.class).toProvider(JavaCompilerProvider.class).asEagerSingleton();
		}

	};
}
 
Example 10
public void configureCodeMinding(Binder binder) {
	try {
		Class.forName("org.eclipse.jface.text.codemining.ICodeMiningProvider");
		binder.bind(ICodeMiningProvider.class)
			.to(DomainmodelCodeMiningProvider.class);
		binder.bind(IReconcileStrategyFactory.class).annotatedWith(Names.named("codeMinding"))
			.to(XtextCodeMiningReconcileStrategy.Factory.class);
	} catch(ClassNotFoundException ignore) {
		// no bindings if code mining is not available at runtime
	}
}
 
Example 11
public <T> void addMultibinding(final Class<T> from, final Class<? extends T> to)
{
    if (null == from || null == to)
        throw new NullPointerException();

    this.bindings.add(new BindingAction()
    {
        @Override
        public void bind(Binder b)
        {
            Multibinder multibinder = Multibinder.newSetBinder(b, from);
            multibinder.addBinding().to(to);
        }
    });
}
 
Example 12
@Before
public void createParentInjector() {
	injector = Guice.createInjector(new Module() {
		@Override
		public void configure(Binder binder) {
			binder.bind(CharSequence.class).to(String.class);
			binder.bind(String.class).toInstance("fromParentInjector");
		}
	});
}
 
Example 13
Source Project: bromium   Source File: AbstractBromiumUiModule.java    License: MIT License 4 votes vote down vote up
public void configureHighlightingLexer(Binder binder) {
	binder.bind(org.eclipse.xtext.parser.antlr.Lexer.class)
		.annotatedWith(Names.named(LexerIdeBindings.HIGHLIGHTING))
		.to(com.hribol.bromium.dsl.parser.antlr.internal.InternalBromiumLexer.class);
}
 
Example 14
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/ui/tests/editor/contentassist/Bug347012TestLanguage.properties");
	super.configure(binder);
}
 
Example 15
public void configureIResourceDescriptions(Binder binder) {
	binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class);
}
 
Example 16
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/common/types/xtext/ui/RefactoringTestLanguage1.properties");
	super.configure(binder);
}
 
Example 17
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
Example 18
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/ui/tests/editor/contentassist/Bug288760TestLanguage.properties");
	super.configure(binder);
}
 
Example 19
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.common.types.xtext.ui.ContentAssistTestLanguage");
}
 
Example 20
Source Project: n4js   Source File: AbstractN4JSUiModule.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public void configureContentAssistLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
		.to(InternalN4JSLexer.class);
}
 
Example 21
public void configureContentAssistLexerProvider(Binder binder) {
	binder.bind(InternalContentAssistContextTestLanguageLexer.class).toProvider(LexerProvider.create(InternalContentAssistContextTestLanguageLexer.class));
}
 
Example 22
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.xtext.ui.ecore2xtext.Ecore2XtextTest");
}
 
Example 23
protected void addLocalBindings(Binder binder) {
}
 
Example 24
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/grammarinheritance/ConcreteTestLanguage.properties");
	super.configure(binder);
}
 
Example 25
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/xbase/testlanguages/XImportSectionTestLang.properties");
	super.configure(binder);
}
 
Example 26
Source Project: n4js   Source File: JSONRuntimeModule.java    License: Eclipse Public License 1.0 4 votes vote down vote up
/** Avoid races in internal serializer caches */
public void configureSerializerPatches(Binder binder) {
	new SerializerPatchModule().configure(binder);
}
 
Example 27
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.ui.tests.quickfix.QuickfixCrossrefTestLanguage");
}
 
Example 28
@Override
public void configure(Binder binder) {
	super.configure(binder);
	
	// bind additional implementations
}
 
Example 29
Source Project: n4js   Source File: AbstractN4JSUiModule.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public void configureCompareViewerTitle(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(UIBindings.COMPARE_VIEWER_TITLE)).toInstance("N4JS Compare");
}
 
Example 30
public void configureContentAssistLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
		.to(InternalEnumRulesUiTestLanguageLexer.class);
}