gpt4 book ai didi

org.eclipse.sisu.wire.WireModule类的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 06:15:05 26 4
gpt4 key购买 nike

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

WireModule介绍

暂无

代码示例

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

public WireModule( final List<Module> modules )
{
  delegate = new org.eclipse.sisu.wire.WireModule( modules );
}

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

public Injector addPlexusInjector( final List<? extends PlexusBeanModule> beanModules,
                  final Module... customModules )
{
  final List<Module> modules = new ArrayList<Module>();
  modules.add( containerModule );
  Collections.addAll( modules, customModules );
  modules.add( new PlexusBindingModule( plexusBeanManager, beanModules ) );
  modules.add( defaultsModule );
  return Guice.createInjector( isAutoWiringEnabled ? new WireModule( modules ) : new MergedModule( modules ) );
}

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

Guice.createInjector( new WireModule( new Module()

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

public void testDefaultParameters()
{
  Guice.createInjector( new WireModule( new AbstractModule()
  {
    @Override
    protected void configure()
    {
      bind( ParametersTest.class );
    }
  } ) ).injectMembers( this );
  assertTrue( properties.isEmpty() );
  assertEquals( 0, arguments.length );
}

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

@SuppressWarnings( { "rawtypes", "unchecked" } )
  public Object invoke( final Object proxy, final Method method, final Object[] args )
    throws Throwable
  {
    final String methodName = method.getName();
    if ( "getInstance".equals( methodName ) )
    {
      final Key key = args[0] instanceof Key ? (Key) args[0] : Key.get( (Class) args[0] );
      final Iterator<Entry> i = injector.getInstance( BeanLocator.class ).locate( key ).iterator();
      return i.hasNext() ? i.next().getValue() : null;
    }
    if ( "injectMembers".equals( methodName ) )
    {
      Guice.createInjector( new WireModule( new Module()
      {
        public void configure( final Binder binder )
        {
          binder.bind( BeanLocator.class ).toProvider( injector.getProvider( BeanLocator.class ) );
          binder.requestInjection( args[0] );
        }
      } ) );
      return null;
    }
    return method.invoke( injector, args );
  }
} );

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

public static void inject( final Object that )
{
  final BeanLocator locator = getBeanLocator();
  if ( null != locator )
  {
    Guice.createInjector( new WireModule( new Module()
    {
      public void configure( final Binder binder )
      {
        binder.bind( BeanLocator.class ).toProvider( Providers.of( locator ) );
        binder.requestInjection( that );
      }
    } ) );
  }
  else
  {
    Logs.trace( "No BeanLocator found for thread {}", Thread.currentThread(), null );
  }
}

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

public void testBeanEntries()
{
  final Injector injector = Guice.createInjector( new WireModule( new TestModule() ) );
  final BeanEntries beans = (BeanEntries) injector.getInstance( Key.get( X.class, Names.named( "BE" ) ) );
  final HintMap hintMap = (HintMap) injector.getInstance( Key.get( X.class, Names.named( "HM" ) ) );
  final Iterator<BeanEntry<Named, Y>> i = beans.entries.iterator();
  assertTrue( i.hasNext() );
  assertSame( hintMap.map.get( "fixed" ), i.next().getValue() );
  assertNotSame( hintMap.map.get( "unscoped" ), i.next().getValue() );
  assertFalse( i.hasNext() );
}

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

public void testGenericInjection()
{
  final Injector injector = Guice.createInjector( new WireModule( new TestModule() ) );
  final GenericInstance genericInstance =
    (GenericInstance) injector.getInstance( Key.get( X.class, Names.named( "GI" ) ) );
  assertEquals( TypeLiteral.get( Integer.class ),
         TypeParameters.get( TypeLiteral.get( genericInstance.number.getClass() ).getSupertype( Z.class ),
                   0 ) );
  assertEquals( TypeLiteral.get( String.class ),
         TypeParameters.get( TypeLiteral.get( genericInstance.chars.getClass() ).getSupertype( Z.class ),
                   0 ) );
  assertEquals( ZImpl.class, genericInstance.random.getClass() );
}

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

public void testNamedImports()
{
  final Injector injector = Guice.createInjector( new WireModule( new TestModule() ) );
  final NamedType namedType = (NamedType) injector.getInstance( Key.get( X.class, Names.named( "NT" ) ) );
  final NamedInstance namedInstance =
    (NamedInstance) injector.getInstance( Key.get( X.class, Names.named( "NI" ) ) );
  assertNotNull( namedType.single );
  assertSame( namedType.fixed, namedType.single );
  assertNull( namedInstance.single );
  final HintMap hintMap = (HintMap) injector.getInstance( Key.get( X.class, Names.named( "HM" ) ) );
  assertSame( namedType.fixed, hintMap.map.get( "fixed" ) );
  assertSame( hintMap.fixed, hintMap.map.get( "fixed" ) );
  assertNotSame( namedType.fixed, hintMap.map.get( "unscoped" ) );
  assertNotSame( hintMap.fixed, hintMap.map.get( "unscoped" ) );
  assertEquals( 2, hintMap.map.size() );
}

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

