List of usage examples for org.springframework.core.env Environment containsProperty
boolean containsProperty(String key);
From source file:io.bitsquare.app.BitsquareEnvironmentTests.java
@Test public void bitsquareVersionShouldBeAvailable() { // we cannot actually test for the value because (a) it requires Gradle's // processResources task filtering (which does not happen within IDEA) and // (b) because we do not know the specific version to test for. Instead just // test that the property has been made available. Environment env = new BitsquareEnvironment(new MockPropertySource()); assertThat(env.containsProperty(APP_VERSION_KEY), is(true)); assertThat(env.getProperty(UserAgent.VERSION_KEY), equalTo(env.getProperty(APP_VERSION_KEY))); }
From source file:com.payu.ratel.config.beans.RegistryBeanProviderFactory.java
protected RegistryStrategiesProvider doCreate(ConfigurableListableBeanFactory beanFactory) { final Environment environment = beanFactory.getBean(Environment.class); if (environment.containsProperty(SERVICE_DISCOVERY_ZK_HOST)) { return new ZookeeperRegistryBeanProvider(beanFactory); } else if (environment.containsProperty(SERVICE_DISCOVERY_ADDRESS)) { return new InMemoryRegistryBeanProviderFactory(beanFactory); }//from w w w . jav a 2 s .co m throw new IllegalStateException(String.format("Provide one of props with registry either %s or %s", SERVICE_DISCOVERY_ZK_HOST, SERVICE_DISCOVERY_ADDRESS)); }
From source file:org.juiser.spring.boot.config.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;/*from w ww . ja va2 s .co m*/ break; } } } if (enabled) { enabled = ClassUtils.isPresent(SPRING_SEC_CLASS_NAME, ctx.getClassLoader()); } return enabled; }
From source file:io.lavagna.config.DataSourceConfig.java
@Bean(destroyMethod = "close") public DataSource getDataSource(Environment env) throws URISyntaxException { HikariDataSource dataSource = new HikariDataSource(); if (env.containsProperty("datasource.url") && // env.containsProperty("datasource.username")) { urlAndCredentials(dataSource, env); } else {/*from w ww . j a v a2s .c o m*/ urlWithCredentials(dataSource, env); } if (System.getProperty("startDBManager") != null) { DatabaseManagerSwing.main(new String[] { "--url", "jdbc:hsqldb:mem:lavagna", "--noexit" }); } return dataSource; }
From source file:com.bose.aem.spring.config.ConfigClientProperties.java
public ConfigClientProperties override(Environment environment) { ConfigClientProperties override = new ConfigClientProperties(); BeanUtils.copyProperties(this, override); override.setName(environment.resolvePlaceholders( "${" + ConfigClientProperties.PREFIX + ".name:${spring.application.name:application}}")); if (environment.containsProperty(ConfigClientProperties.PREFIX + ".profile")) { override.setProfile(environment.getProperty(ConfigClientProperties.PREFIX + ".profile")); }/*from w ww .j a va 2 s . c om*/ if (environment.containsProperty(ConfigClientProperties.PREFIX + ".label")) { override.setLabel(environment.getProperty(ConfigClientProperties.PREFIX + ".label")); } return override; }
From source file:org.springframework.boot.devtools.env.DevToolsPropertyDefaultsPostProcessor.java
private boolean isRemoteRestartEnabled(Environment environment) { return environment.containsProperty("spring.devtools.remote.secret"); }