hudson.lifecycle
Class Lifecycle

java.lang.Object
  extended by hudson.lifecycle.Lifecycle
All Implemented Interfaces:
ExtensionPoint
Direct Known Subclasses:
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".

Since:
1.254
Author:
Kohsuke Kawaguchi

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
Lifecycle()
           
 
Method Summary
 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 hudson.war is known in this life cycle, return it location.
 void restart()
          If this life cycle supports a restart of Hudson, do so.
 void rewriteHudsonWar(File by)
          Replaces hudson.war by the given file.
 void verifyRestartable()
          Can the restart() method restart Hudson?
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lifecycle

public Lifecycle()
Method Detail

get

public static Lifecycle get()
Gets the singleton instance.

Returns:
never null

getHudsonWar

public File getHudsonWar()
If the location of hudson.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.


rewriteHudsonWar

public void rewriteHudsonWar(File by)
                      throws IOException
Replaces hudson.war by the given file.

On some system, most notably Windows, a file being in use cannot be changed, so rewriting hudson.war requires some special trick. Override this method to do so.

Throws:
IOException

canRewriteHudsonWar

public boolean canRewriteHudsonWar()
Can rewriteHudsonWar(File) work?


restart

public void restart()
             throws IOException,
                    InterruptedException
If this life cycle supports a restart of Hudson, do so. Otherwise, throw 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.

Throws:
IOException
InterruptedException

verifyRestartable

public void verifyRestartable()
                       throws RestartNotSupportedException
Can the restart() method restart Hudson?

Throws:
RestartNotSupportedException - If the restart is not supported, throw this exception and explain the cause.

canRestart

public boolean canRestart()
The same as verifyRestartable() except the status is indicated by the return value, not by an exception.



Copyright © 2004-2013 Hudson. All Rights Reserved.