Search in sources :

Example 41 with Provides

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

the class OsxEventSourceModule method provideExternalEventBroker.

@Provides
public ExternalEventBroker provideExternalEventBroker(final CommandLineEventSource commandLineEventSource, final OsxEventSource osxEventSource, final ThreadPoolTool threadPoolTool) {
    ExternalEventBrokerImpl externalEventBroker = new ExternalEventBrokerImpl(threadPoolTool);
    commandLineEventSource.setListener(externalEventBroker);
    osxEventSource.setListener(externalEventBroker);
    return externalEventBroker;
}
Also used : ExternalEventBrokerImpl(io.github.vocabhunter.gui.event.ExternalEventBrokerImpl) Provides(com.google.inject.Provides)

Example 42 with Provides

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

the class StandardEventSourceModule method provideExternalEventBroker.

@Provides
public ExternalEventBroker provideExternalEventBroker(final CommandLineEventSource commandLineEventSource, final ThreadPoolTool threadPoolTool) {
    ExternalEventBrokerImpl externalEventBroker = new ExternalEventBrokerImpl(threadPoolTool);
    commandLineEventSource.setListener(externalEventBroker);
    return externalEventBroker;
}
Also used : ExternalEventBrokerImpl(io.github.vocabhunter.gui.event.ExternalEventBrokerImpl) Provides(com.google.inject.Provides)

Example 43 with Provides

use of com.google.inject.Provides in project aroma-data-operations by RedRoma.

the class ModuleTesting method provideDataSource.

@Provides
DataSource provideDataSource() throws MalformedURLException, SQLException {
    String url = createProductionTestConnection();
    PGSimpleDataSource dataSource = new PGSimpleDataSource();
    dataSource.setUrl(url);
    try (Connection conn = dataSource.getConnection()) {
        System.out.println("Connected");
    }
    return dataSource;
}
Also used : Connection(java.sql.Connection) PGSimpleDataSource(org.postgresql.ds.PGSimpleDataSource) Provides(com.google.inject.Provides)

Example 44 with Provides

use of com.google.inject.Provides in project aroma-data-operations by RedRoma.

the class ModuleCassandraDevCluster method provideReconnectPolicy.

@Provides
ReconnectionPolicy provideReconnectPolicy() {
    long baseAttempt = TimeUnit.SECONDS.toMillis(5);
    long maxTimeWaiting = TimeUnit.MINUTES.toMillis(1);
    ExponentialReconnectionPolicy policy = new ExponentialReconnectionPolicy(baseAttempt, maxTimeWaiting);
    return policy;
}
Also used : ExponentialReconnectionPolicy(com.datastax.driver.core.policies.ExponentialReconnectionPolicy) Provides(com.google.inject.Provides)

Example 45 with Provides

use of com.google.inject.Provides in project EventHub by Codecademy.

the class Module method getEventHubHandler.

@Provides
private EventHubHandler getEventHubHandler(Injector injector, EventHub eventHub) throws ClassNotFoundException {
    Map<String, Provider<Command>> commandsMap = Maps.newHashMap();
    Reflections reflections = new Reflections(PACKAGE_NAME);
    Set<Class<? extends Command>> commandClasses = reflections.getSubTypesOf(Command.class);
    for (Class<? extends Command> commandClass : commandClasses) {
        String path = commandClass.getAnnotation(Path.class).value();
        //noinspection unchecked
        commandsMap.put(path, (Provider<Command>) injector.getProvider(commandClass));
    }
    return new EventHubHandler(eventHub, commandsMap);
}
Also used : Path(com.codecademy.eventhub.web.commands.Path) Command(com.codecademy.eventhub.web.commands.Command) Provider(javax.inject.Provider) Reflections(org.reflections.Reflections) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)126 Singleton (javax.inject.Singleton)36 AbstractModule (com.google.inject.AbstractModule)26 Singleton (com.google.inject.Singleton)24 Injector (com.google.inject.Injector)22 Named (javax.inject.Named)17 LazySingleton (io.druid.guice.LazySingleton)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Named (com.google.inject.name.Named)8 IOException (java.io.IOException)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 Properties (java.util.Properties)5 Client (javax.ws.rs.client.Client)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 Binder (com.google.inject.Binder)3