public final class PluginHandler extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PluginHandler.DeprecatedPlugin
Description of a deprecated plugin
|
static class |
PluginHandler.DynamicURLClassLoader
ClassLoader that makes the addURL method of URLClassLoader public.
|
private static class |
PluginHandler.UpdatePluginsMessagePanel |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TIME_BASED_UPDATE_INTERVAL
Default time-based update interval, in days (pluginmanager.time-based-update.interval)
|
protected static java.util.Collection<PluginHandler.DeprecatedPlugin> |
DEPRECATED_PLUGINS
Deprecated plugins that are removed on start
|
private static PluginHandler.DynamicURLClassLoader |
pluginClassLoader
Global plugin ClassLoader.
|
private static PluginDownloadTask |
pluginDownloadTask |
static java.util.Collection<PluginProxy> |
pluginList
All installed and loaded plugins (resp.
|
static java.util.Map<java.lang.String,java.lang.Exception> |
pluginLoadingExceptions
All exceptions that occured during plugin loading
|
private static java.util.List<java.lang.ClassLoader> |
sources
Add here all ClassLoader whose resource should be searched.
|
private static 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) |
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) |
static void |
extendPluginClassLoader(java.util.Collection<PluginInformation> plugins)
Add more plugins to the plugin class loader.
|
private static void |
filterDeprecatedPlugins(java.awt.Component parent,
java.util.Collection<java.lang.String> plugins)
Removes deprecated plugins from a collection of plugins.
|
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.lang.String |
getBugReportText()
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. |
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 PluginHandler.DynamicURLClassLoader |
getPluginClassLoader()
Get the class loader for loading plugin code.
|
static java.util.Collection<PreferenceSettingFactory> |
getPreferenceSetting() |
static java.util.Collection<java.lang.ClassLoader> |
getResourceClassLoaders() |
static void |
installDownloadedPlugins(boolean dowarn)
Installs downloaded plugins.
|
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.
|
static void |
loadPlugin(java.awt.Component parent,
PluginInformation plugin,
java.lang.ClassLoader 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. |
static void |
refreshLocalUpdatedPluginInfo(java.util.Collection<PluginInformation> updatedPlugins)
Refreshes the given PluginInformation objects with new contents read from their corresponding jar file.
|
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 . |
protected static final java.util.Collection<PluginHandler.DeprecatedPlugin> DEPRECATED_PLUGINS
private static final java.lang.String[] UNMAINTAINED_PLUGINS
public static final int DEFAULT_TIME_BASED_UPDATE_INTERVAL
public static final java.util.Collection<PluginProxy> pluginList
public static final java.util.Map<java.lang.String,java.lang.Exception> pluginLoadingExceptions
private static PluginHandler.DynamicURLClassLoader pluginClassLoader
private static final java.util.List<java.lang.ClassLoader> sources
private static PluginDownloadTask pluginDownloadTask
private PluginHandler()
public static java.util.Collection<java.lang.ClassLoader> getResourceClassLoaders()
private 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 pluginsprivate static 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 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 JOSM version 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 loaded pluginsplugin
- the plugin for which preconditions are checkedlocal
- Determines if the local or up-to-date plugin dependencies are to be checked.public static PluginHandler.DynamicURLClassLoader getPluginClassLoader()
public static void extendPluginClassLoader(java.util.Collection<PluginInformation> plugins)
plugins
- the plugins that should be handled by the plugin class loaderpublic static void loadPlugin(java.awt.Component parent, PluginInformation plugin, java.lang.ClassLoader 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.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 void addDownloadSelection(java.util.List<DownloadSelection> downloadSelections)
public static java.util.Collection<PreferenceSettingFactory> getPreferenceSetting()
public static void installDownloadedPlugins(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.dowarn
- if true, warning messages are displayed; false otherwisepublic static boolean isValidJar(java.io.File jar)
jar
- The fil 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.lang.String getBugReportText()
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()