KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > maven > MavenReporterDescriptor


1 package hudson.maven;
2
3 import hudson.maven.reporters.MavenArtifactArchiver;
4 import hudson.model.Descriptor;
5 import org.apache.commons.jelly.JellyException;
6 import org.kohsuke.stapler.MetaClass;
7 import org.kohsuke.stapler.StaplerRequest;
8 import org.kohsuke.stapler.jelly.JellyClassTearOff;
9
10 /**
11  * {@link Descriptor} for {@link MavenReporter}.
12  *
13  * @author Kohsuke Kawaguchi
14  */

15 public abstract class MavenReporterDescriptor extends Descriptor<MavenReporter> {
16     protected MavenReporterDescriptor(Class JavaDoc<? extends MavenReporter> clazz) {
17         super(clazz);
18     }
19
20     /**
21      * Returns an instance used for automatic {@link MavenReporter} activation.
22      *
23      * <p>
24      * Some {@link MavenReporter}s, such as {@link MavenArtifactArchiver},
25      * can work just with the configuration in POM and don't need any additional
26      * Hudson configuration. They also don't need any explicit enabling/disabling
27      * as they can activate themselves by listening to the callback from the build
28      * (for example javadoc archiver can do the work in response to the execution
29      * of the javadoc target.)
30      *
31      * <p>
32      * Those {@link MavenReporter}s should return a valid instance
33      * from this method. Such instance will then participate into the build
34      * and receive event callbacks.
35      */

36     public MavenReporter newAutoInstance(MavenModule module) {
37         return null;
38     }
39
40     /**
41      * If {@link #hasConfigScreen() the reporter has no configuration screen},
42      * this method can safely return null, which is the default implementation.
43      */

44     public MavenReporter newInstance(StaplerRequest req) throws FormException {
45         return null;
46     }
47
48     /**
49      * Returns true if this descriptor has <tt>config.jelly</tt>.
50      */

51     public final boolean hasConfigScreen() {
52         MetaClass c = MetaClass.get(getClass());
53         try {
54             JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class);
55             return tearOff.findScript(getConfigPage())!=null;
56         } catch(JellyException e) {
57             return false;
58         }
59     }
60 }
61
Popular Tags