Example usage for java.util Properties toString

List of usage examples for java.util Properties toString

Introduction

In this page you can find the example usage for java.util Properties toString.

Prototype

@Override
    public synchronized String toString() 

Source Link

Usage

From source file:org.bml.util.sql.DBUtil.java

/**
 * Creates a ComboPooledDataSource from a properly populated Properties object
 *
 * @param theProperties//  w ww  .ja  v  a 2  s.  c  om
 * @return a ComboPooledDataSource or null on error
 * @throws IOException
 */
public static ComboPooledDataSource makeComboPooledDataSource(Properties theProperties) throws IOException {
    ComboPooledDataSource aComboPooledDataSource = null;

    LOG.info("Begining creation of ComboPooledDataSource " + theProperties.toString());
    try {
        aComboPooledDataSource = new ComboPooledDataSource();
        aComboPooledDataSource.setDriverClass(theProperties.getProperty("JDBC_DRIVER"));
        aComboPooledDataSource.setJdbcUrl(theProperties.getProperty("JDBCURL"));
        aComboPooledDataSource.setUser(theProperties.getProperty("DBUSER"));
        aComboPooledDataSource.setPassword(theProperties.getProperty("DBPASS"));
        aComboPooledDataSource.setPreferredTestQuery("SELECT 1 AS dbcp_connection_test;");
        aComboPooledDataSource.setMaxPoolSize(20);
        aComboPooledDataSource.setIdleConnectionTestPeriod(10000);
        aComboPooledDataSource.setAutoCommitOnClose(true);

        aComboPooledDataSource.setDebugUnreturnedConnectionStackTraces(true);
        aComboPooledDataSource.setMaxConnectionAge(30000);
        aComboPooledDataSource.setAcquireIncrement(2);
        aComboPooledDataSource.setAcquireRetryAttempts(4);
        aComboPooledDataSource.setAcquireRetryDelay(500);
        aComboPooledDataSource.setTestConnectionOnCheckin(true);
        aComboPooledDataSource.setTestConnectionOnCheckout(true);
        aComboPooledDataSource.setMaxIdleTime(5000);
        aComboPooledDataSource.setUnreturnedConnectionTimeout(120000);
        /**
         * try { aComboPooledDataSource.setLogWriter(new PrintWriter(System.out));
         * } catch (SQLException ex) { LOG.warn(ex); }
         */
    } catch (PropertyVetoException ex) {
        LOG.warn(ex);
    }
    LOG.info("Finished creation of ComboPooledDataSource " + theProperties.toString());
    return aComboPooledDataSource;
}

From source file:edu.yale.cs.hadoopdb.sms.SQLQueryGenerator.java

/**
 * Cheats Hive's internal table schema with that to be returned by DBMS 
 */// www  .  ja va 2s.c  o  m
public static void hackMapredWorkSchema(SQLQuery sqlStructure, Table tbl) {

    Properties schema = tbl.getSchema();
    LOG.debug("MetaData Table properties " + tbl + " : " + schema.toString());

    // hacking
    schema.setProperty("columns.types", sqlStructure.getDDLColumnTypes());
    schema.setProperty("serialization.ddl", sqlStructure.getSerializationDDL());
    schema.setProperty("columns", sqlStructure.getDDLColumns());

    LOG.debug("Hacked Table properties " + tbl + " : " + schema.toString());
}

From source file:org.escidoc.browser.elabsmodul.service.ELabsService.java

private static List<String[]> buildConfiguration(final List<Map<String, String>> list) {
    Preconditions.checkNotNull(list, "Config list is null");
    final List<String[]> result = new ArrayList<String[]>();

    if (list.isEmpty()) {
        LOG.error("There is not ConfigMap to process!");
        return null;
    }//  www  .j  a  v  a 2 s  .  c  om

    for (final Map<String, String> map : list) {
        final Properties config = new Properties();
        config.putAll(map);

        if (!config.isEmpty()) {
            LOG.debug(config.toString());
            final ByteArrayOutputStream out = new ByteArrayOutputStream();
            try {
                config.storeToXML(out, "");
                LOG.debug("Configuration Properties XML \n" + out.toString());
            } catch (final IOException e) {
                LOG.error(e.getMessage());
            }
            result.add(new String[] { config.getProperty(ELabsServiceConstants.E_SYNC_DAEMON_ENDPOINT),
                    out.toString() });
        } else {
            LOG.error("Configuration is empty!");
        }
    }
    return result;
}

From source file:org.openengsb.itests.util.AbstractExamTestHelper.java

