com.google.inject.Singleton Java Examples
The following examples show how to use
com.google.inject.Singleton.
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 File: IrisHalImpl.java From arcusplatform with Apache License 2.0 | 6 votes |
@Override protected void configure() { String disable = System.getenv("ZWAVE_DISABLE"); if (disable != null) { bind(ZWaveLocalProcessing.class).to(ZWaveLocalProcessingNoop.class).asEagerSingleton(); return; } String port = System.getenv("ZWAVE_PORT"); if (port == null) { bind(String.class).annotatedWith(Names.named("iris.zwave.port")).toInstance("/dev/ttyO1"); } else { bind(String.class).annotatedWith(Names.named("iris.zwave.port")).toInstance(port); } // bind(ZWaveDriverFactory.class).in(Singleton.class); bind(ZWaveController.class).in(Singleton.class); bind(ZWaveLocalProcessing.class).to(ZWaveLocalProcessingDefault.class).asEagerSingleton(); }
Example #2
Source File: AccessControlModule.java From presto with Apache License 2.0 | 6 votes |
@Provides @Singleton public AccessControl createAccessControl(AccessControlManager accessControlManager) { Logger logger = Logger.get(AccessControl.class); AccessControl loggingInvocationsAccessControl = newProxy( AccessControl.class, new LoggingInvocationHandler( accessControlManager, new LoggingInvocationHandler.ReflectiveParameterNamesProvider(), logger::debug)); return ForwardingAccessControl.of(() -> { if (logger.isDebugEnabled()) { return loggingInvocationsAccessControl; } return accessControlManager; }); }
Example #3
Source File: BridgeEventLoopModule.java From arcusplatform with Apache License 2.0 | 6 votes |
@Singleton @Provides @Named("bridgeEventLoopProvider") public BridgeServerEventLoopProvider provideEventLoopProvider(BridgeServerConfig serverConfig) { switch (serverConfig.getEventLoopProvider()) { case BridgeServerConfig.EVENT_LOOP_PROVIDER_DEFAULT: case BridgeServerConfig.EVENT_LOOP_PROVIDER_NIO: logger.info("using nio event loop provider"); return new BridgeServerNioEventLoopProvider(); case BridgeServerConfig.EVENT_LOOP_PROVIDER_EPOLL: logger.info("using epoll event loop provider"); return new BridgeServerEpollEventLoopProvider(); default: throw new RuntimeException("unknown event loop provider: " + serverConfig.getEventLoopProvider()); } }
Example #4
Source File: AuthenticationModules.java From presto with Apache License 2.0 | 6 votes |
public static Module kerberosHdfsAuthenticationModule() { return new Module() { @Override public void configure(Binder binder) { binder.bind(HdfsAuthentication.class) .to(DirectHdfsAuthentication.class) .in(SINGLETON); configBinder(binder).bindConfig(HdfsKerberosConfig.class); } @Inject @Provides @Singleton @ForHdfs HadoopAuthentication createHadoopAuthentication(HdfsKerberosConfig config, HdfsConfigurationInitializer updater) { String principal = config.getHdfsPrestoPrincipal(); String keytabLocation = config.getHdfsPrestoKeytab(); return createCachingKerberosHadoopAuthentication(principal, keytabLocation, updater); } }; }
Example #5
Source File: GoogleBridgeModule.java From arcusplatform with Apache License 2.0 | 6 votes |
@Provides @Named(GoogleHomeHandler.BEARER_AUTH_NAME) @Singleton public RequestAuthorizer bearerAuth( OAuthDAO oauthDao, BridgeMetrics metrics, GoogleBridgeConfig config ) { return new BearerAuth(oauthDao, metrics, config.getOauthAppId(), (req) -> { Request request = Transformers.GSON.fromJson(req.content().toString(StandardCharsets.UTF_8), Request.class); Response res = new Response(); res.setRequestId(request.getRequestId()); res.setPayload(ImmutableMap.of(Constants.Response.ERROR_CODE, Constants.Error.AUTH_EXPIRED)); DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); response.content().writeBytes(Transformers.GSON.toJson(res).getBytes(StandardCharsets.UTF_8)); return response; }); }
Example #6
Source File: AuthenticationModules.java From presto with Apache License 2.0 | 6 votes |
public static Module kerberosImpersonatingHdfsAuthenticationModule() { return new Module() { @Override public void configure(Binder binder) { binder.bind(HdfsAuthentication.class) .to(ImpersonatingHdfsAuthentication.class) .in(SINGLETON); configBinder(binder).bindConfig(HdfsKerberosConfig.class); } @Inject @Provides @Singleton @ForHdfs HadoopAuthentication createHadoopAuthentication(HdfsKerberosConfig config, HdfsConfigurationInitializer updater) { String principal = config.getHdfsPrestoPrincipal(); String keytabLocation = config.getHdfsPrestoKeytab(); return createCachingKerberosHadoopAuthentication(principal, keytabLocation, updater); } }; }
Example #7
Source File: TestCompositeDriverRegistry.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton public CompositeDriverRegistry provideDriverRegistry(Driver1 driver1, Driver1V1 driver1v1, Driver1V2 driver1v2, Driver2 driver2) { Map<DriverId, DeviceDriver> map0 = new HashMap<>(); map0.put(driver1.getDriverId(), driver1); Map<DriverId, DeviceDriver> map1 = new HashMap<>(); map1.put(driver1v1.getDriverId(), driver1v1); Map<DriverId, DeviceDriver> map2 = new HashMap<>(); map2.put(driver1v2.getDriverId(), driver1v2); Map<DriverId, DeviceDriver> map3 = new HashMap<>(); map3.put(driver2.getDriverId(), driver2); return new CompositeDriverRegistry(new MapDriverRegistry(map0), new MapDriverRegistry(map1), new MapDriverRegistry(map2), new MapDriverRegistry(map3)); }
Example #8
Source File: ThriftMetastoreAuthenticationModule.java From presto with Apache License 2.0 | 5 votes |
@Provides @Singleton @ForHiveMetastore public HadoopAuthentication createHadoopAuthentication(MetastoreKerberosConfig config, HdfsConfigurationInitializer updater) { String principal = config.getHiveMetastoreClientPrincipal(); String keytabLocation = config.getHiveMetastoreClientKeytab(); return createCachingKerberosHadoopAuthentication(principal, keytabLocation, updater); }
Example #9
Source File: TestGroovyDriverRegistry.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton public GroovyScriptEngine provideGroovyScriptEngine(TestDriverConfig driverConfig, CapabilityRegistry registry) throws MalformedURLException { File driverDir = new File(driverConfig.getDriverDirectory()); GroovyScriptEngine engine = new GroovyScriptEngine(new URL[] { driverDir.toURI().toURL(), new File("src/main/resources").toURI().toURL() } ); engine.getConfig().addCompilationCustomizers(new DriverCompilationCustomizer(registry)); return engine; }
Example #10
Source File: BrowserModule.java From aquality-selenium-java with Apache License 2.0 | 5 votes |
@Override protected void configure() { super.configure(); bind(ITimeoutConfiguration.class).to(getTimeoutConfigurationImplementation()).in(Singleton.class); bind(IBrowserProfile.class).to(getBrowserProfileImplementation()).in(Singleton.class); bind(IElementFactory.class).to(getElementFactoryImplementation()); bind(IConfiguration.class).to(getConfigurationImplementation()); }
Example #11
Source File: TestSimplePartitioner.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton public Optional<Set<PartitionListener>> getPartitionListeners() { partitionRef = Capture.newInstance(); PartitionListener partitionListener = EasyMock.createMock(PartitionListener.class); partitionListener.onPartitionsChanged(EasyMock.capture(partitionRef)); EasyMock.expectLastCall().once(); EasyMock.replay(partitionListener); return Optional.of(ImmutableSet.of(partitionListener)); }
Example #12
Source File: ApplicationModule.java From realworld-serverless-application with Apache License 2.0 | 5 votes |
@Singleton @Inject @Provides CognitoUserManager cognitoUserManager(final SsmParameterCachingClient ssm) { String clientId = ssm.getAsString("cognito/userpoolclient/IntegTest/Id"); String userPoolId = ssm.getAsString("cognito/userpool/ApplicationsApi/Id"); return new CognitoUserManager(CognitoIdentityProviderClient.builder() .httpClientBuilder(UrlConnectionHttpClient.builder()) .build(), clientId, userPoolId); }
Example #13
Source File: ApplicationModule.java From realworld-serverless-application with Apache License 2.0 | 5 votes |
@Singleton @Inject @Provides AthenaClient athenaClient(){ return AthenaClient.builder() .httpClientBuilder(UrlConnectionHttpClient.builder()) .build(); }
Example #14
Source File: InMemoryMessageModuleWithoutResourceBundle.java From arcusplatform with Apache License 2.0 | 5 votes |
@Override protected void configure() { bind(InMemoryPlatformMessageBus.class).in(Singleton.class); bind(InMemoryProtocolMessageBus.class).in(Singleton.class); bind(PlatformMessageBus.class).to(InMemoryPlatformMessageBus.class); bind(ProtocolMessageBus.class).to(InMemoryProtocolMessageBus.class); }
Example #15
Source File: ApplicationModule.java From realworld-serverless-application with Apache License 2.0 | 5 votes |
@Singleton @Inject @Provides CognitoUserManager cognitoUserManager(final SsmParameterCachingClient ssm) { String clientId = ssm.getAsString(String.format( "cognito/userpoolclient/IntegTest/realworld-serverless-application-backend-%s-env/Id", System.getProperty("integtests.stage"))); String userPoolId = ssm.getAsString("cognito/userpool/ApplicationsApi/Id"); return new CognitoUserManager(CognitoIdentityProviderClient.builder() .httpClientBuilder(UrlConnectionHttpClient.builder()) .build(), clientId, userPoolId); }
Example #16
Source File: DefaultPersistenceInjectionModule.java From openAGV with Apache License 2.0 | 5 votes |
@Override protected void configure() { bind(ModelManager.class).to(OpenTCSModelManager.class).in(Singleton.class); bind(ModelFileReader.class).to(UnifiedModelReader.class); bind(ModelFilePersistor.class).to(UnifiedModelPersistor.class); }
Example #17
Source File: TestReconContainerDBProvider.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@Before public void setUp() throws IOException { tempFolder.create(); injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { File dbDir = tempFolder.getRoot(); OzoneConfiguration configuration = new OzoneConfiguration(); configuration.set(OZONE_RECON_DB_DIR, dbDir.getAbsolutePath()); bind(OzoneConfiguration.class).toInstance(configuration); bind(DBStore.class).toProvider(ReconContainerDBProvider.class).in( Singleton.class); } }); }
Example #18
Source File: KernelInjectionModule.java From openAGV with Apache License 2.0 | 5 votes |
/** * Sets the recharge position supplier implementation to be used. * * @param clazz The implementation. * @deprecated Will be removed along with the deprecated supplier interface. */ @Deprecated @ScheduledApiChange(when = "5.0") protected void bindRechargePositionSupplier( Class<? extends org.opentcs.components.kernel.RechargePositionSupplier> clazz) { bind(org.opentcs.components.kernel.RechargePositionSupplier.class).to(clazz).in(Singleton.class); }
Example #19
Source File: ApplicationModule.java From realworld-serverless-application with Apache License 2.0 | 5 votes |
@Singleton @Inject @Provides AWSServerlessApplicationRepository AWSServerlessApplicationRepository(final SsmParameterCachingClient ssm, final CognitoUserManager cognitoUserManager) { String endpoint = ssm.getAsString("apigateway/ApplicationsApi/Endpoint"); return new AWSServerlessApplicationRepositoryRecordingClient(AWSServerlessApplicationRepository.builder() .endpoint(endpoint) .signer(new CognitoAuthorizerImpl(cognitoUserManager)) .build()); }
Example #20
Source File: AppModule.java From smartapp-sdk-java with Apache License 2.0 | 5 votes |
@Provides @Singleton public PingHandler pingHandler() { return new DefaultPingHandler() { @Override public ExecutionResponse handle(ExecutionRequest executionRequest) throws Exception { LOG.debug("PING: executionRequest = " + executionRequest); return super.handle(executionRequest); } }; }
Example #21
Source File: AppModule.java From smartapp-sdk-java with Apache License 2.0 | 5 votes |
@Provides @Singleton public UpdateHandler updateHandler() { // The update lifecycle event is called when the user updates configuration options previously set via // the install lifecycle event so this should be similar to that handler. return executionRequest -> { LOG.debug("UPDATE: executionRequest = " + executionRequest); return Response.ok(new UpdateResponseData()); }; }
Example #22
Source File: AppModule.java From smartapp-sdk-java with Apache License 2.0 | 5 votes |
@Provides @Singleton public UninstallHandler uninstallHandler() { return executionRequest -> { LOG.debug("UNINSTALL: executionRequest = " + executionRequest); return Response.ok(new UninstallResponseData()); }; }
Example #23
Source File: Module.java From reactor-guice with Apache License 2.0 | 5 votes |
@Singleton @Provides public Gson gson () { return new GsonBuilder() .serializeNulls() .setDateFormat("yyyy-MM-dd HH:mm:ss") .setLongSerializationPolicy(LongSerializationPolicy.STRING) .create(); }
Example #24
Source File: TestDriverModule.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton @Named(DriverConfig.NAMED_EXECUTOR) public ThreadPoolExecutor driverExecutor(DriverConfig config) { return new ThreadPoolBuilder() .withBlockingBacklog() .withMaxPoolSize(config.getDriverThreadPoolSize()) .withNameFormat("driver-thread-%d") .build() ; }
Example #25
Source File: TestIrisTestCase.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton @Named("provides") public String provides() { methods.add("provides"); assertServiceLocatorNotInitialized(); return "provides"; }
Example #26
Source File: GroovyDriverTestCase.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton public GroovyScriptEngine scriptEngine(Set<CompilationCustomizer> customizers) { GroovyScriptEngine engine = scriptEngine(); for(CompilationCustomizer customizer: customizers) { engine.getConfig().addCompilationCustomizers(customizer); } engine.getConfig().setScriptExtensions(ImmutableSet.of("driver", "capability", "groovy")); return engine; }
Example #27
Source File: InMemoryMessageModule.java From arcusplatform with Apache License 2.0 | 5 votes |
@Override protected void configure() { bind(InMemoryPlatformMessageBus.class).in(Singleton.class); bind(InMemoryProtocolMessageBus.class).in(Singleton.class); bind(PlatformMessageBus.class).to(InMemoryPlatformMessageBus.class); bind(ProtocolMessageBus.class).to(InMemoryProtocolMessageBus.class); bind(ResourceBundleDAO.class).to(EmptyResourceBundle.class); bind(IntraServiceMessageBus.class).to(InMemoryIntraServiceMessageBus.class).in(Singleton.class); }
Example #28
Source File: TestGetPreferencesHandler.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton @Named(NAME_EXECUTOR) public Executor executor() { return directExecutor(); }
Example #29
Source File: ClientServerModule.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton public SameCodeManager provideSameCodeManager() throws IllegalArgumentException, URISyntaxException { Resource sameCodesDirectory = Resources.getResource(sameCodesPath); Resource sameCodesStateMappingsDirectory = Resources.getResource(sameCodeStateMappingsPath); return new SameCodeManager(sameCodesDirectory, sameCodesStateMappingsDirectory); }
Example #30
Source File: AlarmServiceModule.java From arcusplatform with Apache License 2.0 | 5 votes |
@Provides @Singleton @Named(AlarmService.NAME_EXECUTOR_POOL) public ExecutorService alarmPool() { return new ThreadPoolBuilder() .withBlockingBacklog() .withMaxPoolSize(100) .withKeepAliveMs(10000) .withMetrics("alarm") .withNameFormat("alarm-%d") .build(); }