File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\init\Initializer.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.annotation_indexer.Indexed;
27 import org.jvnet.hudson.reactor.Task;
28
29 import java.lang.annotation.Documented;
30 import static java.lang.annotation.ElementType.METHOD;
31 import java.lang.annotation.Retention;
32 import static java.lang.annotation.RetentionPolicy.RUNTIME;
33 import java.lang.annotation.Target;
34
35 import static hudson.init.InitMilestone.STARTED;
36 import static hudson.init.InitMilestone.COMPLETED;
37
38 /**
39 * Placed on static methods to indicate that this method is to be run during the Jenkins start up to perform
40 * some sort of initialization tasks.
41 *
42 * <h3>Example</h3>
43 * <pre>
44 &#64;Initializer(after=JOB_LOADED)
45 public static void init() throws IOException {
46 ....
47 }
48 * </pre>
49 *
50 * @author Kohsuke Kawaguchi
51 */
52 @Indexed
53 @Documented
54 @Retention(RUNTIME)
55 @Target(METHOD)
56 public @interface Initializer {
57 /**
58 * Indicates that the specified milestone is necessary before executing this initializer.
59 *
60 * <p>
61 * This has the identical purpose as {@link #requires()}, but it's separated to allow better type-safety
62 * when using {@link InitMilestone} as a requirement (since enum member definitions need to be constant.)
63 */
64 InitMilestone after() default STARTED;
65
66 /**
67 * Indicates that this initializer is a necessary step before achieving the specified milestone.
68 *
69 * <p>
70 * This has the identical purpose as {@link #attains()}. See {@link #after()} for why there are two things
71 * to achieve the same goal.
72 */
73 InitMilestone before() default COMPLETED;
74
75 /**
76 * Indicates the milestones necessary before executing this initializer.
77 */
78 String[] requires() default {};
79
80 /**
81 * Indicates the milestones that this initializer contributes to.
82 *
83 * A milestone is considered attained if all the initializers that attains the given milestone
84 * completes. So it works as a kind of join.
85 */
86 String[] attains() default {};
87
88 /**
89 * Key in <tt>Messages.properties</tt> that represents what this task is about. Used for rendering the progress.
90 * Defaults to "${short class name}.${method Name}".
91 */
92 String displayName() default "";
93
94 /**
95 * Should the failure in this task prevent Hudson from starting up?
96 *
97 * @see Task#failureIsFatal()
98 */
99 boolean fatal() default true;
100 }
101