From 8a2a463d46b3dce73015462c9f6a2a258dd25f5b Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期五, 25 二月 2022 11:40:11 +0800
Subject: [PATCH] 优化diamante
---
java110-core/src/main/java/com/java110/core/event/cmd/ServiceCmdEventPublishing.java | 45 +++++++++++++++++++++++++++++++++------------
1 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/java110-core/src/main/java/com/java110/core/event/cmd/ServiceCmdEventPublishing.java b/java110-core/src/main/java/com/java110/core/event/cmd/ServiceCmdEventPublishing.java
index 28e8ac0..3af6d82 100644
--- a/java110-core/src/main/java/com/java110/core/event/cmd/ServiceCmdEventPublishing.java
+++ b/java110-core/src/main/java/com/java110/core/event/cmd/ServiceCmdEventPublishing.java
@@ -1,16 +1,12 @@
package com.java110.core.event.cmd;
-import com.java110.core.annotation.Java110Cmd;
-import com.java110.core.context.DataFlowContext;
+import com.alibaba.fastjson.JSONObject;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.center.DataFlowListenerOrderComparator;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.core.event.service.api.ServiceDataFlowListener;
+import com.java110.core.log.LoggerFactory;
import com.java110.dto.CmdListenerDto;
-import com.java110.entity.center.AppService;
import com.java110.utils.constant.CommonConstant;
import com.java110.utils.constant.ResponseConstant;
-import com.java110.utils.constant.ServiceCodeConstant;
import com.java110.utils.exception.BusinessException;
import com.java110.utils.exception.CmdException;
import com.java110.utils.exception.ListenerExecuteException;
@@ -18,10 +14,10 @@
import com.java110.utils.log.LoggerEngine;
import com.java110.utils.util.Assert;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpMethod;
+import sun.misc.ProxyGenerator;
-import java.lang.annotation.Annotation;
+import java.io.File;
+import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -88,8 +84,9 @@
List<ServiceCmdListener> cmdListeners = new ArrayList<ServiceCmdListener>();
for (CmdListenerDto listenerBean : getListeners()) {
+ //ServiceCmdListener listener = ApplicationContextFactory.getBean(listenerBean.getBeanName(), ServiceCmdListener.class);
ServiceCmdListener listener = ApplicationContextFactory.getBean(listenerBean.getBeanName(), ServiceCmdListener.class);
- if(listenerBean.getServiceCode().equals(serviceCode)) {
+ if (listenerBean.getServiceCode().equals(serviceCode)) {
cmdListeners.add(listener);
}
}
@@ -124,7 +121,7 @@
* @param dataFlowContext
*/
public static void multicastEvent(String serviceCode, ICmdDataFlowContext dataFlowContext) throws BusinessException {
- multicastEvent(serviceCode, dataFlowContext, null);
+ multicastEvent(serviceCode, dataFlowContext, null);
}
/**
@@ -199,10 +196,34 @@
@SuppressWarnings({"unchecked", "rawtypes"})
protected static void invokeListener(ServiceCmdListener listener, CmdEvent event) {
try {
- listener.cmd(event);
+ // //杩欓噷澶勭悊涓氬姟閫昏緫鏁版嵁
+ ICmdDataFlowContext dataFlowContext = event.getCmdDataFlowContext();
+ //鑾峰彇璇锋眰鏁版嵁
+ JSONObject reqJson = dataFlowContext.getReqJson();
+
+ logger.debug("API鏈嶅姟 --- 璇锋眰鍙傛暟涓猴細{}", reqJson.toJSONString());
+
+ listener.validate(event, dataFlowContext, reqJson);
+
+ listener.doCmd(event, dataFlowContext, reqJson);
+
+ //logger.debug("API鏈嶅姟 --- 杩斿洖鎶ユ枃淇℃伅锛歿}", dataFlowContext.getResponseEntity());
+ // listener.cmd(event);
} catch (CmdException e) {
LoggerEngine.error("鍙戝竷渚﹀惉澶辫触", e);
throw e;
}
}
+
+ public static void testPoxy(Class clazz) {
+ byte[] bytes = ProxyGenerator.generateProxyClass("$Proxy", new Class[]{clazz});
+ try (
+ FileOutputStream fos = new FileOutputStream(new File("D:/$Proxy.class"))
+ ) {
+ fos.write(bytes);
+ fos.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
--
Gitblit v1.8.0