com.google.inject.Binder源码实例Demo

类com.google.inject.Binder源码实例Demo

下面列出了com.google.inject.Binder 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xtext-eclipse   文件: CommonTypesContribution.java
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);
}
 
源代码2 项目: seed   文件: RestModuleTest.java
@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);
    }};
}
 
源代码3 项目: presto-kinesis   文件: JsonKinesisDecoderModule.java
@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);
}
 
源代码4 项目: digdag   文件: CommandExecutorModule.java
@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);
}
 
源代码5 项目: statecharts   文件: JavaGeneratorModule.java
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);
}
 
源代码6 项目: xades4j   文件: XadesProfileCore.java
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);
    }
}
 
源代码7 项目: atlas   文件: TestModules.java
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);
            }
        }
 
源代码8 项目: arcusplatform   文件: Binders.java
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);
  	   }
  	});
}
 
源代码9 项目: sarl   文件: ExtendedSARLInjectorProvider.java
/** 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();
		}

	};
}
 
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
	}
}
 
源代码11 项目: xades4j   文件: XadesProfileCore.java
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);
        }
    });
}
 
@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");
		}
	});
}
 
源代码13 项目: bromium   文件: AbstractBromiumUiModule.java
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);
}
 
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/ui/tests/editor/contentassist/Bug347012TestLanguage.properties");
	super.configure(binder);
}
 
public void configureIResourceDescriptions(Binder binder) {
	binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class);
}
 
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/common/types/xtext/ui/RefactoringTestLanguage1.properties");
	super.configure(binder);
}
 
源代码17 项目: dsl-devkit   文件: AbstractHelloWorldUiModule.java
public void configureIResourceDescriptionsPersisted(Binder binder) {
	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class);
}
 
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/ui/tests/editor/contentassist/Bug288760TestLanguage.properties");
	super.configure(binder);
}
 
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.common.types.xtext.ui.ContentAssistTestLanguage");
}
 
源代码20 项目: n4js   文件: AbstractN4JSUiModule.java
public void configureContentAssistLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
		.to(InternalN4JSLexer.class);
}
 
public void configureContentAssistLexerProvider(Binder binder) {
	binder.bind(InternalContentAssistContextTestLanguageLexer.class).toProvider(LexerProvider.create(InternalContentAssistContextTestLanguageLexer.class));
}
 
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.xtext.ui.ecore2xtext.Ecore2XtextTest");
}
 
protected void addLocalBindings(Binder binder) {
}
 
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/grammarinheritance/ConcreteTestLanguage.properties");
	super.configure(binder);
}
 
@Override
public void configure(Binder binder) {
	properties = tryBindProperties(binder, "org/eclipse/xtext/xbase/testlanguages/XImportSectionTestLang.properties");
	super.configure(binder);
}
 
源代码26 项目: n4js   文件: JSONRuntimeModule.java
/** Avoid races in internal serializer caches */
public void configureSerializerPatches(Binder binder) {
	new SerializerPatchModule().configure(binder);
}
 
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.ui.tests.quickfix.QuickfixCrossrefTestLanguage");
}
 
源代码28 项目: xtext-core   文件: TreeTestLanguageRuntimeModule.java
@Override
public void configure(Binder binder) {
	super.configure(binder);
	
	// bind additional implementations
}
 
源代码29 项目: n4js   文件: AbstractN4JSUiModule.java
public void configureCompareViewerTitle(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(UIBindings.COMPARE_VIEWER_TITLE)).toInstance("N4JS Compare");
}
 
public void configureContentAssistLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
		.to(InternalEnumRulesUiTestLanguageLexer.class);
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法