@Service
public class StopAddDataListener implements ApplicationListener<ContextClosedEvent> {
private Logger logger= LoggerFactory.getLogger(StartAddDataListener.class);
@Autowired
TCPServer tcpServer;
@Override
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
if(contextClosedEvent.getApplicationContext().getParent() == null) {
NettyStopService nettyStopService = new NettyStopService();
nettyStopService.setTcpServer(tcpServer);
new Thread(nettyStopService).start();
}
}
}