/** * Configures the connection factories for Facebook and Twitter. * @param cfConfig * @param env */ @Override public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) { cfConfig.addConnectionFactory(new TwitterConnectionFactory( env.getProperty("twitter.consumer.key"), env.getProperty("twitter.consumer.secret") )); cfConfig.addConnectionFactory(new GoogleConnectionFactory( env.getProperty("twitter.consumer.key"), //TODO !!!!!!!!!! env.getProperty("twitter.consumer.secret") //TODO !!!!!!!!!! )); FacebookConnectionFactory facebookFactory = new FacebookConnectionFactory( env.getProperty("facebook.app.id"), env.getProperty("facebook.app.secret")); facebookFactory.setScope("public_profile,email,user_friends"); cfConfig.addConnectionFactory(facebookFactory); }
private boolean isSpringSecurityEnabled(ConditionContext ctx) { boolean enabled = true; Environment env = ctx.getEnvironment(); for (String propName : props) { if (env.containsProperty(propName)) { if (!Boolean.parseBoolean(env.getProperty(propName))) { enabled = false; break; } } } if (enabled) { enabled = ClassUtils.isPresent(SPRING_SEC_CLASS_NAME, ctx.getClassLoader()); } return enabled; }
@Bean public twitter4j.conf.Configuration configuration(final Environment environment) { final ConfigurationBuilder cb = new ConfigurationBuilder(); final String consumerKey = environment.getProperty("twitter.consumerKey"); final String consumerSecret = environment.getProperty("twitter.consumerSecret"); cb.setOAuthConsumerSecret(consumerSecret); cb.setOAuthConsumerKey(consumerKey); return cb.build(); }
public DatabaseConfiguration(Environment env, JpaProperties jpaProperties, TenantListRepository tenantListRepository) { this.env = env; this.jpaProperties = jpaProperties; this.tenantListRepository = tenantListRepository; }
/** * Main method, used to run the application. * * @param args the command line arguments * @throws UnknownHostException if the local host name could not be resolved into an address */ public static void main(String[] args) throws UnknownHostException { SpringApplication app = new SpringApplication(BlogApp.class); DefaultProfileUtil.addDefaultProfile(app); Environment env = app.run(args).getEnvironment(); String protocol = "http"; if (env.getProperty("server.ssl.key-store") != null) { protocol = "https"; } log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"), env.getActiveProfiles()); String configServerStatus = env.getProperty("configserver.status"); log.info("\n----------------------------------------------------------\n\t" + "Config Server: \t{}\n----------------------------------------------------------", configServerStatus == null ? "Not found or not setup for this application" : configServerStatus); }
@Test public void test(){ ApplicationContext atc=new AnnotationConfigApplicationContext(SystemProperties.class); SystemPropertiesMap map=(SystemPropertiesMap)atc.getBean("systemPropertiesMap"); PrinterUtils.printILog("SystemPropertiesMap toString:"+map.toString()); Environment environment=(Environment)atc.getBean("environment"); PrinterUtils.printILog("environment getBean password:"+environment.getProperty("password")); }
public UserController(Environment env, MongoTemplate mongo, DateService dates, RandomService random, EmailService email) { this.env = requireNonNull(env); this.mongo = requireNonNull(mongo); this.dates = requireNonNull(dates); this.random = requireNonNull(random); this.email = requireNonNull(email); }
@Override public void start(org.apache.sshd.server.Environment env) throws IOException { terminalType = env.getEnv().get("TERM"); sshThread = new Thread(this, "ssh-cli " + session.getSession().getIoSession() .getAttribute(Constants.USER)); sshThread.start(); }
public TokensPurgeService( final DateService dates, final MongoTemplate mongo, final Environment env) { this.dates = requireNonNull(dates); this.mongo = requireNonNull(mongo); this.env = requireNonNull(env); }
public VaultConnectorBootstrapConfiguration( VaultConnectorGenericBackendProperties connectorVaultProperties, VaultGenericBackendProperties genericBackendProperties, Environment environment) { this.connectorVaultProperties = connectorVaultProperties; this.genericBackendProperties = genericBackendProperties; this.environment = environment; Cloud cloud; VaultServiceInfo vaultServiceInfo = null; try { CloudFactory cloudFactory = new CloudFactory(); cloud = cloudFactory.getCloud(); List<ServiceInfo> serviceInfos = cloud.getServiceInfos(VaultOperations.class); if (serviceInfos.size() == 1) { vaultServiceInfo = (VaultServiceInfo) serviceInfos.get(0); } } catch (CloudException e) { // not running in a Cloud environment } this.vaultServiceInfo = vaultServiceInfo; }
@Override public void addConnectionFactories( final ConnectionFactoryConfigurer configurer, final Environment environment) { final GoogleConnectionFactory factory = new GoogleConnectionFactory( this.properties.getAppId(), this.properties.getAppSecret()); configurer.addConnectionFactory(factory); }
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
@Bean @ConditionalOnMissingBean public ClickHouseDataSource clickHouseDataSource(Environment environment, ClickHouseProperties clickHouseProperties) { return new ClickHouseDataSource( environment.getProperty("clickhouse.metrics.datasource.url", CLICKHOUSE_JDBC_URL), clickHouseProperties); }
/** * Main method, used to run the application. * * @param args the command line arguments * @throws UnknownHostException if the local host name could not be resolved into an address */ public static void main(String[] args) throws UnknownHostException { SpringApplication app = new SpringApplication(GatewayApp.class); DefaultProfileUtil.addDefaultProfile(app); Environment env = app.run(args).getEnvironment(); String protocol = "http"; if (env.getProperty("server.ssl.key-store") != null) { protocol = "https"; } log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"), env.getActiveProfiles()); String configServerStatus = env.getProperty("configserver.status"); log.info("\n----------------------------------------------------------\n\t" + "Config Server: \t{}\n----------------------------------------------------------", configServerStatus == null ? "Not found or not setup for this application" : configServerStatus); }
@Override public void setEnvironment(Environment environment) { this.environment = environment; Map<String, Object> systemEnvironment = ((ConfigurableEnvironment) environment).getSystemEnvironment(); System.out.println("=== System Environment ==="); System.out.println(getMapString(systemEnvironment)); System.out.println(); System.out.println("=== Java System Properties ==="); Map<String, Object> systemProperties = ((ConfigurableEnvironment) environment).getSystemProperties(); System.out.println(getMapString(systemProperties)); }
@Bean public DataSource datasource(Environment env) { PGPoolingDataSource source = new PGPoolingDataSource(); source.setServerName(env.getProperty(POSTGRES_HOST_KEY)); source.setDatabaseName(env.getProperty(POSTGRES_DB)); source.setUser(env.getProperty(POSTGRES_USER)); source.setPassword(env.getProperty(POSTGRES_PASSWORD)); return source; }
protected SystemInput(Environment environment, SystemStreams systemStreams, ObjectMapper objectMapper, long timeout) { this.environment = environment; this.systemStreams = systemStreams; this.objectMapper = objectMapper; this.timeout = timeout; }
/** * Get the profiles that are applied else get default profiles. */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
/** * Main method, used to run the application. */ public static void main(String[] args) throws UnknownHostException { SpringApplication app = new SpringApplication(Application.class); SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args); addDefaultProfile(app, source); Environment env = app.run(args).getEnvironment(); log.info("Access URLs:\n----------------------------------------------------------\n\t" + "Local: \t\thttp://127.0.0.1:{}\n\t" + "External: \thttp://{}:{}\n----------------------------------------------------------", env.getProperty("server.port"), InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port")); }
SenderService(MongoTemplate mongo, RenderService renderer, Environment env) { this.mongo = requireNonNull(mongo); this.renderer = requireNonNull(renderer); this.env = requireNonNull(env); this.mailgun = new RestTemplate(); }
public static String getProperty(String key) { if (environment == null) { synchronized (EnvironmentHelper.class) { environment = InstanceFactory.getInstance(Environment.class); } } return environment.getProperty(key); }
private static Integer getIntegerSetting(Environment environment, String settingName) { Integer result = null; String ptyValue = environment.getProperty(settingName); if (ptyValue != null && !ptyValue.isEmpty()) { try { result = Integer.parseInt(ptyValue); } catch (NumberFormatException nfe) { // swallow } } return result; }
/** * Main method, used to run the application. * * @param args the command line arguments * @throws UnknownHostException if the local host name could not be resolved into an address */ public static void main(String[] args) throws UnknownHostException { MDCUtil.put(); SpringApplication app = new SpringApplication(EntityApp.class); DefaultProfileUtil.addDefaultProfile(app); Environment env = app.run(args).getEnvironment(); String protocol = "http"; if (env.getProperty("server.ssl.key-store") != null) { protocol = "https"; } log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"), env.getActiveProfiles()); String configServerStatus = env.getProperty("configserver.status"); log.info("\n----------------------------------------------------------\n\t" + "Config Server: \t{}\n----------------------------------------------------------", configServerStatus == null ? "Not found or not setup for this application" : configServerStatus); }
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, null); this.basePackage = propertyResolver.getProperty("swagger.basepackage"); this.creatName = propertyResolver.getProperty("swagger.service.developer"); this.serviceName = propertyResolver.getProperty("swagger.service.name"); this.description = propertyResolver.getProperty("swagger.service.description"); }
private void loadEmbeddedYamlOverriddenProperties(final Properties props, final Environment environment) { final Resource resource = resourceLoader.getResource("classpath:/application.yml"); if (resource != null && resource.exists()) { final Map pp = loadYamlProperties(resource); if (pp.isEmpty()) { LOGGER.debug("No properties were located inside [{}]", resource); } else { LOGGER.debug("Found settings [{}] in YAML file [{}]", pp.keySet(), resource); props.putAll(decryptProperties(pp)); } } }
@Bean public ConfigurationManager configurationManager(final Environment environment) { final Optional<String> tomlFile = tomlFileFromEnv.apply(environment); log.info("building broker from tomlFile={}", tomlFile); return new ConfigurationManagerImpl(tomlFile.orElse(null)); }
@Autowired public JdbcRecoverConfiguration(Environment env) { this.env = env; }
@Bean(name = "databaseConfiguration") public DaoConfigurationPropertiesFactoryBean databaseConfigFactory(ConfigurationDao configurationDao, Environment environment) throws Exception { return new DaoConfigurationPropertiesFactoryBean(configurationDao, environment.getActiveProfiles()); }
@Bean(name = "dbProps") public DaoConfigurationPropertiesFactoryBean databaseConfigFactory(ConfigurationDao configurationDao, Environment environment) throws Exception { return new DaoConfigurationPropertiesFactoryBean(configurationDao, environment.getActiveProfiles(), "*"); }
@Autowired public RedisConfiguration(Environment env) { this.env = env; }
public GatewayApp(Environment env) { this.env = env; }
public CacheConfiguration(Environment env) { this.env = env; }
@Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "mqtt."); }
public UaaApp(Environment env) { this.env = env; }
public ProfileInfoResource(Environment env, JHipsterProperties jHipsterProperties) { this.env = env; this.jHipsterProperties = jHipsterProperties; }
@Autowired GreetingController(Environment env){ this.env = env; }
public LoggingAspect(Environment env) { this.env = env; }
public DatabaseConfiguration(Environment env) { this.env = env; }