Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.appserv.server.util;
import com.sun.enterprise.util.SystemPropertyConstants;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Path;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
* This class provides static methods to make accessible the version as well as
* the individual parts that make up the version
*/
public class Version {
private static final String KEY_PRODUCT_NAME = "product.name";
private static final String KEY_PRODUCT_NAME_ABBREVIATION = "product.name.abbreviation";
private static final String KEY_PRODUCT_VERSION = "product.version";
private static final String KEY_GIT_BRANCH = "product.build.git.branch";
private static final String KEY_GIT_COMMIT = "product.build.git.commit";
private static final String KEY_BUILD_TIMESTAMP = "product.build.timestamp";
private static final String KEY_BASED_ON = "based.on";
private static final String KEY_ADMIN_COMMAND_NAME = "admin.command.name";
private static final String KEY_DOMAIN_TEMPLATE_DEFAULTJARFILENAME = "domain.template.defaultJarFileName";
private static final String KEY_DOMAIN_DEFAULT_ADMIN_GROUPS = "domain.admin.groups";
private static final List VERSION_PROPERTIES = new ArrayList<>();
private static final Map VERSION_PROPERTIES_MAP = new HashMap<>();
private static final Properties PROPERTIES = loadVersionProp();
private static final String PRODUCT_NAME;
private static final String PRODUCT_NAME_ABBREVIATION;
private static final String VERSION;
private static final String VERSION_RELEASE;
private static final int VERSION_MAJOR;
private static final int VERSION_MINOR;
private static final int VERSION_PATCH;
private static final String GIT_BRANCH;
private static final String COMMIT;
private static final Instant BUILD_TIMESTAMP;
static {
PRODUCT_NAME = getProperty(KEY_PRODUCT_NAME, "GlassFish");
PRODUCT_NAME_ABBREVIATION = getProperty(KEY_PRODUCT_NAME_ABBREVIATION, "GF");
VERSION = getProperty(KEY_PRODUCT_VERSION, "");
int dotBeforeMinor = VERSION.indexOf('.');
int dotBeforePatch = VERSION.indexOf('.', dotBeforeMinor + 2);
int suffixStart = dotBeforePatch > 0 ? dotBeforePatch + 1
: (dotBeforeMinor > 0 ? dotBeforeMinor + 1 : 0);
for (; suffixStart < VERSION.length(); suffixStart++) {
if (!Character.isDigit(VERSION.charAt(suffixStart))) {
break;
}
}
if (dotBeforeMinor > 0) {
VERSION_MAJOR = parseInt(VERSION.substring(0, dotBeforeMinor), 0);
if (dotBeforePatch > dotBeforeMinor) {
VERSION_MINOR = parseInt(VERSION.substring(dotBeforeMinor + 1, dotBeforePatch), 0);
if (suffixStart > dotBeforePatch) {
VERSION_PATCH = parseInt(VERSION.substring(dotBeforePatch + 1, suffixStart), 0);
} else {
VERSION_PATCH = parseInt(VERSION.substring(dotBeforePatch + 1), 0);
}
} else {
if (suffixStart > dotBeforeMinor) {
VERSION_MINOR = parseInt(VERSION.substring(dotBeforeMinor + 1, suffixStart), 0);
} else {
VERSION_MINOR = parseInt(VERSION.substring(dotBeforeMinor + 1), 0);
}
VERSION_PATCH = 0;
}
} else {
if (suffixStart > 0) {
VERSION_MAJOR = parseInt(VERSION.substring(0, suffixStart), 0);
} else {
VERSION_MAJOR = parseInt(VERSION, 0);
}
VERSION_MINOR = 0;
VERSION_PATCH = 0;
}
VERSION_RELEASE = Integer.toString(VERSION_MAJOR) + '.' + Integer.toString(VERSION_MINOR) + '.'
+ Integer.toString(VERSION_PATCH);
GIT_BRANCH = getProperty(KEY_GIT_BRANCH, null);
COMMIT = getProperty(KEY_GIT_COMMIT, null);
String timestamp = getProperty(KEY_BUILD_TIMESTAMP, null);
BUILD_TIMESTAMP = timestamp == null ? null : Instant.parse(timestamp);
}
/**
* @return whole version string
*/
public static String getVersion() {
return VERSION;
}
/**
* @return major.minor.patch
*/
public static String getVersionNumber() {
return VERSION_RELEASE;
}
/**
* @return Eclipse GlassFish 7.0.0
*/
public static String getProductId() {
return getProductName() + " " + getVersionNumber();
}
/**
* @return
*