@ExportedBean public abstract class PluginManager extends AbstractModelObject implements OnMaster, org.kohsuke.stapler.StaplerOverridable
PluginWrapper
s.Modifier and Type | Class and Description |
---|---|
static class |
PluginManager.FailedPlugin
Remembers why a plugin failed to deploy.
|
static class |
PluginManager.PluginCycleDependenciesMonitor
AdministrativeMonitor that checks if there are any plugins with cycle dependencies. |
static class |
PluginManager.PluginUpdateMonitor
AdministrativeMonitor that informs the administrator about a required plugin update. |
class |
PluginManager.UberClassLoader
ClassLoader that can see all plugins. |
Modifier and Type | Field and Description |
---|---|
protected List<PluginWrapper> |
activePlugins
All active plugins, topologically sorted so that when X depends on Y, Y appears in the list before X does.
|
static Permission |
CONFIGURE_UPDATECENTER |
javax.servlet.ServletContext |
context
Deprecated.
as of 1.355
PluginManager can now live longer than Jenkins instance, so
use Hudson.getInstance().servletContext instead. |
protected List<PluginManager.FailedPlugin> |
failedPlugins |
static boolean |
FAST_LOOKUP |
protected List<PluginWrapper> |
plugins
All discovered plugins.
|
boolean |
pluginUploaded
Once plugin is uploaded, this flag becomes true.
|
File |
rootDir
Plug-in root directory.
|
ClassLoader |
uberClassLoader
ClassLoader that can load all the publicly visible classes from plugins
(and including the classloader that loads Hudson itself.) |
static Permission |
UPLOAD_PLUGINS |
Constructor and Description |
---|
PluginManager(javax.servlet.ServletContext context,
File rootDir) |
Modifier and Type | Method and Description |
---|---|
protected void |
copyBundledPlugin(URL src,
String fileName)
Copies the bundled plugin from the given URL to the destination of the given file name (like 'abc.jpi'),
with a reasonable up-to-date check.
|
protected PluginStrategy |
createPluginStrategy()
Creates a hudson.PluginStrategy, looking at the corresponding system property.
|
<T> Collection<Class<? extends T>> |
discover(Class<T> spi)
Discover all the service provider implementations of the given class,
via META-INF/services.
|
org.kohsuke.stapler.HttpResponse |
doCheckUpdatesServer() |
void |
doInstall(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Performs the installation of the plugins.
|
org.kohsuke.stapler.HttpResponse |
doInstallNecessaryPlugins(org.kohsuke.stapler.StaplerRequest req)
Runs
prevalidateConfig(java.io.InputStream) on posted XML and redirects to the UpdateCenter . |
net.sf.json.JSONArray |
doPrevalidateConfig(org.kohsuke.stapler.StaplerRequest req)
Like
doInstallNecessaryPlugins(StaplerRequest) but only checks if everything is installed
or if some plugins need updates or installation. |
org.kohsuke.stapler.HttpResponse |
doProxyConfigure(org.kohsuke.stapler.StaplerRequest req) |
org.kohsuke.stapler.HttpResponse |
doSiteConfigure(String site)
Bare-minimum configuration mechanism to change the update center.
|
org.kohsuke.stapler.HttpResponse |
doUpdateSources(org.kohsuke.stapler.StaplerRequest req) |
org.kohsuke.stapler.HttpResponse |
doUploadPlugin(org.kohsuke.stapler.StaplerRequest req)
Uploads a plugin.
|
void |
dynamicLoad(File arc)
TODO: revisit where/how to expose this.
|
Api |
getApi() |
Manifest |
getBundledPluginManifest(String shortName)
Returns the manifest of a bundled but not-extracted plugin.
|
org.jenkinsci.bytecode.Transformer |
getCompatibilityTransformer() |
String |
getDisplayName() |
List<PluginManager.FailedPlugin> |
getFailedPlugins() |
Collection<PluginManagerStaplerOverride> |
getOverrides()
Find all registered overrides (intended to allow overriding/adding views)
|
PluginWrapper |
getPlugin(Class<? extends Plugin> pluginClazz)
Get the plugin instance that implements a specific class, use to find your plugin singleton.
|
PluginWrapper |
getPlugin(String shortName)
Get the plugin instance with the given short name.
|
List<PluginWrapper> |
getPlugins()
All discovered plugins.
|
List<PluginWrapper> |
getPlugins(Class<? extends Plugin> pluginSuperclass)
Get the plugin instances that extend a specific class, use to find similar plugins.
|
PluginStrategy |
getPluginStrategy() |
Descriptor<ProxyConfiguration> |
getProxyDescriptor() |
String |
getSearchUrl()
Returns the URL of this item relative to the parent
SearchItem . |
File |
getWorkDir()
If non-null, the base directory for all exploded .hpi/.jpi plugins.
|
protected String |
identifyPluginShortName(File t) |
org.jvnet.hudson.reactor.TaskBuilder |
initTasks(InitStrategy initStrategy)
Called immediately after the construction.
|
boolean |
isPluginUploaded()
Returns true if any new plugin was added.
|
protected abstract Collection<String> |
loadBundledPlugins()
If the war file has any "/WEB-INF/plugins/[*.jpi | *.hpi]", extract them into the plugin directory.
|
Map<String,hudson.util.VersionNumber> |
parseRequestedPlugins(InputStream configXml)
Parses configuration XML files and picks up references to XML files.
|
List<Future<UpdateCenter.UpdateCenterJob>> |
prevalidateConfig(InputStream configXml)
Prepares plugins for some expected XML configuration.
|
void |
resolveDependantPlugins() |
void |
stop()
Orderly terminates all the plugins.
|
PluginWrapper |
whichPlugin(Class c)
Return the
PluginWrapper that loaded the given class 'c'. |
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
protected final List<PluginWrapper> plugins
protected final List<PluginWrapper> activePlugins
protected final List<PluginManager.FailedPlugin> failedPlugins
public final File rootDir
@Deprecated public final javax.servlet.ServletContext context
PluginManager
can now live longer than Jenkins
instance, so
use Hudson.getInstance().servletContext
instead.public final ClassLoader uberClassLoader
ClassLoader
that can load all the publicly visible classes from plugins
(and including the classloader that loads Hudson itself.)public volatile boolean pluginUploaded
public static boolean FAST_LOOKUP
public static final Permission UPLOAD_PLUGINS
public static final Permission CONFIGURE_UPDATECENTER
public PluginManager(javax.servlet.ServletContext context, File rootDir)
public org.jenkinsci.bytecode.Transformer getCompatibilityTransformer()
public Api getApi()
@CheckForNull public File getWorkDir()
null
to leave this up to the strategy.public Collection<PluginManagerStaplerOverride> getOverrides()
getOverrides
in interface org.kohsuke.stapler.StaplerOverridable
public org.jvnet.hudson.reactor.TaskBuilder initTasks(InitStrategy initStrategy)
Jenkins.pluginManager
.@CheckForNull public Manifest getBundledPluginManifest(String shortName)
public void dynamicLoad(File arc) throws IOException, InterruptedException, RestartRequiredException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void resolveDependantPlugins()
protected abstract Collection<String> loadBundledPlugins() throws Exception
Exception
- Any exception will be reported and halt the startup.protected void copyBundledPlugin(URL src, String fileName) throws IOException
loadBundledPlugins()
.IOException
protected PluginStrategy createPluginStrategy()
public PluginStrategy getPluginStrategy()
public boolean isPluginUploaded()
@Exported public List<PluginWrapper> getPlugins()
public List<PluginManager.FailedPlugin> getFailedPlugins()
public PluginWrapper getPlugin(String shortName)
shortName
- the short name of the pluginnull
if a plugin with the given short name does not exist.public PluginWrapper getPlugin(Class<? extends Plugin> pluginClazz)
pluginClazz
- The class that your plugin implements.null
if for some reason the plugin is not loaded.public List<PluginWrapper> getPlugins(Class<? extends Plugin> pluginSuperclass)
pluginSuperclass
- The class that your plugin is derived from.public String getDisplayName()
getDisplayName
in interface ModelObject
public String getSearchUrl()
SearchItem
SearchItem
.getSearchUrl
in interface SearchItem
public <T> Collection<Class<? extends T>> discover(Class<T> spi)
public PluginWrapper whichPlugin(Class c)
PluginWrapper
that loaded the given class 'c'.public void stop()
public org.kohsuke.stapler.HttpResponse doUpdateSources(org.kohsuke.stapler.StaplerRequest req) throws IOException
IOException
public void doInstall(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public org.kohsuke.stapler.HttpResponse doSiteConfigure(@QueryParameter String site) throws IOException
IOException
public org.kohsuke.stapler.HttpResponse doProxyConfigure(org.kohsuke.stapler.StaplerRequest req) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public org.kohsuke.stapler.HttpResponse doUploadPlugin(org.kohsuke.stapler.StaplerRequest req) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doCheckUpdatesServer() throws IOException
IOException
public Descriptor<ProxyConfiguration> getProxyDescriptor()
public List<Future<UpdateCenter.UpdateCenterJob>> prevalidateConfig(InputStream configXml) throws IOException
config.xml
)
needs some plugins to be installed (or updated), those jobs
will be triggered.
Plugins are dynamically loaded whenever possible.
Requires Jenkins.ADMINISTER
.configXml
- configuration that might be uploadedIOException
- if loading or parsing the configuration failedItemGroupMixIn.createProjectFromXML(java.lang.String, java.io.InputStream)
,
AbstractItem.updateByXml(javax.xml.transform.Source)
,
XStream2
,
UpdateSite.Plugin.deploy(boolean)
,
PluginWrapper.supportsDynamicLoad()
,
UpdateCenter.DownloadJob.SuccessButRequiresRestart
public net.sf.json.JSONArray doPrevalidateConfig(org.kohsuke.stapler.StaplerRequest req) throws IOException
doInstallNecessaryPlugins(StaplerRequest)
but only checks if everything is installed
or if some plugins need updates or installation.
This method runs without side-effect. I'm still requiring the ADMINISTER permission since
XML file can contain various external references and we don't configure parsers properly against
that.IOException
public org.kohsuke.stapler.HttpResponse doInstallNecessaryPlugins(org.kohsuke.stapler.StaplerRequest req) throws IOException
prevalidateConfig(java.io.InputStream)
on posted XML and redirects to the UpdateCenter
.IOException
public Map<String,hudson.util.VersionNumber> parseRequestedPlugins(InputStream configXml) throws IOException
IOException
Copyright © 2019. All rights reserved.