/** * Read and process the information in asenv * There are no arguments because the installation directory is calculated * relative to the jar file you are calling from. * Unlike V2 this class will not set any System Properties. Instead it will * give you a Map<String,String> containing the properties. * <p>To use the class, create an instance and then call getProps(). */ public ASenvPropertyReader() { this(GFLauncherUtils.getInstallDir()); }
static private boolean isValidJavaRoot(String javaRootName) { if (!GFLauncherUtils.ok(javaRootName)) return false; // look for ${javaRootName}/bin/java[.exe] File f = new File(javaRootName); if (GFLauncherUtils.isWindows()) f = new File(f, "bin/java.exe"); else f = new File(f, "bin/java"); return f.exists(); }
/** * * @param s A String that may contain %token% * @return the UNIX-ified format ${token} */ private String windowsToUnixTokens(String s) { String replaced = s; while (true) { if (replaced == null || replaced.indexOf('%') < 0) { break; } replaced = GFLauncherUtils.replace(replaced, "%", "${"); replaced = GFLauncherUtils.replace(replaced, "%", "}"); } if (replaced == null) { return s; } else { return replaced; } }
List<File> getSuffixClasspath() { String cp = map.get("classpath-suffix"); if(GFLauncherUtils.ok(cp)) { return GFLauncherUtils.stringToFiles(cp); } else { return new ArrayList<File>(); } }
private String getStockNativePathString() { // return the path that is setup by the JVM String s = System.getProperty(JAVA_NATIVE_SYSPROP_NAME); if(!GFLauncherUtils.ok(s)) s = ""; return s; }
public static boolean hasToken(String s) { if (s == null) { return false; } if (GFLauncherUtils.isWindows() && hasWindowsToken(s)) { return true; } if (s.indexOf(Token.TOKEN_START) >= 0) { return true; } return false; } ///////////////////////////////////////////////////////////////////////////
private void finalSetup() throws GFLauncherException { if(installDir == null) installDir = GFLauncherUtils.getInstallDir(); if (!GFLauncherUtils.safeIsDirectory(installDir)) { throw new GFLauncherException("noInstallDir", installDir); } // check user-supplied args if (domainParentDir != null) { // if the arg was given -- then it MUST point to a real dir if (!GFLauncherUtils.safeIsDirectory(domainParentDir)) { throw new GFLauncherException("noDomainParentDir", domainParentDir); } } setupServerDirs(); if (!GFLauncherUtils.safeIsDirectory(configDir)) { throw new GFLauncherException("noConfigDir", configDir); } configFile = new File(configDir, CONFIG_FILENAME); if (!GFLauncherUtils.safeExists(configFile)) { throw new GFLauncherException("noConfigFile", configFile); } if (instanceName == null) { instanceName = "server"; } // if we made it here -- we're in pretty good shape! valid = true; }
if (GFLauncherUtils.isRelativePath(value)) {
public static synchronized File getInstallDir() { setInstallDirFromSystemProp();
List<String> getCommands() { List<String> list = new ArrayList<String>(); String stockNativePathsString = getStockNativePathString(); String prefixFileString = getPrefixString(); String suffixFileString = getSuffixString(); String profilerFileString = getProfilerString(); String libFileString = libDir.getPath(); String lib64FileString = getLib64String(); // bnevins: Very simple to change the order right here in the future! // don't worry about extra PS's --> no problem-o // don't worry about duplicates -- SmartFile will get rid of them... StringBuilder sb = new StringBuilder(); sb.append(prefixFileString).append(PS); sb.append(libFileString).append(PS); sb.append(lib64FileString).append(PS); sb.append(stockNativePathsString).append(PS); sb.append(profilerFileString).append(PS); sb.append(suffixFileString); // this looks dumb but there is a lot of potential cleaning going on here // * all duplicate directories are removed // * junk is removed, e.g. ":xxx::yy::::::" goes to "xxx:yy" String finalPathString = GFLauncherUtils.fileListToPathString(GFLauncherUtils.stringToFiles(sb.toString())); String nativeCommand = "-D" + JAVA_NATIVE_SYSPROP_NAME + "=" + finalPathString; list.add(nativeCommand); return list; }
private String getProfilerString() { // if not enabled -- fagetaboutit if(!profiler.isEnabled()) return ""; List<File> ff = profiler.getNativePath(); return GFLauncherUtils.fileListToPathString(ff); }
String getNativeLibrarySuffix() { String s = map.get(NATIVE_LIB_SUFFIX); if(!GFLauncherUtils.ok(s)) s = ""; return s; }
public static boolean hasToken(String s) { if (s == null) { return false; } if (GFLauncherUtils.isWindows() && hasWindowsToken(s)) { return true; } if (s.indexOf(Token.TOKEN_START) >= 0) { return true; } return false; } ///////////////////////////////////////////////////////////////////////////
List<File> getSystemClasspath() { String cp = map.get("system-classpath"); if(GFLauncherUtils.ok(cp)) { return GFLauncherUtils.stringToFiles(cp); } else { return new ArrayList<File>(); } }
if (GFLauncherUtils.isRelativePath(value)) {
public static synchronized File getInstallDir() { setInstallDirFromSystemProp();
void setClasspath() throws GFLauncherException { List<File> mainCP = getMainClasspath(); // subclass provides this List<File> envCP = javaConfig.getEnvClasspath(); List<File> sysCP = javaConfig.getSystemClasspath(); List<File> prefixCP = javaConfig.getPrefixClasspath(); List<File> suffixCP = javaConfig.getSuffixClasspath(); List<File> profilerCP = profiler.getClasspath(); // create a list of all the classpath pieces in the right order List<File> all = new ArrayList<File>(); all.addAll(prefixCP); all.addAll(profilerCP); all.addAll(mainCP); all.addAll(sysCP); all.addAll(envCP); all.addAll(suffixCP); setClasspath(GFLauncherUtils.fileListToPathString(all)); }
String getNativeLibraryPrefix() { String s = map.get(NATIVE_LIB_PREFIX); if(!GFLauncherUtils.ok(s)) s = ""; return s; }
static private boolean isValidJavaRoot(String javaRootName) { if (!GFLauncherUtils.ok(javaRootName)) return false; // look for ${javaRootName}/bin/java[.exe] File f = new File(javaRootName); if (GFLauncherUtils.isWindows()) f = new File(f, "bin/java.exe"); else f = new File(f, "bin/java"); return f.exists(); }
public static boolean hasToken(String s) { if (s == null) { return false; } if (GFLauncherUtils.isWindows() && hasWindowsToken(s)) { return true; } if (s.indexOf(Token.TOKEN_START) >= 0) { return true; } return false; } ///////////////////////////////////////////////////////////////////////////