Java Code Examples for com.google.inject.TypeLiteral

The following examples show how to use com.google.inject.TypeLiteral. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: business   Source File: DomainRegistryImplTest.java    License: Mozilla Public License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked"})
@Test
public void testGetFactoryTypeOfOfT(final @Mocked Factory<?> factory1) {
    DomainRegistry domainRegistry = createDomainRegistry();

    new Expectations() {
        {
            injector.getInstance((Key<Factory<AggregateRoot<Long>>>) any);
            result = factory1;
        }
    };

    Factory<AggregateRoot<Long>> factory2 = domainRegistry.getFactory(
            new TypeLiteral<Factory<AggregateRoot<Long>>>() {}.getType());
    assertThat(factory2).isEqualTo(factory1);
}
 
Example 2
Source Project: guacamole-client   Source File: SharingProfileModule.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<SharingProfile, APISharingProfile>>() {},
                SharingProfileDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<SharingProfile, APISharingProfile>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<SharingProfile, APISharingProfile>>() {},
                SharingProfileResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<SharingProfile, APISharingProfile>>() {}));

    // Bind translator for converting between SharingProfile and APISharingProfile
    bind(new TypeLiteral<DirectoryObjectTranslator<SharingProfile, APISharingProfile>>() {})
            .to(SharingProfileObjectTranslator.class);

}
 
Example 3
@Test
public void scanForMethods() throws Exception {
    class Woot {
        @Yay String foo() {
            return "foo";
        }

        String bar() {
            return "bar";
        }
    }

    List<InjectableMethod<?>> methods = InjectableMethod.forAnnotatedMethods(TypeLiteral.get(Woot.class), new Woot(), Yay.class);
    Injector injector = Guice.createInjector(Lists.transform(methods, InjectableMethod::bindingModule));

    assertEquals("foo", injector.getInstance(String.class));
}
 
Example 4
Source Project: che   Source File: SeleniumClassModule.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) {
  traverseClassHierarchy(
      type.getRawType(),
      (clazz) -> {
        for (Field field : clazz.getDeclaredFields()) {
          if (field.getType() == TestWorkspace.class
              && field.isAnnotationPresent(InjectTestWorkspace.class)) {
            encounter.register(
                new TestWorkspaceInjector<>(
                    field,
                    field.getAnnotation(InjectTestWorkspace.class),
                    injectorProvider.get()));
          }
        }
      });
}
 
Example 5
Source Project: james-project   Source File: AbstractMethodTypeListener.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Allows traverse the input klass hierarchy.
 *
 * @param parentType the owning type being heard
 * @param klass      encountered by Guice.
 * @param encounter  the injection context.
 */
private <I> void hear(final TypeLiteral<I> parentType, Class<? super I> klass, TypeEncounter<I> encounter) {
    Package pkg;
    if (klass == null || ((pkg = klass.getPackage()) != null && pkg.getName().startsWith(JAVA_PACKAGE))) {
        return;
    }

    for (Class<? extends Annotation> annotationType : annotationTypes) {
        for (Method method : klass.getDeclaredMethods()) {
            if (method.isAnnotationPresent(annotationType)) {
                if (method.getParameterTypes().length != 0) {
                    encounter.addError("Annotated methods with @%s must not accept any argument, found %s",
                        annotationType.getName(), method);
                }

                hear(method, parentType, encounter, annotationType);
            }
        }
    }

    hear(parentType, klass.getSuperclass(), encounter);
}
 
Example 6
Source Project: guacamole-client   Source File: ActiveConnectionModule.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<ActiveConnection, APIActiveConnection>>() {},
                ActiveConnectionDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<ActiveConnection, APIActiveConnection>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<ActiveConnection, APIActiveConnection>>() {},
                ActiveConnectionResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<ActiveConnection, APIActiveConnection>>() {}));

    // Bind translator for converting between ActiveConnection and APIActiveConnection
    bind(new TypeLiteral<DirectoryObjectTranslator<ActiveConnection, APIActiveConnection>>() {})
            .to(ActiveConnectionObjectTranslator.class);

}
 