public static Option[] baseConfiguration() throws Exception {
    String loglevel = LOG_LEVEL;//from  w  w  w . ja v  a2s  . co m
    String debugPort = Integer.toString(DEBUG_PORT);
    boolean hold = true;
    boolean debug = false;
    InputStream paxLocalStream = ClassLoader.getSystemResourceAsStream("itests.local.properties");
    if (paxLocalStream != null) {
        Properties properties = new Properties();
        properties.load(paxLocalStream);
        loglevel = (String) ObjectUtils.defaultIfNull(properties.getProperty("loglevel"), loglevel);
        debugPort = (String) ObjectUtils.defaultIfNull(properties.getProperty("debugport"), debugPort);
        debug = ObjectUtils.equals(Boolean.TRUE.toString(), properties.getProperty("debug"));
        hold = ObjectUtils.equals(Boolean.TRUE.toString(), properties.getProperty("hold"));
    }
    Properties portNames = new Properties();
    InputStream portsPropertiesFile = ClassLoader.getSystemResourceAsStream("ports.properties");
    if (portsPropertiesFile == null) {
        throw new IllegalStateException("ports-configuration not found");
    }
    portNames.load(portsPropertiesFile);
    LOGGER.warn("running itests with the following port-config");
    LOGGER.warn(portNames.toString());
    LogLevel realLogLevel = transformLogLevel(loglevel);
    Option[] mainOptions = new Option[] { new VMOption("-Xmx2048m"), new VMOption("-XX:MaxPermSize=256m"),
            karafDistributionConfiguration().frameworkUrl(maven().groupId("org.openengsb.framework")
                    .artifactId("openengsb-framework").type("zip").versionAsInProject()),
            logLevel(realLogLevel),
            editConfigurationFilePut(WebCfg.HTTP_PORT, (String) portNames.get("jetty.http.port")),
            editConfigurationFilePut(ManagementCfg.RMI_SERVER_PORT, (String) portNames.get("rmi.server.port")),
            editConfigurationFilePut(ManagementCfg.RMI_REGISTRY_PORT,
                    (String) portNames.get("rmi.registry.port")),
            editConfigurationFilePut(
                    new ConfigurationPointer("etc/org.openengsb.infrastructure.jms.cfg", "openwire"),
                    (String) portNames.get("jms.openwire.port")),
            editConfigurationFilePut(
                    new ConfigurationPointer("etc/org.openengsb.infrastructure.jms.cfg", "stomp"),
                    (String) portNames.get("jms.stomp.port")),
            mavenBundle(maven().groupId("org.openengsb.wrapped").artifactId("net.sourceforge.htmlunit-all")
                    .versionAsInProject()) };
    if (debug) {
        return combine(mainOptions, debugConfiguration(debugPort, hold));
    }
    return mainOptions;
}

From source file:org.imsglobal.simplelti.SimpleLTIUtil.java

public static String postLaunchHTML(Properties newMap) {
    String launchurl = newMap.getProperty("launchurl");
    if (launchurl == null) {
        M_log.warning("SimpleLTIUtil could not find launchurl");
        M_log.warning(newMap.toString());
        return null;
    }/*from w  ww  .ja v  a  2s  . c o  m*/
    // Check to see if we already have a nonce
    String nonce = newMap.getProperty("sec_nonce");
    if (nonce == null) {
        String secret = newMap.getProperty("_secret");
        String org_secret = newMap.getProperty("_org_secret");
        String org_id = newMap.getProperty("org_id");
        addNonce(newMap, secret, org_id, org_secret);
    }
    // Check for required parameters - Non-fatal
    String course_id = newMap.getProperty("course_id");
    String user_id = newMap.getProperty("user_id");
    if (course_id == null || user_id == null) {
        M_log.warning("SimpleLTIUtil requires both course_id and user_id");
        M_log.warning(newMap.toString());
    }
    StringBuffer text = new StringBuffer();
    text.append("<form action=\"" + launchurl + "\" name=\"ltiLaunchForm\" method=\"post\">\n");
    for (Object okey : newMap.keySet()) {
        if (!(okey instanceof String))
            continue;
        String key = (String) okey;
        if (key == null)
            continue;
        String value = newMap.getProperty(key);
        if (value == null)
            continue;
        if (key.startsWith("internal_"))
            continue;
        if (key.startsWith("_"))
            continue;
        if ("action".equalsIgnoreCase(key))
            continue;
        if ("launchurl".equalsIgnoreCase(key))
            continue;
        if (value.equals(""))
            continue;
        // This will escape the contents pretty much - at least 
        // we will be safe and not generate dangerous HTML
        key = encodeFormText(key);
        value = encodeFormText(value);
        text.append("<input type=\"hidden\" size=\"40\" name=\"");
        text.append(key);
        text.append("\" value=\"");
        text.append(value);
        text.append("\"/>\n");
    }
    text.append("<div id=\"ltiLaunchFormSubmitArea\">\n"
            + "  <input type=\"hidden\" size=\"40\" name=\"action\" value=\"direct\"/>\n"
            + "  <input type=\"submit\" value=\"Continue\">  If you are not redirected in 15 seconds press Continue.\n"
            + "</div>\n" + "</form>\n" + " <script language=\"javascript\"> \n"
            + "    document.getElementById(\"ltiLaunchFormSubmitArea\").style.display = \"none\";\n"
            + "    document.ltiLaunchForm.submit(); \n" + " </script> \n");

    String htmltext = text.toString();
    return htmltext;
}

From source file:org.cesecore.keys.token.p11.Pkcs11SlotLabel.java

