Class ModuleAutoFinder

java.lang.Object
org.opt4j.config.ModuleAutoFinder
All Implemented Interfaces:
ModuleList

public class ModuleAutoFinder extends Object implements ModuleList
The ModuleAutoFinder searches the classpath for all PropertyModules that are not annotated with Ignore.
  • Field Details

    • 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 Details

    • ModuleAutoFinder

      @Inject public ModuleAutoFinder()
      Constructs a ModuleAutoFinder.
    • 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 a ModuleAutoFinder.
      Parameters:
      accept - the accept transformer
      ignore - the ignore transformer
      directories - additional directories for the classpath
  • Method Details

    • 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 interface ModuleList
      Returns:
      the classes of all modules
    • getAll

      protected Collection<Class<? extends com.google.inject.Module>> getAll()
      Returns all not abstract classes that implement PropertyModule.
      Returns:
      all property modules
    • isJar

      protected boolean isJar(File file)
      Returns true 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 one directory.
      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 directory
      file - the current file
      Returns:
      the list of all found classes
    • getAllClasses

      protected List<Class<?>> getAllClasses(ZipFile zipFile)
      Retrieves all Classes from a ZipFile (Jar archive).
      Parameters:
      zipFile - the Jar archive
      Returns:
      the list of all classes
    • invokeOut

      protected void invokeOut(String message)
      Invoke an out message for the ModuleAutoFinderListener.
      Parameters:
      message - the message
    • invokeErr

      protected void invokeErr(String message)
      Invoke an err message for the ModuleAutoFinderListener.
      Parameters:
      message - the message
    • addListener

      public void addListener(ModuleAutoFinderListener listener)
      Parameters:
      listener - the listener to be added
    • removeListener

      public void removeListener(ModuleAutoFinderListener listener)
      Parameters:
      listener - the listener to be removed
      See Also: