Package org.apache.camel.spi
Interface TypeConverterRegistry
- All Superinterfaces:
AutoCloseable
,CamelContextAware
,Service
,StaticService
Registry for type converters.
The utilization
TypeConverterRegistry.Statistics
is by default disabled, as it has a slight performance impact under very high
concurrent load. The statistics can be enabled using TypeConverterRegistry.Statistics.setStatisticsEnabled(boolean)
method.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Utilization statistics of the registry. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBulkTypeConverters
(BulkTypeConverters bulkTypeConverters) Registers a new set of type converters that are bulked together into a singleBulkTypeConverters
class.void
addFallbackTypeConverter
(TypeConverter typeConverter, boolean canPromote) Registers a new fallback type convertervoid
addTypeConverter
(Class<?> toType, Class<?> fromType, TypeConverter typeConverter) Registers a new type converter.void
addTypeConverters
(Object typeConverters) Registers all the type converters from the instance, each converter must be implemented as a method and annotated withConverter
.Gets the injectorGets the utilization statistics of this type converter registryWhat should happen when attempting to add a duplicate type converter.The logging level to use when logging that a type converter already exists when attempting to add a duplicate type converter.Performs a lookup for a given type converter.boolean
removeTypeConverter
(Class<?> toType, Class<?> fromType) Removes the type convertervoid
setInjector
(Injector injector) Sets the injector to be used for creating new instances during type conversions.void
setTypeConverterExists
(TypeConverterExists typeConverterExists) What should happen when attempting to add a duplicate type converter.void
setTypeConverterExistsLoggingLevel
(LoggingLevel typeConverterExistsLoggingLevel) The logging level to use when logging that a type converter already exists when attempting to add a duplicate type converter.int
size()
Number of type converters in the registry.Methods inherited from interface org.apache.camel.CamelContextAware
getCamelContext, setCamelContext
-
Method Details
-
addBulkTypeConverters
Registers a new set of type converters that are bulked together into a singleBulkTypeConverters
class. -
addTypeConverter
Registers a new type converter. This method may throwTypeConverterExistsException
if configured to fail if an existing type converter already exists- Parameters:
toType
- the type to convert tofromType
- the type to convert fromtypeConverter
- the type converter to use
-
removeTypeConverter
Removes the type converter- Parameters:
toType
- the type to convert tofromType
- the type to convert from- Returns:
- true if removed, false if the type converter didn't exist
-
addTypeConverters
Registers all the type converters from the instance, each converter must be implemented as a method and annotated withConverter
.- Parameters:
typeConverters
- instance which implements the type converters
-
addFallbackTypeConverter
Registers a new fallback type converter- Parameters:
typeConverter
- the type converter to usecanPromote
- whether or not the fallback type converter can be promoted to a first class type converter
-
lookup
Performs a lookup for a given type converter.- Parameters:
toType
- the type to convert tofromType
- the type to convert from- Returns:
- the type converter or null if not found.
-
setInjector
Sets the injector to be used for creating new instances during type conversions.- Parameters:
injector
- the injector
-
getInjector
Injector getInjector()Gets the injector- Returns:
- the injector
-
getStatistics
TypeConverterRegistry.Statistics getStatistics()Gets the utilization statistics of this type converter registry- Returns:
- the utilization statistics
-
size
int size()Number of type converters in the registry.- Returns:
- number of type converters in the registry.
-
getTypeConverterExistsLoggingLevel
LoggingLevel getTypeConverterExistsLoggingLevel()The logging level to use when logging that a type converter already exists when attempting to add a duplicate type converter. The default logging level is DEBUG -
setTypeConverterExistsLoggingLevel
The logging level to use when logging that a type converter already exists when attempting to add a duplicate type converter. The default logging level is DEBUG -
getTypeConverterExists
TypeConverterExists getTypeConverterExists()What should happen when attempting to add a duplicate type converter. The default behavior is to ignore the duplicate. -
setTypeConverterExists
What should happen when attempting to add a duplicate type converter. The default behavior is to ignore the duplicate.
-