public class DefaultPackageScanClassResolver extends ServiceSupport implements PackageScanClassResolver, StaticService, NonManagedService
PackageScanClassResolver
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
DefaultPackageScanClassResolver() |
Modifier and Type | Method and Description |
---|---|
void |
addClassLoader(ClassLoader classLoader)
Adds the class loader to the existing loaders
|
void |
addFilter(PackageScanFilter filter)
Add a filter that will be applied to all scan operations
|
protected void |
addIfMatching(PackageScanFilter test,
String fqn,
Set<Class<?>> classes)
Add the class designated by the fully qualified class name provided to
the set of resolved classes if and only if it is approved by the Test
supplied.
|
protected URL |
customResourceLocator(URL url) |
protected List<String> |
doLoadJarClassEntries(InputStream stream,
String urlPath)
Loads all the class entries from the JAR.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
protected void |
find(PackageScanFilter test,
String packageName,
ClassLoader loader,
Set<Class<?>> classes) |
protected void |
find(PackageScanFilter test,
String packageName,
Set<Class<?>> classes) |
Set<Class<?>> |
findAnnotated(Class<? extends Annotation> annotation,
String... packageNames)
Attempts to discover classes that are annotated with to the annotation.
|
Set<Class<?>> |
findAnnotated(Set<Class<? extends Annotation>> annotations,
String... packageNames)
Attempts to discover classes that are annotated with to the annotation.
|
Set<Class<?>> |
findByFilter(PackageScanFilter filter,
String... packageNames)
Attempts to discover classes filter by the provided filter
|
Set<Class<?>> |
findImplementations(Class<?> parent,
String... packageNames)
Attempts to discover classes that are assignable to the type provided.
|
Set<ClassLoader> |
getClassLoaders()
Gets the ClassLoader instances that should be used when scanning for classes.
|
protected Enumeration<URL> |
getResources(ClassLoader loader,
String packageName)
Strategy to get the resources by the given classloader.
|
boolean |
isAcceptableScheme(String urlPath) |
void |
removeFilter(PackageScanFilter filter)
Removes the filter
|
void |
setAcceptableSchemes(String schemes) |
void |
setClassLoaders(Set<ClassLoader> classLoaders)
Sets the ClassLoader instances that should be used when scanning for
classes.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
protected final org.slf4j.Logger log
public DefaultPackageScanClassResolver()
public void addClassLoader(ClassLoader classLoader)
PackageScanClassResolver
addClassLoader
in interface PackageScanClassResolver
classLoader
- the loader to addpublic void addFilter(PackageScanFilter filter)
PackageScanClassResolver
addFilter
in interface PackageScanClassResolver
filter
- filter to filter desired classes in all scan operationspublic void removeFilter(PackageScanFilter filter)
PackageScanClassResolver
removeFilter
in interface PackageScanClassResolver
filter
- filter to filter desired classes in all scan operationspublic void setAcceptableSchemes(String schemes)
public boolean isAcceptableScheme(String urlPath)
public Set<ClassLoader> getClassLoaders()
PackageScanClassResolver
PackageScanClassResolver.addClassLoader(ClassLoader)
method if you want to add new classloaders
to the class loaders list.getClassLoaders
in interface PackageScanClassResolver
public void setClassLoaders(Set<ClassLoader> classLoaders)
PackageScanClassResolver
setClassLoaders
in interface PackageScanClassResolver
classLoaders
- loaders to use when scanning for classespublic Set<Class<?>> findAnnotated(Class<? extends Annotation> annotation, String... packageNames)
PackageScanClassResolver
findAnnotated
in interface PackageScanClassResolver
annotation
- the annotation that should be present on matching classespackageNames
- one or more package names to scan (including subpackages) for classespublic Set<Class<?>> findAnnotated(Set<Class<? extends Annotation>> annotations, String... packageNames)
PackageScanClassResolver
findAnnotated
in interface PackageScanClassResolver
annotations
- the annotations that should be present (any of them) on matching classespackageNames
- one or more package names to scan (including subpackages) for classespublic Set<Class<?>> findImplementations(Class<?> parent, String... packageNames)
PackageScanClassResolver
findImplementations
in interface PackageScanClassResolver
parent
- the class of interface to find subclasses or implementations ofpackageNames
- one or more package names to scan (including subpackages) for classespublic Set<Class<?>> findByFilter(PackageScanFilter filter, String... packageNames)
PackageScanClassResolver
findByFilter
in interface PackageScanClassResolver
filter
- filter to filter desired classes.packageNames
- one or more package names to scan (including subpackages) for classesprotected void find(PackageScanFilter test, String packageName, Set<Class<?>> classes)
protected void find(PackageScanFilter test, String packageName, ClassLoader loader, Set<Class<?>> classes)
protected URL customResourceLocator(URL url) throws IOException
IOException
protected Enumeration<URL> getResources(ClassLoader loader, String packageName) throws IOException
WebSpherePackageScanClassResolver
to take care of WebSphere's oddity of resource loading.loader
- the classloaderpackageName
- the packagename for the package to loadIOException
- is thrown by the classloaderprotected List<String> doLoadJarClassEntries(InputStream stream, String urlPath)
stream
- the inputstream of the jar file to be examined for classesurlPath
- the url of the jar file to be examined for classesprotected void addIfMatching(PackageScanFilter test, String fqn, Set<Class<?>> classes)
test
- the test used to determine if the class matchesfqn
- the fully qualified name of a classprotected 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()
Apache Camel