Class ConversionServiceFactoryBean

java.lang.Object
org.springframework.context.support.ConversionServiceFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<org.springframework.core.convert.ConversionService>, org.springframework.beans.factory.InitializingBean

public class ConversionServiceFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<org.springframework.core.convert.ConversionService>, org.springframework.beans.factory.InitializingBean
A factory providing convenient access to a ConversionService configured with converters appropriate for most environments. Set the "converters" property to supplement the default converters.

This implementation creates a DefaultConversionService. Subclasses may override createConversionService() in order to return a GenericConversionService instance of their choosing.

Like all FactoryBean implementations, this class is suitable for use when configuring a Spring application context using Spring <beans> XML. When configuring the container with @Configuration classes, simply instantiate, configure and return the appropriate ConversionService object from a @Bean method.

Since:
3.0
Author:
Keith Donald, Juergen Hoeller, Chris Beams
  • Constructor Details

    • ConversionServiceFactoryBean

      public ConversionServiceFactoryBean()
  • Method Details

    • setConverters

      public void setConverters(Set<?> converters)
      Configure the set of custom converter objects that should be added: implementing Converter, ConverterFactory, or GenericConverter.
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • createConversionService

      protected org.springframework.core.convert.support.GenericConversionService createConversionService()
      Create the ConversionService instance returned by this factory bean.

      Creates a simple GenericConversionService instance by default. Subclasses may override to customize the ConversionService instance that gets created.

    • getObject

      @Nullable public org.springframework.core.convert.ConversionService getObject()
      Specified by:
      getObject in interface org.springframework.beans.factory.FactoryBean<org.springframework.core.convert.ConversionService>
    • getObjectType

      public Class<? extends org.springframework.core.convert.ConversionService> getObjectType()
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<org.springframework.core.convert.ConversionService>
    • isSingleton

      public boolean isSingleton()
      Specified by:
      isSingleton in interface org.springframework.beans.factory.FactoryBean<org.springframework.core.convert.ConversionService>