• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Toolable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
@Inject
@Toolable
@SuppressWarnings("unchecked")
void initialize(Injector injector) {
    final Binding<T> realBinding = injector.getBinding(this.rewritten);
    final Provider<T> realProvider = injector.getProvider(realBinding.getKey());

    // The proxy will be a sub type of the source type of the binding
    final Class<T> proxyType = (Class<T>) realBinding.getKey()
            .getTypeLiteral().getRawType();

    this.dependencies = Collections.singleton(
            Dependency.get(this.rewritten));
    this.ref = InstanceBuilder.forType(proxyType)
            .withConstructionStrategy(this.strategy)
            .dispatchTo(realProvider)
            .create(injector);
}
 
开发者ID:skuzzle,项目名称:guice-scoped-proxy-extension,代码行数:19,代码来源:ScopedProxyBinder.java


示例2: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
/**
 * At injector-creation time, we initialize the invocation handler. At this time we make sure
 * all factory methods will be able to build the target types.
 */
@Inject @Toolable
void initialize(Injector injector) {
  if (this.injector != null) {
    throw new ConfigurationException(ImmutableList.of(new Message(FactoryProvider2.class,
        "Factories.create() factories may only be used in one Injector!")));
  }

  this.injector = injector;

  for (Map.Entry<Method, AssistData> entry : assistDataByMethod.entrySet()) {
    Method method = entry.getKey();
    AssistData data = entry.getValue();
    Object[] args;
    if(!data.optimized) {
      args = new Object[method.getParameterTypes().length];
      Arrays.fill(args, "dummy object for validating Factories");
    } else {
      args = null; // won't be used -- instead will bind to data.providers.
    }
    getBindingFromNewInjector(method, args, data); // throws if the binding isn't properly configured
  }
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:27,代码来源:FactoryProvider2.java


示例3: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
/**
 * Invoked by Guice at Injector-creation time to prepare providers for each
 * element in this set. At this time the set's size is known, but its
 * contents are only evaluated when get() is invoked.
 */
@Toolable @Inject void initialize(Injector injector) {
  List<Binding<T>> bindings = Lists.newArrayList();
  List<Dependency<?>> dependencies = Lists.newArrayList();
  for (Binding<?> entry : injector.findBindingsByType(elementType)) {
    if (keyMatches(entry.getKey())) {
      @SuppressWarnings("unchecked") // protected by findBindingsByType()
      Binding<T> binding = (Binding<T>) entry;
      bindings.add(binding);
      dependencies.add(Dependency.get(binding.getKey()));
    }
  }

  this.bindings = ImmutableList.copyOf(bindings);
  this.dependencies = ImmutableSet.copyOf(dependencies);
  this.permitDuplicates = permitsDuplicates(injector);
  this.binder = null;
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:23,代码来源:Multibinder.java


示例4: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
@Inject
@Toolable
void initialize(Injector injector) {
    List<Binding<T>> bindings = new ArrayList<Binding<T>>();

    for ( Binding<?> entry : injector.findBindingsByType(elementType) ) {
        if ( !keyMatches(entry.getKey()) )
            continue;

        @SuppressWarnings("unchecked")
        Binding<T> binding = (Binding<T>) entry;
        bindings.add(binding);
    }

    Collections.sort(bindings, new PriorityComparator());
    this.bindings = Collections.unmodifiableList(bindings);
}
 
开发者ID:wellingtonsteve,项目名称:guice-utils,代码行数:18,代码来源:ListBinder.java


示例5: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
/**
 * At injector-creation time, we initialize the invocation handler. At this time we make sure all
 * factory methods will be able to build the target types.
 */
@Inject
@Toolable
void initialize(Injector injector) {
  if (this.injector != null) {
    throw new ConfigurationException(
        ImmutableList.of(
            new Message(
                FactoryProvider2.class,
                "Factories.create() factories may only be used in one Injector!")));
  }

  this.injector = injector;

  for (Map.Entry<Method, AssistData> entry : assistDataByMethod.entrySet()) {
    Method method = entry.getKey();
    AssistData data = entry.getValue();
    Object[] args;
    if (!data.optimized) {
      args = new Object[method.getParameterTypes().length];
      Arrays.fill(args, "dummy object for validating Factories");
    } else {
      args = null; // won't be used -- instead will bind to data.providers.
    }
    getBindingFromNewInjector(
        method, args, data); // throws if the binding isn't properly configured
  }
}
 
开发者ID:google,项目名称:guice,代码行数:32,代码来源:FactoryProvider2.java


示例6: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
@Inject
@Toolable
void initialize(Injector injector) {
    manager = injector.getInstance(Key.get(typeLiteral));
}
 
开发者ID:Netflix,项目名称:fabricator,代码行数:6,代码来源:NamedInstanceProvider.java


示例7: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
@Inject
@Toolable
void initialize(Injector injector) {
    this.factory = (ComponentFactory<T>) injector.getInstance(clazz);
}
 
开发者ID:Netflix,项目名称:fabricator,代码行数:6,代码来源:ComponentFactoryFactoryProvider.java


示例8: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
@Inject
@Toolable
void initialize(Injector injector) {
    this.injector.set(injector);
    this.factory = new BindingComponentFactory<T>(clazz, binderResolver, this);
}
 
开发者ID:Netflix,项目名称:fabricator,代码行数:7,代码来源:GuiceBindingComponentFactoryProvider.java


示例9: configure

import com.google.inject.spi.Toolable; //导入依赖的package包/类
public void configure(Binder binder) {
  checkConfiguration(!isInitialized(), "OptionalBinder was already initialized");

  final Provider<Map<Source, Provider<T>>> mapProvider = binder.getProvider(mapKey);
  binder.bind(optionalProviderKey).toProvider(
      new RealOptionalBinderProviderWithDependencies<Optional<Provider<T>>>(typeKey) {
    private Optional<Provider<T>> optional;

    @Toolable @Inject void initialize(Injector injector) {
      RealOptionalBinder.this.binder = null;
      Map<Source, Provider<T>> map = mapProvider.get();
      // Map might be null if duplicates prevented MapBinder from initializing
      if (map != null) {
        if (map.containsKey(Source.ACTUAL)) {
          // TODO(sameb): Consider exposing an option that will allow
          // ACTUAL to fallback to DEFAULT if ACTUAL's provider returns null.
          // Right now, an ACTUAL binding can convert from present -> absent
          // if it's bound to a provider that returns null.
          optional = Optional.fromNullable(map.get(Source.ACTUAL)); 
        } else if (map.containsKey(Source.DEFAULT)) {
          optional = Optional.fromNullable(map.get(Source.DEFAULT));
        } else {
          optional = Optional.absent();
        }
        
        // Also set up the bindings for the SPI.
        if (map.containsKey(Source.ACTUAL)) {
          actualBinding = getBindingFromMapProvider(injector, map.get(Source.ACTUAL));
        }
        if (map.containsKey(Source.DEFAULT)) {
          defaultBinding = getBindingFromMapProvider(injector, map.get(Source.DEFAULT));
        }
      }
    }
    
    public Optional<Provider<T>> get() {
      return optional;
    }

    public Set<Dependency<?>> getDependencies() {
      return dependencies;
    }
  });
  
  // Optional is immutable, so it's safe to expose Optional<Provider<T>> as
  // Optional<javax.inject.Provider<T>> (since Guice provider implements javax Provider).
  @SuppressWarnings({"unchecked", "cast"})
  Key massagedOptionalProviderKey = (Key) optionalProviderKey;
  binder.bind(optionalJavaxProviderKey).to(massagedOptionalProviderKey);

  binder.bind(optionalKey).toProvider(new RealOptionalKeyProvider());
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:53,代码来源:OptionalBinder.java


示例10: initialize

import com.google.inject.spi.Toolable; //导入依赖的package包/类
@Inject
@Toolable
protected void initialize(RibbonResourceFactory factory) {
    this.factory = factory;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:6,代码来源:RibbonResourceProvider.java


示例11: method

import com.google.inject.spi.Toolable; //导入依赖的package包/类
@Toolable @SuppressWarnings("unused") @Inject void method(M m) { this.m = m; } 
开发者ID:cgruber,项目名称:guice-old,代码行数:2,代码来源:ToolStageInjectorTest.java


示例12: staticMethod

import com.google.inject.spi.Toolable; //导入依赖的package包/类
@Toolable @SuppressWarnings("unused") @Inject static void staticMethod(SM sm) { Tooled.sm = sm; } 
开发者ID:cgruber,项目名称:guice-old,代码行数:2,代码来源:ToolStageInjectorTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JSON类代码示例发布时间:2022-05-23
下一篇:
Java DefaultNodeMatcher类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap