1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.core.execution.tasks;
17
18 import java.lang.reflect.Method;
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.springframework.util.Assert;
23 import org.springframework.util.ReflectionUtils;
24
25 public class MethodCall implements Runnable {
26 private Object target;
27 private String method;
28 private List<Object> args = new ArrayList<Object>();
29
30 public void run() {
31 Assert.notNull(target, "target");
32 Assert.notNull(method, "method");
33 Method methodRef = ReflectionUtils
34 .findMethod(target.getClass(), method);
35 if (args.size() == 0)
36 ReflectionUtils.invokeMethod(methodRef, target);
37 else
38 ReflectionUtils.invokeMethod(methodRef, methodRef, args.toArray());
39 }
40
41 public void setTarget(Object target) {
42 this.target = target;
43 }
44
45 public void setMethod(String method) {
46 this.method = method;
47 }
48
49 public void setArgs(List<Object> args) {
50 this.args = args;
51 }
52
53 }