13
13
import org .eclipse .jetty .servlet .ServletContextHandler ;
14
14
15
15
import javax .servlet .ServletContextEvent ;
16
+ import java .io .IOException ;
16
17
import java .io .InputStream ;
17
18
import java .util .Properties ;
18
19
import java .util .logging .ConsoleHandler ;
22
23
23
24
public class Main {
24
25
private static final Log LOG = new Log ();
26
+ private static String VERSION = null ;
25
27
26
28
public static void main (String [] args ) throws Exception {
27
29
configureLogging ();
28
30
29
- String version = "UNKNOWN/DEVELOPMENT" ;
30
- InputStream is = Main .class .getResourceAsStream ("/version.prop" );
31
-
32
- if (is != null ) {
33
- Properties props = new Properties ();
34
- props .load (is );
35
- version = props .getProperty ("version" );
36
- }
37
-
38
31
final Injector injector = Guice .createInjector (new ConfigModule (args ), new JettyModule (), new SitebricksModule () {
39
32
@ Override
40
33
protected void configureSitebricks () {
41
34
scan (ProxyResource .class .getPackage ());
42
35
}
43
36
});
44
37
45
- LOG .info ("Starting BrowserMob Proxy version {}" , version );
38
+ LOG .info ("Starting BrowserMob Proxy version {}" , getVersion () );
46
39
47
40
Server server = injector .getInstance (Server .class );
48
41
GuiceServletContextListener gscl = new GuiceServletContextListener () {
@@ -59,6 +52,23 @@ protected Injector getInjector() {
59
52
server .join ();
60
53
}
61
54
55
+ public static String getVersion () throws IOException {
56
+ if (VERSION == null ) {
57
+ String version = "UNKNOWN/DEVELOPMENT" ;
58
+ InputStream is = Main .class .getResourceAsStream ("/version.prop" );
59
+
60
+ if (is != null ) {
61
+ Properties props = new Properties ();
62
+ props .load (is );
63
+ version = props .getProperty ("version" );
64
+ }
65
+
66
+ VERSION = version ;
67
+ }
68
+
69
+ return VERSION ;
70
+ }
71
+
62
72
public static void configureLogging () {
63
73
Logger logger = Logger .getLogger ("" );
64
74
Handler [] handlers = logger .getHandlers ();
0 commit comments