if (!CollectionUtils.isEmpty(httpProviderConf.getUsePackage())){ booleanisPac=false ; for (String pac : httpProviderConf.getUsePackage()) { if (service.startsWith(pac)){ isPac = true ; break ; } } if (!isPac){ //调用的是未经配置的包 logger.error("service is not correct,service="+service); response.setCode("2"); response.setSuccess(false); response.setDescription("service is not correct,service="+service); }
//设置缓存 cacheMap.put(service,serviceCla) ; } Method[] methods = serviceCla.getMethods(); MethodtargetMethod=null ; for (Method m : methods) { if (m.getName().equals(method)){ targetMethod = m ; break ; } }
if (method == null){ logger.error("method is not correct,method="+method); response.setCode("2"); response.setSuccess(false); response.setDescription("method is not correct,method="+method); }
Objectbean=this.applicationContext.getBean(serviceCla); Objectresult=null ; Class<?>[] parameterTypes = targetMethod.getParameterTypes(); if (parameterTypes.length == 0){ //没有参数 result = targetMethod.invoke(bean); }elseif (parameterTypes.length == 1){ Objectjson= JSON.parseObject(httpRequest.getParam(), parameterTypes[0]); result = targetMethod.invoke(bean,json) ; }else { logger.error("Can only have one parameter"); response.setSuccess(false); response.setCode("2"); response.setDescription("Can only have one parameter"); } return JSON.toJSONString(result) ;
s = request.getHeader("Proxy-Client-IP"); } if (s == null || s.length() == 0 || "unknown".equalsIgnoreCase(s)) {
s = request.getHeader("WL-Proxy-Client-IP"); } if (s == null || s.length() == 0 || "unknown".equalsIgnoreCase(s)) { s = request.getHeader("HTTP_CLIENT_IP"); } if (s == null || s.length() == 0 || "unknown".equalsIgnoreCase(s)) {
s = request.getHeader("HTTP_X_FORWARDED_FOR"); } if (s == null || s.length() == 0 || "unknown".equalsIgnoreCase(s)) {
s = request.getRemoteAddr(); } if ("127.0.0.1".equals(s) || "0:0:0:0:0:0:0:1".equals(s)) try { s = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException unknownhostexception) { return""; } return s; }