Package edu.umd.cs.findbugs
Class PluginLoader
- java.lang.Object
-
- edu.umd.cs.findbugs.PluginLoader
-
public class PluginLoader extends java.lang.Object
Loader for a FindBugs plugin. A plugin is a jar file containing two metadata files, "findbugs.xml" and "messages.xml". Those files specify- the bug pattern Detector classes,
- the bug patterns detected (including all text for displaying detected instances of those patterns), and
- the "bug codes" which group together related bug instances
The PluginLoader creates a Plugin object to store the Detector factories and metadata.
- Author:
- David Hovemeyer
- See Also:
Plugin
,PluginException
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PluginLoader.Summary
-
Constructor Summary
Constructors Constructor Description PluginLoader()
Deprecated.PluginLoader(boolean fake, java.net.URL url)
Deprecated.PluginLoader(java.net.URL url)
Deprecated.PluginLoader(java.net.URL url, java.lang.ClassLoader parent)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ClassLoader
getClassLoader()
static PluginLoader
getCorePluginLoader()
Plugin
getPlugin()
org.dom4j.Document
getPluginDescriptor()
static PluginLoader
getPluginLoader(java.net.URL url, java.lang.ClassLoader parent, boolean isInitial, boolean optional)
java.net.URL
getResource(java.lang.String name)
Get a resource using the URLClassLoader classLoader.java.net.URI
getURI()
java.net.URL
getURL()
boolean
hasParent()
boolean
isCorePlugin()
static java.net.URL
loadFromFindBugsEtcDir(java.lang.String name)
static java.net.URL
loadFromFindBugsPluginDir(java.lang.String name)
Plugin
loadPlugin()
Get the Plugin.java.lang.String
toString()
static PluginLoader.Summary
validate(java.io.File file)
-
-
-
Constructor Detail
-
PluginLoader
@Deprecated public PluginLoader(java.net.URL url) throws PluginException
Deprecated.Constructor.- Parameters:
url
- the URL of the plugin Jar file- Throws:
PluginException
- if the plugin cannot be fully loaded
-
PluginLoader
@Deprecated public PluginLoader(java.net.URL url, java.lang.ClassLoader parent) throws PluginException
Deprecated.Constructor.- Parameters:
url
- the URL of the plugin Jar fileparent
- the parent classloader- Throws:
PluginException
-
PluginLoader
@Deprecated public PluginLoader() throws PluginException
Deprecated.Constructor. Loads a plugin using the caller's class loader. This constructor should only be used to load the "core" findbugs detectors, which are built into findbugs.jar.- Throws:
PluginException
-
PluginLoader
@Deprecated public PluginLoader(boolean fake, java.net.URL url)
Deprecated.Fake plugin.
-
-
Method Detail
-
hasParent
public boolean hasParent()
-
getURL
public java.net.URL getURL()
-
getURI
public java.net.URI getURI()
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
-
loadPlugin
public Plugin loadPlugin() throws PluginException
Get the Plugin.- Throws:
PluginException
- if the plugin cannot be fully loaded
-
getPlugin
public Plugin getPlugin()
-
getResource
public java.net.URL getResource(java.lang.String name)
Get a resource using the URLClassLoader classLoader. We try findResource first because (based on experiment) we can trust it to prefer resources in the jarfile to resources on the filesystem. Simply calling classLoader.getResource() allows the filesystem to override the jarfile, which can mess things up if, for example, there is a findbugs.xml or messages.xml in the current directory.- Parameters:
name
- resource to get- Returns:
- URL for the resource, or null if it could not be found
-
loadFromFindBugsEtcDir
@CheckForNull public static java.net.URL loadFromFindBugsEtcDir(java.lang.String name)
-
loadFromFindBugsPluginDir
@CheckForNull public static java.net.URL loadFromFindBugsPluginDir(java.lang.String name)
-
getPluginDescriptor
public org.dom4j.Document getPluginDescriptor() throws PluginException, PluginDoesntContainMetadataException
-
getPluginLoader
public static PluginLoader getPluginLoader(java.net.URL url, java.lang.ClassLoader parent, boolean isInitial, boolean optional) throws PluginException
- Throws:
PluginException
-
getCorePluginLoader
@Nonnull public static PluginLoader getCorePluginLoader()
-
isCorePlugin
public boolean isCorePlugin()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
validate
public static PluginLoader.Summary validate(java.io.File file) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
-