com.google.inject.Module类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(407)

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

Module介绍

[英]A module contributes configuration information, typically interface bindings, which will be used to create an Injector. A Guice-based application is ultimately composed of little more than a set of Modules and some bootstrapping code.

Your Module classes can use a more streamlined syntax by extending AbstractModule rather than implementing this interface directly.

In addition to the bindings configured via #configure, bindings will be created for all methods annotated with @Provides. Use scope and binding annotations on these methods to configure the bindings.
[中]

代码示例

代码示例来源:origin: embulk/embulk

@Override
  public void configure(Binder binder) {
    ServiceLoader<Extension> serviceLoader = ServiceLoader.load(Extension.class, classLoader);
    for (Extension extension : serviceLoader) {
      for (Module module : extension.getModules(systemConfig)) {
        module.configure(binder);
      }
    }
  }
}

代码示例来源:origin: jooby-project/jooby

.map(loadClass)
.filter(C)
.forEach(klass -> ((Module) newObject(klass)).configure(binder));

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

module.configure(binder);
} catch (RuntimeException e) {
 Collection<Message> messages = Errors.getMessagesFromThrowable(e);

代码示例来源:origin: org.sonatype.sisu/sisu-inject-bean

public void configure( final Binder binder )
  {
    delegate.configure( binder );
  }
}

代码示例来源:origin: org.sonatype.sisu/sisu-inject-plexus

public void configure( final Binder binder )
  {
    delegate.configure( binder );
  }
}

代码示例来源:origin: org.eclipse.sisu/org.eclipse.sisu.plexus

public PlexusBeanSource configure( final Binder binder )
{
  if ( null != spaceModule )
  {
    spaceModule.configure( binder );
  }
  return beanSource;
}

代码示例来源:origin: org.sonatype.sisu/sisu-inject-bean

public void configure( final Binder binder )
{
  delegate.configure( binder );
}

代码示例来源:origin: io.joynr.java.core/libjoynr

@Override
public void configure(Binder binder) {
  assert module != null;
  module.configure(binder);
}

代码示例来源:origin: net.spals.appbuilder/spals-appbuilder-app-core

@Override
  public void configure(final BootstrapBinder bootstrapBinder) {
    module.configure(bootstrapBinder);
  }
}

代码示例来源:origin: org.eclipse.sisu/org.eclipse.sisu.plexus

public void configure( final Binder binder )
{
  BeanScheduler.MODULE.configure( binder );
}

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

public void install(Module module) {
 module.configure(this);
}

代码示例来源:origin: com.b2international.snowowl/com.b2international.commons.base

@Override
public void configure(final Binder binder) {
  for (final Module module : modules) {
    try {
      module.configure(binder);
    } catch (final Exception e) {
      LOGGER.error(e.getMessage(), e);
    }
  }
}

代码示例来源:origin: org.eclipse/xtext

public void configure(Binder binder) {
  for (Module module : modules) {
    try {
      module.configure(binder);
    } catch(Exception e) {
      LOGGER.error(e.getMessage(), e);
    }
  }
}

代码示例来源:origin: io.digdag/digdag-core

@Deprecated
  private void configureDeprecatedExtension(Binder binder)
  {
    ServiceLoader<io.digdag.core.Extension> serviceLoader = ServiceLoader.load(io.digdag.core.Extension.class, classLoader);
    for (io.digdag.core.Extension extension : serviceLoader) {
      for (Module module : extension.getModules()) {
        module.configure(binder);
      }
    }
  }
}

代码示例来源:origin: org.eclipse/xtext

public void configure(Binder binder) {
  Module compound = getBindings();
  compound.configure(binder);
}

代码示例来源:origin: org.atteo.moonshine/container

@Override
  public void configure(Binder binder) {
    if (modules.add(module)) {
      module.configure(createForwardingBinder(binder));
      binder.install(ProviderMethodsModule.forModule(module));
    }
  }
};

代码示例来源:origin: io.digdag/digdag-core

@Override
public void configure(Binder binder)
{
  ServiceLoader<Extension> serviceLoader = ServiceLoader.load(Extension.class, classLoader);
  for (Extension extension : serviceLoader) {
    for (Module module : extension.getModules()) {
      module.configure(binder);
    }
  }
  configureDeprecatedExtension(binder);
}

代码示例来源:origin: org.atteo.moonshine/container

@Override
  protected void configure() {
    if (modules.add(module)) {
      module.configure(createForwardingBinder(binder()));
      install(ProviderMethodsModule.forModule(module));
    }
  }
};

代码示例来源:origin: org.eclipse.sisu/org.eclipse.sisu.plexus

public void configure( final Binder binder )
  {
    final List<PlexusBeanSource> sources = new ArrayList<PlexusBeanSource>( modules.length );
    for ( final PlexusBeanModule module : modules )
    {
      final PlexusBeanSource source = module.configure( binder );
      if ( null != source )
      {
        sources.add( source );
      }
    }

    // attach custom logic to support Plexus requirements/configuration/lifecycle
    final PlexusBeanBinder plexusBinder = new PlexusBeanBinder( manager, sources );
    binder.bindListener( Matchers.any(), new BeanListener( plexusBinder ) );
    if ( manager instanceof Module )
    {
      ( (Module) manager ).configure( binder );
    }
  }
}

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

public void install(Module module) {
 if (modules.add(module)) {
  Binder binder = this;
  if (module instanceof PrivateModule) {
   binder = binder.newPrivateBinder();
  }
  try {
   module.configure(binder);
  } catch (RuntimeException e) {
   Collection<Message> messages = Errors.getMessagesFromThrowable(e);
   if (!messages.isEmpty()) {
    elements.addAll(messages);
   } else {
    addError(e);
   }
  }
  binder.install(ProviderMethodsModule.forModule(module));
 }
}

相关文章

Module类方法