Class Lifecycle
- java.lang.Object
-
- hudson.lifecycle.Lifecycle
-
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
ExitLifecycle,SolarisSMFLifecycle,UnixLifecycle,WindowsServiceLifecycle
public abstract class Lifecycle extends Object implements ExtensionPoint
Provides the capability for starting/stopping/restarting/uninstalling Hudson.The steps to perform these operations depend on how Hudson is launched, so the concrete instance of this method (which is VM-wide singleton) is discovered by looking up a FQCN from the system property "hudson.lifecycle". (This may be set to a class defined in a plugin, in which case the singleton switches during startup.)
- Since:
- 1.254
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLifecycle.PlaceholderLifecycle-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description Lifecycle()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRestart()The same asverifyRestartable()except the status is indicated by the return value, not by an exception.booleancanRewriteHudsonWar()CanrewriteHudsonWar(File)work?static Lifecycleget()Gets the singleton instance.FilegetHudsonWar()If the location ofjenkins.waris known in this life cycle, return it location.voidonExtendTimeout(long timeout, TimeUnit unit)Tell the service manager to extend the startup or shutdown timeout.voidonReady()Called when Jenkins startup is finished or when Jenkins has finished reloading its configuration.voidonReload(String user, String remoteAddr)Called when Jenkins is reloading its configuration.voidonStatusUpdate(String status)Called when Jenkins service state has changed.voidonStop(String user, String remoteAddr)Called when Jenkins is beginning its shutdown.voidrestart()If this life cycle supports a restart of Hudson, do so.voidrewriteHudsonWar(File by)Replaces jenkins.war by the given file.booleansupportsDynamicLoad()WhetherPluginManager.dynamicLoad(File)should be supported at all.voidverifyRestartable()Can therestart()method restart Hudson?
-
-
-
Method Detail
-
get
@NonNull public static Lifecycle get()
Gets the singleton instance.
-
getHudsonWar
public File getHudsonWar()
If the location ofjenkins.waris known in this life cycle, return it location. Otherwise return null to indicate that it is unknown.When a non-null value is returned, Hudson will offer an upgrade UI to a newer version.
-
rewriteHudsonWar
public void rewriteHudsonWar(File by) throws IOException
Replaces jenkins.war by the given file.On some system, most notably Windows, a file being in use cannot be changed, so rewriting
jenkins.warrequires some special trick. Override this method to do so.- Throws:
IOException
-
canRewriteHudsonWar
public boolean canRewriteHudsonWar()
CanrewriteHudsonWar(File)work?
-
restart
public void restart() throws IOException, InterruptedExceptionIf this life cycle supports a restart of Hudson, do so. Otherwise, throwUnsupportedOperationException, which is what the default implementation does.The restart operation may happen synchronously (in which case this method will never return), or asynchronously (in which case this method will successfully return.)
Throw an exception if the operation fails unexpectedly.
- Throws:
IOExceptionInterruptedException
-
verifyRestartable
public void verifyRestartable() throws RestartNotSupportedExceptionCan therestart()method restart Hudson?- Throws:
RestartNotSupportedException- If the restart is not supported, throw this exception and explain the cause.
-
canRestart
public boolean canRestart()
The same asverifyRestartable()except the status is indicated by the return value, not by an exception.
-
onReady
public void onReady()
Called when Jenkins startup is finished or when Jenkins has finished reloading its configuration.- Since:
- 2.333
-
onReload
public void onReload(@NonNull String user, @CheckForNull String remoteAddr)Called when Jenkins is reloading its configuration.Callers must also send an
onReady()notification when Jenkins has finished reloading its configuration.- Since:
- 2.333
-
onStop
public void onStop(@NonNull String user, @CheckForNull String remoteAddr)Called when Jenkins is beginning its shutdown.- Since:
- 2.333
-
onExtendTimeout
public void onExtendTimeout(long timeout, @NonNull TimeUnit unit)Tell the service manager to extend the startup or shutdown timeout. The value specified is a time during which eitheronExtendTimeout(long, TimeUnit)must be called again or startup/shutdown must complete.- Parameters:
timeout- The amount by which to extend the timeout.unit- The time unit of the timeout argument.- Since:
- 2.335
-
onStatusUpdate
public void onStatusUpdate(String status)
Called when Jenkins service state has changed.- Parameters:
status- The status string. This is free-form and can be used for various purposes: general state feedback, completion percentages, human-readable error message, etc.- Since:
- 2.333
-
supportsDynamicLoad
@Restricted(org.kohsuke.accmod.restrictions.Beta.class) public boolean supportsDynamicLoad()
WhetherPluginManager.dynamicLoad(File)should be supported at all. If not,RestartRequiredExceptionwill always be thrown.- Returns:
- true by default
- Since:
- 2.449
-
-