Errai 3.0.1-SNAPSHOT

org.jboss.errai.reflections.util
Class ConfigurationBuilder

java.lang.Object
  extended by org.jboss.errai.reflections.util.ConfigurationBuilder
All Implemented Interfaces:
Configuration

public class ConfigurationBuilder
extends Object
implements Configuration

a fluent builder for 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 Summary
ConfigurationBuilder()
           
 
Method Summary
 boolean acceptsInput(String inputFqn)
          the fully qualified name filter used to filter types to be scanned
 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
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationBuilder

public ConfigurationBuilder()
Method Detail

getScanners

public Set<Scanner> getScanners()
Description copied from interface: Configuration
the scanner instances used for scanning different metadata

Specified by:
getScanners in interface Configuration

setScanners

public ConfigurationBuilder setScanners(Scanner... scanners)
set the scanners instances for scanning different metadata


getUrls

public Set<URL> getUrls()
Description copied from interface: Configuration
the urls to be scanned

Specified by:
getUrls in interface Configuration

setUrls

public ConfigurationBuilder setUrls(Collection<URL> urls)
set the urls to be scanned

use ClasspathHelper convenient methods to get the relevant urls


setUrls

public ConfigurationBuilder setUrls(URL... urls)
set the urls to be scanned

use ClasspathHelper convenient methods to get the relevant urls


setUrls

public ConfigurationBuilder setUrls(Collection<URL>... urlss)
set the urls to be scanned

use ClasspathHelper convenient methods to get the relevant urls


addUrls

public ConfigurationBuilder addUrls(Collection<URL> urls)
add urls to be scanned

use ClasspathHelper convenient methods to get the relevant urls


addUrls

public ConfigurationBuilder addUrls(URL... urls)
add urls to be scanned

use ClasspathHelper convenient methods to get the relevant urls


addUrls

public ConfigurationBuilder addUrls(Collection<URL>... urlss)
add urls to be scanned

use ClasspathHelper convenient methods to get the relevant urls


getMetadataAdapter

public MetadataAdapter getMetadataAdapter()
Description copied from interface: Configuration
the metadata adapter used to fetch metadata from classes

Specified by:
getMetadataAdapter in interface Configuration

setMetadataAdapter

public ConfigurationBuilder setMetadataAdapter(MetadataAdapter metadataAdapter)
sets the metadata adapter used to fetch metadata from classes


acceptsInput

public boolean acceptsInput(String inputFqn)
Description copied from interface: Configuration
the fully qualified name filter used to filter types to be scanned

Specified by:
acceptsInput in interface Configuration

filterInputsBy

public ConfigurationBuilder filterInputsBy(com.google.common.base.Predicate<String> inputsFilter)
sets the input filter for all resources to be scanned

supply a Predicate or use the FilterBuilder


getExecutorService

public ExecutorService getExecutorService()
Description copied from interface: Configuration
executor service used to scan files if null, scanning is done in a simple for loop

Specified by:
getExecutorService in interface Configuration

setExecutorService

public ConfigurationBuilder setExecutorService(ExecutorService executorService)
sets the executor service used for scanning.


useParallelExecutor

public ConfigurationBuilder useParallelExecutor()
sets the executor service used for scanning to ThreadPoolExecutor with core size as Runtime.availableProcessors()

default is ThreadPoolExecutor with a single core


useParallelExecutor

public ConfigurationBuilder useParallelExecutor(int availableProcessors)
sets the executor service used for scanning to ThreadPoolExecutor with core size as the given availableProcessors parameter

default is ThreadPoolExecutor with a single core


getSerializer

public Serializer getSerializer()
Description copied from interface: Configuration
the default serializer to use when saving Reflection

Specified by:
getSerializer in interface Configuration

setSerializer

public ConfigurationBuilder setSerializer(Serializer serializer)
sets the serializer used when issuing Reflections.save(java.lang.String)


Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.