use of org.apache.activemq.artemis.core.version.impl.VersionImpl in project activemq-artemis by apache.
the class VersionLoader method load.
private static Version[] load() {
Properties versionProps = new Properties();
final InputStream in = VersionImpl.class.getClassLoader().getResourceAsStream(VersionLoader.PROP_FILE_NAME);
try {
if (in == null) {
ActiveMQClientLogger.LOGGER.noVersionOnClasspath(getClasspathString());
throw new RuntimeException(VersionLoader.PROP_FILE_NAME + " is not available");
}
try {
versionProps.load(in);
String versionName = versionProps.getProperty("activemq.version.versionName");
int majorVersion = Integer.valueOf(versionProps.getProperty("activemq.version.majorVersion"));
int minorVersion = Integer.valueOf(versionProps.getProperty("activemq.version.minorVersion"));
int microVersion = Integer.valueOf(versionProps.getProperty("activemq.version.microVersion"));
int[] incrementingVersions = parseCompatibleVersionList(versionProps.getProperty("activemq.version.incrementingVersion"));
int[] compatibleVersionArray = parseCompatibleVersionList(versionProps.getProperty("activemq.version.compatibleVersionList"));
List<Version> definedVersions = new ArrayList<>(incrementingVersions.length);
for (int incrementingVersion : incrementingVersions) {
definedVersions.add(new VersionImpl(versionName, majorVersion, minorVersion, microVersion, incrementingVersion, compatibleVersionArray));
}
// We want the higher version to be the first
Collections.sort(definedVersions, new Comparator<Version>() {
@Override
public int compare(Version version1, Version version2) {
return version2.getIncrementingVersion() - version1.getIncrementingVersion();
}
});
return definedVersions.toArray(new Version[incrementingVersions.length]);
} catch (IOException e) {
// way
throw new RuntimeException("unable to load " + VersionLoader.PROP_FILE_NAME, e);
}
} finally {
try {
if (in != null)
in.close();
} catch (Throwable ignored) {
}
}
}
Aggregations