in plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntimeDelegate.java [174:264]
public String detectVersion() {
URL systemjarURL = null;
//
// Check lib directory first
//
File libDir = getRuntime().getLocation().append("lib").toFile();
if (libDir.exists()) {
File[] libs = libDir.listFiles();
for (int i = 0; i < libs.length; i++) {
if (libs[i].getName().startsWith("geronimo-system")) {
try {
systemjarURL = libs[i].toURL();
break;
}
catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
}
//
// Check pre-2.1 repository if necessary
//
if (systemjarURL == null) {
File systemDir = getRuntime().getLocation().append("repository/org/apache/geronimo/modules/geronimo-system").toFile();
if (systemDir.exists() && systemDir.isDirectory() && systemDir.canRead()) {
List<File> dirFiles = scanDirectory(systemDir);
for (File jarFile : dirFiles) {
if (jarFile.getName().startsWith("geronimo-system") && jarFile.getName().endsWith("jar")) {
try {
systemjarURL = jarFile.toURL();
break;
}
catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
}
}
//
// Check 2.1 repository if necessary
//
if (systemjarURL == null) {
File systemDir = getRuntime().getLocation().append("repository/org/apache/geronimo/framework/geronimo-system").toFile();
if (systemDir.exists() && systemDir.isDirectory() && systemDir.canRead()) {
List<File> dirFiles = scanDirectory(systemDir);
for (File jarFile : dirFiles) {
if (jarFile.getName().startsWith("geronimo-system") && jarFile.getName().endsWith("jar")) {
try {
systemjarURL = jarFile.toURL();
break;
}
catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
}
}
if (systemjarURL != null) {
try {
String version = null;
JarFile jar = new JarFile(systemjarURL.getFile());
Enumeration<JarEntry> entries = jar.entries();
while(entries.hasMoreElements()){
JarEntry entry = entries.nextElement();
if (entry.getName().indexOf("geronimo-version.properties")!=-1 ||
entry.getName().indexOf("server-version.properties")!=-1 ){
InputStream is = jar.getInputStream(entry);
Properties properties = new Properties();
properties.load(is);
version = properties.getProperty("version");
is.close();
}
}
jar.close();
return version;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}