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

Java PrivateElements类代码示例

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

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



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

示例1: indexBindings

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
private ImmutableMap<Key<?>, Binding<?>> indexBindings(Iterable<Element> elements) {
  ImmutableMap.Builder<Key<?>, Binding<?>> builder = ImmutableMap.builder();
  for (Element element : elements) {
    if (element instanceof Binding) {
      Binding<?> binding = (Binding<?>) element;
      builder.put(binding.getKey(), binding);
    } else if (element instanceof PrivateElements) {
      PrivateElements privateElements = (PrivateElements) element;
      Map<Key<?>, Binding<?>> privateBindings = indexBindings(privateElements.getElements());
      for (Key<?> exposed : privateElements.getExposedKeys()) {
        builder.put(exposed, privateBindings.get(exposed));
      }
    }
  }
  return builder.build();
}
 
开发者ID:google,项目名称:guice,代码行数:17,代码来源:ServletScopesTest.java


示例2: indexBindings

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
ImmutableMap<Key<?>, Binding<?>> indexBindings(Iterable<Element> elements) {
  ImmutableMap.Builder<Key<?>, Binding<?>> builder = ImmutableMap.builder();
  for (Element element : elements) {
    if (element instanceof Binding) {
      Binding<?> binding = (Binding<?>) element;
      builder.put(binding.getKey(), binding);
    } else if (element instanceof PrivateElements) {
      PrivateElements privateElements = (PrivateElements) element;
      Map<Key<?>, Binding<?>> privateBindings = indexBindings(privateElements.getElements());
      for (Key<?> exposed : privateElements.getExposedKeys()) {
        builder.put(exposed, privateBindings.get(exposed));
      }
    }
  }
  return builder.build();
}
 
开发者ID:google,项目名称:guice,代码行数:17,代码来源:ScopesTest.java


