View Javadoc
1   package io.extact.rms.client.console;
2   
3   import static io.extact.rms.client.console.ui.ClientConstants.*;
4   
5   import java.util.logging.LogManager;
6   
7   import jakarta.enterprise.inject.spi.CDI;
8   
9   import org.slf4j.bridge.SLF4JBridgeHandler;
10  
11  import lombok.extern.slf4j.Slf4j;
12  
13  import io.extact.rms.client.console.ui.ScreenController;
14  import io.extact.rms.client.console.ui.textio.TextIoUtils;
15  import io.extact.rms.platform.env.Environment;
16  
17  @Slf4j
18  public class ConsoleMain {
19      private static final String START_UP_LOGO ="""
20                  ____    __  ___  _____
21                 / __ \\  /  |/  / / ___/
22                / /_/ / / /|_/ /  \\__ \\
23               / _, _/ / /  / /_ ___/ /
24              /_/ |_(_)_/  /_/(_)____(_)
25              """;
26  
27      public static void main(String[] args) throws Exception {
28  
29          // Fiddlerの設定
30          // System.setProperty("http.proxyHost", "localhost");
31          // System.setProperty("http.proxyPort", "8888");
32          // System.setProperty("web-api/mp-rest/url", "http://pmr216n.primo.mamezou.com:7001");
33          // System.err.println("★Fiddlerの設定が入ってるのでFiddler立ち上げてね!");
34          // System.err.println("★あと宛先アドレスはlocalhostではなくFQCN指定の方に変えてね!");
35          try {
36              // java.util.loggingの出力をSLF4Jへdelegate
37              LogManager.getLogManager().reset();
38              SLF4JBridgeHandler.removeHandlersForRootLogger();
39              SLF4JBridgeHandler.install();
40  
41              // CDIコンテナの起動
42              io.helidon.microprofile.cdi.Main.main(args);
43  
44              startupLog();
45              startupLogo();
46  
47              ScreenController controller = CDI.current().select(ScreenController.class).get();
48              while (true) {
49                  try {
50                      controller.start();
51                      break;
52                  } catch (Exception e) {
53                      log.error("Back to start..", e);
54                      TextIoUtils.printErrorInformation(UNKNOWN_ERROR_INFORMATION);
55                  }
56              }
57              // swingコンソールはmainプロセスが残るためexitする
58              System.exit(0);
59          } catch (Throwable e) {
60              log.error("error occured.", e);
61              throw e;
62          }
63      }
64  
65      private static void startupLog() {
66          var mainJarInfo = Environment.getMainJarInfo();
67          log.info(System.lineSeparator() +
68                  "Startup-Module:" + mainJarInfo.startupModuleInfo() + System.lineSeparator() +
69                  "Version:" + mainJarInfo.getVersion() + System.lineSeparator() +
70                  "Build-Time:" + mainJarInfo.getBuildtimeInfo()
71                  );
72      }
73  
74      private static void startupLogo() {
75          TextIoUtils.println(START_UP_LOGO);
76      }
77  }