List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:io.ignitr.springboot.common.metadata.DeploymentContext.java
/** * @return application name */ public String getName() { return appName != null ? appName : System.getenv(ENV_APP_NAME); }
From source file:com.github.trask.sandbox.mail.AmazonMailServiceTest.java
@Before public void before() throws Exception { preExistingThreads = ThreadChecker.currentThreadList(); String popGmailUsername = System.getenv("POP_GMAIL_USERNAME"); String popGmailPassword = System.getenv("POP_GMAIL_PASSWORD"); popClient = new PopGmailClient(popGmailUsername, popGmailPassword); popClient.pop();/*w w w . ja v a2 s . c o m*/ executorService = new SameThreadScheduledExecutorService(); String awsEmailAccessKey = System.getenv("AWS_EMAIL_ACCESS_KEY"); String awsEmailSecretKey = System.getenv("AWS_EMAIL_SECRET_KEY"); mailService = new AmazonMailService(awsEmailAccessKey, awsEmailSecretKey, executorService); }
From source file:com.ibm.watson.apis.conversation_enhanced.rest.SetupResource.java
/** * Method to fetch config JSON object and also the workspace_id. * //from w w w .j ava2s. c o m * @return response */ @GET @Produces(MediaType.APPLICATION_JSON) public Response getConfig() { String workspace_id = System.getenv(Constants.WORKSPACE_ID); //$NON-NLS-1$ logger.debug(MessageFormat.format(Messages.getString("SetupResource.WORKSPACE_ID_IS"), workspace_id)); JsonObject config = new JsonObject(); config.addProperty(Constants.SETUP_STATUS_MESSAGE, Messages.getString("SetupResource.SETUP_STATUS_MSG")); //$NON-NLS-1$ //$NON-NLS-2$ config.addProperty(Constants.SETUP_STEP, "0"); //$NON-NLS-1$ //$NON-NLS-2$ config.addProperty(Constants.SETUP_STATE, Constants.NOT_READY); //$NON-NLS-1$ //$NON-NLS-2$ config.addProperty(Constants.SETUP_PHASE, Messages.getString("SetupResource.PHASE_ERROR")); //$NON-NLS-1$ //$NON-NLS-2$ config.addProperty(Constants.SETUP_MESSAGE, Messages.getString("SetupResource.ERROR_CHECK_LOGS")); //$NON-NLS-1$ //$NON-NLS-2$ // Fetch the updated config JSON object from the servlet listener config = new ServletContextListener().getJsonConfig(); config.addProperty(Constants.SETUP_STATUS_MESSAGE, Messages.getString("SetupResource.SETUP_STATUS_MSG")); //$NON-NLS-1$ //$NON-NLS-2$ logger.debug(Messages.getString("SetupResource.CONFIG_STATUS") + config); // The following checks for the workspace_id after the Retrieve and // Rank service is ready for the user. This is done so that when the initial setup is being // done, the user can setup the Conversation service Workspace and provide it's id. if (config.get(Constants.SETUP_STEP).getAsInt() == 3 && config.get(Constants.SETUP_STATE).getAsString().equalsIgnoreCase(Constants.READY)) { if (StringUtils.isNotBlank(workspace_id)) { config.addProperty(Constants.WORKSPACE_ID, workspace_id); //$NON-NLS-1$ } else { config.addProperty(Constants.SETUP_STEP, "0"); //$NON-NLS-1$ //$NON-NLS-2$ config.addProperty(Constants.SETUP_STATE, Constants.NOT_READY); //$NON-NLS-1$ //$NON-NLS-2$ config.addProperty(Constants.SETUP_PHASE, Messages.getString("SetupResource.PHASE_ERROR")); //$NON-NLS-1$ //$NON-NLS-2$ config.addProperty(Constants.SETUP_MESSAGE, Messages.getString("SetupResource.WORKSPACE_ID_ERROR")); //$NON-NLS-1$ //$NON-NLS-2$ } } return Response.ok(config.getAsJsonObject().toString().trim()).type(MediaType.APPLICATION_JSON) .header("Cache-Control", "no-cache").build(); }
From source file:eu.annocultor.common.Utils.java
/** * Passing parameters via env variable, versus command line, * works around the fact that maven exec plugin launches a shell * that enforces its own interpretation of wildcards. * //from w w w.j a v a 2s. c o m * E.g. on Win a parameter input_files/*.xml gets replaced * with input_files/first-file-name.xml where first-file-name is the * name of the first file in input_files. * */ public static String[] getCommandLineFromANNOCULTOR_ARGS(String... args) { List<String> resArgs = new ArrayList<String>(); resArgs.addAll(Arrays.asList(args)); String envArgs = System.getenv("ANNOCULTOR_ARGS"); if (envArgs != null) resArgs.addAll(Arrays.asList(envArgs.split(" "))); return resArgs.toArray(new String[] {}); }
From source file:com.ibm.watson.apis.conversation_with_discovery.rest.SetupResource.java
/** * Method to fetch config JSON object and also the workspace_id. * * @return response/*from w w w . j a va2s . c om*/ */ @GET @Produces(MediaType.APPLICATION_JSON) public Response getConfig() { String workspaceId = System.getenv(Constants.WORKSPACE_ID); logger.debug(MessageFormat.format(Messages.getString("SetupResource.WORKSPACE_ID_IS"), workspaceId)); JsonObject config = new JsonObject(); config.addProperty(Constants.SETUP_STATUS_MESSAGE, Messages.getString("SetupResource.SETUP_STATUS_MSG")); config.addProperty(Constants.SETUP_STEP, "0"); config.addProperty(Constants.SETUP_STATE, Constants.NOT_READY); config.addProperty(Constants.SETUP_PHASE, Messages.getString("SetupResource.PHASE_ERROR")); config.addProperty(Constants.SETUP_MESSAGE, Messages.getString("SetupResource.CHECK_LOGS")); // Fetch the updated config JSON object from the servlet listener config = new AppServletContextListener().getJsonConfig(); config.addProperty(Constants.SETUP_STATUS_MESSAGE, Messages.getString("SetupResource.SETUP_STATUS_MSG")); logger.debug(Messages.getString("SetupResource.CONFIG_STATUS") + config); config.addProperty(Constants.WORKSPACE_ID, workspaceId); if (config.has(Constants.SETUP_STEP) && (config.get(Constants.SETUP_STEP).getAsInt() == 3) && config.get(Constants.SETUP_STATE).getAsString().equalsIgnoreCase(Constants.READY)) { if (StringUtils.isBlank(workspaceId)) { config.addProperty(Constants.SETUP_STEP, "0"); config.addProperty(Constants.SETUP_STATE, Constants.NOT_READY); config.addProperty(Constants.SETUP_PHASE, Messages.getString("SetupResource.PHASE_ERROR")); config.addProperty(Constants.SETUP_MESSAGE, Messages.getString("SetupResource.WORKSPACE_ID_ERROR")); } } return Response.ok(config.getAsJsonObject().toString().trim()).type(MediaType.APPLICATION_JSON) .header("Cache-Control", "no-cache").build(); }
From source file:com.thoughtworks.cruise.context.configuration.ValidLdapConfiguration.java
protected void postProcess(CruiseConfigDom dom) throws Exception { String ldapServerIp = System.getenv("LDAP_SERVER_IP"); if (StringUtils.isBlank(ldapServerIp)) throw new RuntimeException(String.format("%s is not set", ldapServerIp)); dom.getLdap().setText("ldap://" + ldapServerIp); }
From source file:Main.java
public static String getSdkPath() { String sdkPath = System.getenv("ANDROID_SDK"); if (null != sdkPath) { return sdkPath; }/* w w w.j a v a2s . c o m*/ throw new RuntimeException( "Can not find sdk path in your computer's environment, please add it, with the Key: ANDROID_SDK, and the Value: [SDK PATH]"); }
@Test public void testPropertyResolved() { System.setProperty("ENVIRONMENT", "dev"); System.setProperty("ENV", "dev"); ctx = new ClassPathXmlApplicationContext(new String[] { "classpath:SpringPropertySourcesPlaceholderConfigurer-composite-config-withstringlocations.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"); String valueOps = (String) ctx.getBean("string-ops"); assertEquals("devproperties", value); assertEquals("dev", valueSys); assertEquals(System.getenv("PATH"), valueEnv); assertEquals(System.getenv("PATH"), valuePath); assertEquals("ops have overridden me", valueOps); PropertySource p = ((PropertySource) ctx.getBean("environmentalProperties")); assertEquals("${ENVIRONMENT}", p.getProperty("sys")); assertEquals("${PATH}", p.getProperty("env")); }
From source file:com.cloud.utils.PropertiesUtil.java
/** * Searches the class path and local paths to find the config file. * @param path path to find. if it starts with / then it's absolute path. * @return File or null if not found at all. *//*from w ww . j a v a 2 s. co m*/ public static File findConfigFile(String path) { ClassLoader cl = PropertiesUtil.class.getClassLoader(); URL url = cl.getResource(path); if (url != null && "file".equals(url.getProtocol())) { return new File(url.getFile()); } url = ClassLoader.getSystemResource(path); if (url != null && "file".equals(url.getProtocol())) { return new File(url.getFile()); } File file = new File(path); if (file.exists()) { return file; } String newPath = "conf" + (path.startsWith(File.separator) ? "" : "/") + path; url = ClassLoader.getSystemResource(newPath); if (url != null && "file".equals(url.getProtocol())) { return new File(url.getFile()); } url = cl.getResource(newPath); if (url != null && "file".equals(url.getProtocol())) { return new File(url.getFile()); } newPath = "conf" + (path.startsWith(File.separator) ? "" : File.separator) + path; file = new File(newPath); if (file.exists()) { return file; } newPath = System.getProperty("catalina.home"); if (newPath == null) { newPath = System.getenv("CATALINA_HOME"); } if (newPath == null) { newPath = System.getenv("CATALINA_BASE"); } if (newPath == null) { return null; } file = new File(newPath + File.separator + "conf" + File.separator + path); if (file.exists()) { return file; } return null; }
From source file:cop.maven.plugins.RamlMojoIT.java
@SuppressWarnings("CallToSystemGetenv") private static String getMavenHome() { return StringUtils.defaultString(System.getenv("MAVEN_HOME"), System.getenv("M2_HOME")); }