hudson
Class PluginWrapper

java.lang.Object
  extended by hudson.PluginWrapper
All Implemented Interfaces:
Comparable<PluginWrapper>

public class PluginWrapper
extends Object
implements Comparable<PluginWrapper>

Represents a Hudson plug-in and associated control information for Hudson to control Plugin.

A plug-in is packaged into a jar file whose extension is ".hpi", A plugin needs to have a special manifest entry to identify what it is.

At the runtime, a plugin has two distinct state axis.

  1. Enabled/Disabled. If enabled, Hudson is going to use it next time Hudson runs. Otherwise the next run will ignore it.
  2. Activated/Deactivated. If activated, that means Hudson is using the plugin in this session. Otherwise it's not.

For example, an activated but disabled plugin is still running but the next time it won't.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class PluginWrapper.Dependency
           
 
Field Summary
 URL baseResourceURL
          Base URL for loading static resources from this plugin.
 ClassLoader classLoader
          ClassLoader for loading classes from this plugin.
 PluginManager parent
          PluginManager to which this belongs to.
 
Constructor Summary
PluginWrapper(PluginManager parent, File archive, Manifest manifest, URL baseResourceURL, ClassLoader classLoader, File disableFile, List<PluginWrapper.Dependency> dependencies, List<PluginWrapper.Dependency> optionalDependencies)
           
 
Method Summary
 int compareTo(PluginWrapper pw)
          Sort by short name.
 void disable()
          Disables this plugin next time Hudson runs.
 org.kohsuke.stapler.HttpResponse doMakeDisabled()
           
 org.kohsuke.stapler.HttpResponse doMakeEnabled()
           
 org.kohsuke.stapler.HttpResponse doPin()
           
 org.kohsuke.stapler.HttpResponse doUnpin()
           
 void enable()
          Enables this plugin next time Hudson runs.
 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.
 URL getBaseResourceURL()
           
 ClassLoader getClassLoader()
           
 List<PluginWrapper.Dependency> getDependencies()
           
 URL getIndexPage()
          Returns the URL of the index page jelly script.
 UpdateSite.Plugin getInfo()
          returns the UpdateSite.Plugin object, or null.
 String getLongName()
          Returns a one-line descriptive name of this plugin.
 Manifest getManifest()
           
 List<PluginWrapper.Dependency> getOptionalDependencies()
           
 PluginManager getParent()
           
 Plugin getPlugin()
          Gets the instance of Plugin contributed by this plugin.
 String getPluginClass()
           
 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 hasUpdate()
          Returns true if this plugin has update in the update center.
 boolean isActive()
          Returns true if this plugin is enabled for this session.
 boolean isBundled()
           
 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 Hudson runs.
 boolean isOlderThan(VersionNumber v)
          Returns true if the version of this plugin is older than the given version.
 boolean isPinned()
           
 void releaseClassLoader()
           
 void setPlugin(Plugin plugin)
           
 void stop()
          Terminates the plugin.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

public final PluginManager parent
PluginManager to which this belongs to.


classLoader

public final ClassLoader classLoader
ClassLoader for loading classes from this plugin. Null if disabled.


baseResourceURL

public final URL baseResourceURL
Base URL for loading static resources from this plugin. Null if disabled. The static resources are mapped under hudson/plugin/SHORTNAME/.

Constructor Detail

PluginWrapper

public PluginWrapper(PluginManager parent,
                     File archive,
                     Manifest manifest,
                     URL baseResourceURL,
                     ClassLoader classLoader,
                     File disableFile,
                     List<PluginWrapper.Dependency> dependencies,
                     List<PluginWrapper.Dependency> optionalDependencies)
Parameters:
archive - A .hpi archive file jar file, or a .hpl linked plugin.
manifest - The manifest for the plugin
baseResourceURL - A URL pointing to the resources for this plugin
classLoader - a classloader that loads classes from this plugin and its dependencies
disableFile - if this file exists on startup, the plugin will not be activated
dependencies - a list of mandatory dependencies
optionalDependencies - a list of optional dependencies
Method Detail

getParent

public PluginManager getParent()

getClassLoader

public ClassLoader getClassLoader()

getBaseResourceURL

public URL getBaseResourceURL()

getIndexPage

public URL getIndexPage()
Returns the URL of the index page jelly script.


getDependencies

public List<PluginWrapper.Dependency> getDependencies()

getOptionalDependencies

public List<PluginWrapper.Dependency> getOptionalDependencies()

getShortName

public String getShortName()
Returns the short name suitable for URL.


getPlugin

public Plugin getPlugin()
Gets the instance of Plugin contributed by this plugin.


getUrl

public String getUrl()
Gets the URL that shows more information about this plugin.

Returns:
null if this information is unavailable.
Since:
1.283

toString

public String toString()
Overrides:
toString in class Object

getLongName

public String getLongName()
Returns a one-line descriptive name of this plugin.


getVersion

public String getVersion()
Returns the version number of this plugin


getVersionNumber

public VersionNumber getVersionNumber()
Returns the version number of this plugin


isOlderThan

public boolean isOlderThan(VersionNumber v)
Returns true if the version of this plugin is older than the given version.


stop

public void stop()
Terminates the plugin.


releaseClassLoader

public void releaseClassLoader()

enable

public void enable()
            throws IOException
Enables this plugin next time Hudson runs.

Throws:
IOException

disable

public void disable()
             throws IOException
Disables this plugin next time Hudson runs.

Throws:
IOException

isActive

public boolean isActive()
Returns true if this plugin is enabled for this session.


isBundled

public boolean isBundled()

isEnabled

public boolean isEnabled()
If true, the plugin is going to be activated next time Hudson runs.


getManifest

public Manifest getManifest()

setPlugin

public void setPlugin(Plugin plugin)

getPluginClass

public String getPluginClass()

getUpdateInfo

public UpdateSite.Plugin getUpdateInfo()
If the plugin has an update, returns the UpdateSite.Plugin object.

Returns:
This method may return null — for example, the user may have installed a plugin locally developed.

getInfo

public UpdateSite.Plugin getInfo()
returns the UpdateSite.Plugin object, or null.


hasUpdate

public boolean hasUpdate()
Returns true if this plugin has update in the update center.

This method is conservative in the sense that if the version number is incomprehensible, it always returns false.


isPinned

public boolean isPinned()

compareTo

public int compareTo(PluginWrapper pw)
Sort by short name.

Specified by:
compareTo in interface Comparable<PluginWrapper>

isDowngradable

public boolean isDowngradable()
returns true if backup of previous version of plugin exists


getBackupFile

public File getBackupFile()
Where is the backup file?


getBackupVersion

public String getBackupVersion()
returns the version of the backed up plugin, or null if there's no back up.


doMakeEnabled

public org.kohsuke.stapler.HttpResponse doMakeEnabled()
                                               throws IOException
Throws:
IOException

doMakeDisabled

public org.kohsuke.stapler.HttpResponse doMakeDisabled()
                                                throws IOException
Throws:
IOException

doPin

public org.kohsuke.stapler.HttpResponse doPin()
                                       throws IOException
Throws:
IOException

doUnpin

public org.kohsuke.stapler.HttpResponse doUnpin()
                                         throws IOException
Throws:
IOException


Copyright © 2004-2013 Hudson. All Rights Reserved.