Permalink
Browse files

doc improvement

  • Loading branch information...
1 parent 9fa5c94 commit 8b65afbea63431c2a10186184cd53aca0b92cd55 kohsuke committed Oct 9, 2010
@@ -33,21 +33,32 @@
import hudson.plugins.persona.simple.DefaultQuoteImpl;
/**
+ * A person and his/her set of quotes.
+ * <p>
+ * Normally a persona is someone famous, funny, or both (such as Chuck Norris.)
+ *
* @author Kohsuke Kawaguchi
*/
public abstract class Persona implements ExtensionPoint, ModelObject {
+ /**
+ * Uniquely identifies this persona among other personas.
+ */
public final String id;
protected Persona(String id) {
this.id = id;
}
+ protected Persona() {
+ id = getClass().getName();
+ }
+
/**
* Generates a random quote for the given build.
*
* @see DefaultQuoteImpl
*/
- public abstract Action generateQuote(AbstractBuild<?,?> build);
+ public abstract Quote generateQuote(AbstractBuild<?,?> build);
/**
* Returns all the registered {@link Persona}s.
@@ -23,12 +23,14 @@
*/
package hudson.plugins.persona;
+import hudson.model.AbstractBuild;
import hudson.model.Action;
/**
* Marks those actions that are quotes from persona.
*
* @author Kohsuke Kawaguchi
+ * @see Persona#generateQuote(AbstractBuild)
*/
public interface Quote extends Action {
}
@@ -23,6 +23,7 @@
*/
package hudson.plugins.persona;
+import hudson.Extension;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
@@ -75,6 +76,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
return true;
}
+ @Extension
public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {
@Override
public boolean isApplicable(Class<? extends AbstractProject> jobType) {
@@ -83,7 +85,7 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
@Override
public String getDisplayName() {
- return "Associate Quotes";
+ return "Associate Persona";
}
public ListBoxModel doFillPersonaItems() {
@@ -3,11 +3,14 @@
import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.plugins.persona.Persona;
+import hudson.plugins.persona.Quote;
import java.util.List;
import java.util.Random;
/**
+ * Partial implementation of {@link Persona} that renders the plain text quote with an icon.
+ *
* @author Kohsuke Kawaguchi
*/
public abstract class SimplePersona extends Persona {
@@ -31,7 +34,7 @@ protected SimplePersona(String id, List<String> quotes) {
public abstract Image getImage(AbstractBuild<?, ?> build);
@Override
- public synchronized Action generateQuote(AbstractBuild<?, ?> build) {
+ public synchronized Quote generateQuote(AbstractBuild<?, ?> build) {
return new DefaultQuoteImpl(build,this,quotes.get(random.nextInt(quotes.size())));
}
@@ -78,8 +78,14 @@ private String findImage(URL imageBase, String imageBasePath, String baseName) t
throw new IOException("No image found that matches "+imageBase+"/"+baseName+".*");
}
-
-
+ /**
+ * Parses a persona from an XML file.
+ *
+ * @param xml
+ * Location of the XML file.
+ * @param imageBase
+ * Base URL to find images like icon.png, success.jpg, and so on.
+ */
private SimplePersona parsePersona(URL xml, final URL imageBase, final String imageBasePath) throws DocumentException, IOException {
Document d = new SAXReader().read(xml);
Element r = d.getRootElement();

0 comments on commit 8b65afb

Please sign in to comment.