From 068fc7f2e81178e55fa191a13709af64b1a163f6 Mon Sep 17 00:00:00 2001 From: EricsHu <hrr145632> Date: 星期一, 05 十二月 2022 14:27:43 +0800 Subject: [PATCH] 处理编码 --- src/main/java/com/qxueyou/scc/base/handler/QCacheMonitor.java | 54 +++++++++++++++++++++++++++--------------------------- 1 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/base/handler/QCacheMonitor.java b/src/main/java/com/qxueyou/scc/base/handler/QCacheMonitor.java index 51c599c..c878daf 100644 --- a/src/main/java/com/qxueyou/scc/base/handler/QCacheMonitor.java +++ b/src/main/java/com/qxueyou/scc/base/handler/QCacheMonitor.java @@ -47,12 +47,12 @@ private static Pattern argPattern = Pattern.compile("\\$\\{arg([0-9])\\}"); - //判断当前线程是否已经执行过目标方法的标志 + //鍒ゆ柇褰撳墠绾跨▼鏄惁宸茬粡鎵ц杩囩洰鏍囨柟娉曠殑鏍囧織 private final ThreadLocal<Map<String, Object>> targetMethodResult = new ThreadLocal<Map<String, Object>>(); private Configuration cfg; - /** 缓存 **/ + /** 缂撳瓨 **/ @Autowired ICacheService cache; @@ -86,9 +86,9 @@ excuteMethodKey = this.getExecuteMethodKey(pjp); - //读取缓存的注解 + //璇诲彇缂撳瓨鐨勬敞瑙� annoQCacheReader = AnnotationUtils.findAnnotation(methodSignature.getMethod(), QCacheReader.class); - //清理缓存注解 + //娓呯悊缂撳瓨娉ㄨВ annoQCacheCleaner = AnnotationUtils.findAnnotation(methodSignature.getMethod(), QCacheCleaner.class); if(annoQCacheReader!=null && annoQCacheCleaner==null){ @@ -104,7 +104,7 @@ this.processReadCache(pjp, annoQCacheReader, methodSignature); } } catch (Exception e) { - logger.error("缓存处理失败,msg=" + e.getMessage(), e); + logger.error("缂撳瓨澶勭悊澶辫触锛宮sg=" + e.getMessage(), e); } return clearAndReturnMethodResult(pjp,excuteMethodKey); @@ -120,7 +120,7 @@ strCacheKey = this.checkAndGenerateCacheKey(pjp.getTarget().getClass(), qCacheReader.cacheKey(), methodSignature, converToParamMap(pjp.getArgs())); - //执行方法对应的key值 + //鎵ц鏂规硶瀵瑰簲鐨刱ey鍊� String excuteMethodKey = this.getExecuteMethodKey(pjp); if (StringUtils.isNotEmpty(strCacheKey)) { @@ -138,7 +138,7 @@ targetMethodResult.get().get(excuteMethodKey), expireTime); } }else{ - //如果result存在,则直接放入targetMethodResult中 + //濡傛灉result瀛樺湪锛屽垯鐩存帴鏀惧叆targetMethodResult涓� Map<String,Object> map = new HashMap<String,Object>(); map.put(excuteMethodKey, result); targetMethodResult.set(map); @@ -147,7 +147,7 @@ executeTargetMethod(pjp,excuteMethodKey); } } catch (Throwable e) { - throw new Exception("添加缓存发生异常,strCacheKey=" + strCacheKey, e); + throw new Exception("娣诲姞缂撳瓨鍙戠敓寮傚父,strCacheKey=" + strCacheKey, e); } } @@ -169,11 +169,11 @@ for (int i = 0; i < strClearBucketArr.length; i++) { strClearBucketArr[i] = CacheConstants.QXY_SERVICE_CACHE_NS.concat(strClearBucketArr[i]); } - logger.info("清理的bucket:"+ArrayUtils.toString(strClearBucketArr)); + logger.info("娓呯悊鐨刡ucket:"+ArrayUtils.toString(strClearBucketArr)); this.qCacheRedis.del(strClearBucketArr); } } catch (Throwable e) { - logger.error("清理缓存发生异常,strClearBucketArr" + ArrayUtils.toString(strClearBucketArr, ""), e); + logger.error("娓呯悊缂撳瓨鍙戠敓寮傚父锛宻trClearBucketArr" + ArrayUtils.toString(strClearBucketArr, ""), e); } } @@ -182,16 +182,16 @@ String strNewKey = null; if (StringUtils.isNotEmpty(key)) { - logger.info("处理前的key:" + key); + logger.info("澶勭悊鍓嶇殑key:" + key); - // 对部分参数进行替换处理 + // 瀵归儴鍒嗗弬鏁拌繘琛屾浛鎹㈠鐞� strNewKey = replaceArgInfo(key, paramMap); - // freeMarker解析cackeKey + // freeMarker瑙f瀽cackeKey strNewKey = parseCacheKey(strNewKey, targetClass, methodSignature, paramMap); - logger.info("处理后的key:" + strNewKey); + logger.info("澶勭悊鍚庣殑key:" + strNewKey); if (strNewKey.length() > MAX_KEY_LENGTH) { - throw new Exception("Service缓存时Key过长,大于250个字符"); + throw new Exception("Service缂撳瓨鏃禟ey杩囬暱锛屽ぇ浜�250涓瓧绗�"); } } return strNewKey; @@ -227,7 +227,7 @@ out.flush(); return new String(stream.toByteArray(), "UTF-8"); } catch (Exception e) { - logger.error("使用freemark解析cacheKey失败", e); + logger.error("浣跨敤freemark瑙f瀽cacheKey澶辫触", e); throw e; } finally { IoUtils.closeQuietly(stream); @@ -241,17 +241,17 @@ String strParamName = null; Class<?> paramClz = null; - logger.info("替换前的key:" + strCacheKey); + logger.info("鏇挎崲鍓嶇殑key:" + strCacheKey); if (StringUtils.isNotEmpty(strCacheKey) && paramMap != null && !paramMap.isEmpty()) { matcher = argPattern.matcher(strCacheKey); while (matcher.find()) { strParamName = "arg" + matcher.group(1); - // 参数类型判断 + // 鍙傛暟绫诲瀷鍒ゆ柇 if (paramMap.containsKey(strParamName)) { if(paramMap.get(strParamName)!=null){ paramClz = paramMap.get(strParamName).getClass(); if (paramClz.isAssignableFrom(java.lang.Object.class)) { - throw new Exception("错误:缓存参数类型不能是Object.class类型的对象"); + throw new Exception("閿欒:缂撳瓨鍙傛暟绫诲瀷涓嶈兘鏄疧bject.class绫诲瀷鐨勫璞�"); } else if (paramClz.isAssignableFrom(java.util.List.class) || paramClz.isArray()) { matcher.appendReplacement(sbBuffer, "<#list " + strParamName + " as node>_${node}</#list>"); } else if (paramClz.isAssignableFrom(java.util.Map.class)) { @@ -262,11 +262,11 @@ } } } else { - throw new Exception("错误:参数表达式中存在不合法的参数"); + throw new Exception("閿欒:鍙傛暟琛ㄨ揪寮忎腑瀛樺湪涓嶅悎娉曠殑鍙傛暟"); } } matcher.appendTail(sbBuffer); - logger.info("替换后的key:" + sbBuffer.toString()); + logger.info("鏇挎崲鍚庣殑key:" + sbBuffer.toString()); return sbBuffer.toString(); }else{ return strCacheKey; @@ -305,7 +305,7 @@ } /** - * 执行目标方法,只允许执行一次,并保存当前结果 + * 鎵ц鐩爣鏂规硶锛屽彧鍏佽鎵ц涓�娆★紝骞朵繚瀛樺綋鍓嶇粨鏋� * @param pjp * @param key * @throws Throwable @@ -315,7 +315,7 @@ if(StringUtils.isEmpty(excuteMethodKey)){ excuteMethodKey = this.getExecuteMethodKey(pjp); } - //是否需要判断是否是void方法 + //鏄惁闇�瑕佸垽鏂槸鍚︽槸void鏂规硶 if(targetMethodResult.get()==null || !targetMethodResult.get().containsKey(excuteMethodKey)){ Map<String,Object> map = new HashMap<String,Object>(); map.put(excuteMethodKey, pjp.proceed()); @@ -324,7 +324,7 @@ } /** - * 返回并清理ThreadLocal<Map<String, Object>>的MAP中的KEY + * 杩斿洖骞舵竻鐞員hreadLocal<Map<String, Object>>鐨凪AP涓殑KEY * @param pjp * @param key * @throws Throwable @@ -335,7 +335,7 @@ if(StringUtils.isEmpty(excuteMethodKey)){ excuteMethodKey = getExecuteMethodKey(pjp); } - //是否需要判断是否是void方法(TODO) + //鏄惁闇�瑕佸垽鏂槸鍚︽槸void鏂规硶(TODO) if(targetMethodResult.get()!=null && targetMethodResult.get().containsKey(excuteMethodKey)){ result =targetMethodResult.get().get(excuteMethodKey); targetMethodResult.get().remove(excuteMethodKey); @@ -346,7 +346,7 @@ } /** - * 返回当前目标方法的执行结果存储在ThreadLocal<Map<String, Object>>的MAP中的KEY + * 杩斿洖褰撳墠鐩爣鏂规硶鐨勬墽琛岀粨鏋滃瓨鍌ㄥ湪ThreadLocal<Map<String, Object>>鐨凪AP涓殑KEY * @param pjp * @return key */ @@ -382,7 +382,7 @@ // } // es.shutdown(); // if(es.awaitTermination(1, java.util.concurrent.TimeUnit.HOURS)){ -// System.out.println("线程执行完成"); +// System.out.println("绾跨▼鎵ц瀹屾垚"); // } // long end = System.currentTimeMillis(); // System.out.println(start-end); -- Gitblit v1.8.0