@Override protected void configure() { bind(GraphStore.class).in(Singleton.class); bind(Settings.class).in(Singleton.class); bind(Query.class).in(Singleton.class); bind(BookmarkStore.class).to(SimpleBookmarkStore.class).in(Singleton.class); bind(GraphDimensionsCalculator.class).in(Singleton.class); bind(GraphMovementCalculator.class).in(Singleton.class); bind(GenomeNavigation.class).in(Singleton.class); bind(GraphAnnotation.class).in(Singleton.class); bind(GraphVisualizer.class).in(Singleton.class); bind(MainController.class).in(Singleton.class); bind(SequenceVisualizer.class).in(Singleton.class); bind(StatusBar.class).in(Singleton.class); }
@Provides @Named("passwordSaltCache") @Singleton public Cache<String, String> getAdminSaltLoadingCache( CacheManager cacheManager, PasswordCredentialsFacade passwordCredentialsFacade, @Named("passwordSaltRedisDao") RedisDao<String, String> passwordSaltRedisDao, @Named("passwordSaltCacheGroup") String passwordSaltCacheGroup) { LoadingCacheRedisImpl<String, String> l2Cache = new LoadingCacheRedisImpl<>(); l2Cache.setRedisDao(passwordSaltRedisDao); l2Cache.setCacheLoader((email) -> passwordCredentialsFacade.getSaltForEmail(email).toMaybe()); LoadingCacheGuavaImpl<String, String> l1Cache = new LoadingCacheGuavaImpl<>(); l1Cache.setGuavaCache(CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS).build()); l1Cache.setCacheLoader((key) -> l2Cache.get(key)); cacheManager.registerCacheGroup(passwordSaltCacheGroup, l1Cache, l2Cache); return l1Cache; }
@Override protected void configure() { bind(Configuration.class).toProvider(ConfigurationProvider.class).in(Singleton.class); bind(TransportClient.class).toProvider(TransportClientProvider.class).in(Singleton.class); bind(JsonFormat.Printer.class).toInstance(JsonFormat.printer()); bind(JsonFormat.Parser.class).toInstance(JsonFormat.parser()); }
@Provides @Singleton public Map<ApiVersion, Function<BuildType, BuildTypeData>> buildTypeByApiVersion( ) { return ImmutableMap.of( ApiVersion.API_6_0, btype -> new BuildTypeData( btype.getId( ), btype.getName( ), btype.getProjectId( ), btype.getProjectName( ) ), ApiVersion.API_7_0, btype -> new BuildTypeData( btype.getId( ), btype.getName( ), btype.getProjectId( ), btype.getProjectName( ) ), ApiVersion.API_8_0, btype -> new BuildTypeData( btype.getId( ), btype.getName( ), btype.getProjectId( ), btype.getProjectName( ) ), ApiVersion.API_8_1, btype -> new BuildTypeData( btype.getId( ), btype.getName( ), btype.getProjectId( ), btype.getProjectName( ) ) ); }
@Provides @Named("authenticatableCache") @Singleton public LoadingCache<AuthenticationCredentials, AuthenticatedEntity> getLoadingCache( @Named("authenticatableRedisDao") RedisDao<AuthenticationCredentials, AuthenticatedEntity> authenticatableRedisDao, AuthenticationFacade authenticationFacade, CacheManager cacheManager, @Named("authenticationCacheGroup") String authenticationCacheGroupName ) { LoadingCacheRedisImpl<AuthenticationCredentials, AuthenticatedEntity> l2Cache = new LoadingCacheRedisImpl<>(); l2Cache.setRedisDao(authenticatableRedisDao); l2Cache.setCacheLoader((key) -> authenticationFacade.determineDao(key).authenticate(key)); l2Cache.setName("AUTHENTICATION_REDIS_CACHE"); LoadingCacheGuavaImpl<AuthenticationCredentials, AuthenticatedEntity> l1Cache = new LoadingCacheGuavaImpl<>(); l1Cache.setGuavaCache(CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS).build()); l1Cache.setCacheLoader((key) -> l2Cache.get(key)); l2Cache.setName("AUTHENTICATION_GUAVA_CACHE"); cacheManager.registerCacheGroup(authenticationCacheGroupName, l1Cache, l2Cache); return l1Cache; }
@Override protected void configure() { bind(MotTestReadService.class).to(MotTestReadServiceDatabase.class); bind(VehicleReadService.class).to(VehicleReadServiceDatabase.class); bind(TradeReadService.class).to(TradeReadServiceDatabase.class); bind(MotrReadService.class).to(MotrReadServiceDatabase.class); bind(TradeReadDao.class).to(TradeReadDaoJdbc.class); bind(MotTestReadDao.class).to(MotTestReadDaoJdbc.class); bind(VehicleReadDao.class).to(VehicleReadDaoJdbc.class); bind(ConnectionManager.class).in(Singleton.class); DbConnectionInterceptor dbConnectionInterceptor = new DbConnectionInterceptor(); requestInjection(dbConnectionInterceptor); bindInterceptor(Matchers.any(), Matchers.annotatedWith(ProvideDbConnection.class), dbConnectionInterceptor); }
@Provides @Singleton public NamedParameterJdbcTemplate getJdbcTemplate( @Named("jdbc.driver") String driver, @Named("jdbc.username") String username, @Named("jdbc.password") String password, @Named("jdbc.url") String url, @Named("jdbc.maxActive") Integer maxActive, @Named("jdbc.maxIdle") Integer maxIdle, @Named("jdbc.initialSize") Integer initialSize, @Named("jdbc.validationQuery") String validationQuery) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driver); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setUrl(url); dataSource.setMaxActive(maxActive); dataSource.setMaxIdle(maxIdle); dataSource.setInitialSize(initialSize); dataSource.setValidationQuery(validationQuery); return new NamedParameterJdbcTemplate(dataSource); }
@Override public void run(ApiConfig configuration, Environment environment) throws Exception { LOGGER.info("api started up"); injector = guiceBundle.getInjector(); JerseyEnvironment jersey = environment.jersey(); register(environment.lifecycle(), REFLECTIONS.getSubTypesOf(Managed.class)); // registers NbdServer // injector.getInstance(SessionFactory.class); //init DB installCorsFilter(environment); //init all Singletons semi-eagerly REFLECTIONS.getTypesAnnotatedWith(Singleton.class).forEach(injector::getInstance); final Set<Class<?>> resources = REFLECTIONS.getTypesAnnotatedWith(Path.class); register(jersey, resources); jersey.register(new LoggingExceptionMapper<Throwable>() { @Override protected String formatErrorMessage(long id, Throwable exception) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw); return sw.toString(); } }); jersey.register(new JsonProcessingExceptionMapper(true)); jersey.register(new EarlyEofExceptionMapper()); final TrivialAuthenticator instance = injector.getInstance(TrivialAuthenticator.class); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<Principal>() .setAuthenticator(instance) .setAuthorizer((principal, role) -> false) .buildAuthFilter())); environment.jersey().register(RolesAllowedDynamicFeature.class); }
/** * Checks whether the same instance is provided by different injector instances when the class of the provided * instance is annotated with {@code @Singleton}. */ @Test public void testInjectorsSharingSameSingleton() throws Exception { final Class<N4JSTypeSystem> testedType = N4JSTypeSystem.class; final Singleton[] singletons = testedType.getAnnotationsByType(Singleton.class); assertTrue(testedType.getSimpleName() + " is not annotated with " + Singleton.class.getName() + ".", !Arrays2.isEmpty(singletons)); final String injectorId = N4JSActivator.ORG_ECLIPSE_N4JS_N4JS; final Injector parentInjector = N4JSActivator.getInstance().getInjector(injectorId); final MockUIPlugin mockBundle = new MockUIPlugin(); try { mockBundle.start(/* context */ null); assertTrue("Mock bundle is not running yet.", Bundle.ACTIVE == mockBundle.getBundle().getState()); final Injector childInjector = mockBundle.getN4JSChildInjector(); final N4JSTypeSystem instanceFromParent = parentInjector.getInstance(testedType); final N4JSTypeSystem instanceFromChild = childInjector.getInstance(testedType); assertTrue( "Expected the same instance of " + testedType.getSimpleName() + " from parent and child injectors.", instanceFromChild == instanceFromParent); } finally { mockBundle.stop(/* context */ null); } }
private void init() { bindDescriptors.add(new BindDescriptor<Scheduler>().bind(Scheduler.class) .to(SchedulerMockImpl.class) .in(Singleton.class)); bindDescriptors.add(new BindDescriptor<ConnectionModuleFactory>().bind(ConnectionModuleFactory.class) .to(ConnectionModuleFactoryMock.class) .in(Singleton.class)); bindDescriptors.add(new BindDescriptor<PanelCache>().bind(PanelCache.class)); bindDescriptors.add(new BindDescriptor<FeedbackParserFactory>().bind(FeedbackParserFactory.class) .to(FeedbackParserFactoryMock.class)); }
@Provides @Singleton public TouchRecognitionFactory getTouchRecognitionFactory() { TouchRecognitionFactory factory = mock(TouchRecognitionFactory.class); when(factory.getTouchRecognition(Matchers.any(Widget.class), Matchers.anyBoolean())).thenReturn(spy(new HasTouchHandlersMock())); return factory; }
@Provides @Singleton ResourceTwo provideResourceTwo( @ResourceTwoFeature BeadledomClient beadledomClient, ExampleClientConfig config) { BeadledomWebTarget target = beadledomClient.target(config.uri()); return target.proxy(ResourceTwo.class); }
@Provides @Singleton ResourceOne provideResourceOne( @ResourceOneFeature BeadledomClient client, ExampleClientConfig config) { BeadledomWebTarget target = client.target(config.uri()); return target.proxy(ResourceOne.class); }
@Override protected void configureServlets() { bind(MetricReporterService.class).in(Singleton.class); bind(MonitorFilter.class).in(Scopes.SINGLETON); filter("/*").through(MonitorFilter.class); bind(DataPointsMonitor.class).in(Scopes.SINGLETON); bind(new TypeLiteral<List<KairosMetricReporter>>(){}).toProvider(KairosMetricReporterListProvider.class); }
@Override protected void configure() { logger.info("Configuring module TelnetServerModule"); bind(TelnetServer.class).in(Singleton.class); bind(PutCommand.class).in(Singleton.class); bind(PutMillisecondCommand.class).in(Singleton.class); bind(VersionCommand.class).in(Singleton.class); bind(CommandProvider.class).to(GuiceCommandProvider.class); }
/** {@inheritDoc} */ @Override protected void configure() { GinMultibinder.newSetBinder(binder(), ProjectWizardRegistrar.class) .addBinding() .to(SampleWizardRegistrar.class); bind(NewXFileView.class).to(NewXFileViewImpl.class).in(Singleton.class); }
@Provides @Singleton ConfigurationUpdateManager configurationManager(ConfigurationLoader loader, TaskManager<Configuration> taskRegistry, Cluster cluster, ShutdownHook shutdownHook) { ConfigurationUpdateManager manager = new ConfigurationUpdateManager(loader, taskRegistry, cluster, shutdownHook); manager.initialize(); return manager; }
@Provides @Singleton Cluster getCluster(AppConfig appConfig, ShutdownHook shutdownHook) throws FileNotFoundException { Cluster cluster = new Cluster(appConfig, shutdownHook); cluster.initialize(); return cluster; }
@Provides @Singleton Map<Class<?>, TileViewProvider> modelToView( ) { return ImmutableMap.<Class<?>, TileViewProvider>builder( ) .put( TileViewModel.class, from -> new TileView( (TileViewModel) from ) ) .put( ProjectTileViewModel.class, from -> new ProjectTileView( (ProjectTileViewModel) from ) ) .build( ); }
@Provides @Named("publisherSaltRedisCache") @Singleton public LoadingCache<Long, String> getLoadingCache( @Named("publisherSaltRedisDao") RedisDao<Long, String> publisherSaltRedisDao, PublisherDao publisherDao) { LoadingCacheRedisImpl<Long, String> l2Cache = new LoadingCacheRedisImpl<>(); l2Cache.setRedisDao(publisherSaltRedisDao); l2Cache.setCacheLoader((key) -> publisherDao.read(key).map((publisher) -> {LOG.debug("found publisher for l3 [{}]", publisher.getSalt());return publisher.getSalt();})); return l2Cache; }
@Provides @Singleton public Map<ApiVersion, Function<Build, BuildData>> buildByApiVersion( ) { return ImmutableMap.of( ApiVersion.API_6_0, build -> new BuildData( build.getId( ), build.getStatus( ), build.isRunning( ) ? BuildState.running : BuildState.finished, build.isRunning( ) ? build.getRunningInformation( ).getPercentageComplete( ) : 100, Optional.ofNullable( build.getFinishDate( ) ), build.isRunning( ) ? Duration.of( build.getRunningInformation( ).getEstimatedTotalTime( ) - build.getRunningInformation( ).getElapsedTime( ), ChronoUnit.SECONDS ) : Duration.ZERO ), ApiVersion.API_7_0, build -> new BuildData( build.getId( ), build.getStatus( ), build.isRunning( ) ? BuildState.running : BuildState.finished, build.isRunning( ) ? build.getRunningInformation( ).getPercentageComplete( ) : 100, Optional.ofNullable( build.getFinishDate( ) ), build.isRunning( ) ? Duration.of( build.getRunningInformation( ).getEstimatedTotalTime( ) - build.getRunningInformation( ).getElapsedTime( ), ChronoUnit.SECONDS ) : Duration.ZERO ), ApiVersion.API_8_0, build -> new BuildData( build.getId( ), build.getStatus( ), build.isRunning( ) ? BuildState.running : BuildState.finished, build.isRunning( ) ? build.getRunningInformation( ).getPercentageComplete( ) : 100, Optional.ofNullable( build.getFinishDate( ) ), build.isRunning( ) ? Duration.of( build.getRunningInformation( ).getEstimatedTotalTime( ) - build.getRunningInformation( ).getElapsedTime( ), ChronoUnit.SECONDS ) : Duration.ZERO ), ApiVersion.API_8_1, build -> new BuildData( build.getId( ), build.getStatus( ), build.getState( ), build.getState( ) == BuildState.running ? build.getRunningInformation( ).getPercentageComplete( ) : 100, Optional.ofNullable( build.getFinishDate( ) ), build.getState( ) == BuildState.running ? Duration.of( build.getRunningInformation( ).getEstimatedTotalTime( ) - build.getRunningInformation( ).getElapsedTime( ), ChronoUnit.SECONDS ) : Duration.ZERO ) ); }
@Provides @Singleton Configuration loadConfiguration( ) { final Path configFilePath = Paths.get( "config.json" ); try ( FileReader reader = new FileReader( configFilePath.toFile( ) ) ) { final Gson gson = new Gson( ); return gson.fromJson( reader, Configuration.class ); } catch ( IOException ignored ) { LoggerFactory.getLogger( Loggers.MAIN ).warn( "No configuration file found: starting with empty configuration" ); return new Configuration( ); } }
@Provides @Singleton public static MultiPolygon cuttingPolygon() { try { return (MultiPolygon) new WKTReader().read( "MULTIPOLYGON(((54.34325872314781236 -20.61496515623700532,56.20675565566304499 -20.52773158072990256,56.53804399922131552 -22.11893214296294374,54.34325872314781236 -20.61496515623700532)),((45.76082007284154685 -12.16431241022008969,45.30012222008084422 -13.70552511507818316,44.24672881517291501 -12.87682810499747887,45.76082007284154685 -12.16431241022008969)),((-53.86388748311465946 5.9300516002076753,-51.44935634671445968 4.76504916553769853,-51.70792505978874942 4.19506156747111181,-52.83132503956516501 2.4209224580431643,-54.32717352606223926 2.39156340662024069,-53.83024101072182077 3.6321541115028646,-54.2857624831172032 4.29314308441856074,-54.08647183894422739 5.45617454375176525,-54.04894308127529001 5.52444692910178681,-54.01012022851432448 5.68929854945286895,-53.86388748311465946 5.9300516002076753)),((-61.85375163455503156 14.06546914580407481,-62.18664019134411092 16.64787734392540486,-60.90047985829539812 16.83954045237971897,-60.7491668779367302 15.5735551833788346,-60.83395065310463679 15.58945214122281797,-60.820204658746718 15.48741187449387446,-61.55340163874092241 15.71241305874829131,-61.42503152353879159 15.13474754033868663,-60.68359791978130602 15.20536026450606748,-60.54741623745849921 14.19660706211492318,-61.85375163455503156 14.06546914580407481)),((-63.19163391488151404 18.12705107605973254,-62.95869679831711352 18.16148398444583378,-62.63646712040302589 17.84641758720206184,-63.06351850077108168 17.80329849052715119,-63.19163391488151404 18.12705107605973254)),((130.64811297539733914 42.4089408931416898,130.64862906920575369 42.40916150523329264,130.64976990815063118 42.40597258227973754,130.64922665151021874 42.40577201566927101,130.64811297539733914 42.4089408931416898)),((-179.86638637234364069 64.46187797602119929,-180.00604840193145151 74.87444244885811884,-168.92251888879093258 66.66319302487512743,-170.92273521053905938 63.8183665365200099,-179.86638637234364069 64.46187797602119929)),((-32.23687931365659409 41.00322294346950258,-10.95160324003838959 33.77514040848681987,-12.8151001725536009 28.49700205139115994,-16.29362777991532951 25.80751738504828197,-21.22154189034444727 25.05957208261644098,-34.39025354678528146 39.48611111943009178,-32.23687931365659409 41.00322294346950258)),((-4.29807673062524298 35.17427072899176466,-4.29573216751812215 35.17192616588464205,-4.30101236006188969 35.1696013049885039,-4.30323870990310464 35.1725763388471222,-4.29807673062524298 35.17427072899176466)),((-3.90460387505969742 35.2190341523478665,-3.89898874492919845 35.2184036815963708,-3.89956010904774031 35.21434502613362127,-3.90387489325328163 35.21452234603248144,-3.90460387505969742 35.2190341523478665)),((41.58922823667976587 41.39234273873661607,42.83697397429832421 41.35241003993462527,43.53060894362342736 40.12088814935270165,44.20353839147614394 37.38451555963339246,38.33352305405325922 37.45029534317792042,36.3406166123356158 36.72769605894164613,32.96561661233585738 32.7433656803990587,12.03233440374839525 34.74042051093653782,10.99705833012883183 37.90913363243296885,-1.66436805023835932 36.52413596631321013,-2.42442190500871257 35.16599412262308988,-2.91180021380271947 35.27788708635199555,-2.94306244307358389 35.26923457430100228,-2.96218366565237723 35.2863648108078749,-2.96444245206846135 35.29986105936659158,-2.95684552339777618 35.31583072456704997,-2.93662528758489438 35.3335160029610833,-2.920610860821093 35.52648204242316865,-3.15354797738549308 35.43901922510887914,-5.33377468367367502 35.86489342748320297,-5.34439804822826048 35.87220248338983453,-5.39503017940569762 35.92806746547326213,-5.41019177952885766 35.93163121315374298,-5.41611274517569719 35.91013132850874001,-5.4214949847002698 35.91034769960721462,-5.42793885115186914 35.93580267822458296,-15.32046827071287787 38.26105057334554971,-27.41249281058935239 67.92514246412061141,-13.82967072470070491 68.41785336074353552,-10.35114311733898163 60.15053943510117307,-2.5658670437198734 60.96471012236952447,-0.41249281059118176 67.48527097807296116,-13.66402655292157498 71.21397599847657034,8.366648293702724 81.91103386089542937,107.75315136118064174 82.58107491394852673,179.91167150444769618 75.86878198512971494,179.99698255943999925 51.32875309004389663,146.06987585267864915 43.34780609778923122,145.32756874602708308 43.74354076873730435,145.59446679036946648 44.50845897065210721,138.846833086198302 46.78412166762605295,132.86981588384665542 40.68975414994621076,130.69701627192824844 42.29851249303852256,130.58822555924959374 42.78151351047888085,131.0910692985312096 42.84916937419573912,136.3718321948878156 47.86930878660565725,126.90562534403356665 53.7126410110197483,73.6304519746798718 57.58263070642278336,46.13351945934431342 56.22609091846244667,46.47992836694044172 46.86289373607478836,49.12396580092318032 46.36406504507204573,49.23206133323007094 46.3238956965291635,49.31613264440002098 46.36855210988171905,49.32553191264764081 46.17683382157971295,48.5858590705527007 41.8472293868033276,44.18720044093952737 43.57590255610006125,40.1237070372695328 43.61199216677211865,39.94216467134140913 43.41904389344349369,41.58922823667976587 41.39234273873661607)))"); } catch (ParseException e) { throw propagate(e); } }
private void bindCoreComponents() { install(new JpaPersistModule(new MemoryServerConfig().getString(ServerVariable.DATA_SOURCE))); bind(DBInitializer.class).asEagerSingleton(); bind(ServerConfig.class).to(MemoryServerConfig.class).in(Singleton.class); bind(RESTContext.class).in(Singleton.class); bind(RouteInitializer.class).in(Singleton.class); bind(SparkPluginInitializer.class).in(Singleton.class); }
private Module createLoadTestModule() { return new PrivateModule() { @Override protected void configure() { bind(LoadTestDriver.class).to(loadTestDriverClass).in(Singleton.class); bind(LoadTestDriversCoordinator.class).in(Singleton.class); bind(WorkerEntryProcessor.class).to(entryProcessorClass).in(Singleton.class); bind(Generator.class).annotatedWith(Names.named(KEY_GENERATOR)).to(keyGeneratorClass) .in(Singleton.class); bind(Generator.class).annotatedWith(Names.named(VALUE_GENERATOR)).to(valueGeneratorClass) .in(Singleton.class); bind(LoadTestConfig.class).toInstance(LoadTestConfig.defaultConfig()); } }; }
@Override public Module createModule() { return Modules.override(super.createModule()).with(new AbstractModule() { @Override protected void configure() { install(new StatisticsModule()); install(createLoadTestModule()); if (leadProxyClass != null) { bind(Lead.class).to(leadProxyClass).in(Singleton.class); } } }); }
@Override protected void configure() { bind(ExecutorManager.class).asEagerSingleton(); bind(MetricRegistry.class).in(Singleton.class); bind(Statistics.class).in(Singleton.class); bind(StatisticsCollector.class).in(Singleton.class); bind(LocalStatisticsUpdater.class).toProvider(LocalStatisticsUpdaterProvider.class).in(Singleton.class); bind(RemoteStatisticsUpdaterManager.class).in(Singleton.class); bind(new TypeLiteral<List<ReporterProvider>>() {}).toProvider(new ListOf<>(PROVIDERS)).in(Singleton.class); bind(StatisticsDriver.class).in(Singleton.class); bind(StatisticsConfig.class).toInstance(config); bind(ReportersManager.class).in(Singleton.class); }
@Override public Module createModule() { setSuperClusterAddress("localhost:9999"); setConsumerBufferLimit(3); listeners.add(LastTransactionListener.class); return Modules.override(super.createModule()).with(new AbstractModule() { @Override protected void configure() { bind(IdSequencer.class).to(InMemoryIdSequencer.class).in(Singleton.class); bind(LeadService.class).to(LeadServiceForTests.class).in(Singleton.class); bind(ConsumerPingCheckStrategy.class).to(FastConsumerPingCheckStrategy.class).in(Singleton.class); bind(DoubleLeadService.class).in(Singleton.class); bind(RPCService.class).to(MockRPCService.class); if (kafkaFactory != null) { bind(KafkaFactory.class).to(kafkaFactory).in(Singleton.class); } else { bind(KafkaFactory.class).to(KafkaFactoryForTests.class).in(Singleton.class); } bind(GapDetectionStrategy.class).toProvider(new GapDetectionProvider()); bind(RPCManager.class).to(MockRPCManager.class); bind(RPCUpdater.class).to(MockRPCManager.class); bind(Long.class).annotatedWith(Names.named(Lead.MAIN_PING_CHECK_KEY)).toInstance(MAIN_PING_CHECK_TIME); bind(Long.class).annotatedWith(Names.named(Lead.CONSUMER_PING_CHECK_KEY)) .toInstance(CONSUMER_PING_CHECK_TIME); bind(ReconciliationState.class).to(TestReconciliationState.class); } }); }
@Provides @Named("openAthensEntity") @Singleton public IdentityProviderDao provideOpenAthensEntityDao(DbExecutor dbExecutor) throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties properties = new Properties(); properties.load(classLoader.getResourceAsStream("dao/open-athens-entity-dao-db.properties")); return new IdentityProviderDaoDbImpl(properties.getProperty("open-athens-entity.dao.db.create"), properties.getProperty("open-athens-entity.dao.db.read"), properties.getProperty("open-athens-entity.dao.db.filter"), dbExecutor, OpenAthensEntity.class); }
@Provides @Named("oauthEntity") @Singleton public IdentityProviderDao provideOauthEntityDao(DbExecutor dbExecutor) throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties properties = new Properties(); properties.load(classLoader.getResourceAsStream("dao/oauth-entity-dao-db.properties")); return new IdentityProviderDaoDbImpl(properties.getProperty("oauth-entity.dao.db.create"), properties.getProperty("oauth-entity.dao.db.read"), properties.getProperty("oauth-entity.dao.db.filter"), dbExecutor, OauthEntity.class); }
@Provides @Named("identityProviderDaoMap") @Singleton public Map<IdentityProviderType, IdentityProviderDao> provideIdentityProviderDaoMap( @Named("samlEntity") IdentityProviderDao samlDao, @Named("openAthensEntity") IdentityProviderDao openAthensDao, @Named("oauthEntity") IdentityProviderDao oauthDao) { Map<IdentityProviderType, IdentityProviderDao> daoMap = new HashMap<>(); daoMap.put(IdentityProviderType.SAML, samlDao); daoMap.put(IdentityProviderType.OPEN_ATHENS, openAthensDao); daoMap.put(IdentityProviderType.OAUTH, oauthDao); return daoMap; }
@Provides @Named("beanFactoryMap") @Singleton public Map<Class<?>, BeanFactory<?>> provideBeanFactoryMap(AuthenticatableBeanFactory authenticatableBeanFactory, AuthenticationCredentialsBeanFactory credentialsBeanFactory) { Map<Class<?>, BeanFactory<?>> beanFactoryMap = new HashMap<>(); beanFactoryMap.put(Authenticatable.class, authenticatableBeanFactory); beanFactoryMap.put(AuthenticationCredentials.class, credentialsBeanFactory); return beanFactoryMap; }
/** * Default constructor. */ public TranspilerComponent() { if (getClass().isAnnotationPresent(Singleton.class)) throw new IllegalStateException("subclasses of TranspilerComponent must not be annotated with @Singleton"); }
@Override protected void configure() { bind(Application.class).in(Singleton.class); }
@Provides @Singleton private ObjectMapper provideObjectMapper() { return new ObjectMapper(); }
protected <F, T extends F> void bindPageScoped(Class<F> clazz, TypeLiteral<PageScopedProvider<T>> typeLiteral) { bind(typeLiteral).in(Singleton.class); bind(clazz).annotatedWith(PageScoped.class).toProvider(Key.get(typeLiteral)); }
protected <F, T extends F> void bindModuleScoped(Class<F> clazz, TypeLiteral<? extends Provider<T>> typeLiteral) { bind(typeLiteral).in(Singleton.class); bind(clazz).annotatedWith(ModuleScoped.class).toProvider(Key.get(typeLiteral)); }
@Provides @Singleton JerseyClient jerseyClientProvider() { return JerseyClientBuilder.createClient(); }
@Provides @Singleton public JerseyClient jerseyClientProvider() { return JerseyClientBuilder.createClient(); }
@Provides @Named("authenticationCacheGroup") @Singleton public String getAuthenticationCacheGroupName() { return "AUTHENTICATION_CACHE_GROUP"; }