Example usage for java.util Properties keySet

List of usage examples for java.util Properties keySet

Introduction

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

Prototype

@Override
    public Set<Object> keySet() 

Source Link

Usage

From source file:com.mirth.connect.server.controllers.DefaultConfigurationController.java

@Override
public void setServerSettings(ServerSettings settings) throws ControllerException {
    String serverName = settings.getServerName();
    if (serverName != null) {
        saveProperty(PROPERTIES_CORE + "." + serverId, "server.name", serverName);
        this.serverName = serverName;
    }/*from  w  w  w .  jav  a2  s.  c o m*/

    Properties properties = settings.getProperties();
    for (Object name : properties.keySet()) {
        saveProperty(PROPERTIES_CORE, (String) name, (String) properties.get(name));
    }
}

From source file:com.mnxfst.testing.client.TSClient.java

/**
 * Executes the referenced test plan for all given host names. The result contains a mapping from a host name to the returned result identifier
 * of that ptest-server instance //from  w ww  .  ja  v a 2 s  .  c  o  m
 * @param hostNames
 * @param port
 * @param threads
 * @param recurrences
 * @param recurrenceType
 * @param testplan
 * @param additionalParameters
 * @param urlEncoding
 * @return
 * @throws TSClientConfigurationException
 * @throws TSClientExecutionException
 */
protected Map<String, String> executeTestPlan(String[] hostNames, int port, long threads, long recurrences,
        TSPlanRecurrenceType recurrenceType, byte[] testplan, Properties additionalParameters,
        String urlEncoding) throws TSClientConfigurationException, TSClientExecutionException {

    // the ptest-server understands http get, thus we use it TODO refactor to post and send testplan as well and do not reference it anymore!
    StringBuffer buffer = new StringBuffer("/?");
    buffer.append(REQUEST_PARAMETER_EXECUTE).append("=1");
    buffer.append("&").append(REQUEST_PARAMETER_RECURRENCES).append("=").append(recurrences);
    buffer.append("&").append(REQUEST_PARAMETER_RECURRENCE_TYPE).append("=").append(recurrenceType.toString());
    buffer.append("&").append(REQUEST_PARAMETER_THREADS).append("=").append(threads);

    try {
        if (additionalParameters != null && !additionalParameters.isEmpty()) {
            for (Object key : additionalParameters.keySet()) {
                String value = (String) additionalParameters.get(key);
                buffer.append("&").append(key).append("=").append(URLEncoder.encode(value, urlEncoding));
            }
        }
    } catch (UnsupportedEncodingException e) {
        throw new TSClientConfigurationException(
                "Unsupported encoding type: " + urlEncoding + ". Error: " + e.getMessage());
    }

    StringBuffer hn = new StringBuffer();
    for (int i = 0; i < hostNames.length; i++) {
        hn.append(hostNames[i]);
        if (i < hostNames.length - 1)
            hn.append(", ");
    }

    System.out.println("Execute testplan:");
    System.out.println("\thostNames: " + hn.toString());
    System.out.println("\tport: " + port);
    System.out.println("\tthreads: " + threads);
    System.out.println("\trecurrences: " + recurrences);
    System.out.println("\trecurrenceType: " + recurrenceType);
    System.out.println("\turl enc: " + urlEncoding);
    System.out.println("\n\turi: " + buffer.toString());

    TSClientPlanExecCallable[] testplanCallables = new TSClientPlanExecCallable[hostNames.length];
    for (int i = 0; i < hostNames.length; i++) {
        testplanCallables[i] = new TSClientPlanExecCallable(hostNames[i], port, buffer.toString(), testplan);
    }

    ExecutorService executorService = Executors.newFixedThreadPool(hostNames.length);
    List<Future<NameValuePair>> executionResults = new ArrayList<Future<NameValuePair>>();
    try {
        executionResults = executorService.invokeAll(Arrays.asList(testplanCallables));
    } catch (InterruptedException e) {
        System.out.println("Test execution interrupted: " + e.getMessage());
    }

    // collect results from callables
    Map<String, String> result = new HashMap<String, String>();
    for (Future<NameValuePair> r : executionResults) {
        try {
            NameValuePair nvp = r.get();
            result.put(nvp.getName(), nvp.getValue());
        } catch (InterruptedException e) {
            System.out.println("Interrupted while waiting for results. Error: " + e.getMessage());
        } catch (ExecutionException e) {
            System.out.println("Interrupted while waiting for results. Error: " + e.getMessage());
        }
    }

    return result;
}

