1 package com.opensymphony.webwork.config_browser; 2 3 import com.opensymphony.xwork.ObjectFactory; 4 import com.opensymphony.xwork.config.entities.ActionConfig; 5 import ognl.OgnlRuntime; 6 import org.apache.commons.logging.Log; 7 import org.apache.commons.logging.LogFactory; 8 9 import java.beans.PropertyDescriptor ; 10 import java.util.Set ; 11 import java.util.TreeSet ; 12 13 18 public class ShowConfigAction extends ActionNamesAction { 19 private static final PropertyDescriptor [] PDSAT = new PropertyDescriptor [0]; 20 21 private String namespace; 22 private String actionName; 23 private ActionConfig config; 24 private Set actionNames; 25 private String detailView = "results"; 26 private PropertyDescriptor [] properties; 27 private static Log log = LogFactory.getLog(ShowConfigAction.class); 28 29 public String getDetailView() { 30 return detailView; 31 } 32 33 public void setDetailView(String detailView) { 34 this.detailView = detailView; 35 } 36 37 public Set getActionNames() { 38 return actionNames; 39 } 40 41 public String getNamespace() { 42 return namespace; 43 } 44 45 public String stripPackage(Class clazz) { 46 return clazz.getName().substring(clazz.getName().lastIndexOf('.') + 1); 47 } 48 49 public void setNamespace(String namespace) { 50 this.namespace = namespace; 51 } 52 53 public String getActionName() { 54 return actionName; 55 } 56 57 public void setActionName(String actionName) { 58 this.actionName = actionName; 59 } 60 61 public ActionConfig getConfig() { 62 return config; 63 } 64 65 public PropertyDescriptor [] getProperties() { 66 return properties; 67 } 68 69 public String execute() throws Exception { 70 super.execute(); 71 config = ConfigurationHelper.getActionConfig(namespace, actionName); 72 actionNames = 73 new TreeSet (ConfigurationHelper.getActionNames(namespace)); 74 try { 75 Class clazz = ObjectFactory.getObjectFactory().getClassInstance(getConfig().getClassName()); 76 java.util.Collection pds = OgnlRuntime.getPropertyDescriptors(clazz).values(); 77 properties = (PropertyDescriptor []) pds.toArray(PDSAT); 78 } catch (Exception e) { 79 log.error("Unable to get properties for action " + actionName, e); 80 addActionError("Unable to retrieve action properties: " + e.toString()); 81 } 82 83 if (hasErrors()) return ERROR; 85 else 86 return SUCCESS; 87 } 88 } 89 90 | Popular Tags |