public final class PluginHandler extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PluginHandler.DeprecatedPlugin
Description of a deprecated plugin
|
(package private) static class |
PluginHandler.PluginInformationAction |
private static class |
PluginHandler.UpdatePluginsMessagePanel |
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,PluginClassLoader> |
classLoaders
Plugin class loaders.
|
static int |
DEFAULT_TIME_BASED_UPDATE_INTERVAL
Default time-based update interval, in days (pluginmanager.time-based-update.interval)
|
(package private) static java.util.Collection<PluginHandler.DeprecatedPlugin> |
DEPRECATED_PLUGINS
Deprecated plugins that are removed on start
|
private static DynamicURLClassLoader |
joinedPluginResourceCL
Class loader to locate resources from plugins.
|
private static PluginDownloadTask |
pluginDownloadTask |
(package private) static java.util.Collection<PluginProxy> |
pluginList
All installed and loaded plugins (resp.
|
(package private) static java.util.Collection<PluginInformation> |
pluginListNotLoaded
All installed but not loaded plugins
|
(package private) static java.util.Map<java.lang.String,java.lang.Throwable> |
pluginLoadingExceptions
All exceptions that occurred during plugin loading
|
private static java.util.List<java.lang.ClassLoader> |
sources
Add here all ClassLoader whose resource should be searched.
|
(package private) static java.util.List<java.lang.String> |
UNMAINTAINED_PLUGINS
List of unmaintained plugins.
|
Modifier | Constructor and Description |
---|---|
private |
PluginHandler() |
Modifier and Type | Method and Description |
---|---|
static void |
addDownloadSelection(java.util.List<DownloadSelection> downloadSelections)
Called in the download dialog to give the plugins a chance to modify the list
of bounding box selectors.
|
private static void |
alertFailedPluginUpdate(java.awt.Component parent,
java.util.Collection<PluginInformation> plugins) |
private static void |
alertJOSMUpdateRequired(java.awt.Component parent,
java.lang.String plugin,
int requiredVersion) |
private static void |
alertMissingPluginInformation(java.awt.Component parent,
java.util.Collection<java.lang.String> plugins) |
private static void |
alertMissingRequiredPlugin(java.awt.Component parent,
java.lang.String plugin,
java.util.Set<java.lang.String> missingRequiredPlugin)
Alerts the user if a plugin required by another plugin is missing, and offer to download them & restart JOSM
|
private static int |
askUpdateDisableKeepPluginAfterException(PluginProxy plugin) |
static java.util.List<PluginInformation> |
buildListOfPluginsToLoad(java.awt.Component parent,
ProgressMonitor monitor)
Builds the set of plugins to load.
|
static boolean |
checkAndConfirmPluginUpdate(java.awt.Component parent)
Checks whether the locally available plugins should be updated and
asks the user if running an update is OK.
|
static boolean |
checkLoadPreconditions(java.awt.Component parent,
java.util.Collection<PluginInformation> plugins,
PluginInformation plugin)
Checks whether all preconditions for loading the plugin
plugin are met. |
private static boolean |
checkOfflineAccess() |
static boolean |
checkRequiredPluginsPreconditions(java.awt.Component parent,
java.util.Collection<PluginInformation> plugins,
PluginInformation plugin,
boolean local)
Checks if required plugins preconditions for loading the plugin
plugin are met. |
static boolean |
confirmDisablePlugin(java.awt.Component parent,
java.lang.String reason,
java.lang.String name)
Ask the user for confirmation that a plugin shall be disabled.
|
private static void |
downloadRequiredPluginsAndRestart(java.awt.Component parent,
java.util.Set<java.lang.String> missingRequiredPlugin) |
private static void |
extendJoinedPluginResourceCL(java.util.Collection<PluginInformation> plugins)
Add more plugins to the joined plugin resource class loader.
|
(package private) static void |
filterDeprecatedPlugins(java.awt.Component parent,
java.util.Collection<java.lang.String> plugins)
Removes deprecated plugins from a collection of plugins.
|
(package private) static void |
filterUnmaintainedPlugins(java.awt.Component parent,
java.util.Collection<java.lang.String> plugins)
Removes unmaintained plugins from a collection of plugins.
|
private static java.util.Set<PluginInformation> |
findRequiredPluginsToDownload(java.util.Collection<PluginInformation> pluginsToUpdate,
java.util.List<PluginInformation> allPlugins,
java.util.Set<PluginInformation> pluginsToDownload) |
static java.io.File |
findUpdatedJar(java.lang.String name)
Replies the updated jar file for the given plugin name.
|
static java.util.Collection<java.lang.String> |
getBugReportInformation()
Returns the list of loaded plugins as a
String to be displayed in status report. |
static java.util.Set<java.lang.String> |
getDeprecatedAndUnmaintainedPlugins()
Returns the set of deprecated and unmaintained plugins.
|
static javax.swing.JPanel |
getInfoPanel()
Returns the list of loaded plugins as a
JPanel to be displayed in About dialog. |
private static DynamicURLClassLoader |
getJoinedPluginResourceCL()
Get class loader to locate resources from plugins.
|
static java.lang.Object |
getPlugin(java.lang.String name)
Returns the plugin of the specified name.
|
private static PluginProxy |
getPluginCausingException(java.lang.Throwable ex)
Replies the plugin which most likely threw the exception
ex . |
static PluginClassLoader |
getPluginClassLoader(java.lang.String name)
Returns the plugin class loader for the plugin of the specified name.
|
static java.util.Collection<PluginClassLoader> |
getPluginClassLoaders()
Returns all plugin classloaders.
|
static java.util.List<PluginInformation> |
getPlugins()
Returns the list of currently installed and loaded plugins, sorted by name.
|
static java.util.Collection<PreferenceSettingFactory> |
getPreferenceSetting()
Returns the list of plugin preference settings.
|
static java.util.Collection<java.lang.ClassLoader> |
getResourceClassLoaders()
Returns all ClassLoaders whose resource should be searched.
|
static void |
installDownloadedPlugins(java.util.Collection<PluginInformation> pluginsToLoad,
boolean dowarn)
Installs downloaded plugins.
|
private static boolean |
isDependency(PluginInformation pi,
java.lang.String depName) |
static boolean |
isValidJar(java.io.File jar)
Determines if the specified file is a valid and accessible JAR file.
|
static void |
loadEarlyPlugins(java.awt.Component parent,
java.util.Collection<PluginInformation> plugins,
ProgressMonitor monitor)
Loads plugins from
plugins which have the flag PluginInformation.early set to true. |
static void |
loadLatePlugins(java.awt.Component parent,
java.util.Collection<PluginInformation> plugins,
ProgressMonitor monitor)
Loads plugins from
plugins which have the flag PluginInformation.early set to false. |
private static java.util.Map<java.lang.String,PluginInformation> |
loadLocallyAvailablePluginInformation(ProgressMonitor monitor)
Loads locally available plugin information from local plugin jars and from cached
plugin lists.
|
private static void |
loadPlugin(java.awt.Component parent,
PluginInformation plugin,
PluginClassLoader pluginClassLoader)
Loads and instantiates the plugin described by
plugin using
the class loader pluginClassLoader . |
static void |
loadPlugins(java.awt.Component parent,
java.util.Collection<PluginInformation> plugins,
ProgressMonitor monitor)
Loads the plugin in
plugins from locally available jar files into memory. |
private static void |
logJavaUpdateRequired(java.lang.String plugin,
int requiredVersion) |
private static void |
logWrongPlatform(java.lang.String plugin,
java.lang.String pluginPlatform) |
static void |
refreshLocalUpdatedPluginInfo(java.util.Collection<PluginInformation> updatedPlugins)
Refreshes the given PluginInformation objects with new contents read from their corresponding jar file.
|
static boolean |
removePlugins(java.util.List<PluginInformation> deactivatedPlugins)
Remove deactivated plugins, returning true if JOSM should restart
|
static PluginDownloadTask |
updateOrdisablePluginAfterException(java.lang.Throwable e)
Checks whether the exception
e was thrown by a plugin. |
static java.util.Collection<PluginInformation> |
updatePlugins(java.awt.Component parent,
java.util.Collection<PluginInformation> pluginsWanted,
ProgressMonitor monitor,
boolean displayErrMsg)
Updates the plugins in
plugins . |
static final java.util.Collection<PluginHandler.DeprecatedPlugin> DEPRECATED_PLUGINS
static final java.util.List<java.lang.String> UNMAINTAINED_PLUGINS
public static final int DEFAULT_TIME_BASED_UPDATE_INTERVAL
static final java.util.Collection<PluginProxy> pluginList
static final java.util.Collection<PluginInformation> pluginListNotLoaded
static final java.util.Map<java.lang.String,java.lang.Throwable> pluginLoadingExceptions
private static DynamicURLClassLoader joinedPluginResourceCL
getJoinedPluginResourceCL()
private static final java.util.List<java.lang.ClassLoader> sources
private static final java.util.Map<java.lang.String,PluginClassLoader> classLoaders
private static PluginDownloadTask pluginDownloadTask
private PluginHandler()
public static java.util.List<PluginInformation> getPlugins()
public static java.util.Collection<java.lang.ClassLoader> getResourceClassLoaders()
public static java.util.Collection<PluginClassLoader> getPluginClassLoaders()
static void filterDeprecatedPlugins(java.awt.Component parent, java.util.Collection<java.lang.String> plugins)
plugins
.
Also notifies the user about removed deprecated pluginsparent
- The parent Component used to display warning popupplugins
- the collection of pluginsstatic void filterUnmaintainedPlugins(java.awt.Component parent, java.util.Collection<java.lang.String> plugins)
plugins
. Also removes the plugin from the list
of plugins in the preferences, if necessary.
Asks the user for every unmaintained plugin whether it should be removed.parent
- The parent Component used to display warning popupplugins
- the collection of pluginspublic static boolean checkAndConfirmPluginUpdate(java.awt.Component parent)
parent
- the parent component relative to which the confirmation dialog
is to be displayedprivate static boolean checkOfflineAccess()
private static void alertMissingRequiredPlugin(java.awt.Component parent, java.lang.String plugin, java.util.Set<java.lang.String> missingRequiredPlugin)
parent
- The parent Component used to display error popupplugin
- the pluginmissingRequiredPlugin
- the missing required pluginprivate static void downloadRequiredPluginsAndRestart(java.awt.Component parent, java.util.Set<java.lang.String> missingRequiredPlugin)
private static void logWrongPlatform(java.lang.String plugin, java.lang.String pluginPlatform)
private static void logJavaUpdateRequired(java.lang.String plugin, int requiredVersion)
private static void alertJOSMUpdateRequired(java.awt.Component parent, java.lang.String plugin, int requiredVersion)
public static boolean checkLoadPreconditions(java.awt.Component parent, java.util.Collection<PluginInformation> plugins, PluginInformation plugin)
plugin
are met. The
current Java and JOSM versions must be compatible with the plugin and no other plugins this plugin
depends on should be missing.parent
- The parent Component used to display error popupplugins
- the collection of all loaded pluginsplugin
- the plugin for which preconditions are checkedpublic static boolean checkRequiredPluginsPreconditions(java.awt.Component parent, java.util.Collection<PluginInformation> plugins, PluginInformation plugin, boolean local)
plugin
are met.
No other plugins this plugin depends on should be missing.parent
- The parent Component used to display error popup. If parent is
null, the error popup is suppressedplugins
- the collection of all processed pluginsplugin
- the plugin for which preconditions are checkedlocal
- Determines if the local or up-to-date plugin dependencies are to be checked.private static DynamicURLClassLoader getJoinedPluginResourceCL()
PluginClassLoader
for that purpose.)private static void extendJoinedPluginResourceCL(java.util.Collection<PluginInformation> plugins)
plugins
- the plugins to addprivate static void loadPlugin(java.awt.Component parent, PluginInformation plugin, PluginClassLoader pluginClassLoader)
plugin
using
the class loader pluginClassLoader
.parent
- The parent component to be used for the displayed dialogplugin
- the pluginpluginClassLoader
- the plugin class loaderpublic static void loadPlugins(java.awt.Component parent, java.util.Collection<PluginInformation> plugins, ProgressMonitor monitor)
plugins
from locally available jar files into memory.parent
- The parent component to be used for the displayed dialogplugins
- the list of pluginsmonitor
- the progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null.private static boolean isDependency(PluginInformation pi, java.lang.String depName)
public static void loadEarlyPlugins(java.awt.Component parent, java.util.Collection<PluginInformation> plugins, ProgressMonitor monitor)
plugins
which have the flag PluginInformation.early
set to true.parent
- The parent component to be used for the displayed dialogplugins
- the collection of pluginsmonitor
- the progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null.public static void loadLatePlugins(java.awt.Component parent, java.util.Collection<PluginInformation> plugins, ProgressMonitor monitor)
plugins
which have the flag PluginInformation.early
set to false.parent
- The parent component to be used for the displayed dialogplugins
- the collection of pluginsmonitor
- the progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null.private static java.util.Map<java.lang.String,PluginInformation> loadLocallyAvailablePluginInformation(ProgressMonitor monitor)
monitor
- the progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null.private static void alertMissingPluginInformation(java.awt.Component parent, java.util.Collection<java.lang.String> plugins)
public static java.util.List<PluginInformation> buildListOfPluginsToLoad(java.awt.Component parent, ProgressMonitor monitor)
parent
- The parent component to be used for the displayed dialogmonitor
- the progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null.private static void alertFailedPluginUpdate(java.awt.Component parent, java.util.Collection<PluginInformation> plugins)
private static java.util.Set<PluginInformation> findRequiredPluginsToDownload(java.util.Collection<PluginInformation> pluginsToUpdate, java.util.List<PluginInformation> allPlugins, java.util.Set<PluginInformation> pluginsToDownload)
public static java.util.Collection<PluginInformation> updatePlugins(java.awt.Component parent, java.util.Collection<PluginInformation> pluginsWanted, ProgressMonitor monitor, boolean displayErrMsg)
plugins
.parent
- the parent component for message boxespluginsWanted
- the collection of plugins to update. Updates all plugins if null
monitor
- the progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null.displayErrMsg
- if true
, a blocking error message is displayed in case of I/O exception.java.lang.IllegalArgumentException
- if plugins is nullpublic static boolean confirmDisablePlugin(java.awt.Component parent, java.lang.String reason, java.lang.String name)
parent
- The parent component to be used for the displayed dialogreason
- the reason for disabling the pluginname
- the plugin namepublic static java.lang.Object getPlugin(java.lang.String name)
name
- The plugin namenull
otherwise.public static PluginClassLoader getPluginClassLoader(java.lang.String name)
name
- The plugin namenull
otherwise.public static void addDownloadSelection(java.util.List<DownloadSelection> downloadSelections)
downloadSelections
- list of bounding box selectorspublic static java.util.Collection<PreferenceSettingFactory> getPreferenceSetting()
public static void installDownloadedPlugins(java.util.Collection<PluginInformation> pluginsToLoad, boolean dowarn)
dowarn
is true, this methods emits warning messages on the console if a downloaded
but not yet installed plugin .jar can't be be installed. If dowarn
is false, the
installation of the respective plugin is silently skipped.pluginsToLoad
- list of plugin informations to updatedowarn
- if true, warning messages are displayed; false otherwisepublic static boolean isValidJar(java.io.File jar)
jar
- The file to checkpublic static java.io.File findUpdatedJar(java.lang.String name)
name
- The plugin name to find.public static void refreshLocalUpdatedPluginInfo(java.util.Collection<PluginInformation> updatedPlugins)
updatedPlugins
- The PluginInformation objects to update.private static int askUpdateDisableKeepPluginAfterException(PluginProxy plugin)
private static PluginProxy getPluginCausingException(java.lang.Throwable ex)
ex
.ex
- the exceptionpublic static PluginDownloadTask updateOrdisablePluginAfterException(java.lang.Throwable e)
e
was thrown by a plugin. If so,
conditionally updates or deactivates the plugin, but asks the user first.e
- the exceptionnull
if it has been disabled or kept as itpublic static java.util.Collection<java.lang.String> getBugReportInformation()
String
to be displayed in status report. Useful for bug reports.public static javax.swing.JPanel getInfoPanel()
JPanel
to be displayed in About dialog.public static java.util.Set<java.lang.String> getDeprecatedAndUnmaintainedPlugins()
public static boolean removePlugins(java.util.List<PluginInformation> deactivatedPlugins)
deactivatedPlugins
- The plugins to deactivate