JT1078AutoConfiguration.java
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.genersoft.iot.vmp.jt1078.config;
import com.genersoft.iot.vmp.jt1078.app.VideoServerApp;
import com.genersoft.iot.vmp.jt1078.cmd.JT1078Template;
import com.genersoft.iot.vmp.jt1078.codec.netty.TcpServer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
/**
* @author QingtaiJiang
* @date 2023/4/27 19:35
* @email qingtaij@163.com
*/
@Order(Integer.MIN_VALUE)
@Configuration
@ConditionalOnProperty(value = "jt1078.enable", havingValue = "true")
public class JT1078AutoConfiguration {
// @Bean(initMethod = "start", destroyMethod = "stop")
// public TcpServer jt1078Server(@Value("${jt1078.port}") Integer port) {
// return new TcpServer(port);
// }
// @Bean(initMethod = "start", destroyMethod = "stop")
@Bean
public VideoServerApp jt1078VideoServerApp(@Value("${jt1078.port}") Integer port) {
VideoServerApp videoServerApp = new VideoServerApp();
new Thread(new Runnable() {
@Override
public void run() {
try {
videoServerApp.createListenter();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}).start();
return videoServerApp;
}
@Bean
public JT1078Template jt1078Template() {
return new JT1078Template();
}
}