Package org.apache.camel.spi
Interface ClassResolver
public interface ClassResolver
A class resolver for loading classes in a loosly coupled manner to cater for different platforms such as standalone,
web container, j2ee container and OSGi platforms.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addClassLoader
(ClassLoader classLoader) Adds a custom class loader to use.Loads the given resources as a URL from all bundles/classloadersLoads the given resource as a streamloadResourceAsURL
(String uri) Loads the given resource as a URLloadResourcesAsURL
(String uri) Loads the given resources as a URL from the current bundle/classloaderClass<?>
resolveClass
(String name) Resolves the given class by its name<T> Class<T>
resolveClass
(String name, Class<T> type) Resolves the given class by its name<T> Class<T>
resolveClass
(String name, Class<T> type, ClassLoader loader) Resolves the given class by its nameClass<?>
resolveClass
(String name, ClassLoader loader) Resolves the given class by its nameClass<?>
resolveMandatoryClass
(String name) Resolves the given class by its name<T> Class<T>
resolveMandatoryClass
(String name, Class<T> type) Resolves the given class by its name<T> Class<T>
resolveMandatoryClass
(String name, Class<T> type, ClassLoader loader) Resolves the given class by its nameClass<?>
resolveMandatoryClass
(String name, ClassLoader loader) Resolves the given class by its name
-
Method Details
-
addClassLoader
Adds a custom class loader to use.- Parameters:
classLoader
- a custom class loader
-
resolveClass
Resolves the given class by its name- Parameters:
name
- full qualified name of class- Returns:
- the class if resolved, null if not found.
-
resolveClass
Resolves the given class by its name- Parameters:
name
- full qualified name of classtype
- the expected type of the class- Returns:
- the class if resolved, null if not found.
-
resolveClass
Resolves the given class by its name- Parameters:
name
- full qualified name of classloader
- use the provided class loader- Returns:
- the class if resolved, null if not found.
-
resolveClass
Resolves the given class by its name- Parameters:
name
- full qualified name of classtype
- the expected type of the classloader
- use the provided class loader- Returns:
- the class if resolved, null if not found.
-
resolveMandatoryClass
Resolves the given class by its name- Parameters:
name
- full qualified name of class- Returns:
- the class if resolved, null if not found.
- Throws:
ClassNotFoundException
- is thrown if class not found
-
resolveMandatoryClass
Resolves the given class by its name- Parameters:
name
- full qualified name of classtype
- the expected type of the class- Returns:
- the class if resolved, null if not found.
- Throws:
ClassNotFoundException
- is thrown if class not found
-
resolveMandatoryClass
Resolves the given class by its name- Parameters:
name
- full qualified name of classloader
- use the provided class loader- Returns:
- the class if resolved, null if not found.
- Throws:
ClassNotFoundException
- is thrown if class not found
-
resolveMandatoryClass
<T> Class<T> resolveMandatoryClass(String name, Class<T> type, ClassLoader loader) throws ClassNotFoundException Resolves the given class by its name- Parameters:
name
- full qualified name of classtype
- the expected type of the classloader
- use the provided class loader- Returns:
- the class if resolved, null if not found.
- Throws:
ClassNotFoundException
- is thrown if class not found
-
loadResourceAsStream
Loads the given resource as a stream- Parameters:
uri
- the uri of the resource- Returns:
- as a stream
-
loadResourceAsURL
Loads the given resource as a URL- Parameters:
uri
- the uri of the resource- Returns:
- as a URL
-
loadResourcesAsURL
Loads the given resources as a URL from the current bundle/classloader- Parameters:
uri
- the uri of the resource- Returns:
- the URLs found on the classpath
-
loadAllResourcesAsURL
Loads the given resources as a URL from all bundles/classloaders- Parameters:
uri
- the uri of the resource- Returns:
- the URLs found on the classpath
-