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

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc.
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
25 package hudson.slaves;
26
27 import hudson.model.Computer;
28 import org.jvnet.localizer.Localizable;
29 import org.kohsuke.stapler.export.ExportedBean;
30 import org.kohsuke.stapler.export.Exported;
31
32 /**
33 * Represents a cause that puts a {@linkplain Computer#isOffline() computer offline}.
34 *
35 * <h2>Views</h2>
36 * <p>
37 * {@link OfflineCause} must have <tt>cause.jelly</tt> that renders a cause
38 * into HTML. This is used to tell users why the node is put offline.
39 * This view should render a block element like DIV.
40 *
41 * @author Kohsuke Kawaguchi
42 * @since 1.320
43 */
44 @ExportedBean
45 public abstract class OfflineCause {
46 /**
47 * {@link OfflineCause} that renders a static text,
48 * but without any further UI.
49 */
50 public static class SimpleOfflineCause extends OfflineCause {
51 public final Localizable description;
52
53 private SimpleOfflineCause(Localizable description) {
54 this.description = description;
55 }
56
57 @Exported(name="description") @Override
58 public String toString() {
59 return description.toString();
60 }
61 }
62
63 public static OfflineCause create(Localizable d) {
64 if (d==null) return null;
65 return new SimpleOfflineCause(d);
66 }
67
68 /**
69 * Caused by unexpected channel termination.
70 */
71 public static class ChannelTermination extends OfflineCause {
72 @Exported
73 public final Exception cause;
74
75 public ChannelTermination(Exception cause) {
76 this.cause = cause;
77 }
78
79 public String getShortDescription() {
80 return cause.toString();
81 }
82 }
83
84 /**
85 * Caused by failure to launch.
86 */
87 public static class LaunchFailed extends OfflineCause {
88 @Override
89 public String toString() {
90 return Messages.OfflineCause_LaunchFailed();
91 }
92 }
93
94 public static class ByCLI extends OfflineCause {
95 @Exported
96 public final String message;
97
98 public ByCLI(String message) {
99 this.message = message;
100 }
101
102 @Override
103 public String toString() {
104 if (message==null)
105 return Messages.OfflineCause_DisconnectedFromCLI();
106 return message;
107 }
108 }
109 }
110