File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\init\InitMilestone.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 package hudson.init;
25
26 import org.jvnet.hudson.reactor.Executable;
27 import org.jvnet.hudson.reactor.Milestone;
28 import org.jvnet.hudson.reactor.TaskBuilder;
29 import org.jvnet.hudson.reactor.TaskGraphBuilder;
30
31 /**
32 * Various key milestone in the initialization process of Hudson.
33 *
34 * <p>
35 * Plugins can use these milestones to execute their initialization at the right moment
36 * (in addition to defining their own milestones by implementing {@link Milestone}.
37 *
38 * <p>
39 * These milestones are achieve in this order.
40 *
41 * @author Kohsuke Kawaguchi
42 */
43 public enum InitMilestone implements Milestone {
44 /**
45 * The very first milestone that gets achieved without doing anything.
46 *
47 * This is used in {@link Initializer#after()} since annotations cannot have null as the default value.
48 */
49 STARTED("Started initialization"),
50
51 /**
52 * By this milestone, all plugins metadata are inspected and their dependencies figured out.
53 */
54 PLUGINS_LISTED("Listed all plugins"),
55
56 /**
57 * By this milestone, all plugin metadata are loaded and its classloader set up.
58 */
59 PLUGINS_PREPARED("Prepared all plugins"),
60
61 /**
62 * By this milestone, all plugins start executing, all extension points loaded, descriptors instantiated
63 * and loaded.
64 *
65 * <p>
66 * This is a separate milestone from {@link #PLUGINS_PREPARED} since the execution
67 * of a plugin often involves finding extension point implementations, which in turn
68 * require all the classes from all the plugins to be loadable.
69 */
70 PLUGINS_STARTED("Started all plugins"),
71
72 /**
73 * By this milestone, all programmatically constructed extension point implementations
74 * should be added.
75 */
76 EXTENSIONS_AUGMENTED("Augmented all extensions"),
77
78 /**
79 * By this milestone, all jobs and their build records are loaded from disk.
80 */
81 JOB_LOADED("Loaded all jobs"),
82
83 /**
84 * The very last milestone
85 *
86 * This is used in {@link Initializer#before()} since annotations cannot have null as the default value.
87 */
88 COMPLETED("Completed initialization");
89
90 private final String message;
91
92 InitMilestone(String message) {
93 this.message = message;
94 }
95
96 /**
97 * Creates a set of dummy tasks to enforce ordering among {@link InitMilestone}s.
98 */
99 public static TaskBuilder ordering() {
100 TaskGraphBuilder b = new TaskGraphBuilder();
101 InitMilestone[] v = values();
102 for (int i=0; i<v.length-1; i++)
103 b.add(null, Executable.NOOP).requires(v[i]).attains(v[i+1]);
104 return b;
105 }
106
107
108 @Override
109 public String toString() {
110 return message;
111 }
112 }
113