1 37 package net.sourceforge.cruisecontrol.listeners; 38 39 import net.sourceforge.cruisecontrol.CruiseControlException; 40 import net.sourceforge.cruisecontrol.PluginXMLHelper; 41 import net.sourceforge.cruisecontrol.ProjectXMLHelper; 42 import net.sourceforge.cruisecontrol.SelfConfiguringPlugin; 43 import net.sourceforge.cruisecontrol.util.ValidationHelper; 44 import org.jdom.Element; 45 import org.apache.log4j.Logger; 46 47 61 public class ListenerTestSelfConfiguringPlugin implements SelfConfiguringPlugin { 62 private static final Logger LOG = Logger.getLogger(ListenerTestSelfConfiguringPlugin.class); 63 64 private ListenerTestNestedPlugin nested; 65 private String string; 66 67 public void configure(Element element) throws CruiseControlException { 68 LOG.debug("configure()"); 69 if (element.getAttribute("string") != null) { 71 setString(element.getAttribute("string").getValue()); 72 } 73 PluginXMLHelper helper = new PluginXMLHelper(new ProjectXMLHelper()); 74 if (null != element.getChild("testnested")) { 75 nested = (ListenerTestNestedPlugin) helper.configure(element.getChild("testnested"), 76 ListenerTestNestedPlugin.class, false); 77 } 78 } 79 80 public void validate() throws CruiseControlException { 81 LOG.debug("validate()"); 82 ValidationHelper.assertIsSet(string, "string", this.getClass()); 83 ValidationHelper.assertIsSet(nested, "testnested", this.getClass()); 84 } 85 86 public void setString(String string) { 87 this.string = string.trim(); 88 } 89 90 public String getString() { 91 return string; 92 } 93 94 public ListenerTestNestedPlugin getNested() { 95 return nested; 96 } 97 } 98 | Popular Tags |