From source file:com.dtolabs.rundeck.ec2.NodeGenerator.java

public static INodeEntry instanceToNode(final Instance inst, final Properties mapping)
        throws GeneratorException {
    String hostSel = mapping.getProperty("hostname.selector");
    String host = applySelector(inst, hostSel, mapping.getProperty("hostname.default"));
    if (null == host) {
        System.err.println("Unable to determine hostname for instance: " + inst.getInstanceId());
        return null;
    }/*  w  w  w  .  j av  a  2 s  . c  o  m*/
    String nameSel = mapping.getProperty("name.selector");
    String name = applySelector(inst, nameSel, mapping.getProperty("name.default"));
    if (null == name) {
        name = host;
    }
    NodeEntryImpl node = new NodeEntryImpl(host, name);
    String descSel = mapping.getProperty("description.selector");
    String desc = applySelector(inst, descSel, mapping.getProperty("description.default"));
    node.setDescription(desc);

    for (final String prop : ResourceXMLConstants.nodeProps) {
        final String value = applySelector(inst, mapping.getProperty(prop + ".selector"),
                mapping.getProperty(prop + ".default"));
        if (null != value) {
            try {
                BeanUtils.setProperty(node, prop, value);
            } catch (Exception e) {
                throw new GeneratorException(e);
            }
        }
    }
    String[] attrProps = new String[] { ResourceXMLConstants.NODE_REMOTE_URL,
            ResourceXMLConstants.NODE_EDIT_URL };
    for (final String attrProp : attrProps) {
        final String value = applySelector(inst, mapping.getProperty(attrProp + ".selector"),
                mapping.getProperty(attrProp + ".default"));
        if (null != value) {
            if (null == node.getAttributes()) {
                node.setAttributes(new HashMap<String, String>());
            }
            node.getAttributes().put(attrProp, value);
        }
    }

    Pattern settingPat = Pattern.compile("^setting\\.(.+?)\\.selector$");
    //evaluate setting selectors
    for (final Object o : mapping.keySet()) {
        String key = (String) o;
        String selector = mapping.getProperty(key);
        Matcher m = settingPat.matcher(key);
        if (m.matches()) {
            String setName = m.group(1);
            if (null == node.getAttributes()) {
                node.setAttributes(new HashMap<String, String>());
            }
            final String value = applySelector(inst, selector,
                    mapping.getProperty("setting." + setName + ".default"));
            if (null != value) {
                //use nodename-settingname to make the setting unique to the node
                node.getAttributes().put(setName, value);
            }
        }
    }
    //evaluate single settings.selector=tags/* mapping
    if ("tags/*".equals(mapping.getProperty("settings.selector"))) {
        //iterate through instance tags and generate settings
        for (final Tag tag : inst.getTags()) {
            if (null == node.getAttributes()) {
                node.setAttributes(new HashMap<String, String>());
            }
            node.getAttributes().put(tag.getKey(), tag.getValue());
        }
    }
    //evaluate single settings.selector=tags/* mapping
    if ("tags/*".equals(mapping.getProperty("attributes.selector"))) {
        //iterate through instance tags and generate settings
        for (final Tag tag : inst.getTags()) {
            if (null == node.getAttributes()) {
                node.setAttributes(new HashMap<String, String>());
            }
            node.getAttributes().put(tag.getKey(), tag.getValue());
        }
    }
    if (null != mapping.getProperty("tags.selector")) {
        final String selector = mapping.getProperty("tags.selector");
        final String value = applySelector(inst, selector, mapping.getProperty("tags.default"));
        if (null != value) {
            final String[] values = value.split(",");
            final HashSet<String> tagset = new HashSet<String>();
            for (final String s : values) {
                tagset.add(s.trim());
            }
            if (null == node.getTags()) {
                node.setTags(tagset);
            } else {
                node.getTags().addAll(tagset);
            }
        }
    }

    //apply specific tag selectors
    Pattern tagPat = Pattern.compile("^tag\\.(.+?)\\.selector$");
    //evaluate tag selectors
    for (final Object o : mapping.keySet()) {
        String key = (String) o;
        String selector = mapping.getProperty(key);
        //split selector by = if present
        String[] selparts = selector.split("=");
        Matcher m = tagPat.matcher(key);
        if (m.matches()) {
            String tagName = m.group(1);
            if (null == node.getAttributes()) {
                node.setAttributes(new HashMap<String, String>());
            }
            final String value = applySelector(inst, selparts[0], null);
            if (null != value) {
                if (selparts.length > 1 && !value.equals(selparts[1])) {
                    continue;
                }
                //use add the tag if the value is not null
                if (null == node.getTags()) {
                    node.setTags(new HashSet());
                }
                node.getTags().add(tagName);
            }
        }
    }

    //apply attribute selectors

    Pattern attribPat = Pattern.compile("^attribute\\.(.+?)\\.selector$");
    //evaluate setting selectors
    for (final Object o : mapping.keySet()) {
        String key = (String) o;
        String selector = mapping.getProperty(key);
        Matcher m = attribPat.matcher(key);
        if (m.matches()) {
            String attrName = m.group(1);
            if (null == node.getAttributes()) {
                node.setAttributes(new HashMap<String, String>());
            }
            final String value = applySelector(inst, selector,
                    mapping.getProperty("attribute." + attrName + ".default"));
            if (null != value) {
                //use nodename-settingname to make the setting unique to the node
                node.getAttributes().put(attrName, value);
            }
        }
    }
    return node;
}

