ApplicationConfig.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package com.its.cctv.config;
  2. import com.its.app.utils.SysUtils;
  3. import lombok.Getter;
  4. import lombok.Setter;
  5. import lombok.ToString;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.boot.context.properties.ConfigurationProperties;
  8. import org.springframework.context.annotation.Configuration;
  9. import javax.annotation.PostConstruct;
  10. @Slf4j
  11. @Getter
  12. @Setter
  13. @ToString
  14. @Configuration
  15. @ConfigurationProperties(prefix = "application")
  16. public class ApplicationConfig {
  17. private String bootingDateTime;
  18. private boolean startSchedule;
  19. private String id = "CTV01";
  20. private String name = "CCTV Communication Server";
  21. private boolean history = true;
  22. private boolean statistics = true;
  23. private String userId = "admin";
  24. private String userPswd = "1234";
  25. // Center Communication Config
  26. private boolean centerCommEnable = true;
  27. private int listenPort = 9903;
  28. protected String bindingAddr = "0.0.0.0";
  29. protected int backlog = 0;
  30. protected int acceptThreads = 0;
  31. protected int workerThreads = 0;
  32. protected int rcvBuf = 0;
  33. protected int sndBuf = 0;
  34. protected int readerIdleTimeSeconds = 0;
  35. protected int writerIdleTimeSeconds = 0;
  36. protected int allIdleTimeSeconds = 0;
  37. protected int connectTimeoutSeconds = 0;
  38. @PostConstruct
  39. private void init() {
  40. this.startSchedule = false;
  41. final int DEFAULT_EVENT_THREADS = Runtime.getRuntime().availableProcessors() * 2;
  42. if (this.bindingAddr.equals("")) {
  43. this.bindingAddr = "0.0.0.0";
  44. }
  45. if (this.backlog == 0) {
  46. this.backlog = 1024;
  47. }
  48. if (this.acceptThreads == 0) {
  49. this.acceptThreads = DEFAULT_EVENT_THREADS;
  50. }
  51. if (this.workerThreads == 0) {
  52. this.workerThreads = DEFAULT_EVENT_THREADS;
  53. }
  54. if (this.rcvBuf == 0) {
  55. this.rcvBuf = Short.MAX_VALUE / 2;
  56. }
  57. if (this.sndBuf == 0) {
  58. this.sndBuf = Short.MAX_VALUE / 2;
  59. }
  60. this.bootingDateTime = SysUtils.getSysTimeStr();
  61. log.info("{}", this);
  62. }
  63. }