| 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 | 5 | private static Logger log = LoggerFactory.getLogger(Home.class); |
| 17 | |
|
| 18 | |
|
| 19 | 0 | public Home() { |
| 20 | 0 | } |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
public static File getHomeDirectory() { |
| 32 | 5565 | if (home == null) |
| 33 | 5 | setHomeDirectory(); |
| 34 | |
|
| 35 | 5565 | return home; |
| 36 | |
} |
| 37 | |
|
| 38 | |
private synchronized static void setHomeDirectory() { |
| 39 | 5 | String dir = System.getProperty("hapi.home", "."); |
| 40 | 5 | home = new File(dir); |
| 41 | |
|
| 42 | 5 | if (!home.isDirectory()) { |
| 43 | 0 | home = new File("."); |
| 44 | 0 | log.warn("The system property hapi.home is not a valid directory: {}. Using . instead", dir); |
| 45 | |
} |
| 46 | |
|
| 47 | 5 | log.info("hapi.home is set to " + home.getAbsolutePath()); |
| 48 | 5 | } |
| 49 | |
|
| 50 | |
public static void main(String args[]) { |
| 51 | 0 | System.out.println("HOME: " + getHomeDirectory().getAbsolutePath()); |
| 52 | 0 | } |
| 53 | |
|
| 54 | |
} |