Package org.opt4j.config
Class ModuleAutoFinder
- java.lang.Object
-
- org.opt4j.config.ModuleAutoFinder
-
- All Implemented Interfaces:
ModuleList
public class ModuleAutoFinder extends Object implements ModuleList
TheModuleAutoFinder
searches the classpath for allPropertyModule
s that are not annotated withIgnore
.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.collections15.Transformer<Class<? extends com.google.inject.Module>,Boolean>
accept
protected ClassLoader
classLoader
protected Collection<String>
directories
protected org.apache.commons.collections15.Transformer<Class<? extends com.google.inject.Module>,Boolean>
ignore
protected Set<ModuleAutoFinderListener>
listeners
-
Constructor Summary
Constructors Constructor Description ModuleAutoFinder()
Constructs aModuleAutoFinder
.ModuleAutoFinder(org.apache.commons.collections15.Transformer<Class<? extends com.google.inject.Module>,Boolean> accept, org.apache.commons.collections15.Transformer<Class<? extends com.google.inject.Module>,Boolean> ignore, Collection<String> directories)
Constructs aModuleAutoFinder
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(ModuleAutoFinderListener listener)
Add aModuleAutoFinderListener
.protected Collection<Class<? extends com.google.inject.Module>>
getAll()
Returns all not abstract classes that implementPropertyModule
.protected List<Class<?>>
getAllClasses(File directory)
Retrieves all Classes from onedirectory
.protected List<Class<?>>
getAllClasses(File root, File file)
Recursive methods searching for classes in a root directory.protected List<Class<?>>
getAllClasses(ZipFile zipFile)
Retrieves all Classes from aZipFile
(Jar archive).Collection<Class<? extends com.google.inject.Module>>
getModules()
Returns the classes of all modules.protected void
invokeErr(String message)
Invoke an err message for theModuleAutoFinderListener
.protected void
invokeOut(String message)
Invoke an out message for theModuleAutoFinderListener
.protected boolean
isJar(File file)
Returnstrue
if the file is a Jar archive.void
removeListener(ModuleAutoFinderListener listener)
Remove aModuleAutoFinderListener
.
-
-
-
Field Detail
-
accept
protected final org.apache.commons.collections15.Transformer<Class<? extends com.google.inject.Module>,Boolean> accept
-
ignore
protected final org.apache.commons.collections15.Transformer<Class<? extends com.google.inject.Module>,Boolean> ignore
-
listeners
protected final Set<ModuleAutoFinderListener> listeners
-
directories
protected final Collection<String> directories
-
classLoader
protected ClassLoader classLoader
-
-
Constructor Detail
-
ModuleAutoFinder
@Inject public ModuleAutoFinder()
Constructs aModuleAutoFinder
.
-
ModuleAutoFinder
public ModuleAutoFinder(org.apache.commons.collections15.Transformer<Class<? extends com.google.inject.Module>,Boolean> accept, org.apache.commons.collections15.Transformer<Class<? extends com.google.inject.Module>,Boolean> ignore, Collection<String> directories)
Constructs aModuleAutoFinder
.- Parameters:
accept
- the accept transformerignore
- the ignore transformerdirectories
- additional directories for the classpath
-
-
Method Detail
-
getModules
public Collection<Class<? extends com.google.inject.Module>> getModules()
Description copied from interface:ModuleList
Returns the classes of all modules.- Specified by:
getModules
in interfaceModuleList
- Returns:
- the classes of all modules
-
getAll
protected Collection<Class<? extends com.google.inject.Module>> getAll()
Returns all not abstract classes that implementPropertyModule
.- Returns:
- all property modules
-
isJar
protected boolean isJar(File file)
Returnstrue
if the file is a Jar archive.- Parameters:
file
- the tested file- Returns:
true
if the file is a Jar archive
-
getAllClasses
protected List<Class<?>> getAllClasses(File directory)
Retrieves all Classes from onedirectory
.- Parameters:
directory
- the directory- Returns:
- all classes in a list
-
getAllClasses
protected List<Class<?>> getAllClasses(File root, File file)
Recursive methods searching for classes in a root directory.- Parameters:
root
- the root directoryfile
- the current file- Returns:
- the list of all found classes
-
getAllClasses
protected List<Class<?>> getAllClasses(ZipFile zipFile)
Retrieves all Classes from aZipFile
(Jar archive).- Parameters:
zipFile
- the Jar archive- Returns:
- the list of all classes
-
invokeOut
protected void invokeOut(String message)
Invoke an out message for theModuleAutoFinderListener
.- Parameters:
message
- the message
-
invokeErr
protected void invokeErr(String message)
Invoke an err message for theModuleAutoFinderListener
.- Parameters:
message
- the message
-
addListener
public void addListener(ModuleAutoFinderListener listener)
Add aModuleAutoFinderListener
.- Parameters:
listener
- the listener to be added
-
removeListener
public void removeListener(ModuleAutoFinderListener listener)
Remove aModuleAutoFinderListener
.- Parameters:
listener
- the listener to be removed- See Also:
addListener(org.opt4j.config.ModuleAutoFinderListener)
-
-