Java 类org.springframework.core.env.Environment 实例源码

项目:gamesboard    文件:SocialContext.java   
/**
   * 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);
  }
项目:juiser    文件:JuiserSpringSecurityCondition.java   
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;
    }
项目:Lyrebird    文件:Twitter4JComponents.java   
@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();
}
项目:xm-ms-balance    文件:DatabaseConfiguration.java   
public DatabaseConfiguration(Environment env,
                             JpaProperties jpaProperties,
                             TenantListRepository tenantListRepository) {
    this.env = env;
    this.jpaProperties = jpaProperties;
    this.tenantListRepository = tenantListRepository;
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:BlogApp.java   
/**
 * 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);
}
项目:JavaStudy    文件:App.java   
@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"));


}
项目:users-service    文件:UserController.java   
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);
}
项目:sshd-shell-spring-boot    文件:SshSessionInstance.java   
@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();
}
项目:users-service    文件:TokensPurgeService.java   
public TokensPurgeService(
        final DateService dates,
        final MongoTemplate mongo,
        final Environment env) {

    this.dates = requireNonNull(dates);
    this.mongo = requireNonNull(mongo);
    this.env   = requireNonNull(env);
}
项目:spring-cloud-vault-connector    文件:VaultConnectorBootstrapConfiguration.java   
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;
}
项目:OAuth-2.0-Cookbook    文件:GoogleConfigurerAdapter.java   
@Override
public void addConnectionFactories(
        final ConnectionFactoryConfigurer configurer,
        final Environment environment) {
    final GoogleConnectionFactory factory = new GoogleConnectionFactory(
            this.properties.getAppId(), this.properties.getAppSecret());
    configurer.addConnectionFactory(factory);
}
项目:spring-io    文件:DefaultProfileUtil.java   
/**
 * 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;
}
项目:cmeter    文件:ClickHouseExporterAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean
public ClickHouseDataSource clickHouseDataSource(Environment environment,
                                                 ClickHouseProperties clickHouseProperties) {
    return new ClickHouseDataSource(
            environment.getProperty("clickhouse.metrics.datasource.url", CLICKHOUSE_JDBC_URL),
            clickHouseProperties);
}
项目:spring-io    文件:GatewayApp.java   
/**
 * 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);
}
项目:spring-test-examples    文件:TestPropertyTest.java   
@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));
}
项目:my-postgres-broker    文件:PostgresConfig.java   
@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;
}
项目:artifactory-resource    文件:SystemInput.java   
protected SystemInput(Environment environment, SystemStreams systemStreams,
        ObjectMapper objectMapper, long timeout) {
    this.environment = environment;
    this.systemStreams = systemStreams;
    this.objectMapper = objectMapper;
    this.timeout = timeout;
}
项目:Armory    文件:DefaultProfileUtil.java   
/**
 * 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;
}
项目:shoucang    文件:Application.java   
/**
 * 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"));

}
项目:email-service    文件:SenderService.java   
SenderService(MongoTemplate mongo,
                     RenderService renderer,
                     Environment env) {

    this.mongo    = requireNonNull(mongo);
    this.renderer = requireNonNull(renderer);
    this.env      = requireNonNull(env);
    this.mailgun  = new RestTemplate();
}
项目:azeroth    文件:EnvironmentHelper.java   
public static String getProperty(String key) {
    if (environment == null) {
        synchronized (EnvironmentHelper.class) {
            environment = InstanceFactory.getInstance(Environment.class);
        }
    }
    return environment.getProperty(key);
}
项目:ColorConverter    文件:Configuration.java   
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;
}
项目:xm-ms-entity    文件:EntityApp.java   
/**
 * 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);
}
项目:FCat    文件:SwaggerConfiguration.java   
@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");
}
项目:codemotion-2017-taller-de-jhipster    文件:DefaultProfileUtil.java   
/**
 * 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;
}
项目:cas-5.1.0    文件:CasCoreBootstrapStandaloneConfiguration.java   
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));
        }
    }
}
项目:spring-zeebe    文件:ZeebeBrokerConfiguration.java   
@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));
}
项目:happylifeplat-transaction    文件:RecoverConfiguration.java   
@Autowired
public JdbcRecoverConfiguration(Environment env) {
    this.env = env;
}
项目:spring-configuration-support    文件:SpringConfigurationSupportAutoConfiguration.java   
@Bean(name = "databaseConfiguration")
public DaoConfigurationPropertiesFactoryBean databaseConfigFactory(ConfigurationDao configurationDao, Environment environment) throws Exception {
    return new DaoConfigurationPropertiesFactoryBean(configurationDao, environment.getActiveProfiles());
}
项目:spring-configuration-support    文件:PropertiesConfig.java   
@Bean(name = "dbProps")
public DaoConfigurationPropertiesFactoryBean databaseConfigFactory(ConfigurationDao configurationDao, Environment environment) throws Exception {
    return new DaoConfigurationPropertiesFactoryBean(configurationDao, environment.getActiveProfiles(), "*");
}
项目:happylifeplat-transaction    文件:AdminConfiguration.java   
@Autowired
public RedisConfiguration(Environment env) {
    this.env = env;
}
项目:spring-io    文件:GatewayApp.java   
public GatewayApp(Environment env) {
    this.env = env;
}
项目:Code4Health-Platform    文件:CacheConfiguration.java   
public CacheConfiguration(Environment env) {
    this.env = env;
}
项目:xm-ms-entity    文件:CacheConfiguration.java   
public CacheConfiguration(Environment env) {
    this.env = env;
}
项目:EsperIoT    文件:MqttClientConfig.java   
@Override
public void setEnvironment(Environment environment) {
    this.propertyResolver = new RelaxedPropertyResolver(environment, "mqtt.");
}
项目:xm-uaa    文件:UaaApp.java   
public UaaApp(Environment env) {
    this.env = env;
}
项目:xm-uaa    文件:ProfileInfoResource.java   
public ProfileInfoResource(Environment env, JHipsterProperties jHipsterProperties) {
    this.env = env;
    this.jHipsterProperties = jHipsterProperties;
}
项目:SpringMicroservice    文件:Application.java   
@Autowired
GreetingController(Environment env){
    this.env = env;
}
项目:RoboInsta    文件:LoggingAspect.java   
public LoggingAspect(Environment env) {
    this.env = env;
}
项目:qualitoast    文件:DatabaseConfiguration.java   
public DatabaseConfiguration(Environment env) {
    this.env = env;
}