|  |  |  | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | // 确保这段代码尽可能快速执行,避免影响JVM的关闭 | 
|---|
|  |  |  | log.info("程序(控制台)关闭钩子类执行"); | 
|---|
|  |  |  | Command com = new Command() ; | 
|---|
|  |  |  | com.id = Command.defaultId ; | 
|---|
|  |  |  | com.code = CodeLocal.stopTcpSv ; | 
|---|
|  |  |  | com.type = CommandType.innerCommand ; | 
|---|
|  |  |  | new CommandInnerDeaLer().deal(com) ; | 
|---|
|  |  |  | Command com1 = new Command() ; | 
|---|
|  |  |  | com1.id = Command.defaultId ; | 
|---|
|  |  |  | com1.code = CodeLocal.stopTcpSv ; | 
|---|
|  |  |  | com1.type = CommandType.innerCommand ; | 
|---|
|  |  |  | new CommandInnerDeaLer().deal(com1) ; | 
|---|
|  |  |  | //Thread.sleep(100L);//实测不执行 | 
|---|
|  |  |  | log.info("关闭程序前,关闭了TCP服务"); | 
|---|
|  |  |  | Command com2 = new Command() ; | 
|---|
|  |  |  | com2.id = Command.defaultId ; | 
|---|
|  |  |  | com2.code = CodeLocal.stopMqttSv ; | 
|---|
|  |  |  | com2.type = CommandType.innerCommand ; | 
|---|
|  |  |  | new CommandInnerDeaLer().deal(com2) ; | 
|---|
|  |  |  | log.info("关闭程序前,关闭了MQTT服务"); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | log.error("程序(控制台)关闭钩子发生异常", e); | 
|---|
|  |  |  | } | 
|---|