From 4f99f59668c9160ca60958b7347944def26f2228 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期日, 27 四月 2025 10:58:53 +0800
Subject: [PATCH] 回退配置

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java |  116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java
new file mode 100644
index 0000000..38cc9dd
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java
@@ -0,0 +1,116 @@
+package com.dy.common.mw.support;
+
+
+import com.dy.common.threadPool.TreadPoolFactory;
+import com.dy.common.mw.UnitAdapterInterface;
+import com.dy.common.mw.UnitInterface;
+import com.dy.common.mw.UnitCallbackInterface;
+
+public class SupportUnit implements UnitInterface {
+	
+	private final static SupportUnit instance = new SupportUnit() ;
+	private static boolean started = false ;
+	
+	private SupportUnitAdapter adapter ;
+	
+	private SupportUnitConfigVo confVo ;
+	
+
+	private SupportUnit(){}
+	
+	public static SupportUnit getInstance(){
+		return instance ;
+	}
+	
+	@Override
+	public void setAdapter(UnitAdapterInterface adapter) throws Exception {
+		if(adapter == null){
+			throw new Exception("鏀寔妯″潡閫傞厤鍣ㄥ璞′笉鑳戒负绌猴紒") ;
+		}
+		
+		this.adapter = (SupportUnitAdapter)adapter ; 
+		this.confVo = this.adapter.getConfig() ;
+		if(this.confVo == null){
+			throw new Exception("鏀寔妯″潡閰嶇疆瀵硅薄涓嶈兘涓虹┖锛�") ;
+		}
+	}
+
+	@Override
+	public void start(UnitCallbackInterface callback) throws Exception {
+		if(!started){
+			started = true ;
+			if(confVo.enableShortThreadPool) {
+				TreadPoolFactory.initThreadPoolShort("鐭换鍔″伐浣滅嚎绋嬫睜",
+						this.confVo.short_maxThread,
+						this.confVo.short_minThread,
+						this.confVo.short_freeTimeout,
+						this.confVo.short_busyTimeout);
+			}else{
+				System.out.println("鐭嚎绋嬫睜閰嶇疆涓嶅惎鍔�");
+			}
+			if(confVo.enableLongThreadPool) {
+				TreadPoolFactory.initThreadPoolLong("闀夸换鍔″伐浣滅嚎绋嬫睜",
+						this.confVo.long_maxThread,
+						this.confVo.long_minThread,
+						this.confVo.long_freeTimeout,
+						this.confVo.long_busyTimeout);
+			}else{
+				System.out.println("闀跨嚎绋嬫睜閰嶇疆涓嶅惎鍔�");
+			}
+			if(this.confVo.showStartInfo){
+				System.out.println("绾跨▼姹犳ā鍧楁垚鍔熷惎鍔�");
+			}
+		}
+		callback.call(null);
+	}
+
+	@Override
+	public void stop(UnitCallbackInterface callback) {
+	}
+	
+	/*
+	public static void main(String[] args) throws Exception{
+		SupportUnitConfigVo supVo = new SupportUnitConfigVo() ;
+		//鐭伐浣滄椂闀跨嚎绋嬫睜锛岀嚎绋嬭礋璐g敤鏃惰緝鐭殑宸ヤ綔浠诲姟
+		supVo.short_maxThread = 100 ;
+		supVo.short_freeTimeout = 5 ;
+		supVo.short_busyTimeout = 60 ;
+		//闀垮伐浣滄椂闀跨嚎绋嬫睜锛岀嚎绋嬭礋璐g敤鏃惰緝闀跨殑宸ヤ綔浠诲姟
+		supVo.long_maxThread = 200 ;
+		if(supVo.long_maxThread < 0){
+			supVo.long_maxThread = -1 ;
+		}
+		supVo.long_minThread = 0 ; 
+		supVo.long_freeTimeout = 60 ;
+		supVo.long_busyTimeout = -1 ;
+		if(supVo.long_busyTimeout < 0){
+			supVo.long_busyTimeout = -1 ;
+		}
+		
+		supVo.enableThreadPool = true ;
+		
+		supVo.showStartInfo = true ;
+
+		SupportUnit supUnit = SupportUnit.getInstance() ;
+		
+		AdapterImp_SupportUnit supAdap = new AdapterImp_SupportUnit();
+		supAdap.setConfig(supVo);
+		supUnit.setAdapter(supAdap);
+		supUnit.start(obj -> {
+		});
+	}
+	private static class AdapterImp_SupportUnit implements SupportUnitAdapter {
+		
+		private SupportUnitConfigVo configVo = null ;
+
+		@Override
+		public SupportUnitConfigVo getConfig() {
+			return this.configVo;
+		}
+
+		public void setConfig(SupportUnitConfigVo configVo) {
+			this.configVo = configVo;
+		}
+	}
+	*/
+}

--
Gitblit v1.8.0