Example usage for org.springframework.core.env Environment getActiveProfiles

List of usage examples for org.springframework.core.env Environment getActiveProfiles

Introduction

In this page you can find the example usage for org.springframework.core.env Environment getActiveProfiles.

Prototype

String[] getActiveProfiles();

Source Link

Document

Return the set of profiles explicitly made active for this environment.

Usage

From source file:io.lavagna.config.DataSourceConfig.java

@Bean
public DatabaseMigrator migrator(Environment env, DataSource dataSource, ApplicationEventPublisher publisher) {

    boolean isDev = ArrayUtils.contains(env.getActiveProfiles(), "dev");

    DatabaseMigrator migrator = new DatabaseMigrator(env, dataSource,
            isDev ? MigrationVersion.LATEST : LATEST_STABLE_VERSION);
    publisher.publishEvent(new DatabaseMigrationDoneEvent(this));
    return migrator;
}

From source file:com.otz.transport.consumer.config.TransportConfiguration.java

@Bean(name = "KafkaProperties")
public Properties kafkaProperties(Environment environment) {
    String kafkaServer = environment.getProperty(environment.getActiveProfiles()[0] + KAFKA);

    Properties properties = new Properties();
    properties.put(GROUP_ID, environment.getProperty(TRANSPORT_KAFKA_GROUP_ID));
    properties.put(ENABLE_AUTO_COMMIT, environment.getProperty(TRANSPORT_KAFKA_ENABLE_AUTO_COMMIT));
    properties.put(AUTO_COMMIT_INTERVAL_MS, environment.getProperty(TRANSPORT_KAFKA_AUTO_COMMIT_INTERVAL_MS));
    properties.put(SESSION_TIMEOUT_MS, environment.getProperty(TRANSPORT_KAFKA_SESSION_TIMEOUT_MS));
    properties.put(KEY_DESERIALIZER, environment.getProperty(TRANSPORT_KAFKA_KEY_DESERIALIZER));
    properties.put(VALUE_DESERIALIZER, environment.getProperty(TRANSPORT_KAFKA_VALUE_DESERIALIZER));

    properties.put(KEY_SERIALIZER, environment.getProperty(TRANSPORT_KAFKA_KEY_SERIALIZER));
    properties.put(VALUE_SERIALIZER, environment.getProperty(TRANSPORT_KAFKA_VALUE_SERIALIZER));

    properties.put(BOOTSTRAP_SERVERS, kafkaServer);

    return properties;
}

From source file:com.bose.aem.spring.config.ConfigClientProperties.java

public ConfigClientProperties(Environment environment) {
    String[] profiles = environment.getActiveProfiles();
    if (profiles.length == 0) {
        profiles = environment.getDefaultProfiles();
    }/*from   www  .  j  av a 2 s . c om*/
    this.setProfile(StringUtils.arrayToCommaDelimitedString(profiles));
}

From source file:org.cloudfoundry.identity.uaa.impl.config.YamlConfigurationValidator.java

@Override
public void setEnvironment(Environment environment) {
    if (Arrays.asList(environment.getActiveProfiles()).contains("strict")) {
        this.exceptionIfInvalid = true;
    }//from  w  w w  .  j av  a 2 s .  c  o m

}

From source file:org.cloudfoundry.identity.uaa.mock.util.MockMvcUtils.java

public static boolean isMySQL(Environment environment) {
    for (String s : environment.getActiveProfiles()) {
        if (s.contains("mysql")) {
            return true;
        }/*from  w ww .  jav  a2 s  .  c o m*/
    }
    return false;
}

From source file:org.opentestsystem.delivery.logging.LoggingConfigRefresher.java

public LoggingConfigRefresher(String configUrl, String configLabel, String appName, Environment environment) {
    this.configUrl = configUrl;
    this.configLabel = configLabel;
    this.environment = environment;
    this.appName = appName;
    this.profiles = StringUtils.join(environment.getActiveProfiles(), ",");
}