001package org.cache2k.impl.util;
002
003/*
004 * #%L
005 * cache2k core package
006 * %%
007 * Copyright (C) 2000 - 2015 headissue GmbH, Munich
008 * %%
009 * This program is free software: you can redistribute it and/or modify
010 * it under the terms of the GNU General Public License as
011 * published by the Free Software Foundation, either version 3 of the 
012 * License, or (at your option) any later version.
013 * 
014 * This program is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017 * GNU General Public License for more details.
018 * 
019 * You should have received a copy of the GNU General Public 
020 * License along with this program.  If not, see
021 * <http://www.gnu.org/licenses/gpl-3.0.html>.
022 * #L%
023 */
024
025import java.io.IOException;
026import java.io.InputStream;
027import java.util.Properties;
028
029/**
030 * Static helper class to provide the cache2k version.
031 *
032 * @author Jens Wilke; created: 2015-06-11
033 */
034public class Cache2kVersion {
035
036  private static String buildNumber = "<unknown>";
037  private static String version = "<unknown>";
038  private static long timestamp = 0;
039
040  static {
041    InputStream in = Cache2kVersion.class.getResourceAsStream("/org.cache2k.impl.version.txt");
042    try {
043      if (in != null) {
044        Properties p = new Properties();
045        p.load(in);
046        System.err.println(p);
047        String s = p.getProperty("buildNumber");
048        if (s != null && s.length() > 0) {
049          buildNumber = s;
050        }
051        version = p.getProperty("version");
052        s = p.getProperty("timestamp");
053        if ( s != null && s.length() > 0 && !"${timestamp}".equals(s)) {
054          timestamp = Long.parseLong(s);
055        } else {
056          timestamp = 4711;
057        }
058      }
059    } catch (Exception e) {
060      Log.getLog(Cache2kVersion.class).warn("error parsing version properties", e);
061    }
062  }
063
064  public static String getBuildNumber() {
065    return buildNumber;
066  }
067
068  public static String getVersion() {
069    return version;
070  }
071
072  public static long getTimestamp() {
073    return timestamp;
074  }
075
076}