|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.camel.support.ServiceSupport org.apache.camel.impl.converter.BaseTypeConverterRegistry
public abstract class BaseTypeConverterRegistry
Base implementation of a type converter registry used for type converters in Camel.
Nested Class Summary | |
---|---|
protected static class |
BaseTypeConverterRegistry.FallbackTypeConverter
Represents a fallback type converter |
protected static class |
BaseTypeConverterRegistry.TypeMapping
Represents a mapping from one type (which can be null) to another |
Nested classes/interfaces inherited from interface org.apache.camel.spi.TypeConverterRegistry |
---|
TypeConverterRegistry.Statistics |
Field Summary | |
---|---|
protected AtomicLong |
attemptCounter
|
protected FactoryFinder |
factoryFinder
|
protected AtomicLong |
failedCounter
|
protected List<BaseTypeConverterRegistry.FallbackTypeConverter> |
fallbackConverters
|
protected AtomicLong |
hitCounter
|
protected Injector |
injector
|
protected org.slf4j.Logger |
log
|
protected AtomicLong |
missCounter
|
protected LRUSoftCache<BaseTypeConverterRegistry.TypeMapping,BaseTypeConverterRegistry.TypeMapping> |
misses
|
protected PackageScanClassResolver |
resolver
|
protected TypeConverterRegistry.Statistics |
statistics
|
protected List<TypeConverterLoader> |
typeConverterLoaders
|
protected ConcurrentMap<BaseTypeConverterRegistry.TypeMapping,TypeConverter> |
typeMappings
|
Fields inherited from class org.apache.camel.support.ServiceSupport |
---|
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending |
Constructor Summary | |
---|---|
BaseTypeConverterRegistry(PackageScanClassResolver resolver,
Injector injector,
FactoryFinder factoryFinder)
|
Method Summary | ||
---|---|---|
void |
addFallbackTypeConverter(TypeConverter typeConverter,
boolean canPromote)
Registers a new fallback type converter |
|
void |
addTypeConverter(Class<?> toType,
Class<?> fromType,
TypeConverter typeConverter)
Registers a new type converter |
|
|
convertTo(Class<T> type,
Exchange exchange,
Object value)
Converts the value to the specified type in the context of an exchange Used when conversion requires extra information from the current exchange (such as encoding). |
|
|
convertTo(Class<T> type,
Object value)
Converts the value to the specified type |
|
protected Object |
doConvertTo(Class<?> type,
Exchange exchange,
Object value,
boolean tryConvert)
|
|
protected TypeConverter |
doLookup(Class<?> toType,
Class<?> fromType,
boolean isSuper)
|
|
protected void |
doStart()
Implementations override this method to support customized start/stop. |
|
protected void |
doStop()
Implementations override this method to support customized start/stop. |
|
Set<Class<?>> |
getFromClassMappings()
|
|
Injector |
getInjector()
Gets the injector |
|
protected
|
getOrFindTypeConverter(Class<?> toType,
Object value)
|
|
TypeConverterRegistry.Statistics |
getStatistics()
Gets the utilization statistics of this type converter registry |
|
Map<Class<?>,TypeConverter> |
getToClassMappings(Class<?> fromClass)
|
|
TypeConverter |
getTypeConverter(Class<?> toType,
Class<?> fromType)
|
|
List<TypeConverterLoader> |
getTypeConverterLoaders()
|
|
Map<BaseTypeConverterRegistry.TypeMapping,TypeConverter> |
getTypeMappings()
|
|
void |
loadCoreTypeConverters()
Loads the core type converters which is mandatory to use Camel |
|
protected void |
loadFallbackTypeConverters()
|
|
protected void |
loadTypeConverters()
Checks if the registry is loaded and if not lazily load it |
|
TypeConverter |
lookup(Class<?> toType,
Class<?> fromType)
Performs a lookup for a given type converter. |
|
|
mandatoryConvertTo(Class<T> type,
Exchange exchange,
Object value)
Converts the value to the specified type in the context of an exchange Used when conversion requires extra information from the current exchange (such as encoding). |
|
|
mandatoryConvertTo(Class<T> type,
Object value)
Converts the value to the specified type |
|
void |
setInjector(Injector injector)
Sets the injector to be used for creating new instances during type conversions. |
|
|
tryConvertTo(Class<T> type,
Exchange exchange,
Object value)
Tries to convert the value to the specified type in the context of an exchange, returning null if not possible to convert. |
|
|
tryConvertTo(Class<T> type,
Object value)
Tries to convert the value to the specified type, returning null if not possible to convert. |
Methods inherited from class org.apache.camel.support.ServiceSupport |
---|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.camel.Service |
---|
start, stop |
Field Detail |
---|
protected final transient org.slf4j.Logger log
protected final ConcurrentMap<BaseTypeConverterRegistry.TypeMapping,TypeConverter> typeMappings
protected final LRUSoftCache<BaseTypeConverterRegistry.TypeMapping,BaseTypeConverterRegistry.TypeMapping> misses
protected final List<TypeConverterLoader> typeConverterLoaders
protected final List<BaseTypeConverterRegistry.FallbackTypeConverter> fallbackConverters
protected final PackageScanClassResolver resolver
protected Injector injector
protected final FactoryFinder factoryFinder
protected final TypeConverterRegistry.Statistics statistics
protected final AtomicLong attemptCounter
protected final AtomicLong missCounter
protected final AtomicLong hitCounter
protected final AtomicLong failedCounter
Constructor Detail |
---|
public BaseTypeConverterRegistry(PackageScanClassResolver resolver, Injector injector, FactoryFinder factoryFinder)
Method Detail |
---|
public List<TypeConverterLoader> getTypeConverterLoaders()
public <T> T convertTo(Class<T> type, Object value)
TypeConverter
convertTo
in interface TypeConverter
type
- the requested typevalue
- the value to be converted
public <T> T convertTo(Class<T> type, Exchange exchange, Object value)
TypeConverter
convertTo
in interface TypeConverter
type
- the requested typeexchange
- the current exchangevalue
- the value to be converted
public <T> T mandatoryConvertTo(Class<T> type, Object value) throws NoTypeConversionAvailableException
TypeConverter
mandatoryConvertTo
in interface TypeConverter
type
- the requested typevalue
- the value to be converted
NoTypeConversionAvailableException
- if no type converters exists to convert to the given typepublic <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value) throws NoTypeConversionAvailableException
TypeConverter
mandatoryConvertTo
in interface TypeConverter
type
- the requested typeexchange
- the current exchangevalue
- the value to be converted
NoTypeConversionAvailableException
- if no type converters exists to convert to the given typepublic <T> T tryConvertTo(Class<T> type, Object value)
TypeConverter
tryConvertTo
in interface TypeConverter
type
- the requested typevalue
- the value to be converted
public <T> T tryConvertTo(Class<T> type, Exchange exchange, Object value)
TypeConverter
tryConvertTo
in interface TypeConverter
type
- the requested typeexchange
- the current exchangevalue
- the value to be converted
protected Object doConvertTo(Class<?> type, Exchange exchange, Object value, boolean tryConvert)
public void addTypeConverter(Class<?> toType, Class<?> fromType, TypeConverter typeConverter)
TypeConverterRegistry
addTypeConverter
in interface TypeConverterRegistry
toType
- the type to convert tofromType
- the type to convert fromtypeConverter
- the type converter to usepublic void addFallbackTypeConverter(TypeConverter typeConverter, boolean canPromote)
TypeConverterRegistry
addFallbackTypeConverter
in interface TypeConverterRegistry
typeConverter
- the type converter to usecanPromote
- whether or not the fallback type converter can be promoted to a first class type converterpublic TypeConverter getTypeConverter(Class<?> toType, Class<?> fromType)
public Injector getInjector()
TypeConverterRegistry
getInjector
in interface TypeConverterRegistry
public void setInjector(Injector injector)
TypeConverterRegistry
setInjector
in interface TypeConverterRegistry
injector
- the injectorpublic Set<Class<?>> getFromClassMappings()
public Map<Class<?>,TypeConverter> getToClassMappings(Class<?> fromClass)
public Map<BaseTypeConverterRegistry.TypeMapping,TypeConverter> getTypeMappings()
protected <T> TypeConverter getOrFindTypeConverter(Class<?> toType, Object value)
public TypeConverter lookup(Class<?> toType, Class<?> fromType)
TypeConverterRegistry
lookup
in interface TypeConverterRegistry
toType
- the type to convert tofromType
- the type to convert from
protected TypeConverter doLookup(Class<?> toType, Class<?> fromType, boolean isSuper)
public void loadCoreTypeConverters() throws Exception
Exception
protected void loadTypeConverters() throws Exception
Exception
protected void loadFallbackTypeConverters() throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public TypeConverterRegistry.Statistics getStatistics()
TypeConverterRegistry
getStatistics
in interface TypeConverterRegistry
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.
doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.
doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |