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.tacitknowledge.util.migration.jdbc.JdbcMigrationLauncherFactoryLoader.java

/**
 * Create the JdbcMigrationLauncherFactory
 *
 * @return JdbcMigrationLauncherFactory (or subclass)
 *///from   ww  w .  j  a v  a  2s. co m
public JdbcMigrationLauncherFactory createFactory() {
    // Get the factory name from the system properties if possible
    String factoryName = System.getProperties().getProperty("migration.factory");
    if (factoryName == null) {
        factoryName = JdbcMigrationLauncherFactory.class.getName();
    }
    log.debug("Creating JdbcMigrationLauncher using " + factoryName);

    // Load the factory
    Class factoryClass = null;
    try {
        factoryClass = Class.forName(factoryName);
    } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException(
                "Migration factory class '" + factoryName + "' not found.  Aborting.");
    }
    try {
        return (JdbcMigrationLauncherFactory) factoryClass.newInstance();
    } catch (Exception e) {
        throw new RuntimeException(
                "Problem while instantiating factory class '" + factoryName + "'.  Aborting.", e);
    }
}

From source file:com.asakusafw.bulkloader.testutil.UnitTestUtil.java

public static void setUpEnv() throws Exception {
    Properties p = System.getProperties();
    p.setProperty(Constants.ASAKUSA_HOME, new File(".").getCanonicalPath());
    p.setProperty(Constants.THUNDER_GATE_HOME, new File(PATH_DIST_TEST).getCanonicalPath());
    ConfigurationLoader.setSysProp(p);//from www. ja  va 2 s . c o m
    System.setProperties(p);
}

From source file:ar.com.zauber.commons.spring.beans.factory.impl.BooleanSystemPropertyCaseBlockTest.java

/** ehh     */
public final void testTrue() {
    System.getProperties().put("babla.activar", "true");
    try {//from w  w  w  .j  av  a 2s  . com
        final ApplicationContext ctx = new ClassPathXmlApplicationContext(
                "classpath:spring-test-switch-systemboolean.xml");
        final String s = (String) ctx.getBean("test1");
        assertEquals("hola", s);
    } finally {
        System.getProperties().remove("babla.activar");
    }
}

From source file:com.pactera.edg.am.metamanager.extractor.util.AdapterContextLoader.java

/**
 * /*from  w w  w . j av  a  2 s .c  o  m*/
 * SpringClassPathXMLApplicationContext,????${var}
 * prop??? ??.properties??,??${var}
 * 
 * @param configLocations
 *            application context?
 * @param props
 *            ??application context????key/value
 * @return ApplicationContext Application
 *         Context,?,??,bean,null
 * @exception
 */
public static ApplicationContext createApplicationContext(String[] configLocations, Properties props) {
    // :spring?system properties??.
    Properties bakProps = null;
    String logMsg = null;
    try {
        if (props != null && props.size() > 0) {
            // system properties
            bakProps = System.getProperties();

            for (Object key : props.keySet()) {
                System.setProperty((String) key, props.getProperty((String) key));
            }

            if (log.isDebugEnabled()) {
                StringBuffer sb = new StringBuffer();
                sb.append("??springxml?${var}prop:\n");
                for (Object key : props.keySet()) {
                    sb.append(key + "=" + System.getProperty((String) key));
                    sb.append("\n");
                }
                log.debug(sb.toString());
            }
        }
        return new ClassPathXmlApplicationContext(configLocations);
    } catch (BeanDefinitionStoreException bse) {
        // 
        logMsg = new StringBuilder("?spring,?")
                .append(Arrays.toString(configLocations)).append(bse.getMessage()).toString();
        log.error(logMsg, bse);
        AdapterExtractorContext.addExtractorLog(ExtractorLogLevel.ERROR, logMsg);
        throw bse;
    } catch (BeanCreationException ce) {
        // BEAN,?RMI??
        logMsg = new StringBuilder("?spring,?BEAN,")
                .append(Arrays.toString(configLocations)).append(ce.getMessage()).toString();
        log.error(logMsg, ce);
        if (logMsg.indexOf("ORA-01017") > -1 || logMsg.indexOf("Invalid password") > -1) {
            // ORACLE????
            AdapterExtractorContext.addExtractorLog(ExtractorLogLevel.ERROR,
                    "??/?,?,???????!");
        } else {
            AdapterExtractorContext.addExtractorLog(ExtractorLogLevel.ERROR, logMsg);
        }
        throw ce;
    } finally {
        // system properties,???,??
        if (bakProps != null) {
            System.setProperties(bakProps);
        }
    }
}

