List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:com.vmware.identity.idm.IdmDataCreator.java
private static InputStream getInputStream(String filename) { InputStream retval = null;//from w w w. jav a2 s . com try { // get env var String envvar = System.getenv(CONFIG_FILE_DIRECTORY_ENV_VAR); String path; if (envvar != null) { // assume Windows path = envvar + "\\"; } else { // assume Linux path = CONFIG_FILE_DIRECTORY + "/"; } // try filesystem first String filePath = path + filename; File file = new File(filePath); if (file.exists()) { retval = new FileInputStream(filePath); } } catch (Exception e) { } if (retval == null) { // fallback to resource file retval = IdmDataCreator.class.getResourceAsStream("/" + filename); } return retval; }
From source file:com.cisco.oss.foundation.logging.converters.FoundationLoggingCompNamePatternConverter.java
public static String getComponentName() { String compName = System.getenv("_RPM_SOFTWARE_NAME"); if (StringUtils.isBlank(compName)) { compName = System.getProperty("app.name"); }/*from w w w . jav a2s . co m*/ if (StringUtils.isBlank(compName)) { compName = "UNKNOWN"; } return compName; }
From source file:com.nike.vault.client.DefaultVaultUrlResolver.java
/** * Attempts to acquire the Vault URL from the following places: * <ul>/*from w ww . ja v a 2s .c om*/ * <li>Environment Variable - <code>VAULT_ADDR</code></li> * <li>Java System Property - <code>vault.addr</code></li> * </ul> * * @throws VaultClientException If unable to resolve the URL * @return Vault URL */ @Override public String resolve() { final String envUrl = System.getenv(VAULT_ADDR_ENV_PROPERTY); final String sysUrl = System.getProperty(VAULT_ADDR_SYS_PROPERTY); if (StringUtils.isNotBlank(envUrl) && HttpUrl.parse(envUrl) != null) { return envUrl; } else if (StringUtils.isNotBlank(sysUrl) && HttpUrl.parse(sysUrl) != null) { return sysUrl; } throw new VaultClientException( "Failed to resolve the Vault URL from the environment and/or system properties."); }
From source file:com.ge.predix.test.utils.ZacTestUtil.java
public void assumeZacServerAvailable() { // Not all tests use Spring so try to get the URL from the environment. if (StringUtils.isEmpty(this.zacUrl)) { this.zacUrl = System.getenv("ZAC_URL"); }/*from w w w . j a va 2s . c o m*/ if (!isServerListening(URI.create(this.zacUrl))) { throw new SkipException("Skipping tests because ZAC is not available."); } }
From source file:org.openmrs.module.appframework.feature.FeatureToggleProperties.java
FeatureToggleProperties() { String propertiesFileName = System.getenv(FEATURE_TOGGLE_PROPERTIES_ENV); if (propertiesFileName == null) { propertiesFileName = OpenmrsUtil.getApplicationDataDirectory() + File.separatorChar + FEATURE_TOGGLE_PROPERTIES_FILE_NAME; }/*from w w w .j a v a2s .com*/ propertiesFile = new File(propertiesFileName); }
From source file:eu.optimis.ics.core.util.PropertiesReader.java
/** * Gets the configuration file path//from ww w.j av a 2 s . c om * @param configFile the properties file * @return configuration file path */ public static String getConfigFilePath(String configFile) { String optimisHome = System.getenv("OPTIMIS_HOME"); if (optimisHome == null) { optimisHome = Constants.OPTIMIS_HOME_DEFAULT; log.debug("ics.core.util.PropertiesReader.getConfigFilePath(): OPTIMIS_HOME_DEFAULT: " + optimisHome); } else { log.debug( "ics.core.util.PropertiesReader.getConfigFilePath(): OPTIMIS_HOME_CUSTOMIZED: " + optimisHome); } File fileObject = new File(optimisHome.concat(configFile)); if (!fileObject.exists()) { try { createDefaultConfigFile(fileObject); } catch (Exception ex) { log.error("ics.core.util.PropertiesReader.getConfigFilePath(): Error reading " + optimisHome.concat(configFile) + " configuration file: " + ex.getMessage()); //ex.printStackTrace(); } } return optimisHome.concat(configFile); }
From source file:com.intel.databackend.config.cloudfoundry.utils.VcapReader.java
public VcapReader() { vcapServices = System.getenv(VCAP_SERVICES); }
From source file:com.example.appengine.analytics.AnalyticsServlet.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { String trackingId = System.getenv("GA_TRACKING_ID"); URIBuilder builder = new URIBuilder(); builder.setScheme("http").setHost("www.google-analytics.com").setPath("/collect").addParameter("v", "1") // API Version. .addParameter("tid", trackingId) // Tracking ID / Property ID. // Anonymous Client Identifier. Ideally, this should be a UUID that // is associated with particular user, device, or browser instance. .addParameter("cid", "555").addParameter("t", "event") // Event hit type. .addParameter("ec", "example") // Event category. .addParameter("ea", "test action"); // Event action. URI uri = null;//from www . j a v a 2 s . c om try { uri = builder.build(); } catch (URISyntaxException e) { throw new ServletException("Problem building URI", e); } URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService(); URL url = uri.toURL(); fetcher.fetch(url); resp.getWriter().println("Event tracked."); }
From source file:com.cisco.oss.foundation.logging.converters.FoundationLoggingCompVersionPatternConverter.java
public static String getComponentVersion() { String compVersion = System.getenv("_ARTIFACT_VERSION"); if (StringUtils.isBlank(compVersion)) { compVersion = "UNKNOWN"; }//from w w w. j a va 2s.com return compVersion; }
From source file:com.netflix.spinnaker.kork.dynomite.LocalRedisDynomiteClient.java
public LocalRedisDynomiteClient(int port) { String rack = StringUtils.isBlank(System.getenv("EC2_REGION")) ? "local" : System.getenv("EC2_REGION"); HostSupplier localHostSupplier = new HostSupplier() { final Host hostSupplierHost = new Host("localhost", rack, Host.Status.Up); @Override// ww w . j ava 2 s. c om public List<Host> getHosts() { return Collections.singletonList(hostSupplierHost); } }; TokenMapSupplier tokenMapSupplier = new TokenMapSupplier() { final Host tokenHost = new Host("localhost", port, rack, Host.Status.Up); final HostToken localHostToken = new HostToken(100000L, tokenHost); @Override public List<HostToken> getTokens(Set<Host> activeHosts) { return Collections.singletonList(localHostToken); } @Override public HostToken getTokenForHost(Host host, Set<Host> activeHosts) { return localHostToken; } }; this.dynoJedisClient = new DynoJedisClient.Builder().withDynomiteClusterName("local") .withApplicationName(String.valueOf(port)).withHostSupplier(localHostSupplier) .withCPConfig(new ConnectionPoolConfigurationImpl(String.valueOf(port)) .setCompressionStrategy(ConnectionPoolConfiguration.CompressionStrategy.NONE) .setLocalRack(rack).withHashtag("{}").withHostSupplier(localHostSupplier) .withTokenSupplier(tokenMapSupplier)) .build(); }