Search in sources :

Example 46 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 47 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 48 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 49 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)

Example 50 with Provides

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

the class Module method getGson.

@Provides
private Gson getGson() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setPrettyPrinting();
    gsonBuilder.registerTypeAdapter(User.class, new UserJsonSerializer());
    gsonBuilder.registerTypeAdapter(Event.class, new EventJsonSerializer());
    return gsonBuilder.create();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) 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