|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.camel.impl.converter.AnnotationTypeConverterLoader
public class AnnotationTypeConverterLoader
A class which will auto-discover Converter
objects and methods to pre-load
the TypeConverterRegistry
of converters on startup.
META_INF_SERVICES
contains a list of packages or FQN class names for Converter
classes. The FQN class names
is loaded first and directly by the class loader.
The PackageScanClassResolver
is being used to scan packages for Converter
classes and
this procedure is slower than loading the Converter
classes directly by its FQN class name.
Therefore its recommended to specify FQN class names in the META_INF_SERVICES
file.
Likewise the procedure for scanning using PackageScanClassResolver
may require custom implementations
to work in various containers such as JBoss, OSGi, etc.
Field Summary | |
---|---|
static String |
META_INF_SERVICES
|
protected PackageScanClassResolver |
resolver
|
protected Set<Class<?>> |
visitedClasses
|
protected Set<String> |
visitedURIs
|
Constructor Summary | |
---|---|
AnnotationTypeConverterLoader(PackageScanClassResolver resolver)
|
Method Summary | |
---|---|
protected String[] |
filterPackageNamesOnly(PackageScanClassResolver resolver,
String[] packageNames,
Set<Class<?>> classes)
Filters the given list of packages and returns an array of only package names. |
protected static String[] |
filterUnwantedPackage(String name,
String[] packageNames)
Filters the given list of packages |
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 |
---|
public static final String META_INF_SERVICES
protected PackageScanClassResolver resolver
protected Set<Class<?>> visitedClasses
protected Set<String> visitedURIs
Constructor Detail |
---|
public AnnotationTypeConverterLoader(PackageScanClassResolver resolver)
Method Detail |
---|
public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException
TypeConverterLoader
load
in interface TypeConverterLoader
registry
- the registry to load the type converters into
TypeConverterLoaderException
- if the type converters could not be loadedprotected String[] filterPackageNamesOnly(PackageScanClassResolver resolver, String[] packageNames, Set<Class<?>> classes)
resolver
- the class resolverpackageNames
- the package namesclasses
- to add loaded @Converter classes
protected String[] findPackageNames() throws IOException
META_INF_SERVICES
location.
IOException
- is thrown for IO related errorsprotected void findPackages(Set<String> packages, ClassLoader classLoader) throws IOException
IOException
protected void loadConverterMethods(TypeConverterRegistry registry, Class<?> type)
protected void registerTypeConverter(TypeConverterRegistry registry, Method method, Class<?> toType, Class<?> fromType, TypeConverter typeConverter)
protected boolean isValidConverterMethod(Method method)
protected void registerFallbackTypeConverter(TypeConverterRegistry registry, TypeConverter typeConverter, Method method)
protected boolean isValidFallbackConverterMethod(Method method)
protected static String[] filterUnwantedPackage(String name, String[] packageNames)
name
- the name to filter outpackageNames
- the packages
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |