ConfigShow.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.persagy.business.maintain;
  2. import java.lang.reflect.Method;
  3. import java.util.List;
  4. import java.util.Map;
  5. import org.springframework.stereotype.Service;
  6. import com.persagy.core.service.BaseBusinessService;
  7. import com.persagy.core.service.BusinessService;
  8. import com.persagy.weather.util.ConfigUtil;
  9. @Service("ConfigShow")
  10. @SuppressWarnings({"unchecked","rawtypes" })
  11. public class ConfigShow extends BaseBusinessService<Map> implements BusinessService {
  12. @Override
  13. public void handle(Map dto, List content) throws Exception {
  14. String method = (String) dto.get("method");
  15. List<String> paramList = (List)dto.get("paramList");
  16. if(method == null) {
  17. throw new Exception("method不能为空!");
  18. }
  19. Method m = null;
  20. Object result = null;
  21. try {
  22. if(paramList != null) {
  23. int paramNum = paramList.size();
  24. if(paramNum > 0) {
  25. Class[] clzAray = new Class[paramNum];
  26. String[] paramValue = new String[paramNum];
  27. for (int i = 0; i < paramNum; i++) {
  28. clzAray[i] = String.class;
  29. paramValue[i] = paramList.get(i);
  30. }
  31. m = ConfigUtil.class.getMethod(method, clzAray);
  32. result = m.invoke(new ConfigUtil(), paramValue);
  33. }
  34. }else {
  35. m = ConfigUtil.class.getMethod(method);
  36. result = m.invoke(new ConfigUtil());
  37. }
  38. }catch (Exception e) {
  39. result = "Error! " + e.getMessage();
  40. }
  41. content.add(result);
  42. }
  43. }