1 28 29 package org.objectweb.openccm.uml.transformation.rules.xml; 30 31 import ispuml.mdaTransformation.RuleContext; 32 import ispuml.mdaTransformation.TransformationException; 33 import ispuml.mdaTransformation.ActionBase; 34 import ispuml.mdaTransformation.rules.xml.CompositeXmlAction; 35 36 37 40 public class CallMethod extends CompositeXmlAction { 41 42 43 private String methodName; 44 45 48 public CallMethod() { 49 isSrcPropertyRequired = false; 52 isDstPropertyRequired = false; 53 action = new TransformAction(); 54 } 55 56 60 public void setMethodName (String methodName) { 61 this.methodName = methodName; 62 } 63 64 67 class TransformAction extends ActionBase { 68 74 public Object execute(Object bean, RuleContext request) throws TransformationException { 75 try { 76 Class param [] = new Class [0]; 77 java.lang.reflect.Method method = bean.getClass().getMethod(methodName, param); 78 return method.invoke(bean, null); 79 } catch (Exception exc) { 80 throw new TransformationException("The method " + methodName + "() does not exist on this bean."); 81 } 82 } 83 84 } } 86 | Popular Tags |