From source file:com.siberhus.tdfl.mapping.BeanWrapLineMapper.java

@SuppressWarnings("unchecked")
protected Properties getBeanProperties(Object bean, Properties properties) throws IntrospectionException {

    Class<?> cls = bean.getClass();

    String[] namesCache = propertyNamesCache.get(cls);
    if (namesCache == null) {
        List<String> setterNames = new ArrayList<String>();
        BeanInfo beanInfo = Introspector.getBeanInfo(cls);
        PropertyDescriptor propDescs[] = beanInfo.getPropertyDescriptors();
        for (PropertyDescriptor propDesc : propDescs) {
            if (propDesc.getWriteMethod() != null) {
                setterNames.add(propDesc.getName());
            }//  w  w  w.j  a va2  s.  c o m
        }
        propertyNamesCache.put(cls, setterNames.toArray(new String[0]));
    }
    // Map from field names to property names
    Map<String, String> matches = propertiesMatched.get(cls);
    if (matches == null) {
        matches = new HashMap<String, String>();
        propertiesMatched.put(cls, matches);
    }

    @SuppressWarnings("rawtypes")
    Set<String> keys = new HashSet(properties.keySet());
    for (String key : keys) {

        if (matches.containsKey(key)) {
            switchPropertyNames(properties, key, matches.get(key));
            continue;
        }

        String name = findPropertyName(bean, key);

        if (name != null) {
            matches.put(key, name);
            switchPropertyNames(properties, key, name);
        }
    }

    return properties;
}

From source file:org.apache.tapestry.request.RequestContext.java

