use of org.nutz.el.opt.RunMethod in project nutz by nutzam.
the class ByMake method run.
public Object run(List<Object> fetchParam) {
if (fetchParam.isEmpty())
throw new ElException("'by' must have params");
String p = (String) fetchParam.remove(0);
String className = p;
String methodName = null;
if (p.contains("#")) {
String[] tmp = p.split("#");
className = tmp[0];
methodName = tmp[1];
}
try {
Class<?> klass = Lang.loadClass(className);
if (methodName == null) {
methodName = "run";
}
if (RunMethod.class.isAssignableFrom(klass)) {
return ((RunMethod) klass.newInstance()).run(fetchParam);
}
Object[] args = fetchParam.toArray();
Method method = Mirror.me(klass).findMethod(methodName, args);
if (Modifier.isStatic(method.getModifiers())) {
return method.invoke(null, args);
} else {
return method.invoke(klass.newInstance(), args);
}
} catch (Exception e) {
throw new ElException(e);
}
}
use of org.nutz.el.opt.RunMethod in project nutz by nutzam.
the class CustomMake method init.
/**
* 加载插件
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public CustomMake init() {
List<String> plug = (List<String>) ((Map) NutConf.get("EL")).get("custom");
String[] t = plug.toArray(new String[0]);
PluginManager<RunMethod> rm = new SimplePluginManager<RunMethod>(t);
for (RunMethod r : rm.gets()) {
me().runms.put(r.fetchSelf(), r);
}
return this;
}
Aggregations