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:com.ambimmort.app.framework.controller.logic.SystemController.java

@RequestMapping(value = "/general.do", method = RequestMethod.GET)
public String viewGeneral(ModelMap model) {

    try {/*from ww  w . j  ava  2s  .co m*/
        Map<String, String> map = new HashMap<String, String>();
        for (String key : System.getProperties().stringPropertyNames()) {
            map.put(key, System.getProperties().getProperty(key));
        }
        model.addAttribute("syspros", map);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "systeminfo/general";
}

From source file:com.eryansky.utils.SigarUtil.java

/**
 * ??/*from   ww w. j  ava 2s  .  c o m*/
 * @throws Exception
 */
public static ServerStatus getServerStatus() throws Exception {
    ServerStatus status = new ServerStatus();
    status.setServerTime(DateFormatUtils.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss"));
    status.setServerName(System.getenv().get("COMPUTERNAME"));

    Runtime rt = Runtime.getRuntime();
    //status.setIp(InetAddress.getLocalHost().getHostAddress());
    status.setJvmTotalMem(rt.totalMemory() / (1024 * 1024));
    status.setJvmFreeMem(rt.freeMemory() / (1024 * 1024));
    status.setJvmMaxMem(rt.maxMemory() / (1024 * 1024));
    Properties props = System.getProperties();
    status.setServerOs(props.getProperty("os.name") + " " + props.getProperty("os.arch") + " "
            + props.getProperty("os.version"));
    status.setJavaHome(props.getProperty("java.home"));
    status.setJavaVersion(props.getProperty("java.version"));
    status.setJavaTmpPath(props.getProperty("java.io.tmpdir"));

    Sigar sigar = new Sigar();
    getServerCpuInfo(sigar, status);
    getServerDiskInfo(sigar, status);
    getServerMemoryInfo(sigar, status);

    return status;
}

From source file:ch.cyberduck.core.sftp.SFTPReadFeatureTest.java

@Test(expected = NotfoundException.class)
public void testReadNotFound() throws Exception {
    final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("sftp.user"),
                    System.getProperties().getProperty("sftp.password")));
    final SFTPSession session = new SFTPSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    new SFTPReadFeature(session).read(
            new Path(new SFTPHomeDirectoryService(session).find(), "nosuchname", EnumSet.of(Path.Type.file)),
            status, new DisabledConnectionCallback());
}

From source file:com.ibm.watson.app.common.codegen.languages.WatsonAppJaxRSServerCodegenTest.java

@After
public void cleanup() {
    Properties props = System.getProperties();
    props.remove(PACKAGE_PREFIX);
    System.setProperties(props);
}

From source file:ch.nydi.spring.config.SystemPropertiesFactoryBean.java

@Override
protected Properties createProperties() throws IOException {
    final Properties originalProperties = super.createProperties();
    final Properties propertiesReplaced = new Properties();

    final PropertyVariableParser propertyParser = new PropertyVariableParser();

    for (final Map.Entry<Object, Object> entry : originalProperties.entrySet()) {
        propertiesReplaced.put(entry.getKey(), propertyParser.replaceVariables((String) entry.getValue()));
    }/*  w  w w.  j a  v a 2 s. c om*/

    if (propagateToSystemProperties) {
        final Properties systemProperties = System.getProperties();
        systemProperties.putAll(propertiesReplaced);
        System.setProperties(systemProperties);
    }

    return propertiesReplaced;
}

From source file:ch.cyberduck.core.s3.S3AccessControlListFeatureTest.java

@Test
public void testReadContainer() throws Exception {
    final S3Session session = new S3Session(new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
            new Credentials(System.getProperties().getProperty("s3.key"),
                    System.getProperties().getProperty("s3.secret"))));
    session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("test-acl-us-east-1-cyberduck",
            EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Acl acl = new S3AccessControlListFeature(session).getPermission(container);
    assertTrue(acl.containsKey(new Acl.GroupUser("http://acs.amazonaws.com/groups/s3/LogDelivery")));
    assertTrue(acl.get(new Acl.GroupUser("http://acs.amazonaws.com/groups/s3/LogDelivery"))
            .contains(new Acl.Role(Acl.Role.WRITE)));
    assertTrue(acl.get(new Acl.GroupUser("http://acs.amazonaws.com/groups/s3/LogDelivery"))
            .contains(new Acl.Role("READ_ACP")));
    assertTrue(acl.containsKey(/* w  w  w.ja v a2 s  .co m*/
            new Acl.CanonicalUser("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6")));
    assertTrue(
            acl.get(new Acl.CanonicalUser("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6"))
                    .contains(new Acl.Role(Acl.Role.FULL)));
    session.close();
}

From source file:com.mycompany.capstone.dao.QuoteDaoDbImpl.java

