Search in sources :

Example 1 with XmlConfigPropertiesAdapter

use of org.eclipse.kura.core.configuration.XmlConfigPropertiesAdapter in project kura by eclipse.

the class XmlJavaComponentConfigurationsMapper method parseConfiguration.

// 
// Unmarshaller's private methods
// 
private ComponentConfigurationImpl parseConfiguration(Element configuration) throws Exception {
    XmlConfigPropertiesAdapter xmlPropAdapter = new XmlConfigPropertiesAdapter();
    // get configuration's properties
    NodeList propertiesList = configuration.getChildNodes();
    // get effective elements
    Element[] propertiesArray = getElementNodes(propertiesList);
    XmlConfigPropertiesAdapted xmlPropertiesAdapted = new XmlConfigPropertiesAdapted();
    for (Element element : propertiesArray) {
        // parse property elements
        NodeList propertyList = element.getChildNodes();
        Element[] propertyArray = getElementNodes(propertyList);
        XmlConfigPropertyAdapted[] xmlConfigProperties = new XmlConfigPropertyAdapted[propertyArray.length];
        for (int propertyIndex = 0; propertyIndex < propertyArray.length; propertyIndex++) {
            XmlConfigPropertyAdapted xmlProperty = parseProperty(propertyArray[propertyIndex]);
            xmlConfigProperties[propertyIndex] = xmlProperty;
        }
        xmlPropertiesAdapted.setProperties(xmlConfigProperties);
    }
    Map<String, Object> propertiesMap = xmlPropAdapter.unmarshal(xmlPropertiesAdapted);
    String pid = configuration.getAttribute(CONFIGURATION_PID);
    return new ComponentConfigurationImpl(pid, null, propertiesMap);
}
Also used : ComponentConfigurationImpl(org.eclipse.kura.core.configuration.ComponentConfigurationImpl) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) XmlConfigPropertiesAdapted(org.eclipse.kura.core.configuration.XmlConfigPropertiesAdapted) XmlConfigPropertyAdapted(org.eclipse.kura.core.configuration.XmlConfigPropertyAdapted) XmlConfigPropertiesAdapter(org.eclipse.kura.core.configuration.XmlConfigPropertiesAdapter)

Example 2 with XmlConfigPropertiesAdapter

use of org.eclipse.kura.core.configuration.XmlConfigPropertiesAdapter in project kura by eclipse.

the class XmlJavaComponentConfigurationsMapper method marshallProperties.

private void marshallProperties(Map<String, Object> propertyMap, Element properties) throws Exception {
    XmlConfigPropertiesAdapter xmlPropAdapter = new XmlConfigPropertiesAdapter();
    XmlConfigPropertiesAdapted configPropAdapted = xmlPropAdapter.marshal(propertyMap);
    XmlConfigPropertyAdapted[] propArray = configPropAdapted.getProperties();
    for (XmlConfigPropertyAdapted propertyObj : propArray) {
        Element property = marshallProperty(propertyObj);
        if (property != null) {
            properties.appendChild(property);
        }
    }
}
Also used : Element(org.w3c.dom.Element) XmlConfigPropertiesAdapted(org.eclipse.kura.core.configuration.XmlConfigPropertiesAdapted) XmlConfigPropertyAdapted(org.eclipse.kura.core.configuration.XmlConfigPropertyAdapted) XmlConfigPropertiesAdapter(org.eclipse.kura.core.configuration.XmlConfigPropertiesAdapter)

Aggregations

XmlConfigPropertiesAdapted (org.eclipse.kura.core.configuration.XmlConfigPropertiesAdapted)2 XmlConfigPropertiesAdapter (org.eclipse.kura.core.configuration.XmlConfigPropertiesAdapter)2 XmlConfigPropertyAdapted (org.eclipse.kura.core.configuration.XmlConfigPropertyAdapted)2 Element (org.w3c.dom.Element)2 ComponentConfigurationImpl (org.eclipse.kura.core.configuration.ComponentConfigurationImpl)1 NodeList (org.w3c.dom.NodeList)1