Example usage for java.lang System getProperties

List of usage examples for java.lang System getProperties

Introduction

In this page you can find the example usage for java.lang System getProperties.

Prototype

public static Properties getProperties() 

Source Link

Document

Determines the current system properties.

Usage

From source file:capital.scalable.restdocs.javadoc.JavadocReaderImpl.java

public static JavadocReaderImpl createWithSystemProperty() {
    String systemProperty = System.getProperties().getProperty(JAVADOC_JSON_DIR_PROPERTY);
    return new JavadocReaderImpl(objectMapper(), toAbsoluteDirs(systemProperty));
}

From source file:edu.clemson.cs.nestbed.client.Client.java

private static void loadProperties() throws IOException {
    Properties systemProperties;// w  w w  . ja v  a  2 s .com
    InputStream propertyStream;

    // Wrap the system properties with our variable-expanding version
    System.setProperties(new VariableProperties(System.getProperties()));

    systemProperties = System.getProperties();
    propertyStream = Client.class.getClassLoader().getResourceAsStream("common.properties");
    systemProperties.load(propertyStream);
    propertyStream.close();
}

From source file:org.springframework.social.openidconnect.api.impl.GAECompatibleClientHttpRequestFactorySelector.java

public static ClientHttpRequestFactory getRequestFactory() {
    Properties properties = System.getProperties();
    String proxyHost = properties.getProperty("http.proxyHost");
    int proxyPort = properties.containsKey("http.proxyPort")
            ? Integer.valueOf(properties.getProperty("http.proxyPort"))
            : 80;//w  w w.ja v a2  s  .  c o m
    if (HTTP_COMPONENTS_AVAILABLE) {
        HttpClientBuilder httpClientBuilder = HttpClients.custom();
        if (proxyHost != null) {
            HttpHost proxy = new HttpHost(proxyHost, proxyPort);
            httpClientBuilder.setProxy(proxy);
        }
        return HttpComponentsClientRequestFactoryCreator.createRequestFactory(httpClientBuilder.build(),
                proxyHost, proxyPort);
    } else {
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        if (proxyHost != null) {
            requestFactory.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)));
        }
        return requestFactory;
    }
}

From source file:Main.java

/**
 * Connect to an HTTP URL and return the response as a string.
 * //from  ww w .ja va  2  s . c  o  m
 * Note that the HTTP method override is used on non-GET requests. (i.e.
 * requests are made as "POST" with method specified in the body).
 * 
 * @param url - the resource to open: must be a welformed URL
 * @param method - the HTTP method to use ("GET", "POST", etc.)
 * @param params - the query parameter for the URL (e.g. access_token=foo)
 * @return the URL contents as a String
 * @throws MalformedURLException - if the URL format is invalid
 * @throws IOException - if a network problem occurs
 */
public static String openUrl(String url, String method, Bundle params)
        throws MalformedURLException, IOException {
    if (method.equals("GET")) {
        url = url + "?" + encodeUrl(params);
    }

    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    conn.setRequestProperty("User-Agent",
            System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK");
    if (!method.equals("GET")) {
        // use method override
        params.putString("method", method);
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);
        conn.getOutputStream().write(encodeUrl(params).getBytes("UTF-8"));
    }

    String response = "";
    try {
        response = read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        // Error Stream contains JSON that we can parse to a FB error
        response = read(conn.getErrorStream());
    }

    return response;
}

From source file:com.threatconnect.sdk.conn.Connection.java

public Connection() throws IOException {
    String fileName = System.getProperties().getProperty("threatconnect.api.config");
    Properties props = ConnectionUtil.loadProperties(fileName);
    this.config = Configuration.build(props);

    this.urlConfig = URLConfiguration.build();
}

From source file:org.psidnell.omnifocus.ApplicationContextFactoryTest.java

@Test
public void testPropertyOverrideFromCommandLine() {

    ApplicationContext beanFactory = ApplicationContextFactory.getContext();

    // The default value
    assertEquals("7d", beanFactory.getBean("configparams", ConfigParams.class).getDueSoon());

    // Now override
    System.getProperties().put("dueSoon", "1d");

    beanFactory = ApplicationContextFactory.getContext();
    assertEquals("1d", beanFactory.getBean("configparams", ConfigParams.class).getDueSoon());
}

From source file:ar.com.zauber.commons.spring.configurers.SystemPropertyPlaceholderConfigurerTest.java

/** test */
public final void testFoo() {

    System.getProperties().put("spring-test-system", "4");
    final ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring-test-system.xml");
    final CheckBean i = (CheckBean) ctx.getBean("foo");
    assertEquals(i.getI(), 4);//from   w  w  w  .ja v  a2 s  .c o m
}

From source file:com.kamike.misc.FsUtils.java

public FsUtils() {
    Properties props = System.getProperties(); //    
    osName = props.getProperty("os.name"); //???   
}

From source file:adalid.util.meta.MetaJavaCompiler.java

public static void compile() {
    String dp1 = System.getProperties().getProperty("user.dir");
    String sep = System.getProperties().getProperty("file.separator");
    File src = new File(dp1 + sep + "src");
    File trg = new File(dp1 + sep + "bin");
    boolean dir = trg.isDirectory() || trg.mkdirs();
    List<File> files = getJavaFiles(src);
    // Get the java compiler provided with this platform
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    // Get the writer for the compiler output
    StringWriter out = new StringWriter();
    // Get the diagnostic listener for non-fatal diagnostics; if null use the compiler's default method for reporting diagnostics
    DiagnosticListener<JavaFileObject> diagnosticListener1 = null; // new DiagnosticCollector<JavaFileObject>();
    // Get the locale to apply when formatting diagnostics; null means the default locale
    Locale locale = null;/*ww w.j a  v a 2  s  . c  o m*/
    // Get the character set used for decoding bytes; if null use the platform default
    Charset charset = null;
    // Get an instance of the standard file manager implementation
    StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnosticListener1, locale, charset);
    // Get the diagnostic listener for non-fatal diagnostics; if null use the compiler's default method for reporting diagnostics
    DiagnosticListener<JavaFileObject> diagnosticListener2 = null; // new DiagnosticCollector<JavaFileObject>();
    // Get the list of compiler options, null means no options
    List<String> options = Arrays
            .asList(new String[] { "-g", "-source", "1.7", "-Xlint:unchecked", "-d", trg.getAbsolutePath() });
    // Get the list of class names (for annotation processing), null means no class names
    List<String> classes = null;
    // Get the list of java file objects to compile
    Iterable<? extends JavaFileObject> units = fileManager.getJavaFileObjectsFromFiles(files);
    // Create the compilation task
    CompilationTask task = compiler.getTask(out, fileManager, diagnosticListener2, options, classes, units);
    // Perform the compilation task
    // task.call(); // java.lang.NullPointerException at com.sun.tools.javac.api.JavacTaskImpl.parse(JavacTaskImpl.java:228)
    if (task instanceof JavacTask) {
        javacTask(task);
    }
}

From source file:org.eclipse.gemini.blueprint.test.provisioning.internal.LocalFileSystemMavenRepositoryTest.java

protected void tearDown() throws Exception {
    System.getProperties().remove("localRepository");
}