ComputerLauncher.java 2.3 KB
Newer Older
1 2 3 4
package hudson.slaves;

import hudson.ExtensionPoint;
import hudson.model.Computer;
K
kohsuke 已提交
5
import hudson.model.Describable;
6 7 8 9 10 11 12 13
import hudson.remoting.Channel.Listener;
import hudson.util.DescriptorList;
import hudson.util.StreamTaskListener;

import java.io.InputStream;
import java.io.OutputStream;

/**
14 15
 * Extension point to allow control over how {@link Computer}s are "launched",
 * meaning how they get connected to their slave agent program.
16
 *
17 18
 * <p>
 * <b>EXPERIMENTAL: SIGNATURE MAY CHANGE IN FUTURE RELEASES</b>
19
 *
20 21 22
 * @author Stephen Connolly
 * @since 24-Apr-2008 22:12:35
 */
23
public abstract class ComputerLauncher implements Describable<ComputerLauncher>, ExtensionPoint {
24
    /**
25
     * Returns true if this {@link ComputerLauncher} supports
26 27 28 29 30 31 32 33 34 35
     * programatic launch of the slave agent in the target {@link Computer}.
     */
    public boolean isLaunchSupported() {
        return true;
    }

    /**
     * Launches the slave agent for the given {@link Computer}.
     *
     * <p>
36
     * If the slave agent is launched successfully, {@link SlaveComputer#setChannel(InputStream, OutputStream, OutputStream, Listener)}
37 38 39 40 41 42 43
     * should be invoked in the end to notify Hudson of the established connection.
     * The operation could also fail, in which case there's no need to make any callback notification,
     * (except to notify the user of the failure through {@link StreamTaskListener}.)
     *
     * @param listener
     *      The progress of the launch, as well as any error, should be sent to this listener.
     */
44
    public abstract void launch(SlaveComputer computer, StreamTaskListener listener);
45

46 47 48 49 50 51
    /**
     * Allows the {@link ComputerLauncher} to tidy-up after a disconnect.
     */
    public void afterDisconnect(SlaveComputer computer, StreamTaskListener listener) {
    }

52 53 54 55 56 57
    /**
     * Allows the {@link ComputerLauncher} to prepare for a disconnect.
     */
    public void beforeDisconnect(SlaveComputer computer, StreamTaskListener listener) {
    }

58
    /**
59
     * All registered {@link ComputerLauncher} implementations.
60
     */
61
    public static final DescriptorList<ComputerLauncher> LIST = new DescriptorList<ComputerLauncher>();
62 63

    static {
64 65
        LIST.load(JNLPLauncher.class);
        LIST.load(CommandLauncher.class);
66
    }
67
}