1 package ca.uhn.hl7v2.util;
2
3 import java.io.File;
4
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
7
8
9
10
11
12
13 public class Home {
14
15 private static File home;
16 private static final Logger log = LoggerFactory.getLogger(Home.class);
17
18
19 public Home() {
20 }
21
22
23
24
25
26
27
28
29
30
31 public static File getHomeDirectory() {
32 if (home == null)
33 setHomeDirectory();
34
35 return home;
36 }
37
38 private synchronized static void setHomeDirectory() {
39 String dir = System.getProperty("hapi.home", ".");
40 home = new File(dir);
41
42 if (!home.isDirectory()) {
43 home = new File(".");
44 log.warn("The system property hapi.home is not a valid directory: {}. Using . instead", dir);
45 }
46
47 log.info("hapi.home is set to " + home.getAbsolutePath());
48 }
49
50 public static void main(String[] args) {
51 System.out.println("HOME: " + getHomeDirectory().getAbsolutePath());
52 }
53
54 }