当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurableEnvironment.getProperty方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:mojtaba-sharif,项目名称:multi-tenancy,代码行数:23,代码来源:DefultProperties.java

示例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());
    }
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:26,代码来源:Application.java

示例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"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gateway,代码行数:25,代码来源:WebSocketIntegrationTests.java

示例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);
            }
        }
    }
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:19,代码来源:ActiveProfileEnvironmentPostProcessor.java

示例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;
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:12,代码来源:KeyVaultEnvironmentPostProcessorHelper.java

示例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();
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:9,代码来源:KeyVaultEnvironmentPostProcessor.java

示例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);
    }
  }
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:14,代码来源:C2monApplicationListener.java

示例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);
    }
  }
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:20,代码来源:CommonModule.java

示例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;
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:9,代码来源:StreamEnvironmentPostProcessor.java

示例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"));
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:5,代码来源:LoggingApplicationListener.java

示例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;
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:7,代码来源:PropertyExtensionPackageProvider.java


注:本文中的org.springframework.core.env.ConfigurableEnvironment.getProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。