Search in sources :

Example 11 with Provides

use of com.google.inject.Provides in project airpal by airbnb.

the class DropwizardModule method provideObjectMapper.

@Singleton
@Provides
protected ObjectMapper provideObjectMapper() {
    ObjectMapper mapper = environment.getObjectMapper();
    mapper.registerSubtypes(new NamedType(CSVPersistentOutput.class, "csv"), new NamedType(HiveTablePersistentOutput.class, "hive"));
    Rosetta.getMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Rosetta.getMapper().enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
    return mapper;
}
Also used : HiveTablePersistentOutput(com.airbnb.airpal.api.output.HiveTablePersistentOutput) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) CSVPersistentOutput(com.airbnb.airpal.api.output.CSVPersistentOutput) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 12 with Provides

use of com.google.inject.Provides in project jmxtrans by jmxtrans.

the class JmxTransModule method scheduler.

@Provides
@Inject
Scheduler scheduler(JmxTransConfiguration configuration, GuiceJobFactory jobFactory) throws SchedulerException, IOException {
    StdSchedulerFactory serverSchedFact = new StdSchedulerFactory();
    try (InputStream stream = openQuartzConfiguration(configuration)) {
        serverSchedFact.initialize(stream);
    }
    Scheduler scheduler = serverSchedFact.getScheduler();
    scheduler.setJobFactory(jobFactory);
    return scheduler;
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Scheduler(org.quartz.Scheduler) Inject(com.google.inject.Inject) Provides(com.google.inject.Provides)

Example 13 with Provides

use of com.google.inject.Provides in project hudson-2.x by hudson.

the class HudsonModule method getPluginManager.

@Provides
private PluginManager getPluginManager() {
    PluginManager target = plugins != null ? plugins : getHudson().getPluginManager();
    checkState(target != null);
    return target;
}
Also used : PluginManager(hudson.PluginManager) Provides(com.google.inject.Provides)

Example 14 with Provides

use of com.google.inject.Provides in project ninja by ninjaframework.

the class LifecycleSupportTest method providedSingletonDisposableShouldBeDisposed.

@Test
public void providedSingletonDisposableShouldBeDisposed() {
    Injector injector = createInjector(new AbstractModule() {

        @Override
        protected void configure() {
        }

        @Provides
        @Singleton
        public MockSingletonService provide() {
            return new MockSingletonService();
        }
    });
    start(injector);
    stop(injector);
    assertThat(MockSingletonService.disposed, equalTo(1));
}
Also used : Injector(com.google.inject.Injector) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Example 15 with Provides

use of com.google.inject.Provides in project PocketHub by pockethub.

the class PocketHubModule method account.

@Provides
Account account(Context context) {
    AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
    Account[] accounts = accountManager.getAccountsByType(context.getString(R.string.account_type));
    return accounts[0];
}
Also used : Account(android.accounts.Account) AccountManager(android.accounts.AccountManager) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)111 AbstractModule (com.google.inject.AbstractModule)26 Singleton (com.google.inject.Singleton)23 Singleton (javax.inject.Singleton)23 Injector (com.google.inject.Injector)22 LazySingleton (io.druid.guice.LazySingleton)12 Named (javax.inject.Named)10 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Named (com.google.inject.name.Named)8 File (java.io.File)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 Properties (java.util.Properties)5 Test (org.junit.Test)5 Key (com.google.inject.Key)4 ExecutorService (java.util.concurrent.ExecutorService)4 ConfigModule (co.cask.cdap.common.guice.ConfigModule)3 DB (com.codecademy.eventhub.base.DB)3 Binder (com.google.inject.Binder)3