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);
}
本文转自tianjian_0913 51CTO博客,原文链接:http://blog.51cto.com/tianjian/1841581,如需转载请自行联系原作者