本文整理汇总了Java中org.springframework.core.env.ConfigurableEnvironment.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableEnvironment.getProperty方法的具体用法?Java ConfigurableEnvironment.getProperty怎么用?Java ConfigurableEnvironment.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.env.ConfigurableEnvironment
的用法示例。
在下文中一共展示了ConfigurableEnvironment.getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onApplicationEvent
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
ConfigurableEnvironment environment = event.getEnvironment();
configurableEnvironment=environment;
Properties props = new Properties();
String databaseMode = environment.getProperty("me.ramon.database-mode");
if (databaseMode != null) {
if (databaseMode.equals("hibernate-multitenant")) {
props.put("spring.jpa.properties.hibernate.multiTenancy", "DATABASE");
props.put("spring.jpa.properties.hibernate.tenant_identifier_resolver", "me.ramon.multitenancy.BaseCurrentTenantIdentifierResolverImp");
props.put("spring.jpa.properties.hibernate.multi_tenant_connection_provider", "me.ramon.multitenancy.BaseMultiTenantConnectionProviderImp");
}
props.put("spring.jpa.hibernate.ddl-auto", "none");
props.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
props.put("hibernate.show_sql", "true");
props.put("logging.level.org.hibernate.SQL", "DEBUG");
props.put("logging.level.org.hibernate.type.descriptor.sql.BasicBinder", "TRACE");
props.put("spring.jpa.properties.hibernate.current_session_context_class", "org.springframework.orm.hibernate4.SpringSessionContext");
environment.getPropertySources().addLast(new PropertiesPropertySource("application1", props));
}
}
示例2: main
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
public static void main(String[] args) {
final SpringApplication app = new SpringApplication(Application.class);
// save the pid into a file...
app.addListeners(new ApplicationPidFileWriter("smarti.pid"));
final ConfigurableApplicationContext context = app.run(args);
final ConfigurableEnvironment env = context.getEnvironment();
try {
//http://localhost:8080/admin/index.html
final URI uri = new URI(
(env.getProperty("server.ssl.enabled", Boolean.class, false) ? "https" : "http"),
null,
(env.getProperty("server.address", "localhost")),
(env.getProperty("server.port", Integer.class, 8080)),
(env.getProperty("server.context-path", "/")).replaceAll("//+", "/"),
null, null);
log.info("{} started: {}",
env.getProperty("server.display-name", context.getDisplayName()),
uri);
} catch (URISyntaxException e) {
log.warn("Could not build launch-url: {}", e.getMessage());
}
}
示例3: initializeSystem
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
private void initializeSystem(ConfigurableEnvironment environment,
LoggingSystem system, LogFile logFile) {
LoggingInitializationContext initializationContext = new LoggingInitializationContext(
environment);
String logConfig = environment.getProperty(CONFIG_PROPERTY);
if (ignoreLogConfig(logConfig)) {
system.initialize(initializationContext, null, logFile);
}
else {
try {
ResourceUtils.getURL(logConfig).openStream().close();
system.initialize(initializationContext, logConfig, logFile);
}
catch (Exception ex) {
// NOTE: We can't use the logger here to report the problem
System.err.println("Logging system failed to initialize "
+ "using configuration from '" + logConfig + "'");
ex.printStackTrace(System.err);
throw new IllegalStateException(ex);
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:LoggingApplicationListener.java
示例4: getListeners
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<ApplicationListener<ApplicationEvent>> getListeners(
ConfigurableEnvironment env) {
String classNames = env.getProperty(PROPERTY_NAME);
List<ApplicationListener<ApplicationEvent>> listeners = new ArrayList<ApplicationListener<ApplicationEvent>>();
if (StringUtils.hasLength(classNames)) {
for (String className : StringUtils.commaDelimitedListToSet(classNames)) {
try {
Class<?> clazz = ClassUtils.forName(className,
ClassUtils.getDefaultClassLoader());
Assert.isAssignable(ApplicationListener.class, clazz, "class ["
+ className + "] must implement ApplicationListener");
listeners.add((ApplicationListener<ApplicationEvent>) BeanUtils
.instantiateClass(clazz));
}
catch (Exception ex) {
throw new ApplicationContextException(
"Failed to load context listener class [" + className + "]",
ex);
}
}
}
AnnotationAwareOrderComparator.sort(listeners);
return listeners;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:DelegatingApplicationListener.java
示例5: setup
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
this.client = new ReactorNettyWebSocketClient();
this.server = new ReactorHttpServer();
this.server.setHandler(createHttpHandler());
this.server.afterPropertiesSet();
this.server.start();
// Set dynamically chosen port
this.serverPort = this.server.getPort();
if (this.client instanceof Lifecycle) {
((Lifecycle) this.client).start();
}
this.gatewayContext = new SpringApplicationBuilder(GatewayConfig.class)
.properties("ws.server.port:"+this.serverPort, "server.port=0", "spring.jmx.enabled=false")
.run();
GatewayConfig config = this.gatewayContext.getBean(GatewayConfig.class);
ConfigurableEnvironment env = this.gatewayContext.getBean(ConfigurableEnvironment.class);
this.gatewayPort = new Integer(env.getProperty("local.server.port"));
}
示例6: postProcessEnvironment
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
Assert.notNull(propName);
String val = environment.getProperty(propName);
if (StringUtils.hasText(val)) {
List<String> list = Arrays.asList(StringUtils.commaDelimitedListToStringArray(
environment.resolvePlaceholders(val)));
Collections.reverse(list);
for (String item : list) {
if (!environment.acceptsProfiles(item)) {
environment.addActiveProfile(item);
log.info("Added active profile : {}", item);
} else {
log.info("Active profile '{}' has already existed.", item);
}
}
}
}
示例7: translateClientVersionProperty
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
private void translateClientVersionProperty(ConfigurableEnvironment environment) {
if(!environment.containsProperty(CUSTOM_VERSION_PROP)) {
return;
}
String versions = environment.getProperty(CUSTOM_VERSION_PROP);
Map<String, Object> properties = new HashMap<>();
properties.put(DEFAULT_VERSION_PROP, versions);
MapPropertySource target = new MapPropertySource(CLIENT_PROPERTY_SOURCE_NAME, properties);
environment.getPropertySources().addFirst(target);
}
开发者ID:gorelikov,项目名称:spring-cloud-discovery-version-filter,代码行数:11,代码来源:PropertyTranslatorPostProcessor.java
示例8: getProperty
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
private String getProperty(ConfigurableEnvironment env, String propertyName) {
Assert.notNull(env, "env must not be null!");
Assert.notNull(propertyName, "propertyName must not be null!");
final String property = env.getProperty(propertyName);
if (property == null || property.isEmpty()) {
throw new IllegalArgumentException("property " + propertyName + " must not be null");
}
return property;
}
示例9: isKeyVaultEnabled
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
private boolean isKeyVaultEnabled(ConfigurableEnvironment environment){
if (environment.getProperty(Constants.AZURE_CLIENTID) == null) {
// User doesn't want to enable Key Vault property initializer.
return false;
}
return environment.getProperty(Constants.AZURE_KEYVAULT_ENABLED, Boolean.class, true)
&& isKeyVaultClientAvailable();
}
示例10: onApplicationEvent
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
ConfigurableEnvironment environment = event.getEnvironment();
String propertySource = environment.getProperty("c2mon.client.conf.url");
if (propertySource != null) {
try {
environment.getPropertySources().addAfter("systemEnvironment", new ResourcePropertySource(propertySource));
} catch (IOException e) {
throw new RuntimeException("Could not read property source", e);
}
}
}
示例11: onApplicationEvent
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
/**
* Listens for the {@link ApplicationEnvironmentPreparedEvent} and injects
* ${c2mon.server.properties} into the environment with the highest precedence
* (if it exists). This is in order to allow users to point to an external
* properties file via ${c2mon.server.properties}.
*/
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
ConfigurableEnvironment environment = event.getEnvironment();
String propertySource = environment.getProperty("c2mon.server.properties");
if (propertySource != null) {
try {
environment.getPropertySources().addAfter("systemEnvironment", new ResourcePropertySource(propertySource));
} catch (IOException e) {
throw new RuntimeException("Could not read property source", e);
}
}
}
示例12: getInitializerClasses
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
private List<Class<?>> getInitializerClasses(ConfigurableEnvironment env) {
String classNames = env.getProperty(PROPERTY_NAME);
List<Class<?>> classes = new ArrayList<Class<?>>();
if (StringUtils.hasLength(classNames)) {
for (String className : StringUtils.tokenizeToStringArray(classNames, ",")) {
classes.add(getInitializerClass(className));
}
}
return classes;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:DelegatingApplicationContextInitializer.java
示例13: findStartIndex
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
private int findStartIndex(ConfigurableEnvironment environment, String binder) {
String prefix = "spring.cloud.stream." + binder + ".binder.headers";
int i = 0;
while (environment.getProperty(prefix + "[" + i + "]")!=null) {
i++;
}
return i;
}
示例14: isSet
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
private boolean isSet(ConfigurableEnvironment environment, String property) {
String value = environment.getProperty(property);
return (value != null && !value.equals("false"));
}
示例15: getPackageNames
import org.springframework.core.env.ConfigurableEnvironment; //导入方法依赖的package包/类
@Override
public Set<String> getPackageNames(ConfigurableEnvironment env) {
@SuppressWarnings("unchecked")
Set<String> packageNames = env.getProperty("extension-packages", Set.class);
return packageNames == null ? Collections.<String> emptySet() : packageNames;
}