private ProxyDriverIntegrator getProxyDriverIntegrator(RequestFilter recordRequestFilter, WebDriverSupplier webDriverSupplier, DriverServiceSupplier driverServiceSupplier, @Named(PATH_TO_DRIVER) String pathToDriverExecutable, @Named(SCREEN) String screen, @Named(TIMEOUT) int timeout, ResponseFilter responseFilter) throws IOException { BrowserMobProxy proxy = createBrowserMobProxy(timeout, recordRequestFilter, responseFilter); proxy.start(0); logger.info("Proxy running on port " + proxy.getPort()); Proxy seleniumProxy = createSeleniumProxy(proxy); DesiredCapabilities desiredCapabilities = createDesiredCapabilities(seleniumProxy); DriverService driverService = driverServiceSupplier.getDriverService(pathToDriverExecutable, screen); WebDriver driver = webDriverSupplier.get(driverService, desiredCapabilities); return new ProxyDriverIntegrator(driver, proxy, driverService); }
@SuppressWarnings("ResultOfMethodCallIgnored") @Inject public KairosDatastore(Datastore datastore, QueryQueuingManager queuingManager, List<DataPointListener> dataPointListeners, KairosDataPointFactory dataPointFactory, @Named(KEEP_CACHE_FILES) boolean keepCacheFiles) throws DatastoreException { m_datastore = checkNotNull(datastore); m_dataPointListeners = checkNotNull(dataPointListeners); m_queuingManager = checkNotNull(queuingManager); m_dataPointFactory = dataPointFactory; m_baseCacheDir = System.getProperty("java.io.tmpdir") + "/kairos_cache/"; m_keepCacheFiles = keepCacheFiles; setupCacheDirectory(); }
@CheckedProvides(IOURIProvider.class) public ProxyDriverIntegrator getProxyDriverIntegrator(IOProvider<RequestFilter> requestFilterIOProvider, IOProvider<ResponseFilter> responseFilterIOURIProvider, WebDriverSupplier webDriverSupplier, DriverServiceSupplier driverServiceSupplier, @Named(PATH_TO_DRIVER) String pathToDriverExecutable, @Named(SCREEN) String screen, @Named(TIMEOUT) int timeout) throws IOException, URISyntaxException { return getProxyDriverIntegrator(requestFilterIOProvider.get(), webDriverSupplier, driverServiceSupplier, pathToDriverExecutable, screen, timeout, responseFilterIOURIProvider.get()); }
@Provides @Named("publisherSaltCache") @Singleton public Cache<Long, String> getPublisherSaltLoadingCache( @Named("publisherSaltRedisCache") LoadingCache<Long, String> publisherSaltRedisCache) { LoadingCacheGuavaImpl<Long, String> l1Cache = new LoadingCacheGuavaImpl<>(); l1Cache.setGuavaCache(CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS).build()); l1Cache.setCacheLoader((key) -> publisherSaltRedisCache.get(key)); return l1Cache; }
private void watchParentDirectory(@Named("encryptionKeyPath") String encryptionKeyPath) { try { seedFile = Paths.get(encryptionKeyPath); watchService = FileSystems.getDefault().newWatchService(); final Path parent = seedFile.getParent(); if (!Files.isDirectory(parent)) { Files.createDirectories(parent); } watchKey = parent.register(watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY); } catch (IOException e) { throw new RuntimeException(e); } }
@Inject public MetaDataStatusProvider( @Named("parentDirs") List<String> parentDir, SerialNumberService serialNumberService) { this.parentDirs = parentDir; this.serialNumberService = serialNumberService; }
@Inject /* default */ TestTreeRegistryImpl(final TestFsmRegistry fsmRegistry, final @Named(TEST_TREE_TIMEOUT_KEY) long timeout) { this.fsmRegistry = fsmRegistry; this.timeout = timeout; cache = synchronizedMap(newHashMap()); mutex = synchronizedMap(newHashMap()); }
@Inject TesterFacadeImpl(final TestFsmRegistry fsmRegistry, final HttpServerManager serverManager, final InternalTestTreeRegistry treeRegistry, @Named(HTTP_SERVER_PORT_KEY) final int port) { this.fsmRegistry = fsmRegistry; this.serverManager = serverManager; this.treeRegistry = treeRegistry; this.port = port; this.actualPort = port; // try with default. }
@Inject protected TimeConstraint(@Named(ConstraintModule.CONSTRAINT_TIME_BEGIN_KEY) String begin, @Named(ConstraintModule.CONSTRAINT_TIME_STOP_KEY) String stop, Clock clock) { this.clock = clock; try { this.begin = LocalTime.parse(begin, formatter); this.stop = LocalTime.parse(stop, formatter); } catch (DateTimeParseException ex) { throw new InvalidConfigurationException("The time format is HH:mm. You specified: begin({}), stop({})", ex, begin, stop); } checkConfiguration(); }
@Inject public XmlTagChanger(@Named("tagToChange") String tagToChange, @Named("oldValue") String tagOldValue, @Named("newValue") String tagNewValue) { this.tagToChange = tagToChange; this.tagOldValue = tagOldValue; this.tagNewValue = tagNewValue; }
@Inject public UT2004LockableLocalWorldView( @Named(WORLDVIEW_DEPENDENCY) ComponentDependencies dependencies, ILifecycleBus bus, IAgentLogger logger, IMediator mediator, ISharedWorldView parentWorldView, ITeamedAgentId agentId) { super(dependencies, bus, logger, parentWorldView, agentId); mediator.setConsumer(this); }
@Inject(optional = true) public void setThreadPool(@Named(JETTY_THREADS_QUEUE_SIZE_PROPERTY) int maxQueueSize, @Named(JETTY_THREADS_MIN_PROPERTY) int minThreads, @Named(JETTY_THREADS_MAX_PROPERTY) int maxThreads, @Named(JETTY_THREADS_KEEP_ALIVE_MS_PROPERTY) long keepAliveMs) { LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(maxQueueSize); m_pool = new ExecutorThreadPool(minThreads, maxThreads, keepAliveMs, TimeUnit.MILLISECONDS, queue); }
@SuppressWarnings("UnusedDeclaration") @Inject(optional = true) public void setBaseCacheDir(@Named(QUERY_CACHE_DIR) String cacheTempDir) { if (cacheTempDir != null && !cacheTempDir.equals("")) { m_baseCacheDir = cacheTempDir; setupCacheDirectory(); } }
@Inject public JavaConverterFactory(@Nonnull Provider<PsiNameHelper> nameHelperProvider, @Nonnull @Named("FieldName") Provider<NamePolicy> fieldNamePolicyProvider, @Nonnull @Named("MethodName") Provider<NamePolicy> methodNamePolicyProvider, @Nonnull @Named("ParameterName") Provider<NamePolicy> parameterNamePolicyProvider) { this.nameHelperProvider = nameHelperProvider; this.fieldNamePolicyProvider = fieldNamePolicyProvider; this.methodNamePolicyProvider = methodNamePolicyProvider; this.parameterNamePolicyProvider = parameterNamePolicyProvider; }
@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; }
@Inject public WebServer(@Named(JETTY_ADDRESS_PROPERTY) String address, @Named(JETTY_PORT_PROPERTY) int port, @Named(JETTY_WEB_ROOT_PROPERTY) String webRoot) throws UnknownHostException { checkNotNull(webRoot); m_port = port; m_webRoot = webRoot; m_address = InetAddress.getByName(address); }
@Inject public void setAuditLevelString(@Named("audit.level") String auditLevelString) { try { this.auditLevel = AuditLevel.valueOf(auditLevelString.toUpperCase()); } catch( IllegalArgumentException e ) { LOGGER.error("Could not parse audit.level property. Setting to NONE"); this.auditLevel = AuditLevel.NONE; } }
@Inject public MetricReporterService(KairosDatastore datastore, List<KairosMetricReporter> reporters, @Named(SCHEDULE_PROPERTY) String schedule, @Named(HOSTNAME) String hostname) { m_datastore = checkNotNull(datastore); m_hostname = checkNotNullOrEmpty(hostname); m_reporters = reporters; m_schedule = schedule; }
@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; }
@Inject public ReplayCommand(IOURIProvider<ReplayBrowser> replayBrowserProvider, IOProvider<TestScenarioSteps> stepsProvider, VirtualScreenProcessCreator virtualScreenProcessCreator, @Named(SCREEN_NUMBER) Integer screenNumber, @Named(MEASUREMENTS_FILE) File measurementsFile, @Named(HAR_FILE) File harFile) { this.replayBrowserProvider = replayBrowserProvider; this.stepsProvider = stepsProvider; this.virtualScreenProcessCreator = virtualScreenProcessCreator; this.screenNumber = screenNumber; this.measurementsFile = measurementsFile; this.harFile = harFile; }
@Inject public PutMillisecondCommand(KairosDatastore datastore, @Named("HOSTNAME") String hostname, LongDataPointFactory longFactory, DoubleDataPointFactory doubleFactory) { checkNotNullOrEmpty(hostname); m_hostName = hostname; m_datastore = datastore; m_longFactory = longFactory; m_doubleFactory = doubleFactory; }
@Provides @Named("passwordSaltRedisDao") public RedisDao<String, String> getAdminSaltRedisDao(JedisPool jedisPool) { return new RedisDaoImpl<String, AuthenticatedEntity>() .setPrefix("ADMIN_SALT") .setPool(jedisPool) .setTtlSeconds(172800) .setDeserializer((salt) -> salt) .setSerializer((salt) -> salt); }
@CheckedProvides(IOProvider.class) public ApplicationConfiguration getApplicationConfiguration(ApplicationConfigurationParser applicationConfigurationParser, @Named(CONFIGURATION_FILE) Provider<File> fileProvider) throws IOException { File file = fileProvider.get(); return applicationConfigurationParser.parseApplicationConfiguration(file); }
@Provides @Named("IgnoreExposedBS") @Nonnull public Gson getGsonWithoutExposed(@Nonnull Injector injector) { GsonBuilder builder = new GsonBuilder(); addTypeAdapters(builder, injector); builder.setPrettyPrinting(); return builder.create(); }
@SuppressWarnings("ResultOfMethodCallIgnored") @Inject public RollUpTasksFileStore(@Named("STORE_DIRECTORY") String storeDirectory, QueryParser parser) throws IOException, RollUpException { checkNotNullOrEmpty(storeDirectory); checkNotNull(parser); createStoreDirectory(storeDirectory); configFile = new File(storeDirectory, FILE_NAME); configFile.createNewFile(); this.parser = parser; readFromFile(); }
@CheckedProvides(IOProvider.class) @Named(PAGE_LOADING_EVENT_DETECTOR) public EventDetector getPageLoadingEventDetector(GetHtmlFromCurrentHostPredicate getHtmlFromCurrentHostPredicate, IOProvider<RequestToPageLoadingEventConverter> requestToPageLoadingEventConverterIOProvider) throws IOException { return new EventDetectorImpl(getHtmlFromCurrentHostPredicate, requestToPageLoadingEventConverterIOProvider.get()); }
@CheckedProvides(IOProvider.class) public List<EventDetector> getEventDetectors(@Named(CONVENTION_EVENT_DETECTOR) EventDetector conventionEventDetector, @Named(PAGE_LOADING_EVENT_DETECTOR) IOProvider<EventDetector> pageLoadingEventDetectorIOProvider) throws IOException { List<EventDetector> eventDetectors = new ArrayList<>(); eventDetectors.add(conventionEventDetector); eventDetectors.add(pageLoadingEventDetectorIOProvider.get()); return eventDetectors; }
@Provides public List<ConditionsUpdater> getConditionsUpdaters(@Named(CONDITION_SATISFIED_PREDICATE) Predicate<HttpRequest> conditionSatisfiedPredicate, @Named(CONDITION_NOT_SATISFIED_PREDICATE) Predicate<HttpRequest> conditionNotSatisfiedPredicate) { List<ConditionsUpdater> conditionsUpdaters = new ArrayList<>(); conditionsUpdaters.add(new ConditionsUpdater(conditionSatisfiedPredicate, new SignalizingStateConditionsUpdater())); conditionsUpdaters.add(new ConditionsUpdater(conditionNotSatisfiedPredicate, ReplayingState::setConditionNotSatisfied)); return conditionsUpdaters; }
@Inject public StatusResource(EncyptionKeyProvider encyptionKeyProvider , @Named("parentDirs") List<String> parentDirs , DownloadFactory downloadFactory , SerialNumberService serialNumberService) { this.encyptionKeyProvider = encyptionKeyProvider; this.parentDirs = parentDirs; this.downloadFactory = downloadFactory; this.serialNumberService = serialNumberService; }
@Provides @Named("samlEntity") @Singleton public IdentityProviderDao provideSamlEntityDao(DbExecutor dbExecutor) throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties properties = new Properties(); properties.load(classLoader.getResourceAsStream("dao/saml-entity-dao-db.properties")); return new IdentityProviderDaoDbImpl(properties.getProperty("saml-entity.dao.db.create"), properties.getProperty("saml-entity.dao.db.read"), properties.getProperty("saml-entity.dao.db.filter"), dbExecutor, SamlEntity.class); }
@Provides @Named("publisherSaltRedisDao") @Singleton public RedisDao<Long, String> getPublisherSaltRedisDao(JedisPool jedisPool) { return new RedisDaoImpl<String, AuthenticatedEntity>() .setPrefix("PUBLISHER_SALT") .setPool(jedisPool) .setTtlSeconds(172800) .setDeserializer((salt) -> salt) .setSerializer((salt) -> salt); }
@Inject public TelnetServer(@Named("kairosdb.telnetserver.address") String address, @Named("kairosdb.telnetserver.port") int port, @Named("kairosdb.telnetserver.max_command_size") int maxCommandLength, CommandProvider commandProvider) throws UnknownHostException { checkArgument(maxCommandLength > 0, "command length must be greater than zero"); this.port = port; this.maxCommandLength = maxCommandLength; this.commandProvider = checkNotNull(commandProvider); this.address = InetAddress.getByName(address); }
@CheckedProvides(IOProvider.class) public RecordingJavascriptGenerator getRecordingJavascriptGenerator(@Named(BASE_RECORDING_TEMPLATE) IOProvider<String> baseTemplateProvider, JavascriptGenerator<ApplicationActionConfiguration> applicationActionJavascriptGenerator) throws IOException { return new RecordingJavascriptGenerator(baseTemplateProvider.get(), applicationActionJavascriptGenerator); }
@Inject public QueryQueuingManager(@Named(CONCURRENT_QUERY_THREAD) int concurrentQueryThreads, @Named("HOSTNAME") String hostname) { checkArgument(concurrentQueryThreads > 0); this.hostname = checkNotNullOrEmpty(hostname); semaphore = new Semaphore(concurrentQueryThreads, true); }
@CheckedProvides(IOProvider.class) @Named(GENERATED_RECORD_JAVASCRIPT) public String getGeneratedRecordJavascript(IOProvider<RecordingJavascriptGenerator> recordingJavascriptGeneratorIOProvider, IOProvider<ApplicationConfiguration> configurationIOProvider) throws IOException { ApplicationConfiguration configuration = configurationIOProvider.get(); RecordingJavascriptGenerator recordingJavascriptGenerator = recordingJavascriptGeneratorIOProvider.get(); return recordingJavascriptGenerator.generate(configuration); }
@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); }
@CheckedProvides(IOProvider.class) @Named(RECORDING_JAVASCRIPT_CODE) public String getRecordingJavascriptCode(@Named(RECORDING_JAVASCRIPT_INJECTOR) IOProvider<JavascriptInjectionPreparator> javascriptInjectorIOProvider) throws IOException { String generatedJavascriptCode = javascriptInjectorIOProvider.get().getInjectionCode(); logger.debug(generatedJavascriptCode); return generatedJavascriptCode; }
@Inject(optional = true) public void setMaxActive(@Named(MAX_ACTIVE) int maxActive) { hostConfig.setMaxActive(maxActive); }
@Inject(optional = true) public void setRunAutoDiscoveryAtStartup(@Named(RUN_AUTO_DISCOVERY_AT_STARTUP) boolean runAutoDiscoveryAtStartup) { hostConfig.setRunAutoDiscoveryAtStartup(runAutoDiscoveryAtStartup); }