View Javadoc

1   package ca.uhn.hl7v2.hoh.util;
2   
3   import java.io.InputStream;
4   import java.util.Properties;
5   
6   import org.slf4j.Logger;
7   import org.slf4j.LoggerFactory;
8   
9   /**
10   * Class to log the HAPI version when HAPI is first used (mostly for troubleshooting purposes)
11   */
12  public class VersionLogger {
13  
14      private static boolean ourInitialized = false;
15  	private static String ourVersion;
16      private static final Logger LOG = LoggerFactory.getLogger(VersionLogger.class);
17      
18      /**
19       * Non-instantiable
20       */
21      private VersionLogger() {
22          // nothing
23      }
24      
25      /**
26       * Logs the HAPI version on the first time this method is invoked, does nothing afterwards
27       */
28      public static void init() {
29          if (!ourInitialized) {
30              try {
31                  InputStream is = VersionLogger.class.getResourceAsStream("/ca/uhn/hl7v2/hoh/hoh-version.properties");
32                  Properties p = new Properties();
33                  p.load(is);
34                  ourVersion = p.getProperty("version");
35  				LOG.info("HL7 over HTTP (HAPI) library version is: " + ourVersion);
36              } catch (Exception e) {
37                  // ignore
38              }
39              ourInitialized = true;
40          }
41      }
42  
43  	/**
44  	 * @return Returns the current version of HAPI
45  	 */
46  	public static String getVersion() {
47  		init();
48  		return ourVersion;
49  	}
50      
51  }