edu.umd.cs.findbugs
Class DetectorFactoryCollection

java.lang.Object
  extended by edu.umd.cs.findbugs.DetectorFactoryCollection

public class DetectorFactoryCollection
extends java.lang.Object

The DetectorFactoryCollection stores all of the DetectorFactory objects used to create the Detectors which implement the various analyses. It is a singleton class.

Author:
David Hovemeyer
See Also:
DetectorFactory

Field Summary
private  java.util.HashMap<java.lang.String,DetectorFactory> factoriesByDetectorClassName
           
private  java.util.HashMap<java.lang.String,DetectorFactory> factoriesByName
           
private  java.util.ArrayList<DetectorFactory> factoryList
           
private static java.lang.Object lock
           
private  java.util.HashMap<java.lang.String,Plugin> pluginByIdMap
           
private static java.io.File[] pluginList
           
private static DetectorFactoryCollection theInstance
           
 
Constructor Summary
private DetectorFactoryCollection()
          Constructor.
 
Method Summary
 void disableAll()
          Disable all detectors.
 void enableAll()
          Enable all detectors.
private  void enableAll(boolean enabled)
           
 java.util.Iterator<DetectorFactory> factoryIterator()
          Return an Iterator over the DetectorFactory objects for all registered Detectors.
 DetectorFactory getFactory(java.lang.String name)
          Look up a DetectorFactory by its short name.
 DetectorFactory getFactoryByClassName(java.lang.String className)
          Look up a DetectorFactory by its class name.
 Plugin getPluginById(java.lang.String pluginId)
          Get a Plugin by its unique id.
static DetectorFactoryCollection instance()
          Get the single instance of DetectorFactoryCollection.
private  void loadPlugins()
          Load all plugins.
 java.util.Iterator<Plugin> pluginIterator()
          Return an Iterator over all available Plugin objects.
private  void registerDetector(DetectorFactory factory)
          Register a DetectorFactory.
static void setPluginList(java.io.File[] pluginList)
          Set the list of plugins to load explicitly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pluginByIdMap

private java.util.HashMap<java.lang.String,Plugin> pluginByIdMap

factoryList

private java.util.ArrayList<DetectorFactory> factoryList

factoriesByName

private java.util.HashMap<java.lang.String,DetectorFactory> factoriesByName

factoriesByDetectorClassName

private java.util.HashMap<java.lang.String,DetectorFactory> factoriesByDetectorClassName

theInstance

private static DetectorFactoryCollection theInstance

lock

private static final java.lang.Object lock

pluginList

private static java.io.File[] pluginList
Constructor Detail

DetectorFactoryCollection

private DetectorFactoryCollection()
Constructor.

Method Detail

setPluginList

public static void setPluginList(java.io.File[] pluginList)
Set the list of plugins to load explicitly. This must be done before the instance of DetectorFactoryCollection is created.

Parameters:
pluginList - list of plugin Jar files to load

instance

public static DetectorFactoryCollection instance()
Get the single instance of DetectorFactoryCollection.


pluginIterator

public java.util.Iterator<Plugin> pluginIterator()
Return an Iterator over all available Plugin objects.


getPluginById

public Plugin getPluginById(java.lang.String pluginId)
Get a Plugin by its unique id.

Parameters:
pluginId - the unique id
Returns:
the Plugin with that id, or null if no such Plugin is found

factoryIterator

public java.util.Iterator<DetectorFactory> factoryIterator()
Return an Iterator over the DetectorFactory objects for all registered Detectors.


getFactory

public DetectorFactory getFactory(java.lang.String name)
Look up a DetectorFactory by its short name.

Parameters:
name - the short name
Returns:
the DetectorFactory, or null if there is no factory with that short name

getFactoryByClassName

public DetectorFactory getFactoryByClassName(java.lang.String className)
Look up a DetectorFactory by its class name.

Parameters:
className - the class name
Returns:
the DetectoryFactory, or null if there is no factory with that class name

disableAll

public void disableAll()
Disable all detectors.


enableAll

public void enableAll()
Enable all detectors.


enableAll

private void enableAll(boolean enabled)

registerDetector

private void registerDetector(DetectorFactory factory)
Register a DetectorFactory.


loadPlugins

private void loadPlugins()
Load all plugins. If a setPluginList() has been called, then those plugins are loaded. Otherwise, the "findbugs.home" property is checked to determine where FindBugs is installed, and the plugin files are dynamically loaded from the plugin directory.