private void writeSystemProperties(IMarkupWriter writer) {
    Properties properties = null;

    object(writer, "JVM System Properties");

    try {// w  ww. j  a v  a  2  s.  com
        properties = System.getProperties();
    } catch (SecurityException se) {
        writer.print("<p>");
        writer.print(se.toString());
        return;
    }

    String pathSeparator = System.getProperty("path.separator", ";");

    writer.begin("table");
    writer.attribute("class", "request-context-object");

    List names = new ArrayList(properties.keySet());
    Collections.sort(names);
    int count = names.size();

    for (int i = 0; i < count; i++) {

        if (i == 0)
            header(writer, "Name", "Value");

        String name = (String) names.get(i);

        String property = properties.getProperty(name);

        if (property != null && property.indexOf(pathSeparator) > 0 && name.endsWith(".path")) {
            writer.begin("tr");
            writer.attribute("class", getRowClass());

            writer.begin("th");
            writer.print(name);
            writer.end();

            writer.begin("td");
            writer.begin("ul");

            StringTokenizer tokenizer = new StringTokenizer(property, pathSeparator);

            while (tokenizer.hasMoreTokens()) {
                writer.beginEmpty("li");
                writer.print(tokenizer.nextToken());
            }

            writer.end("tr");
        } else {
            pair(writer, name, property);
        }
    }

    writer.end(); // System Properties
}

From source file:org.apache.maven.doxia.tools.DefaultSiteTool.java

/**
 * Read site descriptor content from Reader, adding support for deprecated <code>${reports}</code>,
 * <code>${parentProject}</code> and <code>${modules}</code> tags.
 *
 * @param reader/*from  w w  w .  j  ava  2  s. co  m*/
 * @return the input content interpolated with deprecated tags 
 * @throws IOException
 */
private String readSiteDescriptor(Reader reader, String projectId) throws IOException {
    String siteDescriptorContent = IOUtil.toString(reader);

    // This is to support the deprecated ${reports}, ${parentProject} and ${modules} tags.
    Properties props = new Properties();
    props.put("reports", "<menu ref=\"reports\"/>");
    props.put("modules", "<menu ref=\"modules\"/>");
    props.put("parentProject", "<menu ref=\"parent\"/>");

    // warn if interpolation required
    for (Object prop : props.keySet()) {
        if (siteDescriptorContent.contains("$" + prop)) {
            getLogger().warn("Site descriptor for " + projectId + " contains $" + prop
                    + ": should be replaced with " + props.getProperty((String) prop));
        }
        if (siteDescriptorContent.contains("${" + prop + "}")) {
            getLogger().warn("Site descriptor for " + projectId + " contains ${" + prop
                    + "}: should be replaced with " + props.getProperty((String) prop));
        }
    }

    return StringUtils.interpolate(siteDescriptorContent, props);
}

From source file:com.mirth.connect.model.util.ImportConverter3_0_0.java

private static DispatcherMigrationMetaData migrateHttpDispatcherProperties(DonkeyElement properties)
        throws MigrationException {
    logger.debug("Migrating HttpDispatcherProperties");
    Properties oldProperties = readPropertiesElement(properties);
    properties.setAttribute("class", "com.mirth.connect.connectors.http.HttpDispatcherProperties");
    properties.removeChildren();//from w ww. ja v a2 s . co m

    String useQueue = readBooleanProperty(oldProperties, "usePersistentQueues");
    buildQueueConnectorProperties(properties.addChildElement("queueConnectorProperties"), useQueue,
            readBooleanProperty(oldProperties, "rotateQueue"), oldProperties.getProperty("reconnectMillisecs"),
            null);

    properties.addChildElement("host").setTextContent(convertReferences(oldProperties.getProperty("host", "")));
    properties.addChildElement("method").setTextContent(oldProperties.getProperty("dispatcherMethod", "post"));
    properties.addChildElement("includeHeadersInResponse")
            .setTextContent(readBooleanProperty(oldProperties, "dispatcherIncludeHeadersInResponse", false));
    properties.addChildElement("multipart")
            .setTextContent(readBooleanProperty(oldProperties, "dispatcherMultipart", false));
    properties.addChildElement("useAuthentication")
            .setTextContent(readBooleanProperty(oldProperties, "dispatcherUseAuthentication", false));
    properties.addChildElement("authenticationType")
            .setTextContent(oldProperties.getProperty("dispatcherAuthenticationType", "Basic"));
    properties.addChildElement("username")
            .setTextContent(convertReferences(oldProperties.getProperty("dispatcherUsername", "")));
    properties.addChildElement("password")
            .setTextContent(convertReferences(oldProperties.getProperty("dispatcherPassword", "")));
    properties.addChildElement("content")
            .setTextContent(convertReferences(oldProperties.getProperty("dispatcherContent", "")));
    properties.addChildElement("contentType")
            .setTextContent(oldProperties.getProperty("dispatcherContentType", "text/plain"));
    properties.addChildElement("charset")
            .setTextContent(oldProperties.getProperty("dispatcherCharset", "UTF-8"));
    properties.addChildElement("socketTimeout")
            .setTextContent(convertReferences(oldProperties.getProperty("dispatcherSocketTimeout", "30000")));

    try {
        Properties oldHeaderProperties = readPropertiesElement(
                new DonkeyElement(convertReferences(oldProperties.getProperty("dispatcherHeaders"))));

        DonkeyElement headerProperties = properties.addChildElement("headers");
        headerProperties.setAttribute("class", "linked-hash-map");

        for (Object key : oldHeaderProperties.keySet()) {
            String value = oldHeaderProperties.getProperty((String) key);

            DonkeyElement entry = headerProperties.addChildElement("entry");
            entry.addChildElement("string", (String) key);
            entry.addChildElement("string", value);
        }

        Properties oldParameterProperties = readPropertiesElement(
                new DonkeyElement(convertReferences(oldProperties.getProperty("dispatcherParameters"))));

        DonkeyElement parameterProperties = properties.addChildElement("parameters");
        parameterProperties.setAttribute("class", "linked-hash-map");

        for (Object key : oldParameterProperties.keySet()) {
            String value = oldParameterProperties.getProperty((String) key);

            DonkeyElement entry = parameterProperties.addChildElement("entry");
            entry.addChildElement("string", (String) key);
            entry.addChildElement("string", value);
        }

        return new DispatcherMigrationMetaData(oldProperties.getProperty("dispatcherReplyChannelId"),
                Boolean.parseBoolean(useQueue));
    } catch (DonkeyElementException e) {
        throw new MigrationException("Failed to migrate HTTP Dispatcher properties", e);
    }
}

From source file:com.haulmont.cuba.testsupport.TestContainer.java

protected void initAppProperties() {
    final Properties properties = new Properties();

    List<String> locations = getAppPropertiesFiles();
    DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
    for (String location : locations) {
        Resource resource = resourceLoader.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                properties.load(stream);
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(stream);
            }/*from   www .j  a va  2  s . co m*/
        } else {
            log.warn("Resource " + location + " not found, ignore it");
        }
    }

    StrSubstitutor substitutor = new StrSubstitutor(new StrLookup() {
        @Override
        public String lookup(String key) {
            String subst = properties.getProperty(key);
            return subst != null ? subst : System.getProperty(key);
        }
    });
    for (Object key : properties.keySet()) {
        String value = substitutor.replace(properties.getProperty((String) key));
        appProperties.put((String) key, value);
    }

    File dir;
    dir = new File(appProperties.get("cuba.confDir"));
    dir.mkdirs();
    dir = new File(appProperties.get("cuba.logDir"));
    dir.mkdirs();
    dir = new File(appProperties.get("cuba.tempDir"));
    dir.mkdirs();
    dir = new File(appProperties.get("cuba.dataDir"));
    dir.mkdirs();
}

