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


Java MutablePropertySources.contains方法代码示例

本文整理汇总了Java中org.springframework.core.env.MutablePropertySources.contains方法的典型用法代码示例。如果您正苦于以下问题:Java MutablePropertySources.contains方法的具体用法?Java MutablePropertySources.contains怎么用?Java MutablePropertySources.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.env.MutablePropertySources的用法示例。


在下文中一共展示了MutablePropertySources.contains方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addKeyVaultPropertySource

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
public void addKeyVaultPropertySource() {
    final String clientId = getProperty(environment, Constants.AZURE_CLIENTID);
    final String clientKey = getProperty(environment, Constants.AZURE_CLIENTKEY);
    final String vaultUri = getProperty(environment, Constants.AZURE_KEYVAULT_VAULT_URI);

    final long timeAcquiringTimeoutInSeconds = environment.getProperty(
            Constants.AZURE_TOKEN_ACQUIRE_TIMEOUT_IN_SECONDS, Long.class, 60L);

    final KeyVaultClient kvClient = new KeyVaultClient(
            new AzureKeyVaultCredential(clientId, clientKey, timeAcquiringTimeoutInSeconds));

    try {
        final MutablePropertySources sources = environment.getPropertySources();
        final KeyVaultOperation kvOperation = new KeyVaultOperation(kvClient, vaultUri);

        if (sources.contains(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)) {
            sources.addAfter(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
                    new KeyVaultPropertySource(kvOperation));
        } else {
            sources.addFirst(new KeyVaultPropertySource(kvOperation));
        }

    } catch (Exception ex) {
        throw new IllegalStateException("Failed to configure KeyVault property source", ex);
    }
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:27,代码来源:KeyVaultEnvironmentPostProcessorHelper.java

示例2: addDefaultProperty

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private void addDefaultProperty(ConfigurableEnvironment environment, String name,
                                String value) {
    MutablePropertySources sources = environment.getPropertySources();
    Map<String, Object> map = null;
    if (sources.contains("defaultProperties")) {
        PropertySource<?> source = sources.get("defaultProperties");
        if (source instanceof MapPropertySource) {
            map = ((MapPropertySource) source).getSource();
        }
    } else {
        map = new LinkedHashMap<>();
        sources.addLast(new MapPropertySource("defaultProperties", map));
    }
    if (map != null) {
        map.put(name, value);
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:18,代码来源:MetricsEnvironmentPostProcessor.java

示例3: configurePropertySources

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
/**
 * Add, remove or re-order any {@link PropertySource}s in this application's
 * environment.
 * @param environment this application's environment
 * @param args arguments passed to the {@code run} method
 * @see #configureEnvironment(ConfigurableEnvironment, String[])
 */
protected void configurePropertySources(ConfigurableEnvironment environment,
		String[] args) {
	MutablePropertySources sources = environment.getPropertySources();
	if (this.defaultProperties != null && !this.defaultProperties.isEmpty()) {
		sources.addLast(
				new MapPropertySource("defaultProperties", this.defaultProperties));
	}
	if (this.addCommandLineProperties && args.length > 0) {
		String name = CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME;
		if (sources.contains(name)) {
			PropertySource<?> source = sources.get(name);
			CompositePropertySource composite = new CompositePropertySource(name);
			composite.addPropertySource(new SimpleCommandLinePropertySource(
					name + "-" + args.hashCode(), args));
			composite.addPropertySource(source);
			sources.replace(name, composite);
		}
		else {
			sources.addFirst(new SimpleCommandLinePropertySource(args));
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:30,代码来源:SpringApplication.java

示例4: postProcessEnvironment

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
		SpringApplication application) {
	if (CloudPlatform.CLOUD_FOUNDRY.isActive(environment)) {
		Properties properties = new Properties();
		addWithPrefix(properties, getPropertiesFromApplication(environment),
				"vcap.application.");
		addWithPrefix(properties, getPropertiesFromServices(environment),
				"vcap.services.");
		MutablePropertySources propertySources = environment.getPropertySources();
		if (propertySources.contains(
				CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME)) {
			propertySources.addAfter(
					CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME,
					new PropertiesPropertySource("vcap", properties));
		}
		else {
			propertySources
					.addFirst(new PropertiesPropertySource("vcap", properties));
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:CloudFoundryVcapEnvironmentPostProcessor.java

示例5: addPropertySource

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private void addPropertySource(ResourcePropertySource propertySource) {
	String name = propertySource.getName();
	MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment).getPropertySources();
	if (propertySources.contains(name) && this.propertySourceNames.contains(name)) {
		// We've already added a version, we need to extend it
		PropertySource<?> existing = propertySources.get(name);
		if (existing instanceof CompositePropertySource) {
			((CompositePropertySource) existing).addFirstPropertySource(propertySource.withResourceName());
		}
		else {
			if (existing instanceof ResourcePropertySource) {
				existing = ((ResourcePropertySource) existing).withResourceName();
			}
			CompositePropertySource composite = new CompositePropertySource(name);
			composite.addPropertySource(propertySource.withResourceName());
			composite.addPropertySource(existing);
			propertySources.replace(name, composite);
		}
	}
	else {
		if (this.propertySourceNames.isEmpty()) {
			propertySources.addLast(propertySource);
		}
		else {
			String firstProcessed = this.propertySourceNames.get(this.propertySourceNames.size() - 1);
			propertySources.addBefore(firstProcessed, propertySource);
		}
	}
	this.propertySourceNames.add(name);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:ConfigurationClassParser.java

示例6: addJsonPropertySource

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private void addJsonPropertySource(ConfigurableEnvironment environment,
		PropertySource<?> source) {
	MutablePropertySources sources = environment.getPropertySources();
	String name = findPropertySource(sources);
	if (sources.contains(name)) {
		sources.addBefore(name, source);
	}
	else {
		sources.addFirst(source);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:SpringApplicationJsonEnvironmentPostProcessor.java

示例7: findPropertySource

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private String findPropertySource(MutablePropertySources sources) {
	if (ClassUtils.isPresent(SERVLET_ENVIRONMENT_CLASS, null) && sources
			.contains(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME)) {
		return StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME;

	}
	return StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:SpringApplicationJsonEnvironmentPostProcessor.java

示例8: addConfigurationProperties

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private void addConfigurationProperties(
		ConfigurationPropertySources configurationSources) {
	MutablePropertySources existingSources = this.environment
			.getPropertySources();
	if (existingSources.contains(DEFAULT_PROPERTIES)) {
		existingSources.addBefore(DEFAULT_PROPERTIES, configurationSources);
	}
	else {
		existingSources.addLast(configurationSources);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:ConfigFileApplicationListener.java

示例9: matchingPropertySource

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private Condition<ConfigurableEnvironment> matchingPropertySource(
		final String sourceName) {
	return new Condition<ConfigurableEnvironment>(
			"environment containing property source " + sourceName) {

		@Override
		public boolean matches(ConfigurableEnvironment value) {
			MutablePropertySources sources = new MutablePropertySources(
					value.getPropertySources());
			ConfigurationPropertySources.finishAndRelocate(sources);
			return sources.contains(sourceName);
		}

	};
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:ConfigFileApplicationListenerTests.java

示例10: getOrAdd

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Map<String, Object> getOrAdd(MutablePropertySources sources,
		String name) {
	if (sources.contains(name)) {
		return (Map<String, Object>) sources.get(name).getSource();
	}
	Map<String, Object> map = new HashMap<String, Object>();
	sources.addFirst(new MapPropertySource(name, map));
	return map;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:EnvironmentTestUtils.java

示例11: addPropertySource

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private void addPropertySource(PropertySource<?> propertySource) {
	String name = propertySource.getName();
	MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment).getPropertySources();
	if (propertySources.contains(name) && this.propertySourceNames.contains(name)) {
		// We've already added a version, we need to extend it
		PropertySource<?> existing = propertySources.get(name);
		PropertySource<?> newSource = (propertySource instanceof ResourcePropertySource ?
				((ResourcePropertySource) propertySource).withResourceName() : propertySource);
		if (existing instanceof CompositePropertySource) {
			((CompositePropertySource) existing).addFirstPropertySource(newSource);
		}
		else {
			if (existing instanceof ResourcePropertySource) {
				existing = ((ResourcePropertySource) existing).withResourceName();
			}
			CompositePropertySource composite = new CompositePropertySource(name);
			composite.addPropertySource(newSource);
			composite.addPropertySource(existing);
			propertySources.replace(name, composite);
		}
	}
	else {
		if (this.propertySourceNames.isEmpty()) {
			propertySources.addLast(propertySource);
		}
		else {
			String firstProcessed = this.propertySourceNames.get(this.propertySourceNames.size() - 1);
			propertySources.addBefore(firstProcessed, propertySource);
		}
	}
	this.propertySourceNames.add(name);
}
 
开发者ID:txazo,项目名称:spring,代码行数:33,代码来源:ConfigurationClassParser.java

示例12: initServletPropertySources

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
/**
 * Replace {@code Servlet}-based {@link StubPropertySource stub property sources} with
 * actual instances populated with the given {@code servletContext} and
 * {@code servletConfig} objects.
 * <p>This method is idempotent with respect to the fact it may be called any number
 * of times but will perform replacement of stub property sources with their
 * corresponding actual property sources once and only once.
 * @param propertySources the {@link MutablePropertySources} to initialize (must not
 * be {@code null})
 * @param servletContext the current {@link ServletContext} (ignored if {@code null}
 * or if the {@link StandardServletEnvironment#SERVLET_CONTEXT_PROPERTY_SOURCE_NAME
 * servlet context property source} has already been initialized)
 * @param servletConfig the current {@link ServletConfig} (ignored if {@code null}
 * or if the {@link StandardServletEnvironment#SERVLET_CONFIG_PROPERTY_SOURCE_NAME
 * servlet config property source} has already been initialized)
 * @see org.springframework.core.env.PropertySource.StubPropertySource
 * @see org.springframework.core.env.ConfigurableEnvironment#getPropertySources()
 */
public static void initServletPropertySources(
		MutablePropertySources propertySources, ServletContext servletContext, ServletConfig servletConfig) {

	Assert.notNull(propertySources, "propertySources must not be null");
	if (servletContext != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) &&
			propertySources.get(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
		propertySources.replace(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME,
				new ServletContextPropertySource(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, servletContext));
	}
	if (servletConfig != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME) &&
			propertySources.get(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
		propertySources.replace(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME,
				new ServletConfigPropertySource(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, servletConfig));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:WebApplicationContextUtils.java

示例13: initPortletPropertySources

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
/**
 * Replace {@code Servlet}- and {@code Portlet}-based {@link
 * org.springframework.core.env.PropertySource.StubPropertySource stub property
 * sources} with actual instances populated with the given {@code servletContext},
 * {@code portletContext} and {@code portletConfig} objects.
 * <p>This method is idempotent with respect to the fact it may be called any number
 * of times but will perform replacement of stub property sources with their
 * corresponding actual property sources once and only once.
 * @param propertySources the {@link MutablePropertySources} to initialize (must not be {@code null})
 * @param servletContext the current {@link ServletContext} (ignored if {@code null}
 * or if the {@link org.springframework.web.context.support.StandardServletEnvironment#SERVLET_CONTEXT_PROPERTY_SOURCE_NAME
 * servlet context property source} has already been initialized)
 * @param portletContext the current {@link PortletContext} (ignored if {@code null}
 * or if the {@link StandardPortletEnvironment#PORTLET_CONTEXT_PROPERTY_SOURCE_NAME
 * portlet context property source} has already been initialized)
 * @param portletConfig the current {@link PortletConfig} (ignored if {@code null}
 * or if the {@link StandardPortletEnvironment#PORTLET_CONFIG_PROPERTY_SOURCE_NAME
 * portlet config property source} has already been initialized)
 * @see org.springframework.core.env.PropertySource.StubPropertySource
 * @see org.springframework.web.context.support.WebApplicationContextUtils#initServletPropertySources(MutablePropertySources, ServletContext)
 * @see org.springframework.core.env.ConfigurableEnvironment#getPropertySources()
 */
public static void initPortletPropertySources(MutablePropertySources propertySources, ServletContext servletContext,
		PortletContext portletContext, PortletConfig portletConfig) {

	Assert.notNull(propertySources, "propertySources must not be null");
	WebApplicationContextUtils.initServletPropertySources(propertySources, servletContext);

	if (portletContext != null && propertySources.contains(StandardPortletEnvironment.PORTLET_CONTEXT_PROPERTY_SOURCE_NAME)) {
		propertySources.replace(StandardPortletEnvironment.PORTLET_CONTEXT_PROPERTY_SOURCE_NAME,
				new PortletContextPropertySource(StandardPortletEnvironment.PORTLET_CONTEXT_PROPERTY_SOURCE_NAME, portletContext));
	}
	if (portletConfig != null && propertySources.contains(StandardPortletEnvironment.PORTLET_CONFIG_PROPERTY_SOURCE_NAME)) {
		propertySources.replace(StandardPortletEnvironment.PORTLET_CONFIG_PROPERTY_SOURCE_NAME,
				new PortletConfigPropertySource(StandardPortletEnvironment.PORTLET_CONFIG_PROPERTY_SOURCE_NAME, portletConfig));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:PortletApplicationContextUtils.java


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