File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\jenkins\AgentProtocol.java.html

1 package jenkins;
2
3 import hudson.Extension;
4 import hudson.ExtensionList;
5 import hudson.ExtensionPoint;
6 import hudson.TcpSlaveAgentListener;
7 import hudson.model.AperiodicWork;
8 import jenkins.model.Jenkins;
9
10 import java.io.IOException;
11 import java.net.Socket;
12
13 /**
14 * Pluggable Jenkins TCP agent protocol handler called from {@link TcpSlaveAgentListener}.
15 *
16 * <p>
17 * To register your extension, put {@link Extension} annotation on your subtype.
18 * Implementations of this extension point is singleton, and its {@link #handle(Socket)} method
19 * gets invoked concurrently whenever a new connection comes in.
20 *
21 * @author Kohsuke Kawaguchi
22 * @since 1.467
23 * @see TcpSlaveAgentListener
24 */
25 public abstract class AgentProtocol implements ExtensionPoint {
26 /**
27 * Protocol name.
28 *
29 * This is a short string that consists of printable ASCII chars. Sent by the client to select the protocol.
30 */
31 public abstract String getName();
32
33 /**
34 * Called by the connection handling thread to execute the protocol.
35 */
36 public abstract void handle(Socket socket) throws IOException, InterruptedException;
37
38 /**
39 * Returns all the registered {@link AperiodicWork}s.
40 */
41 public static ExtensionList<AgentProtocol> all() {
42 return Jenkins.getInstance().getExtensionList(AgentProtocol.class);
43 }
44
45 public static AgentProtocol of(String protocolName) {
46 for (AgentProtocol p : all()) {
47 if (p.getName().equals(protocolName))
48 return p;
49 }
50 return null;
51 }
52 }
53