1 package org.jicengine.operation; 2 3 import java.util.Collection ; 4 5 14 15 public class MethodInvocationOperation extends InvocationOperation { 16 17 private String methodName; 18 19 public MethodInvocationOperation(String signature, Operation actor, String methodName, Operation[] parameters) 20 { 21 super(signature, actor, parameters); 22 this.methodName = methodName; 23 } 24 25 public Object execute(Object actor, Object [] arguments) throws OperationException 26 { 27 try { 28 if( actor instanceof Class ){ 29 return ReflectionUtils.invokeStaticMethod((Class )actor, this.methodName, arguments); 31 } 32 else { 33 return ReflectionUtils.invokeMethod(actor, this.methodName, arguments); 35 } 36 } catch (java.lang.reflect.InvocationTargetException e){ 37 throw new OperationException("'" + toString() + "' resulted in exception", e.getTargetException()); 40 } catch (Exception e2){ 41 throw new OperationException("'" + toString() + "': " + e2.getMessage(), e2); 42 } 43 } 44 45 } 46 | Popular Tags |