@Override
public Quote create(Quote quote) {

    jdbcTemplate.update(SQL_INSERT_QUOTE, quote.getFirstName(), quote.getLastName(), quote.getEmail(),
            quote.getYear(), quote.getSelectedMake(), quote.getSelectedModel(), quote.getDescription());

    Integer id = jdbcTemplate.queryForObject("SELECT LAST_INSERT_ID()", Integer.class);

    quote.setId(id);/*from  w  ww.j a  va  2  s .c o m*/

    Properties props = (Properties) System.getProperties().clone();
    props.put("mail.smtp.host", "host");
    props.setProperty("mail.smtp.port", "587");
    props.put("mail.smtp.auth", true);

    //Bypass the SSL authentication
    props.put("mail.smtp.ssl.enable", false);
    props.put("mail.smtp.starttls.enable", false);

    SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
    msg.setTo("bennettglob@gmail.com");
    //        msg.setRecipients(Message.RecipientType.TO, ("bennettglob@gmail.com" + quote.getEmail()));

    msg.setText("test");
    try {
        this.mailSender.send(msg);
    } catch (MailException ex) {
        // simply log it and go on...
        System.err.println(ex.getMessage());
    }

    return quote;

}

From source file:ch.cyberduck.core.dav.DAVReadFeatureTest.java

@Test(expected = NotfoundException.class)
public void testReadNotFound() throws Exception {
    final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("webdav.user"),
                    System.getProperties().getProperty("webdav.password")));
    host.setDefaultPath("/dav/basic");
    final DAVSession session = new DAVSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    try {//from   w  ww  .  j a  va  2  s  .  co m
        new DAVReadFeature(session).read(new Path(new DefaultHomeFinderService(session).find(), "nosuchname",
                EnumSet.of(Path.Type.file)), status, new DisabledConnectionCallback());
    } catch (NotfoundException e) {
        assertEquals(
                "Unexpected response (404 Not Found). Please contact your web hosting service provider for assistance.",
                e.getDetail());
        throw e;
    }
}

From source file:io.undertow.test.jsp.basic.SimpleJspTestCase.java

@AfterClass
public static void after() {
    System.getProperties().remove(KEY);
}

From source file:com.vmware.aurora.global.Configuration.java

/**
 * //from  ww  w  .j a  v  a  2s  .  c  o m
 * @return a memory view of all properties inside serengeti.properties and vc.properties
 */
private static PropertiesConfiguration init() {
    PropertiesConfiguration config = null;

    String homeDir = System.getProperties().getProperty("serengeti.home.dir");
    String ngcConfigFile = NGC_PROP_FILE;
    if (homeDir != null && homeDir.length() > 0) {
        StringBuilder builder = new StringBuilder();
        builder.append(homeDir).append(File.separator).append("conf").append(File.separator);
        configFileName = builder.toString() + "serengeti.properties";
        ngcConfigFile = builder.toString() + NGC_PROP_FILE;
    } else {
        configFileName = "serengeti.properties";
    }

    try {
        URL url = ConfigurationUtils.locate(null, configFileName);
        logger.info("Reading properties file serengeti.properties from " + url.getPath());
        serengetiCfg = new PropertiesConfiguration();
        serengetiCfg.setEncoding("UTF-8");
        serengetiCfg.setFileName(configFileName);
        serengetiCfg.load();
        config = (PropertiesConfiguration) serengetiCfg.clone();
    } catch (ConfigurationException ex) {
        String message = "Failed to load serengeti.properties file.";
        logger.fatal(message, ex);
        throw AuroraException.APP_INIT_ERROR(ex, message);
    }

    String propertyFilePrefix = System.getProperty("PROPERTY_FILE_PREFIX", "vc");
    String propertyFileName = propertyFilePrefix + ".properties";

    try {
        logger.info("Reading properties file " + propertyFileName);
        vcCfg = new PropertiesConfiguration(propertyFileName);
        Iterator<?> keys = vcCfg.getKeys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            config.setProperty(key, vcCfg.getProperty(key));
        }
    } catch (ConfigurationException ex) {
        // error out if the configuration file is not there
        String message = "Failed to load vc.properties file.";
        logger.fatal(message, ex);
        throw AuroraException.APP_INIT_ERROR(ex, message);
    }
    // load ngc_registrar.properties
    try {
        logger.info("Reading properties file " + ngcConfigFile);
        ngcCfg = new PropertiesConfiguration(ngcConfigFile);
        ngcCfg.setEncoding("UTF-8");
        Iterator<?> keys = ngcCfg.getKeys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            config.setProperty(key, ngcCfg.getProperty(key));
        }
    } catch (ConfigurationException ex) {
        // error out if the configuration file is not there
        String message = "Failed to load file " + NGC_PROP_FILE;
        logger.fatal(message, ex);
        throw AuroraException.APP_INIT_ERROR(ex, message);
    }

    logConfig(config);
    return config;
}