List of usage examples for java.lang System getenv
public static java.util.Map<String, String> getenv()
From source file:com.sixt.service.framework.servicetest.helper.DockerComposeHelper.java
/** * Set environment variable "etcd_endpoints" to the host and port specified by * docker//from www.j a va 2s. c o m */ public static void setEtcdEnvironment(DockerComposeRule docker) { DockerPort etcd = docker.containers().container("etcd").port(2379); Map<String, String> newEnv = new HashMap<>(); newEnv.put("etcd_endpoints", etcd.inFormat("http://$HOST:$EXTERNAL_PORT")); newEnv.putAll(System.getenv()); setEnv(newEnv); }
From source file:com.redhat.developers.msa.hello.HelloResource.java
@GET @Path("/hello") @Produces("text/plain") @ApiOperation("Returns the greeting in English") public String hello() { String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown"); return String.format("Hello from %s", hostname); }
From source file:org.workspace7.moviestore.controller.SessionsController.java
@CrossOrigin @RequestMapping(method = RequestMethod.GET, value = "/sessions", produces = "application/json") public @ResponseBody String sessions(HttpServletRequest request) { final String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown"); ObjectMapper sessions = new ObjectMapper(); ObjectNode rootNode = sessions.createObjectNode().put("hostName", hostname); String jsonResponse = "{\"message\":\"NO SESSIONS AVAILABLE\"}"; try {/*from w w w . jav a 2 s . co m*/ AdvancedCache<Object, Object> sessionCache = cacheManager.getCache("moviestore-sessions-cache") .getAdvancedCache(); if (sessionCache != null && !sessionCache.isEmpty()) { ArrayNode sessionsArray = rootNode.arrayNode(); Map<Object, Object> sessionsCacheMap = sessionCache.entrySet().stream().collect(CacheCollectors .serializableCollector(() -> Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); sessionsCacheMap.forEach((s, o) -> { MapSession mapSession = (MapSession) o; log.debug("Session Controller Map Session Id {} value : {}", s, mapSession); if (log.isDebugEnabled()) { StringBuilder debugMessage = new StringBuilder(); mapSession.getAttributeNames().forEach(key -> { debugMessage.append("Attribute :" + s + " Value: " + mapSession.getAttribute(key)); }); log.debug("Map Session Attributes : {}", debugMessage); } MovieCart movieCart = mapSession.getAttribute(ShoppingCartController.SESSION_ATTR_MOVIE_CART); if (movieCart != null) { ObjectNode movieCartNode = sessions.createObjectNode(); movieCartNode.put("sessionId", mapSession.getId()); movieCartNode.put("orderId", movieCart.getOrderId()); ArrayNode movieItemsNode = movieCartNode.arrayNode(); movieCart.getMovieItems().forEach((movieId, qty) -> { ObjectNode movieItem = movieItemsNode.addObject(); movieItem.put("movieId", movieId); movieItem.put("orderQuantity", qty); }); movieCartNode.set("movies", movieItemsNode); sessionsArray.add(movieCartNode); } }); rootNode.set("sessions", sessionsArray); } jsonResponse = sessions.writeValueAsString(rootNode); } catch (Exception e) { log.error("Error building JSON response for sesisons", e); } return jsonResponse; }
From source file:org.excalibur.service.compute.executor.Worker.java
public void execute(final Application application, ExecuteResultHandler executeResultHandler) throws ExecuteException, IOException { final String commandLine = application.getExecutableCommandLine(); DefaultExecutor executor = new DefaultExecutor(); CommandLine command = new CommandLine("/bin/sh"); command.addArgument("-c", false); command.addArgument(commandLine, false); executor.execute(command, System.getenv(), executeResultHandler); LOG.debug("Launched the execution of task: [{}], uuid: [{}]", commandLine, application.getId()); }
From source file:io.syndesis.dao.init.ReadApiClientData.java
/** * * @param fileName/*w w w . j a v a2 s .co m*/ * @return * @throws JsonParseException * @throws JsonMappingException * @throws IOException */ public List<ModelData<?>> readDataFromFile(String fileName) throws JsonParseException, JsonMappingException, IOException { try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName)) { if (is == null) { throw new FileNotFoundException("Cannot find file " + fileName + " on classpath"); } String jsonText = findAndReplaceTokens(from(is), System.getenv()); return Json.mapper().readValue(jsonText, MODEL_DATA_TYPE); } }
From source file:com.redhat.developers.msa.namaste.NamasteResource.java
@GET @Path("/namaste") @Produces("text/plain") @ApiOperation("Returns the greeting in Indian") public String namaste() { String hostname = System.getenv().getOrDefault("HOSTNAME", "Unknown"); return String.format("%s ke taraf se namaste", hostname); }
From source file:org.zlogic.vogon.web.ServerTypeDetector.java
/** * Returns true if environment has a variable matching the pattern * * @param pattern the pattern to search/*from www . ja va2s . c o m*/ * @return true if environment has a variable matching the pattern */ protected boolean hasEnvironmentVariable(Pattern pattern) { for (String variable : System.getenv().keySet()) if (pattern.matcher(variable).matches()) return true; return false; }
From source file:com.technofovea.packbsp.WindowsRegistryChecker.java
public WindowsRegistryChecker() { executor.setExitValue(SUCCESSFUL_EXIT); watchdog = new ExecuteWatchdog(WATCHDOG_TIME); executor.setWatchdog(watchdog);/* w w w . j a va 2 s . co m*/ environment = new HashMap<String, String>(System.getenv()); cmd = CommandLine.parse("reg.exe"); cmd.addArgument("query"); cmd.addArgument("${" + KEY_PATH + "}"); cmd.addArgument("/v"); cmd.addArgument("${" + KEY_VALUE_NAME + "}"); }
From source file:com.redhat.developers.msa.hola.HolaResource.java
@GET @Path("/hola") @Produces("text/plain") @ApiOperation("Returns the greeting in Spanish") public String hola() { String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown"); String translation = ConfigResolver.resolve("hello").withDefault("Hola de %s").logChanges(true) // 5 Seconds cache only for demo purpose .cacheFor(TimeUnit.SECONDS, 5).getValue(); return String.format(translation, hostname); }
From source file:com.avast.server.hdfsshell.ui.ShellPromptProvider.java
@PostConstruct public void init() { setPs1(System.getenv().getOrDefault("HDFS_SHELL_PROMPT", DEFAULT_PROMPT)); }