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

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.model;
25
26 import hudson.console.ConsoleNote;
27 import hudson.console.HyperlinkNote;
28 import hudson.util.AbstractTaskListener;
29 import hudson.util.NullStream;
30 import hudson.util.StreamTaskListener;
31
32 import java.io.IOException;
33 import java.io.PrintStream;
34 import java.io.PrintWriter;
35 import java.io.Serializable;
36 import java.util.Formatter;
37
38 /**
39 * Receives events that happen during some lengthy operation
40 * that has some chance of failures, such as a build, SCM change polling,
41 * slave launch, and so on.
42 *
43 * <p>
44 * This interface is implemented by Hudson core and passed to extension points so that
45 * they can record the progress of the operation without really knowing how those information
46 * and handled/stored by Hudson.
47 *
48 * <p>
49 * The information is one way or the other made available to users, and
50 * so the expectation is that when something goes wrong, enough information
51 * shall be written to a {@link TaskListener} so that the user can diagnose
52 * what's going wrong.
53 *
54 * <p>
55 * {@link StreamTaskListener} is the most typical implementation of this interface.
56 * All the {@link TaskListener} implementations passed to plugins from Hudson core are remotable.
57 *
58 * @see AbstractTaskListener
59 * @author Kohsuke Kawaguchi
60 */
61 public interface TaskListener extends Serializable {
62 /**
63 * This writer will receive the output of the build
64 *
65 * @return
66 * must be non-null.
67 */
68 PrintStream getLogger();
69
70 /**
71 * Annotates the current position in the output log by using the given annotation.
72 * If the implementation doesn't support annotated output log, this method might be no-op.
73 * @since 1.349
74 */
75 void annotate(ConsoleNote ann) throws IOException;
76
77 /**
78 * Places a {@link HyperlinkNote} on the given text.
79 *
80 * @param url
81 * If this starts with '/', it's interpreted as a path within the context path.
82 */
83 void hyperlink(String url, String text) throws IOException;
84
85 /**
86 * An error in the build.
87 *
88 * @return
89 * A writer to receive details of the error. Not null.
90 */
91 PrintWriter error(String msg);
92
93 /**
94 * {@link Formatter#format(String, Object[])} version of {@link #error(String)}.
95 */
96 PrintWriter error(String format, Object... args);
97
98 /**
99 * A fatal error in the build.
100 *
101 * @return
102 * A writer to receive details of the error. Not null.
103 */
104 PrintWriter fatalError(String msg);
105
106 /**
107 * {@link Formatter#format(String, Object[])} version of {@link #fatalError(String)}.
108 */
109 PrintWriter fatalError(String format, Object... args);
110
111 /**
112 * {@link TaskListener} that discards the output.
113 */
114 TaskListener NULL = new StreamTaskListener(new NullStream());
115 }
116