KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > scm > ChangeLogAnnotator


1 package hudson.scm;
2
3 import hudson.ExtensionPoint;
4 import hudson.MarkupText;
5 import hudson.util.CopyOnWriteList;
6 import hudson.scm.ChangeLogSet.Entry;
7 import hudson.model.AbstractBuild;
8
9 import java.util.logging.Logger JavaDoc;
10
11 /**
12  * Performs mark up on changelog messages to be displayed.
13  *
14  * <p>
15  * SCM changelog messages are usually plain text, but when we display that in Hudson,
16  * it is often nice to be able to put mark up on the text (for example to link to
17  * external issue tracking system.)
18  *
19  * <p>
20  * Plugins that are interested in doing so may extend this class and call {@link #register()}.
21  * When multiple annotators are registered, their results will be combined.
22  *
23  * @author Kohsuke Kawaguchi
24  * @since 1.70
25  */

26 public abstract class ChangeLogAnnotator implements ExtensionPoint {
27     /**
28      * Called by Hudson to allow markups to be added to the changelog text.
29      *
30      * <p>
31      * This method is invoked each time a page is rendered, so implementations
32      * of this method should not take too long to execute. Also note that
33      * this method may be invoked concurrently by multiple threads.
34      *
35      * <p>
36      * If there's any error during the processing, it should be recorded in
37      * {@link Logger} and the method should return normally.
38      *
39      * @param build
40      * Build that owns this changelog. From here you can access broader contextual
41      * information, like the project, or it settings. Never null.
42      * @param change
43      * The changelog entry for which this method is adding markup.
44      * Never null.
45      * @param text
46      * The text and markups. Implementation of this method is expected to
47      * add additional annotations into this object. If other annotators
48      * are registered, the object may already contain some markups when this
49      * method is invoked. Never null. {@link MarkupText#getText()} on this instance
50      * will return the same string as {@link Entry#getMsgEscaped()}.
51      */

52     public abstract void annotate(AbstractBuild<?,?> build, Entry change, MarkupText text );
53
54     /**
55      * Registers this annotator, so that Hudson starts using this object
56      * for adding markup.
57      */

58     public final void register() {
59         annotators.add(this);
60     }
61
62     /**
63      * Unregisters this annotator, so that Hudson stops using this object.
64      */

65     public final boolean unregister() {
66         return annotators.remove(this);
67     }
68
69     /**
70      * All registered {@link ChangeLogAnnotator}s.
71      */

72     public static final CopyOnWriteList<ChangeLogAnnotator> annotators = new CopyOnWriteList<ChangeLogAnnotator>();
73 }
74
Popular Tags