From 28441b3922e6188f643d145a32c55d4fa285af84 Mon Sep 17 00:00:00 2001
From: wuxw7 <wuxw7@asiainfo.com>
Date: 星期三, 13 六月 2018 00:11:52 +0800
Subject: [PATCH] 日志保存 和 调用链开发

---
 java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContext.java |   79 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContext.java b/java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContext.java
index 9c1ab84..822799e 100644
--- a/java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContext.java
+++ b/java110-core/src/main/java/com/java110/core/context/AbstractDataFlowContext.java
@@ -2,17 +2,22 @@
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.common.factory.ApplicationContextFactory;
+import com.java110.common.log.LoggerEngine;
+import com.java110.common.util.DateUtil;
 import com.java110.entity.center.Business;
 import com.java110.entity.center.DataFlowLinksCost;
 import com.java110.entity.center.DataFlowLog;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.*;
 
 /**
  * 鏁版嵁娴佷笂涓嬫枃
  * Created by wuxw on 2018/5/18.
  */
-public abstract class AbstractDataFlowContext implements DataFlowContext,Orders{
+public abstract class AbstractDataFlowContext extends AbstractTransactionLog implements DataFlowContext,Orders,TransactionLog{
 
     private String dataFlowId;
 
@@ -66,7 +71,37 @@
      * @return
      * @throws Exception
      */
-    public abstract DataFlowContext builder(String reqInfo, Map<String,String> headerAll) throws Exception;
+    public  <T> T builder(String reqInfo, Map<String,String> headerAll) throws Exception{
+        //棰勫鐞�
+        preBuilder(reqInfo, headerAll);
+        //璋冪敤builder
+        T dataFlowContext = (T)doBuilder(reqInfo, headerAll);
+        //鍚庡鐞�
+        afterBuilder((DataFlowContext) dataFlowContext);
+        return dataFlowContext;
+    }
+
+    /**
+     * 棰勫鐞�
+     * @param reqInfo
+     * @param headerAll
+     */
+    protected void preBuilder(String reqInfo, Map<String,String> headerAll) {
+        super.preBuilder(reqInfo,headerAll);
+    }
+
+    /**
+     * 鏋勫缓瀵硅薄
+     * @param reqInfo
+     * @param headerAll
+     * @return
+     * @throws Exception
+     */
+    public abstract DataFlowContext doBuilder(String reqInfo, Map<String,String> headerAll) throws Exception;
+
+    protected void afterBuilder(DataFlowContext dataFlowContext){
+
+    }
 
     public void setTransactionId(String transactionId) {
         this.transactionId = transactionId;
@@ -219,6 +254,16 @@
 
     public String getUserId(){return null;};
 
+    @Override
+    public void setAppId(String appId) {
+
+    }
+
+    @Override
+    public void setUserId(String userId) {
+
+    }
+
     public String getRemark(){return null;};
 
     public String getReqSign(){return null;};
@@ -261,6 +306,36 @@
         return null;
     }
 
+    public String getLogId(){
+        return getbId();
+    }
+
+
+    /**
+     * 涓氬姟缂栫爜 褰撳墠闇�瑕佸鐞嗙殑涓氬姟缂栫爜锛屽彲浠ュ啓灏嗚璇锋眰鏈嶅姟鎻愪緵鏂圭殑鏂规硶鍚�
+     * 涓昏鐢ㄤ簬 鏃ュ織绔睍绀�
+     * @return 褰撳墠鏈嶅姟缂栫爜
+     */
+    public String getServiceCode(){
+        if(this.currentBusiness != null){
+            return currentBusiness.getServiceCode();
+        }
+        return "";
+    }
+
+    /**
+     * 涓氬姟鍚嶇О 褰撳墠闇�瑕佸鐞嗙殑涓氬姟鍚嶇О锛屽彲浠ュ綋鍓嶈皟鐢ㄧ殑涓氬姟鍚嶇О 濡� 鍟嗗搧璐拱 绛�
+     * 涓昏鐢ㄤ簬 鏃ュ織绔睍绀�
+     * @return 褰撳墠鏈嶅姟鍚嶇О
+     */
+    public String getServiceName(){
+        if(this.currentBusiness != null){
+            return currentBusiness.getServiceName();
+        }
+        return "";
+    }
+
+
     public abstract Orders getOrder();
 
     protected AbstractDataFlowContext(Date startDate, String code){

--
Gitblit v1.8.0