This commit is contained in:
2019-03-07 10:24:29 +08:00
parent 6c8c683c31
commit e057d613b9
215 changed files with 70917 additions and 118 deletions

View File

@@ -0,0 +1,53 @@
package net.tccn.qtask.impl;
import net.tccn.qtask.E;
import net.tccn.base.Kv;
import net.tccn.qtask.QTask;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class QTaskMethod extends QTaskAbs implements QTask {
public QTaskMethod(E e) {
super(e);
}
public String getClazz(){
String queryId = getE().queryId;
return queryId.substring(0, queryId.lastIndexOf("."));
}
public String getMethod(){
String queryId = getE().queryId;
return queryId.substring(queryId.lastIndexOf(".") + 1);
}
public Kv getPara() {
return getE().para;
}
// execute JAVA method by CLASS AND METHOD
@Override
public Object execute() {
try {
Class<?> type = Class.forName(getClazz());
Object obj = type.newInstance();
Method method = type.getMethod(getMethod(), Kv.class);
return method.invoke(obj, getPara());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
}