From source file:org.apache.sqoop.orm.ClassWriter.java

/**
 * Generate the ORM code for the class./*www  .  j av  a  2 s  . c om*/
 */
public void generate(String invalidIdentifierPrefix) throws IOException {
    Map<String, Integer> columnTypes = getColumnTypes();

    String[] colNames = getColumnNames(columnTypes);

    // Translate all the column names into names that are safe to
    // use as identifiers.
    String[] cleanedColNames = cleanColNames(colNames, invalidIdentifierPrefix);
    Set<String> uniqColNames = new HashSet<String>();
    for (int i = 0; i < colNames.length; i++) {
        String identifier = cleanedColNames[i];

        // Name can't be blank
        if (identifier.isEmpty()) {
            throw new IllegalArgumentException("We found column without column "
                    + "name. Please verify that you've entered all column names "
                    + "in your query if using free form query import (consider "
                    + "adding clause AS if you're using column transformation)");
        }

        // Guarantee uniq col identifier
        if (uniqColNames.contains(identifier)) {
            throw new IllegalArgumentException(
                    "Duplicate Column identifier " + "specified: '" + identifier + "'");
        }
        uniqColNames.add(identifier);

        // Make sure the col->type mapping holds for the
        // new identifier name, too.
        String col = colNames[i];
        Integer type = columnTypes.get(col);
        if (type == null) {
            // column doesn't have a type, means that is illegal column name!
            throw new IllegalArgumentException("Column name '" + col + "' not in table");
        }
        columnTypes.put(identifier, type);
    }

    // Check that all explicitly mapped columns are present in result set
    Properties mapping = options.getMapColumnJava();
    if (mapping != null && !mapping.isEmpty()) {
        for (Object column : mapping.keySet()) {
            if (!uniqColNames.contains((String) column)) {
                throw new IllegalArgumentException(
                        "No column by the name " + column + "found while importing data");
            }
        }
    }

    // The db write() method may use column names in a different
    // order. If this is set in the options, pull it out here and
    // make sure we format the column names to identifiers in the same way
    // as we do for the ordinary column list.
    String[] dbWriteColNames = options.getDbOutputColumns();
    String[] cleanedDbWriteColNames = null;
    if (null == dbWriteColNames) {
        cleanedDbWriteColNames = cleanedColNames;
    } else {
        cleanedDbWriteColNames = cleanColNames(dbWriteColNames);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("selected columns:");
        for (String col : cleanedColNames) {
            LOG.debug("  " + col);
        }

        if (cleanedDbWriteColNames != cleanedColNames) {
            // dbWrite() has a different set of columns than the rest of the
            // generators.
            LOG.debug("db write column order:");
            for (String dbCol : cleanedDbWriteColNames) {
                LOG.debug("  " + dbCol);
            }
        }
    }

    // Generate the Java code.
    StringBuilder sb = generateClassForColumns(columnTypes, cleanedColNames, cleanedDbWriteColNames);

    // Write this out to a file in the jar output directory.
    // We'll move it to the user-visible CodeOutputDir after compiling.
    String codeOutDir = options.getJarOutputDir();

    // Get the class name to generate, which includes package components.
    String className = new TableClassName(options).getClassForTable(tableName);
    // Convert the '.' characters to '/' characters.
    String sourceFilename = className.replace('.', File.separatorChar) + ".java";
    String filename = codeOutDir + sourceFilename;

    if (LOG.isDebugEnabled()) {
        LOG.debug("Writing source file: " + filename);
        LOG.debug("Table name: " + tableName);
        StringBuilder sbColTypes = new StringBuilder();
        for (String col : colNames) {
            Integer colType = columnTypes.get(col);
            sbColTypes.append(col + ":" + colType + ", ");
        }
        String colTypeStr = sbColTypes.toString();
        LOG.debug("Columns: " + colTypeStr);
        LOG.debug("sourceFilename is " + sourceFilename);
    }

    compileManager.addSourceFile(sourceFilename);

    // Create any missing parent directories.
    File file = new File(filename);
    File dir = file.getParentFile();
    if (null != dir && !dir.exists()) {
        boolean mkdirSuccess = dir.mkdirs();
        if (!mkdirSuccess) {
            LOG.debug("Could not create directory tree for " + dir);
        }
    }

    OutputStream ostream = null;
    Writer writer = null;
    try {
        ostream = new FileOutputStream(filename);
        writer = new OutputStreamWriter(ostream);
        writer.append(sb.toString());
    } finally {
        if (null != writer) {
            try {
                writer.close();
            } catch (IOException ioe) {
                // ignored because we're closing.
            }
        }

        if (null != ostream) {
            try {
                ostream.close();
            } catch (IOException ioe) {
                // ignored because we're closing.
            }
        }
    }
}

