当前位置: 首页>>代码示例>>Java>>正文


Java PrivateBinder类代码示例

本文整理汇总了Java中com.google.inject.PrivateBinder的典型用法代码示例。如果您正苦于以下问题:Java PrivateBinder类的具体用法?Java PrivateBinder怎么用?Java PrivateBinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrivateBinder类属于com.google.inject包,在下文中一共展示了PrivateBinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import com.google.inject.PrivateBinder; //导入依赖的package包/类
@Override
public Void visit(ExposedBinding<? extends T> binding) {
    final PrivateBinder privateBinder = this.binder.newPrivateBinder();
    final Scoper scoper = new Scoper(privateBinder, scoping);
    for(Element element : binding.getPrivateElements().getElements()) {
        if(element instanceof Binding) {
            ((Binding) element).acceptTargetVisitor(scoper);
        } else {
            element.applyTo(privateBinder);
        }
    }
    for(Key key : binding.getPrivateElements().getExposedKeys()) {
        privateBinder.expose(key);
    }
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:Scoper.java

示例2: makeBasicBindingsAndExposures

import com.google.inject.PrivateBinder; //导入依赖的package包/类
public static void makeBasicBindingsAndExposures(PrivateBinder binder,
    Class<? extends Annotation> annotation) {
  binder.bind(SlobFacilities.class).to(FacilitiesImpl.class);
  binder.bind(SlobStore.class).to(SlobStoreImpl.class);
  binder.install(factoryModule(MutationLogFactory.class, MutationLog.class));

  binder.bind(MutationLogFactory.class).annotatedWith(annotation).to(MutationLogFactory.class);
  binder.bind(SlobStore.class).annotatedWith(annotation).to(SlobStore.class);
  binder.bind(LocalMutationProcessor.class).annotatedWith(annotation)
      .to(LocalMutationProcessor.class);
  binder.bind(SlobFacilities.class).annotatedWith(annotation).to(FacilitiesImpl.class);

  binder.expose(MutationLogFactory.class).annotatedWith(annotation);
  binder.expose(SlobStore.class).annotatedWith(annotation);
  binder.expose(LocalMutationProcessor.class).annotatedWith(annotation);
  binder.expose(SlobFacilities.class).annotatedWith(annotation);

  // Make sure a binding for the Set exists.
  Multibinder.newSetBinder(binder, PreCommitAction.class);
  // Make sure a binding for the Set exists.
  Multibinder.newSetBinder(binder, PostCommitAction.class);
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:23,代码来源:StoreModuleHelper.java

示例3: bindFutureProvider

import com.google.inject.PrivateBinder; //导入依赖的package包/类
void bindFutureProvider(PrivateBinder binder) {
  binder = binder.withSource(source);

  ScopedBindingBuilder scoper = binder.bind(bindingKey).toProvider(this);

  if (isVoid(method)) {
    scoper.asEagerSingleton();
  } else {
    if (scopeAnnotation != null) {
      scoper.in(scopeAnnotation);
    }
    if (exposedBinding) {
      binder.expose(bindingKey);
    }
  }
}
 
开发者ID:immutables,项目名称:miscellaneous,代码行数:17,代码来源:Providers.java

示例4: exposeOptions

import com.google.inject.PrivateBinder; //导入依赖的package包/类
protected void exposeOptions() {
    final Binder binder = binder();
    if (!(binder instanceof PrivateBinder)) {
        return;
    }
    exposeOption(Integer.class);
    exposeOption(Long.class);
    exposeOption(Double.class);
    exposeOption(Short.class);
    exposeOption(String.class);
    exposeOption(Boolean.class);
    exposeOption(Byte.class);
    exposeOption(Float.class);
    exposeOption(Integer.class);
    exposeOption(File.class);
    exposeOption(Path.class);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:18,代码来源:OptionModule.java

示例5: _bindServiceProxiesAggregators

import com.google.inject.PrivateBinder; //导入依赖的package包/类
/**
 * Binds the {@link ServiceProxiesAggregator} that MUST contain fields of types implementing {@link ServiceInterface} which are 
 * the concrete proxy implementation to the services
 * 
 * The {@link ServiceInterface} fields of {@link ServiceProxiesAggregator} implementing type are LAZY loaded by 
 * {@link ServicesClientProxyLazyLoaderGuiceMethodInterceptor} which guesses what proxy implementation assign to the field:
 * <ul>
 * 		<li>If the {@link ServiceProxiesAggregator} extends {@link ServiceProxiesAggregatorForDefaultImpls}, the concrete {@link ServiceInterface}-implementing 
 * 			proxy instance is taken from the client properties XML file, so some service impls might be accessed using a BEAN proxy while others might be accessed
 * 			using a REST proxy -depending on the properties file-</li>
 * 		<li>If the {@link ServiceInterface} field's BEAN implementation is available this one will be assigned to the field no matter what type the aggregator is</li>
 * </ul>
 * @param binder
 */
private void _bindServiceProxiesAggregators(final Binder binder) {
	// Inject all Map fields that matches the service interface types with the bean impl or proxy to be used
	// (this Map fields are injected by MapBinders created at ServicesForAppModulePrivateGuiceModule)									
	binder.requestInjection(_serviceInterfaceTypesToImplOrProxyMappings);
	
	// Create a private binder to be used to inject the MethodInterceptor that will intercept all fine-grained
	// proxy accessor method calls at ServicesAggregatorClientProxy 
	// The interceptor lazily loads the fine-grained proxy instances and makes the aggregator creation simpler
	PrivateBinder privateBinder = binder.newPrivateBinder();
	privateBinder.bind(ServiceInterfaceTypesToImplOrProxyMappings.class)
		  		 .toInstance(_serviceInterfaceTypesToImplOrProxyMappings);
	MethodInterceptor serviceProxyGetterInterceptor = new ServicesClientProxyLazyLoaderGuiceMethodInterceptor(_apiAppAndModule,
																											  _coreAppAndModules);
	privateBinder.requestInjection(serviceProxyGetterInterceptor);		// the method interceptor is feeded with a map of service interfaces to bean impl or proxy created below
	
	// Bind the interceptor to ServiceProxiesAggregator type's fine-grained method calls
	binder.bindInterceptor(Matchers.subclassesOf(ServiceProxiesAggregator.class),
						   Matchers.any(),
						   serviceProxyGetterInterceptor);
	
	// Bind every services proxy aggregator implementation
	log.info("[ServiceProxyAggregator] > {}",_servicesProxiesAggregatorType);
	binder.bind(_servicesProxiesAggregatorType)
	      .in(Singleton.class);
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:40,代码来源:ServicesClientAPIBootstrapGuiceModuleBase.java

示例6: _doBindXMLPropertiesComponentProviderAs

import com.google.inject.PrivateBinder; //导入依赖的package包/类
private static void _doBindXMLPropertiesComponentProviderAs(final CoreAppCode coreAppCode,final CoreModule coreAppComponent,
													 		final String bindingName,final String subComponent,
													 		final Binder binder,final boolean expose) {
	log.debug("{}.{}.properties.xml properties are available for injection as a {} object annotated with @XMLPropertiesComponent(\"{}\") INTERNALLY and @XMLPropertiesComponent(\"{}\") EXTERNALLY",
			  coreAppCode,_componentPropertiesIdFor(coreAppComponent,subComponent),
			  XMLPropertiesForAppComponent.class.getSimpleName(),
			  subComponent,
			  _componentPropertiesIdFor(coreAppComponent,subComponent));
	
	// do the binding
	binder.bind(XMLPropertiesForAppComponent.class)
		  .annotatedWith(new XMLPropertiesComponentImpl(bindingName))
		  .toProvider(new XMLPropertiesForXProvider(coreAppCode,coreAppComponent,subComponent))
		  .in(Singleton.class);
	
	// Expose xml properties binding
	if (expose && (binder instanceof PrivateBinder)) {
		log.warn("{}.{}.properties.xml properties are available for injection as a {} object annotated with @XMLPropertiesComponent(\"{}\")",
				 coreAppCode,_componentPropertiesIdFor(coreAppComponent,subComponent),
				 XMLPropertiesForAppComponent.class.getSimpleName(),
				 _componentPropertiesIdFor(coreAppComponent,subComponent));
		PrivateBinder pb = (PrivateBinder)binder;
		pb.expose(Key.get(XMLPropertiesForAppComponent.class,new XMLPropertiesComponentImpl(bindingName)));
	}
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:26,代码来源:ServicesCoreBootstrapGuiceModuleBase.java

示例7: configure

import com.google.inject.PrivateBinder; //导入依赖的package包/类
void configure(Binder binder) {
  binder = binder.withSource(method);

  SecondaryBinder<?, ?> sbinder =
      ThrowingProviderBinder.create(binder).bind(checkedProvider, key.getTypeLiteral());
  if (key.getAnnotation() != null) {
    sbinder = sbinder.annotatedWith(key.getAnnotation());
  } else if (key.getAnnotationType() != null) {
    sbinder = sbinder.annotatedWith(key.getAnnotationType());
  }
  sbinder.scopeExceptions(scopeExceptions);
  ScopedBindingBuilder sbbuilder = sbinder.toProviderMethod(this);
  if (scopeAnnotation != null) {
    sbbuilder.in(scopeAnnotation);
  }

  if (exposed) {
    // the cast is safe 'cause the only binder we have implements PrivateBinder. If there's a
    // misplaced @Exposed, calling this will add an error to the binder's error queue
    ((PrivateBinder) binder).expose(sbinder.getKey());
  }

  CheckedProvideUtils.validateExceptions(
      binder, exceptionTypes, sbinder.getExceptionTypes(), checkedProvider);
}
 
开发者ID:google,项目名称:guice,代码行数:26,代码来源:CheckedProviderMethod.java

示例8: configure

import com.google.inject.PrivateBinder; //导入依赖的package包/类
void configure(Binder binder) {
  binder = binder.withSource(method);

  SecondaryBinder<?, ?> sbinder = 
    ThrowingProviderBinder.create(binder)
      .bind(checkedProvider, key.getTypeLiteral());
  if(key.getAnnotation() != null) {
    sbinder = sbinder.annotatedWith(key.getAnnotation());
  } else if(key.getAnnotationType() != null) {
    sbinder = sbinder.annotatedWith(key.getAnnotationType());
  } 
  ScopedBindingBuilder sbbuilder = sbinder.toProviderMethod(this);
  if(scopeAnnotation != null) {
    sbbuilder.in(scopeAnnotation);
  }

  if (exposed) {
    // the cast is safe 'cause the only binder we have implements PrivateBinder. If there's a
    // misplaced @Exposed, calling this will add an error to the binder's error queue
    ((PrivateBinder) binder).expose(sbinder.getKey());
  }
  
  CheckedProvideUtils.validateExceptions(
      binder, exceptionTypes, sbinder.getExceptionTypes(), checkedProvider);
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:26,代码来源:CheckedProviderMethod.java

示例9: wrap

import com.google.inject.PrivateBinder; //导入依赖的package包/类
static PrivateBinders wrap(PrivateBinder binder) {
    if(binder instanceof PrivateBinders) {
        return (PrivateBinders) binder;
    }
    final PrivateBinder skipped = binder.skipSources(Binders.class,
                                                     PrivateBinders.class,
                                                     ForwardingBinder.class,
                                                     ForwardingPrivateBinder.class);
    return () -> skipped;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:PrivateBinders.java

示例10: of

import com.google.inject.PrivateBinder; //导入依赖的package包/类
/**
 * Creates a wrapped private binder.
 *
 * @param binder the private binder
 * @return a wrapped private binder
 */
@NonNull
static VPrivateBinder of(@NonNull final PrivateBinder binder) {
  // avoid re-wrapping
  if(binder instanceof VPrivateBinder) {
    return (VPrivateBinder) binder;
  }
  return new VPrivateBinderImpl(binder);
}
 
开发者ID:KyoriPowered,项目名称:violet,代码行数:15,代码来源:VPrivateBinder.java

示例11: bindEntityKinds

import com.google.inject.PrivateBinder; //导入依赖的package包/类
public static void bindEntityKinds(PrivateBinder binder, String prefix) {
  binder.bind(String.class).annotatedWith(SlobRootEntityKind.class).toInstance(prefix);
  binder.bind(String.class).annotatedWith(SlobDeltaEntityKind.class)
      .toInstance(prefix + "Delta");
  binder.bind(String.class).annotatedWith(SlobSnapshotEntityKind.class)
      .toInstance(prefix + "Snapshot");
  binder.bind(String.class).annotatedWith(SlobSynchronizationEntityKind.class)
      .toInstance(prefix + "Sync");
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:10,代码来源:StoreModuleHelper.java

示例12: configure

import com.google.inject.PrivateBinder; //导入依赖的package包/类
void configure(PrivateBinder binder) {
  binder = binder.withSource(source);

  if (errors.hasErrors()) {
    for (Message message : errors.getMessages()) {
      binder.addError(message);
    }
  } else {
    bindProvidersInScope(binder);
  }
}
 
开发者ID:immutables,项目名称:miscellaneous,代码行数:12,代码来源:Providers.java

示例13: bindProvidersInScope

import com.google.inject.PrivateBinder; //导入依赖的package包/类
private void bindProvidersInScope(PrivateBinder privateBinder) {
  ScopedBindingBuilder scoper = privateBinder.bind(providersClass);

  if (scopeAnnotation != null) {
    scoper.in(scopeAnnotation);
  }

  for (EventualProvider<?> p : providers) {
    p.bindFutureProvider(privateBinder);
  }
}
 
开发者ID:immutables,项目名称:miscellaneous,代码行数:12,代码来源:Providers.java

示例14: configure

import com.google.inject.PrivateBinder; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
  PrivateBinder privateBinder = binder.newPrivateBinder();
  for (Providers<?> partial : partials) {
    partial.configure(privateBinder);
  }
}
 
开发者ID:immutables,项目名称:miscellaneous,代码行数:8,代码来源:EventualModules.java

示例15: configure

import com.google.inject.PrivateBinder; //导入依赖的package包/类
public void configure() {
  Binder binder = binder().skipSources(PrivateGinModuleAdapter.class,
      BinderAdapter.class, PrivateBinderAdapter.class, PrivateGinModule.class);

  ginModule.configure(new PrivateBinderAdapter((PrivateBinder) binder,
      bindings == null ? null : bindings.createChildGinjectorBindings(ginModule.getClass())));

  // Install provider methods from the GinModule
  binder.install(ProviderMethodsModule.forObject(ginModule));
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:11,代码来源:PrivateGinModuleAdapter.java


注:本文中的com.google.inject.PrivateBinder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。