001/*
002 * Copyright 2015-2018 the original author or authors
003 *
004 * This software is licensed under the Apache License, Version 2.0,
005 * the GNU Lesser General Public License version 2 or later ("LGPL")
006 * and the WTFPL.
007 * You may choose either license to govern your use of this software only
008 * upon the condition that you accept all of the terms of either
009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
010 */
011package org.minidns;
012
013import java.io.BufferedReader;
014import java.io.IOException;
015import java.io.InputStream;
016import java.io.InputStreamReader;
017import java.util.logging.Level;
018import java.util.logging.Logger;
019
020public class MiniDnsInitialization {
021
022    private static final Logger LOGGER = Logger.getLogger(MiniDnsInitialization.class.getName());
023
024    static final String VERSION;
025
026    static {
027        String miniDnsVersion;
028        BufferedReader reader = null;
029        try {
030            InputStream is = MiniDnsInitialization.class.getClassLoader().getResourceAsStream("org.minidns/version");
031            reader = new BufferedReader(new InputStreamReader(is));
032            miniDnsVersion = reader.readLine();
033        } catch(Exception e) {
034            LOGGER.log(Level.SEVERE, "Could not determine MiniDNS version", e);
035            miniDnsVersion = "unkown";
036        } finally {
037            if (reader != null) {
038                try {
039                    reader.close();
040                } catch (IOException e) {
041                    LOGGER.log(Level.WARNING, "IOException closing stream", e);
042                }
043            }
044        }
045        VERSION = miniDnsVersion;
046    }
047}