Example 7
Source Project: joynr   Source File: NoBackendMessagingModule.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(MessageReceiver.class).to(NoBackendMessagingReceiver.class);

    Multibinder<GlobalAddressFactory<? extends Address>> globalAddresses;
    globalAddresses = Multibinder.newSetBinder(binder(),
                                               new TypeLiteral<GlobalAddressFactory<? extends Address>>() {
                                               },
                                               Names.named(GlobalAddressProvider.GLOBAL_ADDRESS_FACTORIES));
    globalAddresses.addBinding().to(NoBackendGlobalAddressFactory.class);

    Multibinder<GlobalAddressFactory<? extends Address>> replyToAddresses;
    replyToAddresses = Multibinder.newSetBinder(binder(),
                                                new TypeLiteral<GlobalAddressFactory<? extends Address>>() {
                                                },
                                                Names.named(ReplyToAddressProvider.REPLY_TO_ADDRESS_FACTORIES));
    replyToAddresses.addBinding().to(NoBackendGlobalAddressFactory.class);

}
 
Example 8
Source Project: arcusplatform   Source File: GsonModule.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
   bind(com.iris.io.json.JsonSerializer.class).to(GsonSerializerImpl.class);
   bind(com.iris.io.json.JsonDeserializer.class).to(GsonDeserializerImpl.class);

   Multibinder
   	.newSetBinder(binder(), new TypeLiteral<com.google.gson.JsonSerializer<?>>() {})
   	.addBinding()
   	.to(AttributeMapSerializer.class);
   Multibinder
   	.newSetBinder(binder(), new TypeLiteral<com.google.gson.JsonDeserializer<?>>() {})
   	.addBinding()
   	.to(AttributeMapSerializer.class);
   Multibinder
      .newSetBinder(binder(), new TypeLiteral<TypeAdapter<?>>() {})
      .addBinding()
      .to(ByteArrayToBase64TypeAdapter.class);
   Multibinder
      .newSetBinder(binder(), new TypeLiteral<TypeAdapterFactory>() {})
      .addBinding()
      .to(TypeTypeAdapterFactory.class);
}
 
Example 9
Source Project: guacamole-client   Source File: ActiveConnectionModule.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<ActiveConnection, APIActiveConnection>>() {},
                ActiveConnectionDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<ActiveConnection, APIActiveConnection>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<ActiveConnection, APIActiveConnection>>() {},
                ActiveConnectionResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<ActiveConnection, APIActiveConnection>>() {}));

    // Bind translator for converting between ActiveConnection and APIActiveConnection
    bind(new TypeLiteral<DirectoryObjectTranslator<ActiveConnection, APIActiveConnection>>() {})
            .to(ActiveConnectionObjectTranslator.class);

}
 
Example 10
public ModuleManifest(@Nullable TypeLiteral<Module> type) {
    // Figure out the module type. If the given type is null,
    // then try to resolve it from this object's superclass.
    this.type = type != null ? Types.assertFullySpecified(type)
                             : new ResolvableType<Module>(){}.in(getClass());
    this.rawType = (Class<Module>) this.type.getRawType();
    this.simpleName = rawType.getSimpleName();

    // Resolve the scope type automatically
    this.scope = (Class<Scope>) new ResolvableType<Scope>(){}.in(getClass()).getRawType();

    // Construct various keys related to the module/scope
    this.key = Key.get(this.type);
    this.optionalKey = Keys.optional(this.key);
    this.wrapperKey = ProvisionWrapper.keyOf(this.type);
    this.contextKey = Key.get(new ResolvableType<Context>(){}.in(getClass()));
    this.setElementKey = Key.get(new ResolvableType<ProvisionWrapper<? extends Base>>(){}.in(getClass()));
}
 
Example 11
Source Project: googleads-java-lib   Source File: AdsSoapModule.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Configures the factories.
 *
 * @param <H> the subclass of {@link AdsServiceClientFactoryHelper}
 * @param <F> the subclass of {@link BaseAdsServiceClientFactory}
 *
 * @param adsServiceClientFactoryTypeLiteral the factory type literal which
 *        contains a {@link AdsServiceClientFactoryInterface}
 * @param adsServiceDescriptorFactoryTypeLiteral the factory type literal
 *        which contains a {@link AdsServiceDescriptorFactoryInterface}
 * @param adsServiceClientTypeLiteral the ads service client literal which
 *        contains a {@link AdsServiceClient}
 * @param adsServiceDescriptorTypeLiteral the ads service descriptor literal
 *        which contains a {@link AdsServiceDescriptor}
 * @param adsServiceClientFactoryHelperClass the {@link AdsServiceClientFactoryHelper} class
 * @param baseAdsServiceClientFactoryClass the {@link BaseAdsServiceClientFactory} class
 */
