1 package org.woehlke.computer.kurzweil;
2
3 import lombok.extern.log4j.Log4j2;
4 import org.woehlke.computer.kurzweil.application.ComputerKurzweilFrame;
5 import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties;
6 import org.woehlke.computer.kurzweil.application.ComputerKurzweilContext;
7 import org.woehlke.computer.kurzweil.commons.Startable;
8
9 import java.io.File;
10 import java.net.URL;
11 import java.net.URLClassLoader;
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 @Log4j2
36 public class ComputerKurzweilApplication implements Startable {
37
38 private final ComputerKurzweilFrame frame;
39
40 public ComputerKurzweilApplication(String[] args) {
41 log.info("start");
42 System.out.println("start");
43 for(String arg:args){
44 log.info(arg);
45 System.out.println(arg);
46 }
47 String configFileName = "/application.yml";
48 URL fileUrl = getClass().getResource(configFileName);
49 File configFile = new File(fileUrl.getFile());
50 log.info("get properties");
51 System.out.println("get properties");
52 ComputerKurzweilProperties properties = ComputerKurzweilProperties.propertiesFactory(configFile);
53 log.info("get Frame");
54 System.out.println("get Frame");
55 this.frame = new ComputerKurzweilFrame(properties);
56 log.info("started");
57 System.out.println("started");
58 }
59
60 public void start(){
61 try {
62 this.frame.start();
63 log.info("Started the Desktop Application");
64 System.out.println("Started the Desktop Application");
65 } catch (IllegalThreadStateException e){
66 System.out.println(e.getLocalizedMessage());
67 log.info(e.getLocalizedMessage());
68 }
69 }
70
71 @Override
72 public void stop() {
73 try {
74 this.frame.stop();
75 log.info("Stopped the Desktop Application");
76 System.out.println("Stopped the Desktop Application");
77 } catch (IllegalThreadStateException e){
78 System.out.println(e.getLocalizedMessage());
79 log.info(e.getLocalizedMessage());
80 }
81 }
82
83
84
85
86
87
88 public static void main(String[] args) {
89 String configFileName = "application.yml";
90 String jarFilePath = "target/computer-kurzweil-app.jar";
91
92
93 ComputerKurzweilApplicationion.html#ComputerKurzweilApplication">ComputerKurzweilApplication application = new ComputerKurzweilApplication(args);
94 application.start();
95 }
96
97 }