示例3: testSpiAccess

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
public void testSpiAccess() {
  Injector injector = Guice.createInjector(new PrivateModule() {
        @Override public void configure() {
          bind(String.class).annotatedWith(named("a")).toInstance("private");
          bind(String.class).annotatedWith(named("b")).toInstance("exposed");
          expose(String.class).annotatedWith(named("b"));
        }
      });

  ExposedBinding<?> binding
      = (ExposedBinding<?>) injector.getBinding(Key.get(String.class, Names.named("b")));
  assertEquals(ImmutableSet.<Dependency<?>>of(Dependency.get(Key.get(Injector.class))),
      binding.getDependencies());
  PrivateElements privateElements = binding.getPrivateElements();
  assertEquals(ImmutableSet.<Key<?>>of(Key.get(String.class, named("b"))),
      privateElements.getExposedKeys());
  assertContains(privateElements.getExposedSource(Key.get(String.class, named("b"))).toString(),
      PrivateModuleTest.class.getName(), getDeclaringSourcePart(getClass()));
  Injector privateInjector = privateElements.getInjector();
  assertEquals("private", privateInjector.getInstance(Key.get(String.class, Names.named("a"))));
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:22,代码来源:PrivateModuleTest.java


示例4: indexBindings

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
ImmutableMap<Key<?>, Binding<?>> indexBindings(Iterable<Element> elements) {
  ImmutableMap.Builder<Key<?>, Binding<?>> builder = ImmutableMap.builder();
  for (Element element : elements) {
    if (element instanceof Binding) {
      Binding<?> binding = (Binding<?>) element;
      builder.put(binding.getKey(), binding);
    } else if (element instanceof PrivateElements) {
      PrivateElements privateElements = (PrivateElements)element;
      Map<Key<?>, Binding<?>> privateBindings = indexBindings(privateElements.getElements());
      for(Key<?> exposed : privateElements.getExposedKeys()) {
        builder.put(exposed, privateBindings.get(exposed));
      }
    }
  }
  return builder.build();
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:17,代码来源:ScopesTest.java


示例5: testSpiAccess

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
public void testSpiAccess() {
  Injector injector = Guice.createInjector(new PrivateModule() {
        public void configure() {
          bind(String.class).annotatedWith(named("a")).toInstance("private");
          bind(String.class).annotatedWith(named("b")).toInstance("exposed");
          expose(String.class).annotatedWith(named("b"));
        }
      });

  ExposedBinding<?> binding
      = (ExposedBinding<?>) injector.getBinding(Key.get(String.class, Names.named("b")));
  assertEquals(ImmutableSet.<Dependency<?>>of(Dependency.get(Key.get(Injector.class))),
      binding.getDependencies());
  PrivateElements privateElements = binding.getPrivateElements();
  assertEquals(ImmutableSet.<Key<?>>of(Key.get(String.class, named("b"))),
      privateElements.getExposedKeys());
  assertContains(privateElements.getExposedSource(Key.get(String.class, named("b"))).toString(),
      PrivateModuleTest.class.getName(), ".configure(PrivateModuleTest.java:");
  Injector privateInjector = privateElements.getInjector();
  assertEquals("private", privateInjector.getInstance(Key.get(String.class, Names.named("a"))));
}
 
开发者ID:utopiazh,项目名称:google-guice,代码行数:22,代码来源:PrivateModuleTest.java


示例6: visit

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
@Override
public Boolean visit(PrivateElements privateElements) {
  for (Key<?> key : privateElements.getExposedKeys()) {
    bindExposed(privateElements, key);
  }
  return false; // leave the private elements for the PrivateElementsProcessor to handle
}
 
开发者ID:google,项目名称:guice,代码行数:8,代码来源:BindingProcessor.java


示例7: bindExposed

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
private <T> void bindExposed(PrivateElements privateElements, Key<T> key) {
  ExposedKeyFactory<T> exposedKeyFactory = new ExposedKeyFactory<>(key, privateElements);
  bindingData.addCreationListener(exposedKeyFactory);
  putBinding(
      new ExposedBindingImpl<T>(
          injector,
          privateElements.getExposedSource(key),
          key,
          exposedKeyFactory,
          privateElements));
}
 
开发者ID:google,项目名称:guice,代码行数:12,代码来源:BindingProcessor.java


示例8: ExposedBindingImpl

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
public ExposedBindingImpl(
    InjectorImpl injector,
    Object source,
    Key<T> key,
    InternalFactory<T> factory,
    PrivateElements privateElements) {
  super(injector, key, source, factory, Scoping.UNSCOPED);
  this.privateElements = privateElements;
}
 
开发者ID:google,项目名称:guice,代码行数:10,代码来源:ExposedBindingImpl.java


示例9: toString

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
@Override
public String toString() {
  return MoreObjects.toStringHelper(PrivateElements.class)
      .add("exposedKeys", getExposedKeys())
      .add("source", getSource())
      .toString();
}
 
开发者ID:google,项目名称:guice,代码行数:8,代码来源:PrivateElementsImpl.java


示例10: visit

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
@Override
public Boolean visit(PrivateElements privateElements) {
  InjectorShell.Builder builder =
      new InjectorShell.Builder().parent(injector).privateElements(privateElements);
  injectorShellBuilders.add(builder);
  return true;
}
 
开发者ID:google,项目名称:guice,代码行数:8,代码来源:PrivateElementProcessor.java


示例11: testSpiAccess

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
public void testSpiAccess() {
  Injector injector =
      Guice.createInjector(
          new PrivateModule() {
            @Override
            public void configure() {
              bind(String.class).annotatedWith(named("a")).toInstance("private");
              bind(String.class).annotatedWith(named("b")).toInstance("exposed");
              expose(String.class).annotatedWith(named("b"));
            }
          });

  ExposedBinding<?> binding =
      (ExposedBinding<?>) injector.getBinding(Key.get(String.class, Names.named("b")));
  assertEquals(
      ImmutableSet.<Dependency<?>>of(Dependency.get(Key.get(Injector.class))),
      binding.getDependencies());
  PrivateElements privateElements = binding.getPrivateElements();
  assertEquals(
      ImmutableSet.<Key<?>>of(Key.get(String.class, named("b"))),
      privateElements.getExposedKeys());
  assertContains(
      privateElements.getExposedSource(Key.get(String.class, named("b"))).toString(),
      PrivateModuleTest.class.getName(),
      getDeclaringSourcePart(getClass()));
  Injector privateInjector = privateElements.getInjector();
  assertEquals("private", privateInjector.getInstance(Key.get(String.class, Names.named("a"))));
}
 
开发者ID:google,项目名称:guice,代码行数:29,代码来源:PrivateModuleTest.java


示例12: visit

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
@Override public Boolean visit(PrivateElements privateElements) {
  InjectorShell.Builder builder = new InjectorShell.Builder()
      .parent(injector)
      .privateElements(privateElements);
  injectorShellBuilders.add(builder);
  return true;
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:8,代码来源:PrivateElementProcessor.java


示例13: visit

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
@Override
public Object visit(PrivateElements privateElements) {
    processElements(privateElements.getElements());
    return super.visit(privateElements);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:DependencyCollector.java


示例14: visit

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
@Override
public Void visit(PrivateElements privateElements) {
    privateElements.getExposedKeys().forEach(binder::expose);
    return super.visit(privateElements);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:ElementExposer.java


示例15: visit

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
public Void visit(PrivateElements privateElements) {
  GinjectorBindings childCollection = children.next();
  
  // Add information about the elements in the child ginjector to the child bindings
  // TODO(bchambers): Use the tree loggers more intelligently -- when visiting
  // a child bindings collection, we should create a new branch.  This is slightly
  // complicated because we process  in two stages -- once here where we
  // add explicit bindings (and record implicit dependencies), and again later
  // to resolve the implicit dependencies.
  GuiceElementVisitor childVisitor = guiceElementVisitorFactory.create(childCollection);
  childVisitor.visitElements(privateElements.getElements());
  messages.addAll(childVisitor.getMessages());
  
  // Add information about the exposed elements in child to the current binding collection
  for (Key<?> key : privateElements.getExposedKeys()) {
    ExposedChildBinding childBinding =
        bindingFactory.getExposedChildBinding(key, childCollection,
            Context.forElement(privateElements));

    // The child must have an explicit binding or pin for anything it exposes.
    //
    // Note that this is correct only because the
    // GuiceElementVisitor runs before any synthetic bindings are
    // inserted into the GinjectorBindings (more specifically,
    // before implicit bindings are generated).  Otherwise,
    // isBound() might return true for keys that weren't explicitly bound.
    //
    // If the above invariant is violated, the effect will be to
    // bypass this error in some cases.  The offending key should
    // still generate an error, but it will not be as clearly
    // described.
    if (!(childCollection.isBound(key) || childCollection.isPinned(key))) {
      errorManager.logError(
          "Key %s was exposed from but not bound in %s.  Did you forget to call bind()?",
          key, childCollection);
    }

    PrettyPrinter.log(logger, TreeLogger.TRACE, "Child binding for %s in %s: %s", key, bindings, childBinding);

    bindings.addBinding(key, childBinding);
  }
  return null;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:44,代码来源:GuiceElementVisitor.java


示例16: getPrivateElements

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
@Override
public PrivateElements getPrivateElements() {
  return privateElements;
}
 
开发者ID:google,项目名称:guice,代码行数:5,代码来源:ExposedBindingImpl.java


示例17: ExposedKeyFactory

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
ExposedKeyFactory(Key<T> key, PrivateElements privateElements) {
  this.key = key;
  this.privateElements = privateElements;
}
 
开发者ID:google,项目名称:guice,代码行数:5,代码来源:ExposedKeyFactory.java


示例18: visit

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
@Override public Boolean visit(PrivateElements privateElements) {
  for (Key<?> key : privateElements.getExposedKeys()) {
    bindExposed(privateElements, key);
  }
  return false; // leave the private elements for the PrivateElementsProcessor to handle
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:7,代码来源:BindingProcessor.java


示例19: bindExposed

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
private <T> void bindExposed(PrivateElements privateElements, Key<T> key) {
  ExposedKeyFactory<T> exposedKeyFactory = new ExposedKeyFactory<T>(key, privateElements);
  bindingData.addCreationListener(exposedKeyFactory);
  putBinding(new ExposedBindingImpl<T>(
      injector, privateElements.getExposedSource(key), key, exposedKeyFactory, privateElements));
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:7,代码来源:BindingProcessor.java


示例20: ExposedBindingImpl

import com.google.inject.spi.PrivateElements; //导入依赖的package包/类
public ExposedBindingImpl(InjectorImpl injector, Object source, Key<T> key,
    InternalFactory<T> factory, PrivateElements privateElements) {
  super(injector, key, source, factory, Scoping.UNSCOPED);
  this.privateElements = privateElements;
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:6,代码来源:ExposedBindingImpl.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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