protected <H extends AdsServiceClientFactoryHelper<C, S, D>,
        F extends BaseAdsServiceClientFactory<C, S, D>>
    void configureFactories(
        TypeLiteral<AdsServiceClientFactoryInterface<C, S, D>> adsServiceClientFactoryTypeLiteral,
        TypeLiteral<AdsServiceDescriptorFactoryInterface<D>>
            adsServiceDescriptorFactoryTypeLiteral,
        TypeLiteral<C> adsServiceClientTypeLiteral,
        TypeLiteral<D> adsServiceDescriptorTypeLiteral,
        Class<H> adsServiceClientFactoryHelperClass,
        Class<F> baseAdsServiceClientFactoryClass) {
  install(
      new FactoryModule<C, D, S, H, F>(
          adsServiceClientFactoryTypeLiteral,
          adsServiceDescriptorFactoryTypeLiteral,
          adsServiceClientTypeLiteral,
          adsServiceDescriptorTypeLiteral,
          adsServiceClientFactoryHelperClass,
          baseAdsServiceClientFactoryClass));
}
 
Example 12
Source Project: joynr   Source File: UrlResolverTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    Properties properties = new Properties();
    gbidArray = new String[]{};
    properties.put(MessagingPropertyKeys.CHANNELID, channelId);

    Injector injector = Guice.createInjector(new JoynrPropertiesModule(properties),
                                             new MessagingTestModule(),
                                             new AtmosphereMessagingModule(),
                                             new AbstractModule() {
                                                 @Override
                                                 protected void configure() {
                                                     bind(RoutingTable.class).toInstance(mockRoutingTable);
                                                     bind(String[].class).annotatedWith(Names.named(MessagingPropertyKeys.GBID_ARRAY))
                                                                         .toInstance(gbidArray);
                                                     bind(RequestConfig.class).toProvider(HttpDefaultRequestConfigProvider.class)
                                                                              .in(Singleton.class);
                                                     bind(MessageRouter.class).toInstance(mockMessageRouter);
                                                     Multibinder.newSetBinder(binder(),
                                                                              new TypeLiteral<JoynrMessageProcessor>() {
                                                                              });
                                                 }
                                             });
    urlResolver = injector.getInstance(UrlResolver.class);
}
 
Example 13
Source Project: attic-apex-core   Source File: InjectConfigTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public <T> void hear(TypeLiteral<T> typeLiteral, TypeEncounter<T> typeEncounter)
{
  for (Class<?> c = typeLiteral.getRawType(); c != Object.class; c = c.getSuperclass()) {
    LOG.debug("Inspecting fields for " + c);
    for (Field field : c.getDeclaredFields()) {
      if (field.isAnnotationPresent(InjectConfig.class)) {
        typeEncounter.register(new ConfigurationInjector<T>(field, field.getAnnotation(InjectConfig.class)));
      }
    }
  }
}
 
Example 14
Source Project: presto   Source File: QueryExecutionFactoryModule.java    License: Apache License 2.0 5 votes vote down vote up
private static <T extends Statement> void bindDataDefinitionTask(
        Binder binder,
        MapBinder<Class<? extends Statement>, QueryExecutionFactory<?>> executionBinder,
        Class<T> statement,
        Class<? extends DataDefinitionTask<T>> task)
{
    checkArgument(getAllQueryTypes().get(statement) == QueryType.DATA_DEFINITION);
    var taskBinder = newMapBinder(binder, new TypeLiteral<Class<? extends Statement>>() {}, new TypeLiteral<DataDefinitionTask<?>>() {});
    taskBinder.addBinding(statement).to(task).in(Scopes.SINGLETON);
    executionBinder.addBinding(statement).to(DataDefinitionExecutionFactory.class).in(Scopes.SINGLETON);
}
 
Example 15
@Override
public <TProp extends QualifyingProperty> PropertyDataObjectGenerator<TProp> getGenerator(
        TProp p) throws PropertyDataGeneratorNotAvailableException
{
    try
    {
        ParameterizedType pt = Types.newParameterizedType(PropertyDataObjectGenerator.class, p.getClass());
        return (PropertyDataObjectGenerator)injector.getInstance(Key.get(TypeLiteral.get(pt)));
    } catch (RuntimeException ex)
    {
        throw new PropertyDataGeneratorNotAvailableException(p, ex);
    }
}
 
Example 16
Source Project: presto   Source File: TestingKinesisConnectorFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(catalogName, "connectorId is null");
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new KinesisModule(),
                binder -> {
                    binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                    binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                    binder.bind(KinesisHandleResolver.class).toInstance(new KinesisHandleResolver());
                    binder.bind(KinesisClientProvider.class).toInstance(kinesisClientProvider);
                    binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {}).to(KinesisTableDescriptionSupplier.class).in(Scopes.SINGLETON);
                });

        Injector injector = app.strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .initialize();

        KinesisConnector connector = injector.getInstance(KinesisConnector.class);
        return connector;
    }
    catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
 
