File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\model\listeners\ItemListener.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.listeners;
25
26 import hudson.ExtensionPoint;
27 import hudson.ExtensionList;
28 import hudson.Extension;
29 import jenkins.model.Jenkins;
30 import hudson.model.Item;
31
32 /**
33 * Receives notifications about CRUD operations of {@link Item}.
34 *
35 * @since 1.74
36 * @author Kohsuke Kawaguchi
37 */
38 public class ItemListener implements ExtensionPoint {
39 /**
40 * Called after a new job is created and added to {@link jenkins.model.Jenkins},
41 * before the initial configuration page is provided.
42 * <p>
43 * This is useful for changing the default initial configuration of newly created jobs.
44 * For example, you can enable/add builders, etc.
45 */
46 public void onCreated(Item item) {
47 }
48
49 /**
50 * Called after a new job is created by copying from an existing job.
51 *
52 * For backward compatibility, the default implementation of this method calls {@link #onCreated(Item)}.
53 * If you choose to handle this method, think about whether you want to call super.onCopied or not.
54 *
55 *
56 * @param src
57 * The source item that the new one was copied from. Never null.
58 * @param item
59 * The newly created item. Never null.
60 *
61 * @since 1.325
62 * Before this version, a copy triggered {@link #onCreated(Item)}.
63 */
64 public void onCopied(Item src, Item item) {
65 onCreated(item);
66 }
67
68 /**
69 * Called after all the jobs are loaded from disk into {@link jenkins.model.Jenkins}
70 * object.
71 */
72 public void onLoaded() {
73 }
74
75 /**
76 * Called right before a job is going to be deleted.
77 *
78 * At this point the data files of the job is already gone.
79 */
80 public void onDeleted(Item item) {
81 }
82
83 /**
84 * Called after a job is renamed.
85 *
86 * @param item
87 * The job being renamed.
88 * @param oldName
89 * The old name of the job.
90 * @param newName
91 * The new name of the job. Same as {@link Item#getName()}.
92 * @since 1.146
93 */
94 public void onRenamed(Item item, String oldName, String newName) {
95 }
96
97 /**
98 * Called after a job has its configuration updated.
99 *
100 * @since 1.460
101 */
102 public void onUpdated(Item item) {
103 }
104
105 /**
106 * @since 1.446
107 * Called at the begenning of the orderly shutdown sequence to
108 * allow plugins to clean up stuff
109 */
110 public void onBeforeShutdown() {
111 }
112
113 /**
114 * Registers this instance to Hudson and start getting notifications.
115 *
116 * @deprecated as of 1.286
117 * put {@link Extension} on your class to have it auto-registered.
118 */
119 public void register() {
120 all().add(this);
121 }
122
123 /**
124 * All the registered {@link ItemListener}s.
125 */
126 public static ExtensionList<ItemListener> all() {
127 return Jenkins.getInstance().getExtensionList(ItemListener.class);
128 }
129
130 public static void fireOnCopied(Item src, Item result) {
131 for (ItemListener l : all())
132 l.onCopied(src,result);
133 }
134
135 public static void fireOnCreated(Item item) {
136 for (ItemListener l : all())
137 l.onCreated(item);
138 }
139
140 public static void fireOnUpdated(Item item) {
141 for (ItemListener l : all())
142 l.onUpdated(item);
143 }
144 }
145