public void testImportSource()
{
  final Injector injector = Guice.createInjector( new WireModule( new TestModule() ) );
  assertEquals( LocatorWiring.class.getName(), injector.getBinding( Y.class ).getSource().toString() );
}

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

@SuppressWarnings( { "unchecked", "rawtypes" } )
  public void testCustomParameters()
  {
    Guice.createInjector( new WireModule( new AbstractModule()
    {
      @Override
      protected void configure()
      {
        bind( ParametersTest.class );
      }

      @Provides
      @Parameters
      String[] arguments()
      {
        return new String[] { "Hello", "World" };
      }

      @Provides
      @Parameters
      Map<String, String> properties()
      {
        return (Map) System.getProperties();
      }
    } ) ).injectMembers( this );

    assertEquals( System.getProperties(), properties );
    assertTrue( Arrays.equals( new String[] { "Hello", "World" }, arguments ) );
  }
}

代码示例来源:origin: org.hudsonci.plugins/maven3-eventspy-3.1

private EventSpy loadDelegate() {
  checkState(locator != null);
  // Setup the Injector to load spy impls from
  URL[] scanPath = {
    getClass().getProtectionDomain().getCodeSource().getLocation(),
  };
  URLClassSpace space = new URLClassSpace(getClass().getClassLoader(), scanPath);
  Injector injector = Guice.createInjector(new WireModule(new SpaceModule(space), this));
  // Log what spies we know about
  if (log.isDebugEnabled()) {
    log.debug("Known spies:");
    for (BeanEntry<?, EventSpySupport> spy : locator.locate(Key.get(EventSpySupport.class))) {
      log.debug("  {}", spy);
    }
  }
  // Load the delegate, default to RemotingEventSpy
  String name = getProperty(DELEGATE_PROPERTY, RemotingEventSpy.class.getName());
  log.debug("Loading delegate named: {}", name);
  Iterator<? extends BeanEntry<?, EventSpySupport>> itr = locator.locate(Key.get(EventSpySupport.class, Names.named(name))).iterator();
  if (itr.hasNext()) {
    return itr.next().getValue();
  }
  throw new RuntimeException("No such delegate: "+name);
}

代码示例来源:origin: io.takari.orchestra/agent

public static void main(String[] args) {
    try {
      ClassLoader cl = Main.class.getClassLoader();
      Module m = new WireModule(new SpaceModule(new URLClassSpace(cl), BeanScanning.CACHE));
      Injector injector = Guice.createInjector(m);

      Main main = injector.getInstance(Main.class);
      main.run();

      // force exit, some non-daemon threads in third-party code may prevent a normal exit
      System.exit(0);
    } catch (Throwable e) {
      log.error("main -> unhandled exception", e);
      System.exit(1);
    }
  }
}

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

Guice.createInjector( new WireModule( new AbstractModule()
Guice.createInjector( new WireModule( new AbstractModule()
Guice.createInjector( new WireModule( new AbstractModule()
Guice.createInjector( new WireModule( new AbstractModule()
Guice.createInjector( new WireModule( new AbstractModule()
Guice.createInjector( new WireModule( new AbstractModule()

代码示例来源:origin: org.sonatype.goodies.dropwizard/dropwizard-support-core

modules.add(new SpaceModule(space, scanning));
return Guice.createInjector(new WireModule(modules));

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

public void testProviderImports()
  final Injector injector = Guice.createInjector( new WireModule( new TestModule() ) );

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

public void testUnrestrictedImport()
  final Injector injector = Guice.createInjector( new WireModule( new TestModule() ) );

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

public void testPlaceholderImports()
  final Injector injector = Guice.createInjector( new WireModule( new TestModule() ) );

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

public void testDuplicatesAreIgnored()
{
  Guice.createInjector( new WireModule( new TestModule(), new TestModule(), new TestModule() ) );
}

代码示例来源:origin: com.walmartlabs.concord.server/concord-server

public static void main(String[] args) throws Exception {
  EnvironmentSelector environmentSelector = new EnvironmentSelector();
  Config cfg = new ConfigurationProcessor("concord-server", environmentSelector.select()).process();
  Injector injector = Guice.createInjector(
      new WireModule(
          new SpaceModule(new URLClassSpace(MigrateDB.class.getClassLoader()), BeanScanning.CACHE),
          new OllieConfigurationModule("com.walmartlabs.concord.server", cfg),
          new DatabaseModule()));
  new MigrateDB().run(injector);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com