1 37 package net.sourceforge.cruisecontrol.servlet; 38 39 import java.io.IOException ; 40 import java.util.Map ; 41 42 import javax.management.AttributeNotFoundException ; 43 import javax.management.InstanceNotFoundException ; 44 import javax.management.InvalidAttributeValueException ; 45 import javax.management.MBeanException ; 46 import javax.management.MalformedObjectNameException ; 47 import javax.management.ReflectionException ; 48 49 import net.sourceforge.cruisecontrol.Configuration; 50 import net.sourceforge.cruisecontrol.interceptor.ConfigurationAware; 51 52 import org.jdom.JDOMException; 53 54 import com.opensymphony.xwork.ActionSupport; 55 import com.opensymphony.webwork.interceptor.SessionAware; 56 57 60 public class ConfigurationServlet extends ActionSupport implements ConfigurationAware, SessionAware { 61 private Configuration configuration; 62 private String project; 63 64 public String execute() { 65 return SUCCESS; 66 } 67 68 public String reload() throws AttributeNotFoundException , InstanceNotFoundException , MBeanException , 69 ReflectionException , IOException , JDOMException { 70 configuration.load(); 71 addActionMessage("Reloaded configuration."); 72 return SUCCESS; 73 } 74 75 public String save() throws InstanceNotFoundException , AttributeNotFoundException , InvalidAttributeValueException , 76 MBeanException , ReflectionException , IOException { 77 configuration.save(); 78 addActionMessage("Saved configuration."); 79 return SUCCESS; 80 } 81 82 public void setConfiguration(Configuration configuration) { 83 this.configuration = configuration; 84 } 85 86 public String getContents() throws AttributeNotFoundException , InstanceNotFoundException , 87 MalformedObjectNameException , NumberFormatException , MBeanException , ReflectionException , IOException , 88 JDOMException { 89 return configuration.getConfiguration(); 90 } 91 92 public void setContents(String contents) throws InstanceNotFoundException , AttributeNotFoundException , 93 InvalidAttributeValueException , MalformedObjectNameException , NumberFormatException , MBeanException , 94 ReflectionException , IOException { 95 this.configuration.setConfiguration(contents); 96 } 97 98 public void setSession(Map map) { 99 project = (String ) map.get("project"); 100 } 101 102 public String getProject() { 103 return project; 104 } 105 } 106 | Popular Tags |