List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:h2weibo.InitServlet.java
public JedisPool createJedisPool() { JedisPool jedisPool;/*from w ww . j a v a 2 s. com*/ GenericObjectPool.Config config = new GenericObjectPool.Config(); config.testOnBorrow = true; config.testWhileIdle = true; config.maxActive = 25; config.maxIdle = 0; config.minIdle = 0; log.debug("Jedis pool created."); try { String services = System.getenv("VCAP_SERVICES"); if (services != null) { JSONObject obj = new JSONObject(services); obj = obj.getJSONArray("redis-2.2").getJSONObject(0).getJSONObject("credentials"); String hostname = obj.getString("hostname"); int port = obj.getInt("port"); String password = obj.getString("password"); jedisPool = new JedisPool(config, hostname, port, 0, password); } else { jedisPool = new JedisPool(config, "localhost"); log.info("Using localhost Redis server"); } return jedisPool; } catch (JSONException e) { log.error("Failed to init", e); return null; } }
From source file:com.example.slackbot.SlackApplication.java
@RequestMapping(value = "/hello", produces = "application/json") public Message hello(@ModelAttribute("token") String token, @ModelAttribute("team_id") String teamId, @ModelAttribute("team_domain") String teamDomain, @ModelAttribute("channel_id") String channelId, @ModelAttribute("channel_name") String channelName, @ModelAttribute("user_id") String userId, @ModelAttribute("user_name") String userName, @ModelAttribute("command") String command, @ModelAttribute("text") String text, @ModelAttribute("response_url") String responseUrl) { String desiredToken = System.getenv("SLACK_TOKEN"); if (!desiredToken.equals(token)) { throw new AccessDeniedException("forbidden"); }/*from w w w . j a v a 2 s . c o m*/ Message message = new Message(); message.setText("Hello " + userName); message.setResponseType(Message.ResponseType.IN_CHANNEL); return message; }
From source file:org.jasig.portlet.calendar.spring.StringEncryptorFactoryBean.java
@Override public StringEncryptor getObject() throws Exception { final StandardPBEStringEncryptor rslt = new StandardPBEStringEncryptor(); /*//w w w .j ava2s .co m * If properties file encryption is used in this deployment, the * encryption key will be made available to the application as an * environment variable called UP_JASYPT_KEY. */ final String encryptionKey = System.getenv(JAYSYPT_ENCRYPTION_KEY_VARIABLE); if (encryptionKey != null) { logger.info("Jasypt support for encrypted property values ENABLED"); rslt.setPassword(encryptionKey); } else { logger.info( "Jasypt support for encrypted property values DISABLED; " + "specify environment variable {} to use this feature", JAYSYPT_ENCRYPTION_KEY_VARIABLE); /* * According to the API docs, not setting a password (on the StandardPBEStringEncryptor) * will result in an EncryptionInitializationException being thrown during initialization, * which will occur on the first call to decrypt(...); */ } return rslt; }
From source file:net.longfalcon.newsj.fs.DefaultFileSystemServiceImpl.java
public void init() { baseDir = config.getNzbFileLocation(); if (ValidatorUtil.isNull(baseDir)) { String userHome;//from w w w.j a v a 2 s. c o m if (SystemUtils.IS_OS_WINDOWS) { // windows is a pain userHome = System.getenv("USERPROFILE"); } else { userHome = System.getenv("HOME"); } baseDir = userHome + File.separator + ".newsj"; } _log.info("Initializing storage in " + baseDir); File baseDirFile = new File(baseDir); if (!baseDirFile.exists()) { baseDirFile.mkdirs(); } baseDirectory = new DirectoryImpl(baseDirFile); }
From source file:org.greencheek.utils.environment.propertyplaceholder.spring.TestEnvironmentalPropertySourcesPlaceholderConfigurerViaBuildersInXml.java
@Test public void testPropertyResolved() { System.setProperty("ENVIRONMENT", "dev"); System.setProperty("ENV", "dev"); ctx = new ClassPathXmlApplicationContext( new String[] { "classpath:SpringPropertySourcesPlaceholderConfigurer-config.xml" }); String value = (String) ctx.getBean("string"); String valueSys = (String) ctx.getBean("string-sys"); String valueEnv = (String) ctx.getBean("string-env"); String valuePath = (String) ctx.getBean("string-path"); assertEquals("devproperties", value); assertEquals("dev", valueSys); assertEquals(System.getenv("PATH"), valueEnv); assertEquals(System.getenv("PATH"), valuePath); }
From source file:org.trustedanalytics.h2oscoringengine.publisher.SwaggerConfig.java
private String getVersion() { String version = System.getenv("VERSION"); if (version == null || version.length() == 0) { version = "dev"; }/* ww w.j ava 2 s . co m*/ return version; }
From source file:com.opensymphony.xwork2.config.providers.XmlConfigurationProviderEnvsSubstitutionTest.java
public void testSubstitution() { assertEquals("bar", container.getInstance(String.class, "foo")); String user;/*from w w w . j a v a 2 s . com*/ if (SystemUtils.IS_OS_WINDOWS) { user = container.getInstance(String.class, "username"); assertEquals(System.getenv("USERNAME"), user); } else { user = container.getInstance(String.class, "user"); assertEquals(System.getenv("USER"), user); } String home; if (SystemUtils.IS_OS_WINDOWS) { home = container.getInstance(String.class, "homedrive.homepath"); assertEquals("Current HOMEDRIVE.HOMEPATH = " + System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH"), home); } else { home = container.getInstance(String.class, "home"); assertEquals("Current HOME = " + System.getenv("HOME"), home); } String os = container.getInstance(String.class, "os"); assertEquals("Current OS = " + System.getProperty("os.name"), os); String unknown = container.getInstance(String.class, "unknown"); assertEquals("Unknown = default", unknown); String devMode = container.getInstance(String.class, StrutsConstants.STRUTS_DEVMODE); assertEquals("false", devMode); }
From source file:com.ibm.actions.TextAction.java
public TextAction() { TEXTUSERNAME = System.getenv("TEXTUSERNAME"); TEXTPASSWORD = System.getenv("TEXTPASSWORD"); }
From source file:com.ansorgit.plugins.bash.editor.codecompletion.BashPathCommandCompletion.java
@Override public void initComponent() { String envPath = System.getenv("PATH"); if (envPath != null) { String[] split = StringUtils.split(envPath, ':'); if (split != null) { //fixme better do this in a background task? for (String path : Arrays.asList(split)) { File dir = new File(path); if (dir.exists() && dir.isDirectory()) { File[] commands = dir.listFiles(new ExecutableFileFilter()); if (commands != null) { for (File command : commands) { cachedCommands.add(command.getName()); }/*www .ja va2 s . c o m*/ } } } } } }
From source file:de.fhg.fokus.nubomedia.App.java
private void getEnvironmentVariabes() { String serverAddress = System.getenv("VNFM_IP"); int serverPort = Integer.parseInt(System.getenv("VNFM_PORT")); String vnfrId = System.getenv("VNFR_ID"); log.info("Instatiating the VNFR service profile with ff System Properties;\n VNFM_IP: " + serverAddress + "\nVNFM_PORT ....: " + serverPort + "\n" + vnfrId); }