@Override public Object getInternalProperty(String key) { return System.getenv(key); }
@Override public Object getInternalProperty(String key) { return System.getenv(key); }
private String getProperty(String name) { String value = null; value = System.getProperty(name); if (value == null) { value = System.getenv(name); } return value; }
@Override @Nullable public String resolvePlaceholder(String placeholderName) { try { String propVal = System.getProperty(placeholderName); if (propVal == null) { // Fall back to searching the system environment. propVal = System.getenv(placeholderName); } return propVal; } catch (Throwable ex) { System.err.println("Could not resolve placeholder '" + placeholderName + "' in [" + this.text + "] as system property: " + ex); return null; } } }
public String[] getEnv() { Map<String,String> envs = System.getenv(); String[] envp = new String[envs.size()]; int i = 0; for (Map.Entry<String,String> e : envs.entrySet()) { envp[i++] = e.getKey()+'+'+e.getValue(); } return envp; }
/** * System environment -> System properties * * @param key key * @return value */ public static String getSystemProperty(String key) { String value = System.getenv(key); if (StringUtils.isEmpty(value)) { value = System.getProperty(key); } return value; }
/** * System environment -> System properties * * @param key key * @return value */ public static String getSystemProperty(String key) { String value = System.getenv(key); if (StringUtils.isEmpty(value)) { value = System.getProperty(key); } return value; }
private static File locateHostsFile() { File hostsFile; if (PlatformDependent.isWindows()) { hostsFile = new File(System.getenv("SystemRoot") + WINDOWS_HOSTS_FILE_RELATIVE_PATH); if (!hostsFile.exists()) { hostsFile = new File(WINDOWS_DEFAULT_SYSTEM_ROOT + WINDOWS_HOSTS_FILE_RELATIVE_PATH); } } else { hostsFile = new File(X_PLATFORMS_HOSTS_FILE_PATH); } return hostsFile; }
@Override @Nullable protected String getSystemAttribute(String attributeName) { try { return System.getenv(attributeName); } catch (AccessControlException ex) { if (logger.isInfoEnabled()) { logger.info("Caught AccessControlException when accessing system environment variable '" + attributeName + "'; its value will be returned [null]. Reason: " + ex.getMessage()); } return null; } } };
@Override public boolean canWork() { try { exe = System.getenv("WINSW_EXECUTABLE"); if (exe==null) return false; // not under winsw return exec("status") ==0; } catch (InterruptedException | IOException e) { LOGGER.log(FINE, getClass()+" unsuitable", e); return false; } }
public static Properties getProperties() { if (PROPERTIES == null) { synchronized (ConfigUtils.class) { if (PROPERTIES == null) { String path = System.getProperty(Constants.DUBBO_PROPERTIES_KEY); if (path == null || path.length() == 0) { path = System.getenv(Constants.DUBBO_PROPERTIES_KEY); if (path == null || path.length() == 0) { path = Constants.DEFAULT_DUBBO_PROPERTIES; } } PROPERTIES = ConfigUtils.loadProperties(path, false, true); } } } return PROPERTIES; }
public static Properties getProperties() { if (PROPERTIES == null) { synchronized (ConfigUtils.class) { if (PROPERTIES == null) { String path = System.getProperty(Constants.DUBBO_PROPERTIES_KEY); if (path == null || path.length() == 0) { path = System.getenv(Constants.DUBBO_PROPERTIES_KEY); if (path == null || path.length() == 0) { path = Constants.DEFAULT_DUBBO_PROPERTIES; } } PROPERTIES = ConfigUtils.loadProperties(path, false, true); } } } return PROPERTIES; }
private static final File getBaseDir() { File baseDir; String baseEnv = System.getenv("BASE"); if (baseEnv != null) { baseDir = new File(baseEnv); } else { LOGGER.log(Level.WARNING, "Could not find environment variable 'BASE' for Jenkins base directory. Falling back to JENKINS_HOME"); baseDir = Jenkins.getInstance().getRootDir(); } return baseDir; }
@Override public Preferences getPreferences (String name) { File libraryPath = new File(System.getenv("HOME"), "Library"); File finalPath = new File(libraryPath, name + ".plist"); @SuppressWarnings("unchecked") NSMutableDictionary<NSString, NSObject> nsDictionary = (NSMutableDictionary<NSString, NSObject>)NSMutableDictionary .read(finalPath); // if it fails to get an existing dictionary, create a new one. if (nsDictionary == null) { nsDictionary = new NSMutableDictionary<NSString, NSObject>(); nsDictionary.write(finalPath, false); } return new IOSPreferences(nsDictionary, finalPath.getAbsolutePath()); }
@Override public Preferences getPreferences (String name) { File libraryPath = new File(System.getenv("HOME"), "Library"); File finalPath = new File(libraryPath, name + ".plist"); String path = libraryPath + "/" + name + ".plist"; NSMutableDictionary<String, Object> nsDictionary = NSMutableDictionary.dictionaryWithContentsOfFile(path); // if it fails to get an existing dictionary, create a new one. if (nsDictionary == null) { nsDictionary = (NSMutableDictionary<String, Object>)NSMutableDictionary.alloc().init(); nsDictionary.writeToFileAtomically(path, false); } return new IOSPreferences(nsDictionary, finalPath.getAbsolutePath()); }
@Override public Preferences getPreferences (String name) { File libraryPath = new File(System.getenv("HOME"), "Library"); File finalPath = new File(libraryPath, name + ".plist"); String path = libraryPath + "/" + name + ".plist"; NSMutableDictionary<String, Object> nsDictionary = NSMutableDictionary.dictionaryWithContentsOfFile(path); // if it fails to get an existing dictionary, create a new one. if (nsDictionary == null) { nsDictionary = (NSMutableDictionary<String, Object>)NSMutableDictionary.alloc().init(); nsDictionary.writeToFileAtomically(path, false); } return new IOSPreferences(nsDictionary, finalPath.getAbsolutePath()); }
private static EnvVars initMaster() { EnvVars vars = new EnvVars(System.getenv()); vars.platform = Platform.current(); if(Main.isUnitTest || Main.isDevelopmentMode) // if unit test is launched with maven debug switch, // we need to prevent forked Maven processes from seeing it, or else // they'll hang vars.remove("MAVEN_OPTS"); return vars; } }
@Test public void testReplaceFromEnv() { Map<String,String> env = System.getenv(); if (env.containsKey("PATH")) { String text = "${PATH}"; assertEquals(env.get("PATH"), SystemPropertyUtils.resolvePlaceholders(text)); } }