com.google.inject.Binding.acceptTargetVisitor()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中com.google.inject.Binding.acceptTargetVisitor()方法的一些代码示例,展示了Binding.acceptTargetVisitor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.acceptTargetVisitor()方法的具体详情如下:
包路径:com.google.inject.Binding
类名称:Binding
方法名:acceptTargetVisitor

Binding.acceptTargetVisitor介绍

[英]Accepts a target visitor. Invokes the visitor method specific to this binding's target.
[中]接受目标访问者。调用特定于此绑定目标的访问者方法。

代码示例

代码示例来源:origin: com.google.inject/guice

@Override
public <T> Boolean visit(Binding<T> binding) {
 return binding.acceptTargetVisitor(
   new Processor<T, Boolean>((BindingImpl<T>) binding) {
    @Override

代码示例来源:origin: com.google.inject/guice

if (index.put(key, valueBinding.acceptTargetVisitor(indexer))) {

代码示例来源:origin: com.google.inject/guice

@SuppressWarnings("unchecked") // protected by findBindingsByType()
Binding<T> binding = (Binding<T>) entry;
if (index.add(binding.acceptTargetVisitor(indexer))) {

代码示例来源:origin: com.google.inject/guice

return command.acceptTargetVisitor(
  new Processor<T, Boolean>((BindingImpl<T>) command) {
   @Override

代码示例来源:origin: com.google.inject.extensions/guice-servlet

public final void testSpiOnInjector() {
 ServletSpiVisitor visitor = new ServletSpiVisitor(true);
 int count = 0;
 Injector injector = Guice.createInjector(new Module());
 for (Binding binding : injector.getBindings().values()) {
  assertEquals(count++, binding.acceptTargetVisitor(visitor));
 }
 validateVisitor(visitor);
}

代码示例来源:origin: com.google.inject.extensions/guice-servlet

public void testServletModuleReuse() {
 Module module = new Module();
 Elements.getElements(module); // use the module once (to, say, introspect bindings)
 Injector injector = Guice.createInjector(module); // use it again.
 Visitor visitor = new Visitor();
 // Validate only a single servlet binding & a single filter binding exist.
 for (Binding<?> binding : injector.getAllBindings().values()) {
  binding.acceptTargetVisitor(visitor);
 }
 assertEquals(
   "wrong linked servlets: " + visitor.linkedServlets, 0, visitor.linkedServlets.size());
 assertEquals("wrong linked filters: " + visitor.linkedFilters, 0, visitor.linkedFilters.size());
 assertEquals(
   "wrong instance servlets: " + visitor.instanceServlets, 1, visitor.instanceServlets.size());
 assertEquals(
   "wrong instance filters: " + visitor.instanceFilters, 1, visitor.instanceFilters.size());
}

代码示例来源:origin: com.atlassian.org.eclipse.sisu/org.eclipse.sisu.inject

@SuppressWarnings( "unchecked" )
public Class<T> getImplementationClass()
{
  return (Class<T>) binding.acceptTargetVisitor( ImplementationVisitor.THIS );
}

代码示例来源:origin: com.netflix.governator/governator-core

public <T> String visit(Binding<T> binding) {
    return binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<T, String>() {
      public String visit(InstanceBinding<? extends T> instanceBinding) {
        return String.format("toInstance() at %s can force undesireable static initialization.  " +
            "Consider replacing with an @Provides method instead.",
            instanceBinding.getSource());
      }
    });
  }
}

代码示例来源:origin: com.google.inject.extensions/guice-servlet

public final void testSpiOnElements() {
 ServletSpiVisitor visitor = new ServletSpiVisitor(false);
 int count = 0;
 for (Element element : Elements.getElements(new Module())) {
  if (element instanceof Binding) {
   assertEquals(count++, ((Binding) element).acceptTargetVisitor(visitor));
  }
 }
 validateVisitor(visitor);
}

代码示例来源:origin: ArcBees/Jukito

@Override
public <T> Void visit(com.google.inject.Binding<T> command) {
  GuiceBindingVisitor<T> bindingVisitor = new GuiceBindingVisitor<>();
  command.acceptTargetVisitor(bindingVisitor);
  return null;
}

代码示例来源:origin: com.google.inject.extensions/guice-grapher

@Override
public Iterable<Node> getNodes(Iterable<Binding<?>> bindings) {
 List<Node> nodes = Lists.newArrayList();
 NodeVisitor visitor = new NodeVisitor();
 for (Binding<?> binding : bindings) {
  nodes.addAll(binding.acceptTargetVisitor(visitor));
 }
 return nodes;
}

代码示例来源:origin: com.atlassian.org.eclipse.sisu/org.eclipse.sisu.inject

private static boolean isAssignableFrom( final TypeLiteral<?> superType, final Binding<?> binding )
{
  // don't match the exact implementation as it's already covered by an explicit binding
  final Class<?> implementation = binding.acceptTargetVisitor( ImplementationVisitor.THIS );
  if ( null != implementation && superType.getRawType() != implementation )
  {
    return TypeParameters.isAssignableFrom( superType, TypeLiteral.get( implementation ) );
  }
  return false;
}

代码示例来源:origin: org.jukito/jukito

@Override
public <T> Void visit(com.google.inject.Binding<T> command) {
  GuiceBindingVisitor<T> bindingVisitor = new GuiceBindingVisitor<>();
  command.acceptTargetVisitor(bindingVisitor);
  return null;
}

代码示例来源:origin: com.google.inject.extensions/guice-grapher

@Override
public Iterable<Edge> getEdges(Iterable<Binding<?>> bindings) {
 List<Edge> edges = Lists.newArrayList();
 EdgeVisitor visitor = new EdgeVisitor();
 for (Binding<?> binding : bindings) {
  edges.addAll(binding.acceptTargetVisitor(visitor));
 }
 return edges;
}

代码示例来源:origin: ops4j/peaberry

public void activate(Injector injector) {
 for (final Key<?> k : keys) {
  injector.getBinding(k).acceptTargetVisitor(mover);
 }
}

代码示例来源:origin: com.atlassian.org.eclipse.sisu/org.eclipse.sisu.inject

@Override
  final Annotation qualifies( final Key<?> requirement, final Binding<?> binding )
  {
    final Class<? extends Annotation> markerType = requirement.getAnnotationType();
    final Annotation qualifier = qualify( binding.getKey() );
    if ( markerType.isInstance( qualifier ) )
    {
      return qualifier;
    }
    final Class<?> implementation = binding.acceptTargetVisitor( ImplementationVisitor.THIS );
    return null != implementation ? implementation.getAnnotation( markerType ) : null;
  }
},

代码示例来源:origin: com.atlassian.org.eclipse.sisu/org.eclipse.sisu.inject

@Override
  public Class<?> visit( final ExposedBinding<?> binding )
  {
    return binding.getPrivateElements().getInjector().getBinding( binding.getKey() ).acceptTargetVisitor( this );
  }
}

代码示例来源:origin: com.google.inject.extensions/guice-assistedinject

public void testSpiOnVisitor() throws Exception {
 AssistedInjectSpiVisitor visitor = new AssistedInjectSpiVisitor();
 Integer count = 0;
 Injector injector = Guice.createInjector(new Module());
 for (Binding<?> binding : injector.getBindings().values()) {
  assertEquals(count++, binding.acceptTargetVisitor(visitor));
 }
 validateVisitor(visitor);
}

代码示例来源:origin: io.github.gwtplus.gin/gin

public <T> Void visit(com.google.inject.Binding<T> command) {
 GuiceBindingVisitor<T> bindingVisitor = bindingVisitorFactory.create(
   command.getKey(), messages, bindings);
 PrettyPrinter.log(logger, TreeLogger.DEBUG, "Adding pin for %s in %s because %s",
   command.getKey(), bindings, command);
 // If we visit a binding for a key, we pin it to the current ginjector,
 // since it indicates that the user explicitly asked for it to be placed
 // there.
 bindings.addPin(command.getKey());
 command.acceptTargetVisitor(bindingVisitor);
 command.acceptScopingVisitor(bindingVisitor);
 return null;
}

代码示例来源:origin: com.google.inject.extensions/guice-assistedinject

public final void testSpiOnElements() throws Exception {
 AssistedInjectSpiVisitor visitor = new AssistedInjectSpiVisitor();
 Integer count = 0;
 for (Element element : Elements.getElements(new Module())) {
  if (element instanceof Binding) {
   assertEquals(count++, ((Binding<?>) element).acceptTargetVisitor(visitor));
  }
 }
 validateVisitor(visitor);
}

相关文章