public abstract class Lifecycle extends Object implements ExtensionPoint
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".
ExtensionPoint.LegacyInstancesAreScopedToHudson
Constructor and Description |
---|
Lifecycle() |
Modifier and Type | Method and Description |
---|---|
boolean |
canRestart()
The same as
verifyRestartable() except the status is indicated by the return value,
not by an exception. |
boolean |
canRewriteHudsonWar()
Can
rewriteHudsonWar(File) work? |
static Lifecycle |
get()
Gets the singleton instance.
|
File |
getHudsonWar()
If the location of
jenkins.war is known in this life cycle,
return it location. |
void |
onExtendTimeout(long timeout,
TimeUnit unit)
Tell the service manager to extend the startup or shutdown timeout.
|
void |
onReady()
Called when Jenkins startup is finished or when Jenkins has finished reloading its
configuration.
|
void |
onReload(String user,
String remoteAddr)
Called when Jenkins is reloading its configuration.
|
void |
onStatusUpdate(String status)
Called when Jenkins service state has changed.
|
void |
onStop(String user,
String remoteAddr)
Called when Jenkins is beginning its shutdown.
|
void |
restart()
If this life cycle supports a restart of Hudson, do so.
|
void |
rewriteHudsonWar(File by)
Replaces jenkins.war by the given file.
|
void |
verifyRestartable()
Can the
restart() method restart Hudson? |
public static Lifecycle get()
public File getHudsonWar()
jenkins.war
is 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.
public void rewriteHudsonWar(File by) throws IOException
On some system, most notably Windows, a file being in use cannot be changed,
so rewriting jenkins.war
requires some special trick. Override this method
to do so.
IOException
public boolean canRewriteHudsonWar()
rewriteHudsonWar(File)
work?public void restart() throws IOException, InterruptedException
UnsupportedOperationException
,
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.
IOException
InterruptedException
public void verifyRestartable() throws RestartNotSupportedException
restart()
method restart Hudson?RestartNotSupportedException
- If the restart is not supported, throw this exception and explain the cause.public boolean canRestart()
verifyRestartable()
except the status is indicated by the return value,
not by an exception.public void onReady()
public void onReload(@NonNull String user, @CheckForNull String remoteAddr)
Callers must also send an onReady()
notification when Jenkins has finished
reloading its configuration.
public void onStop(@NonNull String user, @CheckForNull String remoteAddr)
public void onExtendTimeout(long timeout, @NonNull TimeUnit unit)
onExtendTimeout(long, TimeUnit)
must be called again or
startup/shutdown must complete.timeout
- The amount by which to extend the timeout.unit
- The time unit of the timeout argument.public void onStatusUpdate(String status)
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.Copyright © 2004–2022. All rights reserved.