1 37 package net.sourceforge.cruisecontrol.interceptor; 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.MBeanException ; 45 import javax.management.ReflectionException ; 46 47 import net.sourceforge.cruisecontrol.Configuration; 48 import net.sourceforge.cruisecontrol.PluginConfiguration; 49 import net.sourceforge.cruisecontrol.PluginDetail; 50 51 import org.jdom.JDOMException; 52 53 import com.opensymphony.xwork.Action; 54 import com.opensymphony.xwork.ActionContext; 55 import com.opensymphony.xwork.ActionInvocation; 56 import com.opensymphony.xwork.interceptor.AroundInterceptor; 57 58 61 public class DetailsInterceptor extends AroundInterceptor { 62 protected void before(ActionInvocation invocation) throws Exception { 63 Action action = invocation.getAction(); 64 65 if (action instanceof DetailsAware) { 66 ActionContext invocationContext = invocation.getInvocationContext(); 67 Map parameters = invocationContext.getParameters(); 68 String pluginName = ((String []) parameters.get("pluginName"))[0]; 69 String pluginType = ((String []) parameters.get("pluginType"))[0]; 70 71 Configuration configuration = (Configuration) invocationContext.getSession().get("cc-configuration"); 72 73 PluginConfiguration details = getPluginConfiguration(pluginName, pluginType, configuration); 74 ((DetailsAware) action).setDetails(details); 75 } 76 } 77 78 protected void after(ActionInvocation dispatcher, String result) throws Exception { 79 } 80 81 private PluginConfiguration getPluginConfiguration(String name, String type, Configuration configuration) 82 throws AttributeNotFoundException , InstanceNotFoundException , MBeanException , ReflectionException , 83 IOException , JDOMException { 84 PluginLocator locator = new PluginLocator(configuration); 85 PluginDetail pluginDetail = locator.getPluginDetail(name, type); 86 return new PluginConfiguration(pluginDetail, configuration); 87 } 88 } 89 | Popular Tags |