Example 17
Source Project: googleads-java-lib   Source File: AdManagerJaxWsModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configure() {
  bind(new TypeLiteral<HeaderHandler<AdManagerSession, AdManagerServiceDescriptor>>() {})
      .to(new TypeLiteral<AdManagerJaxWsHeaderHandler>() {});
  install(new JaxWsModule());
  install(new AdManagerModule());
  install(new AdManagerSoapModule());
  configureConfigurations(this.getClass().getResource("conf/props/build.properties"));
}
 
Example 18
Source Project: spoofax   Source File: SpoofaxModule.java    License: Apache License 2.0 5 votes vote down vote up
protected void bindSyntax() {
    bind(SpoofaxSyntaxService.class).in(Singleton.class);
    bind(ISpoofaxSyntaxService.class).to(SpoofaxSyntaxService.class);
    bind(new TypeLiteral<ISyntaxService<ISpoofaxInputUnit, ISpoofaxParseUnit>>() {}).to(SpoofaxSyntaxService.class);
    bind(new TypeLiteral<ISyntaxService<?, ?>>() {}).to(SpoofaxSyntaxService.class);
    bind(ISyntaxService.class).to(SpoofaxSyntaxService.class);

    bind(ITermFactory.class).toInstance(new ImploderOriginTermFactory(new TermFactory()));
}
 
Example 19
Source Project: che   Source File: SystemPermissionsJpaModule.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configure() {

  bind(new TypeLiteral<AbstractPermissionsDomain<SystemPermissionsImpl>>() {})
      .to(SystemDomain.class);
  bind(JpaSystemPermissionsDao.RemoveSystemPermissionsBeforeUserRemovedEventSubscriber.class)
      .asEagerSingleton();

  Multibinder<PermissionsDao<? extends AbstractPermissions>> storages =
      Multibinder.newSetBinder(
          binder(), new TypeLiteral<PermissionsDao<? extends AbstractPermissions>>() {});
  storages.addBinding().to(JpaSystemPermissionsDao.class);
}
 
Example 20
@Override
protected void configure() {
    install(new MinecraftServerManifest());

    bind(new TypeLiteral<PluginResolver<Plugin>>(){}).to(BungeePluginResolver.class);
    bind(Loggers.class).to(BungeeLoggerFactory.class);
    bind(tc.oc.commons.core.chat.Audiences.class).to(tc.oc.commons.bungee.chat.Audiences.class);
    bind(tc.oc.commons.bungee.chat.Audiences.class).to(BungeeAudiences.class);
}
 
Example 21
Source Project: SciGraph   Source File: Neo4jModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
  bind(String.class).annotatedWith(IndicatesNeo4jGraphLocation.class)
      .toInstance(configuration.getLocation());
  bind(CurieUtil.class).toInstance(new CurieUtil(configuration.getCuries()));
  bind(new TypeLiteral<Map<String, String>>() {}).annotatedWith(IndicatesCurieMapping.class)
      .toInstance(configuration.getCuries());
  bind(Vocabulary.class).to(VocabularyNeo4jImpl.class).in(Singleton.class);
  bind(new TypeLiteral<ConcurrentMap<String, Long>>() {}).to(IdMap.class).in(Singleton.class);
}
 