From source file:com.mirth.connect.model.util.ImportConverter3_0_0.java

private static void migrateJmsDispatcherProperties(DonkeyElement properties) throws MigrationException {
    logger.debug("Migrating JmsDispatcherProperties");
    Properties oldProperties = readPropertiesElement(properties);
    properties.setAttribute("class", "com.mirth.connect.connectors.jms.JmsDispatcherProperties");
    properties.removeChildren();/*w w w.  j a va2 s  . co  m*/

    buildQueueConnectorProperties(properties.addChildElement("queueConnectorProperties"));

    properties.addChildElement("useJndi").setTextContent(readBooleanProperty(oldProperties, "useJndi", false));
    properties.addChildElement("jndiProviderUrl")
            .setTextContent(convertReferences(oldProperties.getProperty("jndiProviderUrl", "")));
    properties.addChildElement("jndiInitialContextFactory")
            .setTextContent(oldProperties.getProperty("jndiInitialFactory", ""));
    properties.addChildElement("jndiConnectionFactoryName")
            .setTextContent(oldProperties.getProperty("connectionFactoryJndiName", ""));
    properties.addChildElement("connectionFactoryClass")
            .setTextContent(oldProperties.getProperty("connectionFactoryClass", ""));
    properties.addChildElement("username")
            .setTextContent(convertReferences(oldProperties.getProperty("username", "")));
    properties.addChildElement("password")
            .setTextContent(convertReferences(oldProperties.getProperty("password", "")));

    String destinationName = convertReferences(oldProperties.getProperty("host", ""));
    boolean topic = false;

    if (StringUtils.startsWith(destinationName, "topic://")
            || StringUtils.startsWith(destinationName, "//topic:")) {
        destinationName = destinationName.substring(8);
        topic = true;
    } else if (StringUtils.startsWith(destinationName, "//queue:")
            || StringUtils.startsWith(destinationName, "queue://")) {
        destinationName = destinationName.substring(8);
        topic = false;
    }

    properties.addChildElement("destinationName").setTextContent(destinationName);
    properties.addChildElement("clientId").setTextContent("");
    properties.addChildElement("topic").setTextContent(Boolean.toString(topic));
    properties.addChildElement("template")
            .setTextContent(convertReferences(oldProperties.getProperty("template", "${message.encodedData}")));

    try {
        Properties oldConnectionProperties = readPropertiesElement(
                new DonkeyElement(oldProperties.getProperty("connectionFactoryProperties")));

        DonkeyElement connectionProperties = properties.addChildElement("connectionProperties");
        connectionProperties.setAttribute("class", "linked-hash-map");

        for (Object key : oldConnectionProperties.keySet()) {
            String value = convertReferences(oldConnectionProperties.getProperty((String) key));

            DonkeyElement entry = connectionProperties.addChildElement("entry");
            entry.addChildElement("string", (String) key);
            entry.addChildElement("string", value);
        }
    } catch (DonkeyElementException e) {
        throw new MigrationException(e);
    }
}