From 87e7d0026f2a0feae169f103f90256005968b6aa Mon Sep 17 00:00:00 2001
From: lawrencehj <1934378145@qq.com>
Date: 星期五, 23 七月 2021 16:56:32 +0800
Subject: [PATCH] 解决@value注解无法赋默认值问题

---
 src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java |   47 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
index 7c767ba..0a76f69 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
@@ -72,7 +72,7 @@
 	private SipStack createSipStack() throws PeerUnavailableException {
 		Properties properties = new Properties();
 		properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP");
-		properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getSipIp());
+		properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getMonitorIp());
 		properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false");
 		/**
 		 * sip_server_log.log 鍜� sip_debug_log.log public static final int TRACE_NONE =
@@ -92,23 +92,46 @@
 		ListeningPoint tcpListeningPoint = null;
 		SipProvider tcpSipProvider  = null;
 		try {
-			tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), "TCP");
+			tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getSipPort(), "TCP");
 			tcpSipProvider = sipStack.createSipProvider(tcpListeningPoint);
 			tcpSipProvider.addSipListener(this);
-			logger.info("Sip Server TCP 鍚姩鎴愬姛 port {" + sipConfig.getSipPort() + "}");
-		} catch (TransportNotSupportedException | InvalidArgumentException | TooManyListenersException | ObjectInUseException e) {
-			logger.error(String.format("鍒涘缓SIP鏈嶅姟澶辫触: %s", e.getMessage()));
+			logger.info("Sip Server TCP 鍚姩鎴愬姛 port {" + sipConfig.getMonitorIp() + ":" + sipConfig.getSipPort() + "}");
+//		} catch (TransportNotSupportedException | InvalidArgumentException | TooManyListenersException | ObjectInUseException e) {
+//			logger.error(String.format("鍒涘缓SIP鏈嶅姟澶辫触: %s", e.getMessage()));
+//		}
+		} catch (TransportNotSupportedException e) {
+			e.printStackTrace();
+		} catch (InvalidArgumentException e) {
+			logger.error("鏃犳硶浣跨敤 [ {}:{} ]浣滀负SIP[ TCP ]鏈嶅姟锛屽彲鎺掓煡: 1. sip.monitor-ip 鏄惁涓烘湰鏈虹綉鍗P; 2. sip.port 鏄惁宸茶鍗犵敤"
+					, sipConfig.getMonitorIp(), sipConfig.getSipPort());
+		} catch (TooManyListenersException e) {
+			e.printStackTrace();
+		} catch (ObjectInUseException e) {
+			e.printStackTrace();
 		}
 		return tcpSipProvider;
 	}
 	
 	@Bean("udpSipProvider")
 	@DependsOn("sipStack")
-	private SipProvider startUdpListener() throws Exception {
-		ListeningPoint udpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), "UDP");
-		SipProvider udpSipProvider = sipStack.createSipProvider(udpListeningPoint);
-		udpSipProvider.addSipListener(this);
-		logger.info("Sip Server UDP 鍚姩鎴愬姛 port {" + sipConfig.getSipPort() + "}");
+	private SipProvider startUdpListener() {
+		ListeningPoint udpListeningPoint = null;
+		SipProvider udpSipProvider = null;
+		try {
+			udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getSipPort(), "UDP");
+			udpSipProvider = sipStack.createSipProvider(udpListeningPoint);
+			udpSipProvider.addSipListener(this);
+		} catch (TransportNotSupportedException e) {
+			e.printStackTrace();
+		} catch (InvalidArgumentException e) {
+			logger.error("鏃犳硶浣跨敤 [ {}:{} ]浣滀负SIP[ UDP ]鏈嶅姟锛屽彲鎺掓煡: 1. sip.monitor-ip 鏄惁涓烘湰鏈虹綉鍗P; 2. sip.port 鏄惁宸茶鍗犵敤"
+					, sipConfig.getMonitorIp(), sipConfig.getSipPort());
+		} catch (TooManyListenersException e) {
+			e.printStackTrace();
+		} catch (ObjectInUseException e) {
+			e.printStackTrace();
+		}
+		logger.info("Sip Server UDP 鍚姩鎴愬姛 port [" + sipConfig.getMonitorIp() + ":" + sipConfig.getSipPort() + "]");
 		return udpSipProvider;
 	}
 
@@ -118,7 +141,7 @@
 	 */
 	@Override
 	public void processRequest(RequestEvent evt) {
-		logger.debug(evt.getRequest().toString());
+//		logger.debug(evt.getRequest().toString());
 		// 鐢变簬jainsip鏄崟绾跨▼绋嬪簭锛屼负鎻愰珮鎬ц兘骞跺彂澶勭悊
 		processThreadPool.execute(() -> {
 			if (processorFactory != null) {
@@ -130,7 +153,7 @@
 	@Override
 	public void processResponse(ResponseEvent evt) {
 		Response response = evt.getResponse();
-		logger.debug(evt.getResponse().toString());
+//		logger.debug(evt.getResponse().toString());
 		int status = response.getStatusCode();
 		if (((status >= 200) && (status < 300)) || status == 401) { // Success!
 			ISIPResponseProcessor processor = processorFactory.createResponseProcessor(evt);

--
Gitblit v1.8.0