From 0d6a8d90c57ca279556ea677f6c371d221f19556 Mon Sep 17 00:00:00 2001 From: swwheihei Date: Wed, 22 Jul 2020 21:06:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3spring=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E5=AF=BC=E8=87=B4=E7=9A=84=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/transmit/SIPProcessorFactory.java | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java index 88e7ccf0..fe97e2b6 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java @@ -34,6 +34,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.response.impl.CancelResponseProces import com.genersoft.iot.vmp.gb28181.transmit.response.impl.InviteResponseProcessor; import com.genersoft.iot.vmp.gb28181.transmit.response.impl.OtherResponseProcessor; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.utils.SpringBeanFactory; import com.genersoft.iot.vmp.utils.redis.RedisUtil; /** @@ -82,12 +83,10 @@ public class SIPProcessorFactory { @Autowired private OtherResponseProcessor otherResponseProcessor; - @Autowired - @Qualifier(value="tcpSipProvider") + // 注:这里使用注解会导致循环依赖注入,暂用springBean private SipProvider tcpSipProvider; - - @Autowired - @Qualifier(value="udpSipProvider") + + // 注:这里使用注解会导致循环依赖注入,暂用springBean private SipProvider udpSipProvider; public ISIPRequestProcessor createRequestProcessor(RequestEvent evt) { @@ -97,14 +96,14 @@ public class SIPProcessorFactory { if (Request.INVITE.equals(method)) { InviteRequestProcessor processor = new InviteRequestProcessor(); processor.setRequestEvent(evt); - processor.setTcpSipProvider(tcpSipProvider); - processor.setUdpSipProvider(udpSipProvider); + processor.setTcpSipProvider(getTcpSipProvider()); + processor.setUdpSipProvider(getUdpSipProvider()); return processor; } else if (Request.REGISTER.equals(method)) { RegisterRequestProcessor processor = new RegisterRequestProcessor(); processor.setRequestEvent(evt); - processor.setTcpSipProvider(tcpSipProvider); - processor.setUdpSipProvider(udpSipProvider); + processor.setTcpSipProvider(getTcpSipProvider()); + processor.setUdpSipProvider(getUdpSipProvider()); processor.setHandler(handler); processor.setPublisher(publisher); processor.setSipConfig(sipConfig); @@ -129,8 +128,8 @@ public class SIPProcessorFactory { } else if (Request.MESSAGE.equals(method)) { MessageRequestProcessor processor = new MessageRequestProcessor(); processor.setRequestEvent(evt); - processor.setTcpSipProvider(tcpSipProvider); - processor.setUdpSipProvider(udpSipProvider); + processor.setTcpSipProvider(getTcpSipProvider()); + processor.setUdpSipProvider(getUdpSipProvider()); processor.setPublisher(publisher); processor.setRedis(redis); processor.setDeferredResultHolder(deferredResultHolder); @@ -158,4 +157,18 @@ public class SIPProcessorFactory { } } + private SipProvider getTcpSipProvider() { + if (tcpSipProvider == null) { + tcpSipProvider = (SipProvider) SpringBeanFactory.getBean("tcpSipProvider"); + } + return tcpSipProvider; + } + + private SipProvider getUdpSipProvider() { + if (udpSipProvider == null) { + udpSipProvider = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); + } + return udpSipProvider; + } + }