/**
 * Get the IAIK provider./*from w w w  .  j  a v a2s .  com*/
 * @param slot Slot list index or slot ID.
 * @param libFile P11 module so file.
 * @param isIndex true if first parameter is a slot list index, false if slot ID.
 * @return the provider
 */
private static Provider getIAIKP11Provider(final long slot, final File libFile,
        final Pkcs11SlotLabelType type) {
    // Properties for the IAIK PKCS#11 provider
    final Properties prop = new Properties();
    try {
        prop.setProperty("PKCS11_NATIVE_MODULE", libFile.getCanonicalPath());
    } catch (IOException e) {
        throw new RuntimeException("Could for unknown reason not construct canonical filename.", e);
    }
    // If using Slot Index it is denoted by brackets in iaik
    prop.setProperty("SLOT_ID",
            type.equals(Pkcs11SlotLabelType.SLOT_INDEX) ? ("[" + slot + "]") : Long.toString(slot));
    if (log.isDebugEnabled()) {
        log.debug(prop.toString());
    }
    Provider ret = null;
    try {
        @SuppressWarnings("unchecked")
        final Class<? extends Provider> implClass = (Class<? extends Provider>) Class
                .forName(IAIK_PKCS11_CLASS);
        log.info("Using IAIK PKCS11 provider: " + IAIK_PKCS11_CLASS);
        // iaik PKCS11 has Properties as constructor argument
        ret = implClass.getConstructor(Properties.class).newInstance(new Object[] { prop });
        // It's not enough just to add the p11 provider. Depending on algorithms we may have to install the IAIK JCE provider as well in order
        // to support algorithm delegation
        @SuppressWarnings("unchecked")
        final Class<? extends Provider> jceImplClass = (Class<? extends Provider>) Class
                .forName(IAIK_JCEPROVIDER_CLASS);
        Provider iaikProvider = jceImplClass.getConstructor().newInstance();
        if (Security.getProvider(iaikProvider.getName()) == null) {
            log.info("Adding IAIK JCE provider for Delegation: " + IAIK_JCEPROVIDER_CLASS);
            Security.addProvider(iaikProvider);
        }
    } catch (InvocationTargetException e) {
        // NOPMD: Ignore, reflection related errors are handled elsewhere
    } catch (InstantiationException e) {
        // NOPMD: Ignore, reflection related errors are handled elsewhere
    } catch (IllegalAccessException e) {
        // NOPMD: Ignore, reflection related errors are handled elsewhere
    } catch (IllegalArgumentException e) {
        // NOPMD: Ignore, reflection related errors are handled elsewhere
    } catch (NoSuchMethodException e) {
        // NOPMD: Ignore, reflection related errors are handled elsewhere
    } catch (SecurityException e) {
        // NOPMD: Ignore, reflection related errors are handled elsewhere
    } catch (ClassNotFoundException e) {
        // NOPMD: Ignore, reflection related errors are handled elsewhere
    }
    return ret;
}

From source file:web.ViewModel.java

public void setMappings(Properties mappings) {
    logger.info("web/ViewModel.java Setmappings = " + mappings.toString());
    this.urlMap.putAll(mappings);
}

From source file:PrintTestApp.java

public PrintTestApp() {
    super("PrintTestApp");
    toolkit = getToolkit();//ww  w. j a  va 2s .  co  m
    add("Center", textArea);
    setSize(300, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

    String name = "Test print job";
    Properties properties = new Properties();
    PrintJob pj = toolkit.getPrintJob(PrintTestApp.this, name, properties);
    if (pj == null)
        textArea.setText("A null PrintJob was returned.");
    else {
        String output = "Name: " + name + "\nProperties: " + properties.toString();
        Dimension pageDim = pj.getPageDimension();
        int resolution = pj.getPageResolution();
        boolean lastPageFirst = pj.lastPageFirst();
        output += "\nPage dimension (in pixels):";
        output += "\n height: " + String.valueOf(pageDim.height);
        output += "\n width: " + String.valueOf(pageDim.width);
        output += "\nResolution (pixels/inch): " + String.valueOf(resolution);
        output += "\nLast Page First: " + String.valueOf(lastPageFirst);
        textArea.setText(output);
        Graphics g = pj.getGraphics();
        g.dispose();
        pj.end();
    }
}

From source file:org.red5.spring.ExtendedPropertyPlaceholderConfigurer.java

@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
        throws BeansException {

    props.putAll(copyOfGlobalProperties());
    logger.debug("Placeholder props: {}", props.toString());

    this.mergedProperties = props;

    super.processProperties(beanFactoryToProcess, props);
}

From source file:hydrograph.ui.parametergrid.utils.ParameterFileManager.java

/**
 * //from  www  .  jav  a  2  s .  com
 * get Parameters from file
 * 
 * @return - Parameter map
 * @throws IOException
 */
public Map<String, String> getParameterMap(String parameterFilePath) throws IOException {
    Properties prop = new Properties();

    File file = new File(parameterFilePath);

    if (file.exists()) {
        prop.load(parameterFilePath);

        logger.debug("Fetched properties {} from file {}", prop.toString(), parameterFilePath);
    }

    return prop.getProperties();
}