public class ConfigurationBuilder extends Object implements Configuration
Configuration
, to be used for constructing a Reflections
instance
usage:
new Reflections( new ConfigurationBuilder() .filterInputsBy(new FilterBuilder().include("your project's common package prefix here...")) .setUrls(ClasspathHelper.forClassLoader()) .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner().filterResultsBy(myClassAnnotationsFilter)));
executorService
is used optionally used for parallel scanning. if value is null then scanning is done in a simple for loop
defaults: accept all for inputsFilter
,
executorService
is null,
serializer
is XmlSerializer
Constructor and Description |
---|
ConfigurationBuilder() |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptsInput(String inputFqn)
the fully qualified name filter used to filter types to be scanned
|
ConfigurationBuilder |
addClassLoader(ClassLoader classLoader)
add class loader, might be used for resolving methods/fields
|
ConfigurationBuilder |
addClassLoaders(ClassLoader... classLoaders)
add class loader, might be used for resolving methods/fields
|
ConfigurationBuilder |
addClassLoaders(Collection<ClassLoader> classLoaders)
add class loader, might be used for resolving methods/fields
|
ConfigurationBuilder |
addScanners(Scanner... scanners)
set the scanners instances for scanning different metadata
|
ConfigurationBuilder |
addUrls(Collection<URL>... urlss)
add urls to be scanned
|
ConfigurationBuilder |
addUrls(Collection<URL> urls)
add urls to be scanned
|
ConfigurationBuilder |
addUrls(URL... urls)
add urls to be scanned
|
ConfigurationBuilder |
filterInputsBy(com.google.common.base.Predicate<String> inputsFilter)
sets the input filter for all resources to be scanned
|
ClassLoader[] |
getClassLoaders()
get class loader, might be used for scanning or resolving methods/fields
|
ExecutorService |
getExecutorService()
executor service used to scan files
if null, scanning is done in a simple for loop
|
MetadataAdapter |
getMetadataAdapter()
the metadata adapter used to fetch metadata from classes
|
Set<Scanner> |
getScanners()
the scanner instances used for scanning different metadata
|
Serializer |
getSerializer()
the default serializer to use when saving Reflection
|
Set<URL> |
getUrls()
the urls to be scanned
|
ConfigurationBuilder |
setExecutorService(ExecutorService executorService)
sets the executor service used for scanning.
|
ConfigurationBuilder |
setMetadataAdapter(MetadataAdapter metadataAdapter)
sets the metadata adapter used to fetch metadata from classes
|
ConfigurationBuilder |
setScanners(Scanner... scanners)
set the scanners instances for scanning different metadata
|
ConfigurationBuilder |
setSerializer(Serializer serializer)
sets the serializer used when issuing
Reflections.save(java.lang.String) |
ConfigurationBuilder |
setUrls(Collection<URL>... urlss)
set the urls to be scanned
|
ConfigurationBuilder |
setUrls(Collection<URL> urls)
set the urls to be scanned
|
ConfigurationBuilder |
setUrls(URL... urls)
set the urls to be scanned
|
ConfigurationBuilder |
useParallelExecutor()
sets the executor service used for scanning to ThreadPoolExecutor with core size as
Runtime.availableProcessors() |
ConfigurationBuilder |
useParallelExecutor(int availableProcessors)
sets the executor service used for scanning to ThreadPoolExecutor with core size as the given availableProcessors parameter
|
public Set<Scanner> getScanners()
Configuration
getScanners
in interface Configuration
public ConfigurationBuilder setScanners(Scanner... scanners)
public ConfigurationBuilder addScanners(Scanner... scanners)
public Set<URL> getUrls()
Configuration
getUrls
in interface Configuration
public ConfigurationBuilder setUrls(Collection<URL> urls)
use ClasspathHelper
convenient methods to get the relevant urls
public ConfigurationBuilder setUrls(URL... urls)
use ClasspathHelper
convenient methods to get the relevant urls
public ConfigurationBuilder setUrls(Collection<URL>... urlss)
use ClasspathHelper
convenient methods to get the relevant urls
public ConfigurationBuilder addUrls(Collection<URL> urls)
use ClasspathHelper
convenient methods to get the relevant urls
public ConfigurationBuilder addUrls(URL... urls)
use ClasspathHelper
convenient methods to get the relevant urls
public ConfigurationBuilder addUrls(Collection<URL>... urlss)
use ClasspathHelper
convenient methods to get the relevant urls
public MetadataAdapter getMetadataAdapter()
Configuration
getMetadataAdapter
in interface Configuration
public ConfigurationBuilder setMetadataAdapter(MetadataAdapter metadataAdapter)
public boolean acceptsInput(String inputFqn)
Configuration
acceptsInput
in interface Configuration
public ConfigurationBuilder filterInputsBy(com.google.common.base.Predicate<String> inputsFilter)
supply a Predicate
or use the FilterBuilder
public ExecutorService getExecutorService()
Configuration
getExecutorService
in interface Configuration
public ConfigurationBuilder setExecutorService(ExecutorService executorService)
public ConfigurationBuilder useParallelExecutor()
Runtime.availableProcessors()
default is ThreadPoolExecutor with a single core
public ConfigurationBuilder useParallelExecutor(int availableProcessors)
default is ThreadPoolExecutor with a single core
public Serializer getSerializer()
Configuration
getSerializer
in interface Configuration
public ConfigurationBuilder setSerializer(Serializer serializer)
Reflections.save(java.lang.String)
public ClassLoader[] getClassLoaders()
getClassLoaders
in interface Configuration
public ConfigurationBuilder addClassLoader(ClassLoader classLoader)
public ConfigurationBuilder addClassLoaders(ClassLoader... classLoaders)
public ConfigurationBuilder addClassLoaders(Collection<ClassLoader> classLoaders)
Copyright © 2012. All Rights Reserved.