org.apache.camel.impl.converter
Class AnnotationTypeConverterLoader

java.lang.Object
  extended by org.apache.camel.impl.converter.AnnotationTypeConverterLoader
All Implemented Interfaces:
TypeConverterLoader
Direct Known Subclasses:
ReportingTypeConverterLoader

public class AnnotationTypeConverterLoader
extends Object
implements TypeConverterLoader

A class which will auto-discover converter objects and methods to pre-load the registry of converters on startup

Version:

Field Summary
static String META_INF_SERVICES
           
protected  PackageScanClassResolver resolver
           
protected  Set<Class<?>> visitedClasses
           
protected  Set<URI> visitedURIs
           
 
Constructor Summary
AnnotationTypeConverterLoader(PackageScanClassResolver resolver)
           
 
Method Summary
protected  String[] findPackageNames()
          Finds the names of the packages to search for on the classpath looking for text files on the classpath at the META_INF_SERVICES location.
protected  void findPackages(Set<String> packages, ClassLoader classLoader)
           
protected  boolean isValidConverterMethod(Method method)
           
protected  boolean isValidFallbackConverterMethod(Method method)
           
 void load(TypeConverterRegistry registry)
          A pluggable strategy to load type converters into a registry from some kind of mechanism
protected  void loadConverterMethods(TypeConverterRegistry registry, Class<?> type)
          Loads all of the converter methods for the given type
protected  void registerFallbackTypeConverter(TypeConverterRegistry registry, TypeConverter typeConverter, Method method)
           
protected  void registerTypeConverter(TypeConverterRegistry registry, Method method, Class<?> toType, Class<?> fromType, TypeConverter typeConverter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

META_INF_SERVICES

public static final String META_INF_SERVICES
See Also:
Constant Field Values

resolver

protected PackageScanClassResolver resolver

visitedClasses

protected Set<Class<?>> visitedClasses

visitedURIs

protected Set<URI> visitedURIs
Constructor Detail

AnnotationTypeConverterLoader

public AnnotationTypeConverterLoader(PackageScanClassResolver resolver)
Method Detail

load

public void load(TypeConverterRegistry registry)
          throws TypeConverterLoaderException
Description copied from interface: TypeConverterLoader
A pluggable strategy to load type converters into a registry from some kind of mechanism

Specified by:
load in interface TypeConverterLoader
Parameters:
registry - the registry to load the type converters into
Throws:
TypeConverterLoaderException - if the type converters could not be loaded

findPackageNames

protected String[] findPackageNames()
                             throws IOException,
                                    URISyntaxException
Finds the names of the packages to search for on the classpath looking for text files on the classpath at the META_INF_SERVICES location.

Returns:
a collection of packages to search for
Throws:
IOException - is thrown for IO related errors
URISyntaxException

findPackages

protected void findPackages(Set<String> packages,
                            ClassLoader classLoader)
                     throws IOException,
                            URISyntaxException
Throws:
IOException
URISyntaxException

loadConverterMethods

protected void loadConverterMethods(TypeConverterRegistry registry,
                                    Class<?> type)
Loads all of the converter methods for the given type


registerTypeConverter

protected void registerTypeConverter(TypeConverterRegistry registry,
                                     Method method,
                                     Class<?> toType,
                                     Class<?> fromType,
                                     TypeConverter typeConverter)

isValidConverterMethod

protected boolean isValidConverterMethod(Method method)

registerFallbackTypeConverter

protected void registerFallbackTypeConverter(TypeConverterRegistry registry,
                                             TypeConverter typeConverter,
                                             Method method)

isValidFallbackConverterMethod

protected boolean isValidFallbackConverterMethod(Method method)


Apache CAMEL