org.springframework.core.convert.support.ConfigurableConversionService Java Examples

The following examples show how to use org.springframework.core.convert.support.ConfigurableConversionService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MybatisQueryExecution.java    From spring-data-mybatis with Apache License 2.0 6 votes vote down vote up
public static void potentiallyRemoveOptionalConverter(
		ConfigurableConversionService conversionService) {

	ClassLoader classLoader = MybatisQueryExecution.class.getClassLoader();

	if (ClassUtils.isPresent("java.util.Optional", classLoader)) {

		try {

			Class<?> optionalType = ClassUtils.forName("java.util.Optional",
					classLoader);
			conversionService.removeConvertible(Object.class, optionalType);

		}
		catch (ClassNotFoundException | LinkageError o_O) {
		}
	}
}
 
Example #2
Source File: DemoRestMvcConfiguration.java    From spring-data-dynamodb-demo with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureConversionService(
		ConfigurableConversionService conversionService) {
	conversionService.addConverter(stringToThreadIdConverter());
	conversionService.addConverter(stringToReplyIdConverter());
	super.configureConversionService(conversionService);
}
 
Example #3
Source File: AbstractPropertyResolver.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ConfigurableConversionService getConversionService() {
	// Need to provide an independent DefaultConversionService, not the
	// shared DefaultConversionService used by PropertySourcesPropertyResolver.
	if (this.conversionService == null) {
		synchronized (this) {
			if (this.conversionService == null) {
				this.conversionService = new DefaultConversionService();
			}
		}
	}
	return conversionService;
}
 
Example #4
Source File: UserContextConfiguration.java    From thinking-in-spring-boot-samples with Apache License 2.0 5 votes vote down vote up
public UserContextConfiguration(BeanFactory beanFactory) {
    String beanName = ConfigurableApplicationContext.ENVIRONMENT_BEAN_NAME;
    this.environment = beanFactory.getBean(beanName, Environment.class);
    // 获取 ID 为 conversionService 的 ConversionService Bean,实际为 DefaultFormattingConversionService
    ConfigurableConversionService conversionService =
            beanFactory.getBean("conversionService", ConfigurableConversionService.class);
    // 设置 ConversionService Bean
    ((ConfigurableEnvironment) environment).setConversionService(conversionService);
}
 
Example #5
Source File: AbstractEnvironment.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ConfigurableConversionService getConversionService() {
	return this.propertyResolver.getConversionService();
}
 
Example #6
Source File: AbstractPropertyResolver.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
	this.conversionService = conversionService;
}
 
Example #7
Source File: AbstractPropertyResolver.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigurableConversionService getConversionService() {
	return this.conversionService;
}
 
Example #8
Source File: AbstractEnvironment.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
	this.propertyResolver.setConversionService(conversionService);
}
 
Example #9
Source File: AbstractEnvironment.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigurableConversionService getConversionService() {
	return this.propertyResolver.getConversionService();
}
 
Example #10
Source File: AbstractPropertyResolver.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
	Assert.notNull(conversionService, "ConversionService must not be null");
	this.conversionService = conversionService;
}
 
Example #11
Source File: AbstractEnvironment.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
	this.propertyResolver.setConversionService(conversionService);
}
 
Example #12
Source File: MicronautEnvironment.java    From micronaut-spring with Apache License 2.0 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
    this.conversionService = conversionService;
}
 
Example #13
Source File: MicronautEnvironment.java    From micronaut-spring with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigurableConversionService getConversionService() {
    return conversionService;
}
 
Example #14
Source File: AbstractPropertyResolver.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
	Assert.notNull(conversionService, "ConversionService must not be null");
	this.conversionService = conversionService;
}
 
Example #15
Source File: AbstractEnvironment.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
	this.propertyResolver.setConversionService(conversionService);
}
 
Example #16
Source File: AbstractEnvironment.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public ConfigurableConversionService getConversionService() {
	return this.propertyResolver.getConversionService();
}
 
Example #17
Source File: AbstractPropertyResolver.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
	Assert.notNull(conversionService, "ConversionService must not be null");
	this.conversionService = conversionService;
}
 
Example #18
Source File: AbstractEnvironment.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void setConversionService(ConfigurableConversionService conversionService) {
	this.propertyResolver.setConversionService(conversionService);
}
 
Example #19
Source File: AbstractEnvironment.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public ConfigurableConversionService getConversionService() {
	return this.propertyResolver.getConversionService();
}
 
Example #20
Source File: DefaultNeo4jConverter.java    From sdn-rx with Apache License 2.0 3 votes vote down vote up
DefaultNeo4jConverter(Neo4jConversions neo4jConversions, NodeDescriptionStore nodeDescriptionStore) {

		Assert.notNull(neo4jConversions, "Neo4jConversions must not be null!");

		final ConfigurableConversionService configurableConversionService = new DefaultConversionService();
		neo4jConversions.registerConvertersIn(configurableConversionService);

		this.conversionService = configurableConversionService;
		this.nodeDescriptionStore = nodeDescriptionStore;
	}
 
Example #21
Source File: ConfigurablePropertyResolver.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set the {@link ConfigurableConversionService} to be used when performing type
 * conversions on properties.
 * <p><strong>Note:</strong> as an alternative to fully replacing the
 * {@code ConversionService}, consider adding or removing individual
 * {@code Converter} instances by drilling into {@link #getConversionService()}
 * and calling methods such as {@code #addConverter}.
 * @see PropertyResolver#getProperty(String, Class)
 * @see #getConversionService()
 * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter
 */
void setConversionService(ConfigurableConversionService conversionService);
 
Example #22
Source File: ConfigurablePropertyResolver.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Return the {@link ConfigurableConversionService} used when performing type
 * conversions on properties.
 * <p>The configurable nature of the returned conversion service allows for
 * the convenient addition and removal of individual {@code Converter} instances:
 * <pre class="code">
 * ConfigurableConversionService cs = env.getConversionService();
 * cs.addConverter(new FooConverter());
 * </pre>
 * @see PropertyResolver#getProperty(String, Class)
 * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter
 */
ConfigurableConversionService getConversionService();
 
Example #23
Source File: ConfigurablePropertyResolver.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Return the {@link ConfigurableConversionService} used when performing type
 * conversions on properties.
 * <p>The configurable nature of the returned conversion service allows for
 * the convenient addition and removal of individual {@code Converter} instances:
 * <pre class="code">
 * ConfigurableConversionService cs = env.getConversionService();
 * cs.addConverter(new FooConverter());
 * </pre>
 * @see PropertyResolver#getProperty(String, Class)
 * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter
 */
ConfigurableConversionService getConversionService();
 
Example #24
Source File: ConfigurablePropertyResolver.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Set the {@link ConfigurableConversionService} to be used when performing type
 * conversions on properties.
 * <p><strong>Note:</strong> as an alternative to fully replacing the
 * {@code ConversionService}, consider adding or removing individual
 * {@code Converter} instances by drilling into {@link #getConversionService()}
 * and calling methods such as {@code #addConverter}.
 * @see PropertyResolver#getProperty(String, Class)
 * @see #getConversionService()
 * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter
 */
void setConversionService(ConfigurableConversionService conversionService);
 
Example #25
Source File: ConfigurablePropertyResolver.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Set the {@link ConfigurableConversionService} to be used when performing type
 * conversions on properties.
 * <p><strong>Note:</strong> as an alternative to fully replacing the
 * {@code ConversionService}, consider adding or removing individual
 * {@code Converter} instances by drilling into {@link #getConversionService()}
 * and calling methods such as {@code #addConverter}.
 * @see PropertyResolver#getProperty(String, Class)
 * @see #getConversionService()
 * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter
 */
void setConversionService(ConfigurableConversionService conversionService);
 
Example #26
Source File: ConfigurablePropertyResolver.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Return the {@link ConfigurableConversionService} used when performing type
 * conversions on properties.
 * <p>The configurable nature of the returned conversion service allows for
 * the convenient addition and removal of individual {@code Converter} instances:
 * <pre class="code">
 * ConfigurableConversionService cs = env.getConversionService();
 * cs.addConverter(new FooConverter());
 * </pre>
 * @see PropertyResolver#getProperty(String, Class)
 * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter
 */
ConfigurableConversionService getConversionService();
 
Example #27
Source File: ConfigurablePropertyResolver.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * @return the {@link ConfigurableConversionService} used when performing type
 * conversions on properties.
 * <p>The configurable nature of the returned conversion service allows for
 * the convenient addition and removal of individual {@code Converter} instances:
 * <pre class="code">
 * ConfigurableConversionService cs = env.getConversionService();
 * cs.addConverter(new FooConverter());
 * </pre>
 * @see PropertyResolver#getProperty(String, Class)
 * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter
 */
ConfigurableConversionService getConversionService();
 
Example #28
Source File: ConfigurablePropertyResolver.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Set the {@link ConfigurableConversionService} to be used when performing type
 * conversions on properties.
 * <p><strong>Note:</strong> as an alternative to fully replacing the {@code
 * ConversionService}, consider adding or removing individual {@code Converter}
 * instances by drilling into {@link #getConversionService()} and calling methods
 * such as {@code #addConverter}.
 * @see PropertyResolver#getProperty(String, Class)
 * @see #getConversionService()
 * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter
 */
void setConversionService(ConfigurableConversionService conversionService);