List of usage examples for java.lang System getenv
public static java.util.Map<String, String> getenv()
From source file:com.kylinolap.rest.service.AdminService.java
/** * Get Java Env info as string//from w w w. jav a 2 s. c o m * * @return */ @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN) public String getEnv() { logger.debug("Get Kylin Runtime environment"); PropertiesConfiguration tempConfig = new PropertiesConfiguration(); // Add Java Env try { String content = ""; ByteArrayOutputStream baos = new ByteArrayOutputStream(); // env Map<String, String> env = System.getenv(); for (String envName : env.keySet()) { tempConfig.addProperty(envName, env.get(envName)); } // properties Properties properteis = System.getProperties(); for (Object propName : properteis.keySet()) { tempConfig.setProperty((String) propName, properteis.get(propName)); } // do save tempConfig.save(baos); content = baos.toString(); return content; } catch (ConfigurationException e) { logger.debug("Failed to get Kylin Runtime env", e); throw new InternalErrorException("Failed to get Kylin env Config", e); } }
From source file:com.redhat.developers.helloworld.HelloworldVerticle.java
private String hello(String name) { String configGreeting = ApplicationConfiguration.load(config()).getString("GREETING"); String greeting = configGreeting == null ? "Hello {name} from {hostname} with {version}" : configGreeting; Map<String, String> values = new HashMap<String, String>(); values.put("name", name); values.put("hostname", System.getenv().getOrDefault("HOSTNAME", "unknown")); values.put("version", version); return new StrSubstitutor(values, "{", "}").replace(greeting); }
From source file:net.maritimecloud.portal.infrastructure.mail.SmtpMailAdapterITTest.java
private void echoEnvironmentVariables() { System.getenv().forEach((k, v) -> System.out.println(k + "=" + v)); }
From source file:org.focusns.service.env.impl.EnvironmentServiceImpl.java
protected Environment lookupOS() { if (envOS == null) { Properties props = System.getProperties(); Map<String, String> env = System.getenv(); ///*from ww w. j a v a2 s . co m*/ envOS = new EnvironmentOS(); envOS.setOsName(props.getProperty("os.name")); envOS.setOsVersion(props.getProperty("os.version")); envOS.setOsArch(props.getProperty("os.arch")); envOS.setOsPatch(props.getProperty("sun.os.patch.level")); envOS.setOsPath(env.get("Path")); } // return envOS; }
From source file:pivotal.au.se.gemfirexdweb.controller.LoginController.java
@RequestMapping(value = "/login", method = RequestMethod.GET) public String login(Model model, HttpSession session) throws Exception { logger.debug("Received request to show login page"); String vcapServices = null;/*from ww w .j a va 2s . co m*/ vcapServices = System.getenv().get("VCAP_SERVICES"); if (vcapServices != null) { if (vcapServices.length() > 0) { try { // we have a bound application to HAWQ possibly get connect details. logger.debug("PCFHawqWeb bound to PHD service..."); JSONObject GemFireXDURI = (JSONObject) getPCFObject(vcapServices.trim()); String username = "", password = ""; String pcfurl = (String) GemFireXDURI.get("uri"); String[] splitStr = pcfurl.split(";"); for (String s : splitStr) { String tmp = ""; int length = 0, startpos = 0; if (s.startsWith("user")) { length = s.length(); startpos = s.indexOf("="); username = s.substring(startpos + 1, length); } else if (s.startsWith("password")) { length = s.length(); startpos = s.indexOf("="); password = s.substring(startpos + 1, length); } } logger.debug("\n---- Ready to roll ----"); logger.debug("url = " + pcfurl); logger.debug("username = " + username); logger.debug("password = " + password); logger.debug("----"); ConnectionManager cm = ConnectionManager.getInstance(); Connection conn; conn = AdminUtil.getNewConnection(pcfurl); SQLFireJDBCConnection newConn = new SQLFireJDBCConnection(conn, pcfurl, new java.util.Date().toString(), username); cm.addConnection(newConn, session.getId()); session.setAttribute("user_key", session.getId()); session.setAttribute("user", username); session.setAttribute("schema", username); session.setAttribute("url", pcfurl); session.setAttribute("prefs", new UserPref()); session.setAttribute("history", new LinkedList()); session.setAttribute("connectedAt", new java.util.Date().toString()); Map<String, String> schemaMap = AdminUtil.getSchemaMap(); // get schema count now schemaMap = QueryUtil.populateSchemaMap(conn, schemaMap, username); session.setAttribute("schemaMap", schemaMap); // This will resolve to /WEB-INF/jsp/main.jsp return "main"; } catch (Exception ex) { model.addAttribute("error", ex.getMessage()); model.addAttribute("loginAttribute", new Login()); // This will resolve to /WEB-INF/jsp/loginpage.jsp return "loginpage"; } } } // Create new QueryWindow and add to model // This is the formBackingObject Login login = new Login(); login.setUrl("jdbc:gemfirexd://localhost:1527/"); model.addAttribute("loginAttribute", login); // This will resolve to /WEB-INF/jsp/loginpage.jsp return "loginpage"; }
From source file:de.cosmocode.palava.core.Main.java
private Main(String[] args) { final CmdLineParser parser = new CmdLineParser(options); try {/* w ww . j a va2 s .c o m*/ parser.parseArgument(args); } catch (CmdLineException e) { System.err.println("Usage: java [options] configuration-files..."); parser.printUsage(System.err); throw new IllegalArgumentException(e); } if (options.isInterceptStreams()) { SystemStreamWrapper.redirectSystemStreams(); LOG.info("SYSOUT and SYSERR will be logged through the logging system"); } LOG.info("Options: {}", options); LOG.info("Environment: {}", System.getenv()); LOG.info("System: {}", System.getProperties()); final Properties properties; try { properties = MultiProperties.load(options.getConfigs()); } catch (IOException e) { throw new IllegalArgumentException(e); } framework = Palava.newFramework(properties); }
From source file:com.netflix.spinnaker.halyard.deploy.provider.v1.KubernetesProvider.java
@Override public void bootstrapClouddriver() { JobRequest request = new JobRequest().setTokenizedCommand(Arrays.asList("kubectl", "create", "-f", "-")) .setTimeoutMillis(TimeUnit.MINUTES.toMillis(TIMEOUT_MINUTES)); InputStream cloudddriverConfig = getClass().getResourceAsStream(CLOUDRIVER_CONFIG_PATH); String jobId = jobExecutor.startJob(request, System.getenv(), cloudddriverConfig); JobStatus jobStatus = jobExecutor.backoffWait(jobId, TimeUnit.SECONDS.toMillis(MIN_POLL_INTERVAL_SECONDS), TimeUnit.SECONDS.toMillis(MAX_POLL_INTERVAL_SECONDS)); System.out.println(jobStatus.getStdOut()); System.out.println(jobStatus.getStdErr()); }
From source file:io.syndesis.dao.init.ReadApiClientData.java
public List<ModelData<?>> readDataFromString(String jsonText) throws JsonParseException, JsonMappingException, IOException { String json = findAndReplaceTokens(jsonText, System.getenv()); return Json.mapper().readValue(json, MODEL_DATA_TYPE); }
From source file:com.acapulcoapp.alloggiatiweb.AddRegion.java
/** * If no profile has been configured, set by default the "dev" profile. *///from w w w .j a va2 s .c om private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) { if (!source.containsProperty("spring.profiles.active") && !System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) { app.setAdditionalProfiles("dev"); //public static final String SPRING_PROFILE_DEVELOPMENT = "dev"; } }
From source file:ee.ignite.logtojira.AppenderServiceImpl.java
private String composeEnvironmentDescription() { StringBuilder result = new StringBuilder(); for (Entry<String, String> e : System.getenv().entrySet()) { result.append(e.getKey());//from w w w . ja v a 2 s. com result.append("="); result.append(e.getValue()); result.append("; "); } result.append("\n\n"); for (Entry<Object, Object> e : System.getProperties().entrySet()) { result.append(e.getKey()); result.append("="); result.append(e.getValue()); result.append("; "); } return result.toString(); }