className:实现类的名称,包含全路径
functionName:方法名
beanName:beanId,即@Service()中value的值
FwaApplicationUtils.getInstance().getApplicationContext():获取spring_context
代码如下:
Class<?> clz = Class.forName(className);
Object myservice = FwaApplicationUtils.getInstance().getApplicationContext().getBean(beanName);
Method m =null;
if(paramsType.equalsIgnoreCase("map")){
m = clz.getMethod(functionName,Map.class);
Map<String, String> map=new HashMap<String, String>();
map.put("periodId", "201606");
m.invoke(myservice,map);
}else if(paramsType.equalsIgnoreCase("string")){
m = clz.getMethod(functionName,String.class);
String kpiTime="201603";
m.invoke(myservice,kpiTime);
}else{
m = clz.getMethod(functionName);
m.invoke(myservice);
}
时间: 2025-01-04 11:00:28