From source file:com.enonic.cms.web.boot.BootEnvironment.java

private void resolveHomeDir() {
    final HomeResolver resolver = new HomeResolver();
    resolver.addSystemProperties(System.getenv());
    resolver.addSystemProperties(System.getProperties());
    resolver.resolve();//from  w ww . j a  v  a 2s  . com
}

From source file:ubach.ben.reminders.EmailAlertsConfigurationFactory.java

private Properties buildMailProperties() {
    Properties mailProperties = new Properties(System.getProperties());
    mailProperties.put("mail.smtp.port", String.valueOf(port));
    mailProperties.put("mail.smtp.auth", String.valueOf(auth));
    mailProperties.put("mail.smtp.starttls.enable", String.valueOf(starttls));
    log.info("Mail properties: {}", mailProperties);
    return mailProperties;
}

From source file:com.qspin.qtaste.util.PythonHelper.java

/**
 * Executes a python script, returning its output or not.
 *
 * @param fileName the filename of the python script to execute
 * @param redirectOutput true to redirect outputs and return them, false otherwise
 * @param arguments the arguments to pass to the python script
 * @return the output of the python script execution (combined standard and error outputs) or null if outputs were not
 * redirected/*from  w  w  w .  j av a  2  s . c o m*/
 * @throws PyException in case of exception during Python script execution
 */
public static String execute(String fileName, boolean redirectOutput, String... arguments) throws PyException {
    Properties properties = new Properties();
    properties.setProperty("python.home", StaticConfiguration.JYTHON_HOME);
    properties.setProperty("python.path", StaticConfiguration.FORMATTER_DIR);
    PythonInterpreter.initialize(System.getProperties(), properties, new String[] { "" });

    try (PythonInterpreter interp = new PythonInterpreter(new org.python.core.PyStringMap(),
            new org.python.core.PySystemState())) {
        StringWriter output = null;
        if (redirectOutput) {
            output = new StringWriter();
            interp.setOut(output);
            interp.setErr(output);
        }
        interp.cleanup();
        interp.exec("import sys;sys.argv[1:]= [r'" + StringUtils.join(arguments, "','") + "']");
        interp.exec("__name__ = '__main__'");
        interp.exec("execfile(r'" + fileName + "')");
        return redirectOutput ? output.toString() : null;
    }
}

From source file:org.jboss.as.test.clustering.cluster.web.ClusteredWebTestCase.java

@BeforeClass
public static void printSysProps() {
    Properties sysprops = System.getProperties();
    System.out.println("System properties:\n" + sysprops);
}

From source file:com.aerospike.client.rest.AerospikeRESTfulService.java

@Bean(destroyMethod = "close")
public AerospikeClient asClient() throws AerospikeException {
    Properties as = System.getProperties();
    return new AerospikeClient(as.getProperty("seedHost"), Integer.parseInt(as.getProperty("port")));
}

From source file:com.nridge.core.base.std.Platform.java

/**
 * Determines if the current platform that the JVM is executing within is
 * a Mac-based operating system./*from w  w w.  j  a v  a 2  s  .  co  m*/
 * @return <i>true</i> if it is or <i>false</i> otherwise.
 */
public static boolean isMac() {
    String osName;
    Properties osProperties;

    osProperties = System.getProperties();
    osName = (String) osProperties.get("os.name");
    return StringUtils.isNotEmpty(osName) && osName.startsWith(PLATFORM_MACOS);
}