@ExportedBean public class PluginWrapper extends Object implements Comparable<PluginWrapper>, ModelObject
Plugin
.
A plug-in is packaged into a jar file whose extension is ".jpi"
(or ".hpi"
for backward compatibility),
A plugin needs to have a special manifest entry to identify what it is.
At the runtime, a plugin has two distinct state axis.
For example, an activated but disabled plugin is still running but the next time it won't.
Modifier and Type | Class and Description |
---|---|
static class |
PluginWrapper.Dependency |
static class |
PluginWrapper.PluginDisableResult
The result of the disablement of a plugin and its dependents plugins.
|
static class |
PluginWrapper.PluginDisableStatus
An enum to hold the status of a disabling action against a plugin.
|
static class |
PluginWrapper.PluginDisableStrategy
The strategies defined for disabling a plugin.
|
static class |
PluginWrapper.PluginWrapperAdministrativeMonitor
Administrative Monitor for failed plugins
|
Modifier and Type | Field and Description |
---|---|
URL |
baseResourceURL
Base URL for loading static resources from this plugin.
|
ClassLoader |
classLoader
ClassLoader for loading classes from this plugin. |
static String |
MANIFEST_FILENAME
Name of the plugin manifest file (to help find where we parse them.)
|
static PluginWrapper.PluginWrapperAdministrativeMonitor |
NOTICE |
PluginManager |
parent
PluginManager to which this belongs to. |
Constructor and Description |
---|
PluginWrapper(PluginManager parent,
File archive,
Manifest manifest,
URL baseResourceURL,
ClassLoader classLoader,
File disableFile,
List<PluginWrapper.Dependency> dependencies,
List<PluginWrapper.Dependency> optionalDependencies) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(PluginWrapper pw)
Sort by short name.
|
void |
disable()
Deprecated.
|
PluginWrapper.PluginDisableResult |
disable(PluginWrapper.PluginDisableStrategy strategy)
Disable this plugin using a strategy.
|
org.kohsuke.stapler.HttpResponse |
doDoUninstall() |
org.kohsuke.stapler.HttpResponse |
doMakeDisabled() |
org.kohsuke.stapler.HttpResponse |
doMakeEnabled() |
org.kohsuke.stapler.HttpResponse |
doPin()
Deprecated.
|
org.kohsuke.stapler.HttpResponse |
doUnpin()
Deprecated.
|
void |
enable()
Enables this plugin next time Jenkins runs.
|
List<UpdateSite.Warning> |
getActiveWarnings() |
Api |
getApi() |
File |
getBackupFile()
Where is the backup file?
|
String |
getBackupVersion()
returns the version of the backed up plugin,
or null if there's no back up.
|
Set<String> |
getDependants()
Deprecated.
Please use
getDependents() . |
List<PluginWrapper.Dependency> |
getDependencies()
Gets all dependencies of this plugin on other plugins.
|
List<String> |
getDependencyErrors() |
Set<String> |
getDependents()
Get the list of components that depend on this plugin.
|
List<UpdateSite.Deprecation> |
getDeprecations() |
List<String> |
getDerivedDependencyErrors() |
String |
getDisplayName() |
Set<String> |
getImpliedDependents()
Get list of implied dependencies.
|
URL |
getIndexPage()
Returns the URL of the index page jelly script.
|
UpdateSite.Plugin |
getInfo()
returns the
UpdateSite.Plugin object, or null. |
String |
getIssueTrackerReportUrl() |
String |
getLongName()
Deprecated.
For most purposes, use
getDisplayName() . |
List<PluginWrapper.Dependency> |
getMandatoryDependencies()
Like
getDependencies() but omits optional dependencies. |
Set<String> |
getMandatoryDependents()
Like
getDependents() but excluding optional dependencies. |
Manifest |
getManifest() |
Set<String> |
getOptionalDependants()
Deprecated.
Please use
getOptionalDependents() . |
List<PluginWrapper.Dependency> |
getOptionalDependencies() |
Set<String> |
getOptionalDependents() |
List<String> |
getOriginalDependencyErrors() |
Plugin |
getPlugin()
Gets the instance of
Plugin contributed by this plugin. |
String |
getPluginClass() |
Plugin |
getPluginOrFail()
Gets the instance of
Plugin contributed by this plugin. |
String |
getRequiredCoreVersion()
Returns the required Jenkins core version of this plugin.
|
String |
getShortName()
Returns the short name suitable for URL.
|
UpdateSite.Plugin |
getUpdateInfo()
If the plugin has
an update ,
returns the UpdateSite.Plugin object. |
String |
getUrl()
Gets the URL that shows more information about this plugin.
|
String |
getVersion()
Returns the version number of this plugin
|
VersionNumber |
getVersionNumber()
Returns the version number of this plugin
|
boolean |
hasCycleDependency() |
boolean |
hasDependants()
Deprecated.
Please use
hasDependents() . |
boolean |
hasDependencies()
Does this plugin depend on any other plugins.
|
boolean |
hasDependents()
Does this plugin have anything that depends on it.
|
boolean |
hasDerivedDependencyErrors() |
boolean |
hasImpliedDependents() |
boolean |
hasLicensesXml() |
boolean |
hasMandatoryDependencies()
Like
hasDependencies() but omitting optional dependencies. |
boolean |
hasMandatoryDependents()
Like
hasDependents() but excluding optional dependencies. |
boolean |
hasOptionalDependants()
Deprecated.
Please use
hasOptionalDependents() . |
boolean |
hasOptionalDependents()
Does this plugin have anything that depends optionally on it.
|
boolean |
hasOriginalDependencyErrors() |
boolean |
hasUpdate()
Returns true if this plugin has update in the update center.
|
void |
injectJarsToClasspath(File... jars)
Inject the specified jar file(s) to the plugins classpath.
|
boolean |
isActive()
Returns true if this plugin is enabled for this session.
|
boolean |
isBundled()
Is this plugin bundled in the WAR?
Normally false as noted in
PluginManager.loadBundledPlugins() :
this does not apply to “detached” plugins. |
boolean |
isDeleted()
Returns true if this plugin is deleted.
|
boolean |
isDeprecated()
Is this plugin deprecated?
|
boolean |
isDetached()
|
boolean |
isDowngradable()
returns true if backup of previous version of plugin exists
|
boolean |
isEnabled()
If true, the plugin is going to be activated next time
Jenkins runs.
|
boolean |
isOlderThan(VersionNumber v)
Returns true if the version of this plugin is older than the given version.
|
boolean |
isPinned()
Deprecated.
|
boolean |
isPinningForcingOldVersion()
Deprecated.
removed without replacement
|
void |
releaseClassLoader() |
void |
setDependants(Set<String> dependents)
Deprecated.
Please use
setDependents(java.util.Set<java.lang.String>) . |
void |
setDependents(Set<String> dependents)
Set the list of components that depend on this plugin.
|
void |
setHasCycleDependency(boolean hasCycle) |
void |
setOptionalDependants(Set<String> optionalDependents)
Deprecated.
|
void |
setOptionalDependents(Set<String> optionalDependents)
Set the list of components that depend optionally on this plugin.
|
void |
setPlugin(Plugin plugin) |
void |
stop()
Terminates the plugin.
|
YesNoMaybe |
supportsDynamicLoad()
Does this plugin supports dynamic loading?
|
String |
toString() |
public final PluginManager parent
PluginManager
to which this belongs to.public final ClassLoader classLoader
ClassLoader
for loading classes from this plugin.
Null if disabled.public final URL baseResourceURL
CONTEXTPATH/plugin/SHORTNAME/
.@Extension public static final PluginWrapper.PluginWrapperAdministrativeMonitor NOTICE
public static final String MANIFEST_FILENAME
public PluginWrapper(PluginManager parent, File archive, Manifest manifest, URL baseResourceURL, ClassLoader classLoader, File disableFile, List<PluginWrapper.Dependency> dependencies, List<PluginWrapper.Dependency> optionalDependencies)
archive
- A .jpi archive file jar file, or a .jpl linked plugin.manifest
- The manifest for the pluginbaseResourceURL
- A URL pointing to the resources for this pluginclassLoader
- a classloader that loads classes from this plugin and its dependenciesdisableFile
- if this file exists on startup, the plugin will not be activateddependencies
- a list of mandatory dependenciesoptionalDependencies
- a list of optional dependencies@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<String> getOriginalDependencyErrors()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean hasOriginalDependencyErrors()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<String> getDerivedDependencyErrors()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean hasDerivedDependencyErrors()
public void setDependents(@NonNull Set<String> dependents)
dependents
- The list of components that depend on this plugin.@Deprecated public void setDependants(@NonNull Set<String> dependents)
setDependents(java.util.Set<java.lang.String>)
.public void setOptionalDependents(@NonNull Set<String> optionalDependents)
optionalDependents
- The list of components that depend optionally on this plugin.@Deprecated public void setOptionalDependants(@NonNull Set<String> optionalDependents)
setOptionalDependents(java.util.Set<java.lang.String>)
.@NonNull public Set<String> getDependents()
getOptionalDependents()
.@Deprecated @NonNull public Set<String> getDependants()
getDependents()
.@NonNull public Set<String> getMandatoryDependents()
getDependents()
but excluding optional dependencies.@NonNull public Set<String> getOptionalDependents()
@Deprecated @NonNull public Set<String> getOptionalDependants()
getOptionalDependents()
.public boolean hasDependents()
true
if something (Jenkins core, or another plugin) depends on this
plugin, otherwise false
.public boolean hasMandatoryDependents()
hasDependents()
but excluding optional dependencies.@Deprecated public boolean hasDependants()
hasDependents()
.public boolean hasOptionalDependents()
true
if something (Jenkins core, or another plugin) depends optionally on this
plugin, otherwise false
.@Deprecated public boolean hasOptionalDependants()
hasOptionalDependents()
.public boolean hasDependencies()
true
if this plugin depends on other plugins, otherwise false
.public boolean hasMandatoryDependencies()
hasDependencies()
but omitting optional dependencies.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isDeprecated()
true
if and only if an update site reports deprecations for this plugin.@Restricted(value=org.kohsuke.accmod.restrictions.Beta.class) public void injectJarsToClasspath(File... jars) throws Exception
Warning: This is advanced usage that you should not be needed in 99.9% of all cases, any jar insertion should happen early into the plugins lifecycle to prevent classloading issues in dependent plugins.
Rather than use this functionality it is to have co-operative behaviour between any consumer of the libraries and load the classes in a separate ClassLoader
.
you can expose third-party libraries from a dynamic location in various ways, such as:
URLClassLoader
loading them both, parented to the plugin ClassLoader
Exception
- if the File could not be inserted into the classpath for some reason.public String getDisplayName()
getDisplayName
in interface ModelObject
public Api getApi()
public URL getIndexPage()
@Exported public List<PluginWrapper.Dependency> getDependencies()
getOptionalDependencies()
(missing optional dependencies will however be omitted).public List<PluginWrapper.Dependency> getMandatoryDependencies()
getDependencies()
but omits optional dependencies.public List<PluginWrapper.Dependency> getOptionalDependencies()
@Exported public String getShortName()
@CheckForNull public Plugin getPlugin()
Plugin
contributed by this plugin.null
if it is not present in the plugin instance store.@NonNull public Plugin getPluginOrFail() throws Exception
Plugin
contributed by this plugin.Exception
- no plugin in the PluginManager.PluginInstanceStore
@Exported public String getUrl()
@Exported @Deprecated public String getLongName()
getDisplayName()
.@Exported public YesNoMaybe supportsDynamicLoad()
@Exported public String getVersion()
@Exported @CheckForNull public String getRequiredCoreVersion()
public VersionNumber getVersionNumber()
public boolean isOlderThan(VersionNumber v)
public void stop()
public void releaseClassLoader()
public void enable() throws IOException
IOException
@Deprecated public void disable() throws IOException
disable(PluginDisableStrategy)
disable(PluginDisableStrategy)
IOException
@NonNull public PluginWrapper.PluginDisableResult disable(@NonNull PluginWrapper.PluginDisableStrategy strategy)
strategy
- strategy to use@Exported public boolean isActive()
public boolean hasCycleDependency()
public void setHasCycleDependency(boolean hasCycle)
@Exported public boolean isBundled()
PluginManager.loadBundledPlugins()
:
this does not apply to “detached” plugins.@Exported public boolean isEnabled()
public Manifest getManifest()
public void setPlugin(Plugin plugin)
public String getPluginClass()
public boolean hasLicensesXml()
public UpdateSite.Plugin getUpdateInfo()
an update
,
returns the UpdateSite.Plugin
object.public UpdateSite.Plugin getInfo()
UpdateSite.Plugin
object, or null.@Exported public boolean hasUpdate()
This method is conservative in the sense that if the version number is incomprehensible, it always returns false.
@Exported @Deprecated public boolean isPinned()
@Exported public boolean isDeleted()
@Exported public boolean isDetached()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean hasImpliedDependents()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull public Set<String> getImpliedDependents()
public int compareTo(PluginWrapper pw)
compareTo
in interface Comparable<PluginWrapper>
@Exported public boolean isDowngradable()
public File getBackupFile()
@Exported public String getBackupVersion()
@Deprecated public boolean isPinningForcingOldVersion()
public org.kohsuke.stapler.HttpResponse doMakeEnabled() throws IOException
IOException
public org.kohsuke.stapler.HttpResponse doMakeDisabled() throws IOException
IOException
@Deprecated public org.kohsuke.stapler.HttpResponse doPin() throws IOException
IOException
@Deprecated public org.kohsuke.stapler.HttpResponse doUnpin() throws IOException
IOException
public org.kohsuke.stapler.HttpResponse doDoUninstall() throws IOException
IOException
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public List<UpdateSite.Warning> getActiveWarnings()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<UpdateSite.Deprecation> getDeprecations()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public String getIssueTrackerReportUrl()
Copyright © 2004–2022. All rights reserved.