本文整理匯總了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;
}