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

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

Introduction

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

Prototype

@Nullable
String getProperty(String key);

Source Link

Document

Return the property value associated with the given key, or null if the key cannot be resolved.

Usage

From source file:com.stormpath.tutorial.config.Roles.java

@Autowired
public Roles(Environment env) {
    USER = env.getProperty("stormpath.authorized.group.user");
}

From source file:io.lavagna.service.DatabaseMigrator.java

private boolean canMigrate(Environment env) {
    return !"true".equals(env.getProperty("datasource.disable.migration"));
}

From source file:com.otz.transport.config.FunnelPluginConfiguration.java

@Bean
public Cluster couchbaseCluster(Environment environment) {
    String clustersString = environment.getProperty(environment.getActiveProfiles()[0] + ".couchbase");
    String clusters[] = clustersString.split(",");
    return CouchbaseCluster.create(clusters);
}

From source file:info.estebanluengo.alfrescoAPI.test.conf.TestProperties.java

@Autowired
public TestProperties(Environment environment) {
    username = environment.getProperty("username");
    password = environment.getProperty("password");
    server = environment.getProperty("server");
    filename = environment.getProperty("filename");
}

From source file:io.pivotal.ecosystem.servicebroker.Config.java

@Bean
public BrokerApiVersion brokerApiVersion(Environment env) {
    return new BrokerApiVersion(env.getProperty("API_VERSION"));
}

From source file:io.pivotal.spring.cloud.service.config.CloudEnvironmentBootstrapConfigurationIntegrationTest.java

@Test
public void environment() throws Exception {
    Environment env = context.getEnvironment();
    assertEquals("app-name", env.getProperty("spring.application.name"));
}

From source file:org.meruvian.yama.webapi.service.commons.FileInfoService.java

@Override
public void setEnvironment(Environment environment) {
    this.uploadBasePath = environment.getProperty("upload.path.base");
}

From source file:com.searchbox.framework.config.SocialConfig.java

/**
 * Configures the connection factories for Facebook and Twitter.
 * //from  w  w  w. j a va  2  s . com
 * @param cfConfig
 * @param env
 */
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    if (env.getProperty("twitter.consumer.key") != null && env.getProperty("twitter.consumer.secret") != null) {
        cfConfig.addConnectionFactory(new TwitterConnectionFactory(env.getProperty("twitter.consumer.key"),
                env.getProperty("twitter.consumer.secret")));
    }
    if (env.getProperty("facebook.app.id") != null && env.getProperty("facebook.app.secret") != null) {
        cfConfig.addConnectionFactory(new FacebookConnectionFactory(env.getProperty("facebook.app.id"),
                env.getProperty("facebook.app.secret")));
    }
}

From source file:de.techdev.config.SocialConfig.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer configurer, Environment env) {
    String id = env.getProperty("wunderlist.client.id");
    String secret = env.getProperty("wunderlist.client.secret");

    if (id.isEmpty()) {
        throw new IllegalStateException("wunderlist.client.id is not set");
    }// www. jav a  2 s.  co m

    if (secret.isEmpty()) {
        throw new IllegalStateException("wunderlist.client.secret is not set");
    }

    configurer.addConnectionFactory(new WunderlistConnectionFactory(id, secret));
}

From source file:com.otz.transport.config.TransportProducerConfiguration.java

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

    Properties properties = new Properties();
    properties.put(RETRIES, environment.getProperty(TRANSPORT_RETRIES));
    properties.put(BATCH_SIZE, environment.getProperty(TRANSPORT_BATCH_SIZE));
    properties.put(TIMEOUT_MS, environment.getProperty(TRANSPORT_TIMEOUT_MS));
    properties.put(BUFFER_MEMORY, environment.getProperty(TRANSPORT_BUFFER_MEMORY));
    properties.put(ACK, environment.getProperty(TRANSPORT_ACK));
    properties.put(MAX_BLOCK, environment.getProperty(TRANSPORT_MAX_BLOCK));
    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;
}