Example 22
Source Project: bt   Source File: ProtocolModule.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Contribute a message handler for some message type.
 * <p>Binding key is a unique message type ID, that will be used
 * to encode and decode the binary representation of a message of this type.
 *
 * @since 1.0
 * @deprecated since 1.5 in favor of {@link ProtocolModuleExtender#addMessageHandler(int, Class)} and its' overloaded versions
 */
@Deprecated
public static MapBinder<Integer, MessageHandler<? extends Message>> contributeMessageHandler(Binder binder) {
    return MapBinder.newMapBinder(
            binder,
            new TypeLiteral<Integer>(){},
            new TypeLiteral<MessageHandler<?>>(){},
            MessageHandlers.class);
}
 
Example 23
Source Project: seed   Source File: GenericGuiceProvider.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public T get() {
    Key<GenericGuiceFactory<T>> factoryKey = (Key<GenericGuiceFactory<T>>) Key.get(
            TypeLiteral.get(
                    Types.newParameterizedType(GenericGuiceFactory.class, defaultImplClass)
            ));
    GenericGuiceFactory<T> genericGuiceFactory = injector.getInstance(factoryKey);
    return genericGuiceFactory.createResolvedInstance(genericClasses);
}
 
Example 24
Source Project: arcusplatform   Source File: TestDriverModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
   bind(DriverConfig.class);
   // required to inject drivers into ServiceLocatorDriverRegistry
   bindMapToInstancesOf(
         new TypeLiteral<Map<DriverId, DeviceDriver>> () {},
         new Function<DeviceDriver, DriverId>() {
            @Override
            public DriverId apply(DeviceDriver driver) {
               return driver.getDriverId();
            }
         }
   );
   bind(PlatformDriverService.class)
      .asEagerSingleton();
   bind(ResourceBundleDAO.class)
      .to(EmptyResourceBundle.class);

   Multibinder<DriverServiceRequestHandler> handlers = bindSetOf(DriverServiceRequestHandler.class);
   handlers.addBinding().to(UpgradeDriverRequestHandler.class);
   handlers.addBinding().to(MessageHandler.class);

   bindSetOf(DriverRegistry.class)
      .addBinding()
      .to(MapDriverRegistry.class);

   bind(DriverExecutorRegistry.class).to(PlatformDriverExecutorRegistry.class);
}
 
Example 25
Source Project: arcusplatform   Source File: ActionConfigJsonModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
   bindSetOf(TypeAdapterFactory.class)
      .addBinding()
      .toInstance(createActionConfigSerializer());
   bindSetOf(new TypeLiteral<TypeAdapter<?>>() {})
      .addBinding()
      .toInstance(new AttributeTypeAdapter());
   bindSetOf(new TypeLiteral<TypeAdapter<?>>() {})
      .addBinding()
      .toInstance(new TemplatedExpressionTypeAdapter());
}
 
Example 26
Source Project: runelite   Source File: FeedPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void configure(Binder binder)
{
	// CHECKSTYLE:OFF
	binder.bind(new TypeLiteral<Supplier<FeedResult>>(){})
		.toInstance(feedSupplier);
	// CHECKSTYLE:ON
}
 
Example 27
Source Project: googleads-java-lib   Source File: AdWordsJaxWsModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configure() {
  bind(new TypeLiteral<HeaderHandler<AdWordsSession, AdWordsServiceDescriptor>>() {})
      .to(new TypeLiteral<AdWordsJaxWsHeaderHandler>() {});
  install(new JaxWsModule());
  install(new AdWordsModule());
  install(new AdWordsSoapModule());
  configureConfigurations(this.getClass().getResource("conf/props/build.properties"));
}
 
Example 28
@Override
protected void configure() {
    final TypeLiteral<Range<T>> rangeType = Ranges.typeOf(type);
    final TypeLiteral<RangeParser<T>> rangeParserType = new ResolvableType<RangeParser<T>>(){}.with(typeArg);
    final TypeLiteral<RangeProperty<T>> rangePropertyType = new ResolvableType<RangeProperty<T>>(){}.with(typeArg);

    bindPrimitiveParser(rangeType).to(rangeParserType); // NodeParser<Range<T>> -> RangeParser<T>
    bind(rangeParserType); // RangeParser<T>

    install(new PropertyManifest<>(rangeType, rangePropertyType));
}
 
Example 29
Source Project: termsuite-core   Source File: IndexedCorpusModule.java    License: Apache License 2.0 5 votes vote down vote up
public <T> void hear(TypeLiteral<T> typeLiteral, TypeEncounter<T> typeEncounter) {
     Class<?> clazz = typeLiteral.getRawType();
     while (clazz != null) {
       for (Field field : clazz.getDeclaredFields()) {
         boolean injectAnnoPresent = 
         		field.isAnnotationPresent(fr.univnantes.termsuite.framework.InjectLogger.class);
if (field.getType() == Logger.class &&
           injectAnnoPresent) {
           typeEncounter.register(new Slf4JMembersInjector<T>(field));
         }
       }
       clazz = clazz.getSuperclass();
     }
   }
 
Example 30
Source Project: attic-aurora   Source File: OfferManagerModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
  install(new PrivateModule() {
    @Override
    protected void configure() {
      bind(new TypeLiteral<Ordering<HostOffer>>() { })
          .toInstance(OfferOrderBuilder.create(options.offer.offerOrder));
      bind(OfferSetImpl.class).in(Singleton.class);
      bind(OfferSet.class).to(OfferSetImpl.class);
      expose(OfferSet.class);
    }
  });
}