package jenkins;

import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.TcpSlaveAgentListener;
import hudson.model.AperiodicWork;
import jenkins.model.Jenkins;

import java.io.IOException;
import java.net.Socket;

/**
 * Pluggable Jenkins TCP agent protocol handler called from {@link TcpSlaveAgentListener}.
 *
 * <p>
 * To register your extension, put {@link Extension} annotation on your subtype.
 * Implementations of this extension point is singleton, and its {@link #handle(Socket)} method
 * gets invoked concurrently whenever a new connection comes in.
 *
 * @author Kohsuke Kawaguchi
 * @since 1.467
 * @see TcpSlaveAgentListener
 */
public abstract class AgentProtocol implements ExtensionPoint {
    /**
     * Protocol name.
     *
     * This is a short string that consists of printable ASCII chars. Sent by the client to select the protocol.
     */
    public abstract String getName();

    /**
     * Called by the connection handling thread to execute the protocol.
     */
    public abstract void handle(Socket socket) throws IOException, InterruptedException;

    /**
     * Returns all the registered {@link AperiodicWork}s.
     */
    public static ExtensionList<AgentProtocol> all() {
        return Jenkins.getInstance().getExtensionList(AgentProtocol.class);
    }

    public static AgentProtocol of(String protocolName) {
        for (AgentProtocol p : all()) {
            if (p.getName().equals(protocolName))
                return p;
        }
        return null;
    }
}

@@ -886,32 +886,183 @@
 t the protocol.%0A
+     *%0A     * @return%0A     *      null to be disabled. This is useful for avoiding getting used%0A     *      until the protocol is properly configured.%0A
      */%0A    publ
@@ -1597,23 +1597,60 @@
     
-if (p.getName()
+String n = p.getName();%0A            if (n!=null && n
 .equ

allow null from the name