ItemListener.java 1.3 KB
Newer Older
1 2 3 4 5
package hudson.model.listeners;

import hudson.ExtensionPoint;
import hudson.model.Hudson;
import hudson.model.Item;
M
mindless 已提交
6
import hudson.model.Job;
7 8

/**
K
kohsuke 已提交
9 10
 * Receives notifications about CRUD operations of {@link Item}.
 *
11 12 13 14 15 16 17 18 19 20 21
 * @since 1.74
 * @author Kohsuke Kawaguchi
 */
public class ItemListener implements ExtensionPoint {
    /**
     * Called after a new job is created and added to {@link Hudson}.
     */
    public void onCreated(Item item) {
    }

    /**
M
mindless 已提交
22 23
     * Called after all the jobs are loaded from disk into {@link Hudson}
     * object.
24 25 26 27 28 29 30 31 32 33 34
     */
    public void onLoaded() {
    }

    /**
     * Called right before a job is going to be deleted.
     *
     * At this point the data files of the job is already gone.
     */
    public void onDeleted(Item item) {
    }
35 36 37 38 39 40 41 42 43 44 45 46 47 48

    /**
     * Called after a job is renamed.
     *
     * @param item
     *      The job being renamed.
     * @param oldName
     *      The old name of the job.
     * @param newName
     *      The new name of the job. Same as {@link Item#getName()}.
     * @since 1.146
     */
    public void onRenamed(Item item, String oldName, String newName) {
    }
K
kohsuke 已提交
49 50 51 52 53 54 55

    /**
     * Registers this instance to Hudson and start getting notifications.
     */
    public void register() {
        Hudson.getInstance().getJobListeners().add(this);
    }
56
}