Package com.google.gerrit.server.plugins
Class JarScanner
- java.lang.Object
-
- com.google.gerrit.server.plugins.JarScanner
-
- All Implemented Interfaces:
PluginContentScanner
,AutoCloseable
public class JarScanner extends Object implements PluginContentScanner, AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JarScanner.ClassData
-
Nested classes/interfaces inherited from interface com.google.gerrit.server.plugins.PluginContentScanner
PluginContentScanner.ExtensionMetaData
-
-
Field Summary
-
Fields inherited from interface com.google.gerrit.server.plugins.PluginContentScanner
EMPTY
-
-
Constructor Summary
Constructors Constructor Description JarScanner(Path src)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Enumeration<PluginEntry>
entries()
Return all the resources inside a pluginList<String>
findSubClassesOf(Class<?> superClass)
Optional<PluginEntry>
getEntry(String resourcePath)
Return the plugin resource associated to a pathInputStream
getInputStream(PluginEntry entry)
Return the InputStream of the resource entryManifest
getManifest()
Return the plugin meta-data manifestMap<Class<? extends Annotation>,Iterable<PluginContentScanner.ExtensionMetaData>>
scan(String pluginName, Iterable<Class<? extends Annotation>> annotations)
Scans the plugin for declared public annotated classes
-
-
-
Constructor Detail
-
JarScanner
public JarScanner(Path src) throws IOException
- Throws:
IOException
-
-
Method Detail
-
scan
public Map<Class<? extends Annotation>,Iterable<PluginContentScanner.ExtensionMetaData>> scan(String pluginName, Iterable<Class<? extends Annotation>> annotations) throws InvalidPluginException
Description copied from interface:PluginContentScanner
Scans the plugin for declared public annotated classes- Specified by:
scan
in interfacePluginContentScanner
- Parameters:
pluginName
- the plugin nameannotations
- annotations declared by the plugin classes- Returns:
- map of annotations and associated plugin classes found
- Throws:
InvalidPluginException
- if the plugin is not valid or corrupted
-
findSubClassesOf
public List<String> findSubClassesOf(Class<?> superClass) throws IOException
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getEntry
public Optional<PluginEntry> getEntry(String resourcePath) throws IOException
Description copied from interface:PluginContentScanner
Return the plugin resource associated to a path- Specified by:
getEntry
in interfacePluginContentScanner
- Parameters:
resourcePath
- full path of the resource inside the plugin package- Returns:
- the resource object or Optional.absent() if the resource was not found
- Throws:
IOException
- if there was a problem retrieving the resource
-
entries
public Enumeration<PluginEntry> entries()
Description copied from interface:PluginContentScanner
Return all the resources inside a plugin- Specified by:
entries
in interfacePluginContentScanner
- Returns:
- the enumeration of all resources found
-
getInputStream
public InputStream getInputStream(PluginEntry entry) throws IOException
Description copied from interface:PluginContentScanner
Return the InputStream of the resource entry- Specified by:
getInputStream
in interfacePluginContentScanner
- Parameters:
entry
- resource entry inside the plugin package- Returns:
- the resource input stream
- Throws:
IOException
- if there was an I/O problem accessing the resource
-
getManifest
public Manifest getManifest() throws IOException
Description copied from interface:PluginContentScanner
Return the plugin meta-data manifest- Specified by:
getManifest
in interfacePluginContentScanner
- Returns:
- Manifest of the plugin or null if plugin has no meta-data
- Throws:
IOException
- if an I/O problem occurred whilst accessing the Manifest
-
-