Search in sources :

Example 91 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project hazelcast by hazelcast.

the class XmlConfigBuilder method handleSet.

private void handleSet(Node node) {
    Node attName = node.getAttributes().getNamedItem("name");
    String name = getTextContent(attName);
    SetConfig sConfig = new SetConfig();
    sConfig.setName(name);
    for (Node n : childElements(node)) {
        String nodeName = cleanNodeName(n);
        String value = getTextContent(n).trim();
        if ("max-size".equals(nodeName)) {
            sConfig.setMaxSize(getIntegerValue("max-size", value));
        } else if ("backup-count".equals(nodeName)) {
            sConfig.setBackupCount(getIntegerValue("backup-count", value));
        } else if ("async-backup-count".equals(nodeName)) {
            sConfig.setAsyncBackupCount(getIntegerValue("async-backup-count", value));
        } else if ("item-listeners".equals(nodeName)) {
            for (Node listenerNode : childElements(n)) {
                if ("item-listener".equals(cleanNodeName(listenerNode))) {
                    NamedNodeMap attrs = listenerNode.getAttributes();
                    boolean incValue = getBooleanValue(getTextContent(attrs.getNamedItem("include-value")));
                    String listenerClass = getTextContent(listenerNode);
                    sConfig.addItemListenerConfig(new ItemListenerConfig(listenerClass, incValue));
                }
            }
        } else if ("statistics-enabled".equals(nodeName)) {
            sConfig.setStatisticsEnabled(getBooleanValue(value));
        }
    }
    this.config.addSetConfig(sConfig);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node)

Example 92 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project hazelcast by hazelcast.

the class XmlConfigBuilder method handleTcpIp.

private void handleTcpIp(Node node) {
    NamedNodeMap atts = node.getAttributes();
    JoinConfig join = config.getNetworkConfig().getJoin();
    TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
    for (int a = 0; a < atts.getLength(); a++) {
        Node att = atts.item(a);
        String value = getTextContent(att).trim();
        if (att.getNodeName().equals("enabled")) {
            tcpIpConfig.setEnabled(getBooleanValue(value));
        } else if (att.getNodeName().equals("connection-timeout-seconds")) {
            tcpIpConfig.setConnectionTimeoutSeconds(getIntegerValue("connection-timeout-seconds", value));
        }
    }
    Set<String> memberTags = new HashSet<String>(Arrays.asList("interface", "member", "members"));
    for (Node n : childElements(node)) {
        String value = getTextContent(n).trim();
        if (cleanNodeName(n).equals("member-list")) {
            handleMemberList(n);
        } else if (cleanNodeName(n).equals("required-member")) {
            if (tcpIpConfig.getRequiredMember() != null) {
                throw new InvalidConfigurationException("Duplicate required-member" + " definition found in XML configuration. ");
            }
            tcpIpConfig.setRequiredMember(value);
        } else if (memberTags.contains(cleanNodeName(n))) {
            tcpIpConfig.addMember(value);
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) HashSet(java.util.HashSet)

Example 93 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project hazelcast by hazelcast.

the class XmlConfigBuilder method handleInterfaces.

private void handleInterfaces(Node node) {
    NamedNodeMap atts = node.getAttributes();
    InterfacesConfig interfaces = config.getNetworkConfig().getInterfaces();
    for (int a = 0; a < atts.getLength(); a++) {
        Node att = atts.item(a);
        if ("enabled".equals(att.getNodeName())) {
            String value = att.getNodeValue();
            interfaces.setEnabled(getBooleanValue(value));
        }
    }
    for (Node n : childElements(node)) {
        if ("interface".equals(lowerCaseInternal(cleanNodeName(n)))) {
            String value = getTextContent(n).trim();
            interfaces.addInterface(value);
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node)

Example 94 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project hazelcast by hazelcast.

the class XmlConfigBuilder method handleManagementCenterConfig.

private void handleManagementCenterConfig(Node node) {
    NamedNodeMap attrs = node.getAttributes();
    Node enabledNode = attrs.getNamedItem("enabled");
    boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode));
    Node intervalNode = attrs.getNamedItem("update-interval");
    int interval = intervalNode != null ? getIntegerValue("update-interval", getTextContent(intervalNode)) : ManagementCenterConfig.UPDATE_INTERVAL;
    String url = getTextContent(node);
    ManagementCenterConfig managementCenterConfig = config.getManagementCenterConfig();
    managementCenterConfig.setEnabled(enabled);
    managementCenterConfig.setUpdateInterval(interval);
    managementCenterConfig.setUrl("".equals(url) ? null : url);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node)

Example 95 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project hazelcast by hazelcast.

the class XmlConfigBuilder method handleAWS.

private void handleAWS(Node node) {
    JoinConfig join = config.getNetworkConfig().getJoin();
    NamedNodeMap atts = node.getAttributes();
    AwsConfig awsConfig = join.getAwsConfig();
    for (int a = 0; a < atts.getLength(); a++) {
        Node att = atts.item(a);
        String value = getTextContent(att).trim();
        if ("enabled".equals(lowerCaseInternal(att.getNodeName()))) {
            awsConfig.setEnabled(getBooleanValue(value));
        } else if (att.getNodeName().equals("connection-timeout-seconds")) {
            awsConfig.setConnectionTimeoutSeconds(getIntegerValue("connection-timeout-seconds", value));
        }
    }
    for (Node n : childElements(node)) {
        String value = getTextContent(n).trim();
        if ("secret-key".equals(cleanNodeName(n))) {
            awsConfig.setSecretKey(value);
        } else if ("access-key".equals(cleanNodeName(n))) {
            awsConfig.setAccessKey(value);
        } else if ("region".equals(cleanNodeName(n))) {
            awsConfig.setRegion(value);
        } else if ("host-header".equals(cleanNodeName(n))) {
            awsConfig.setHostHeader(value);
        } else if ("security-group-name".equals(cleanNodeName(n))) {
            awsConfig.setSecurityGroupName(value);
        } else if ("tag-key".equals(cleanNodeName(n))) {
            awsConfig.setTagKey(value);
        } else if ("tag-value".equals(cleanNodeName(n))) {
            awsConfig.setTagValue(value);
        } else if ("iam-role".equals(cleanNodeName(n))) {
            awsConfig.setIamRole(value);
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node)

Aggregations

NamedNodeMap (org.w3c.dom.NamedNodeMap)993 Node (org.w3c.dom.Node)690 NodeList (org.w3c.dom.NodeList)339 Attr (org.w3c.dom.Attr)295 Element (org.w3c.dom.Element)238 Document (org.w3c.dom.Document)154 ArrayList (java.util.ArrayList)92 HashMap (java.util.HashMap)91 DocumentBuilder (javax.xml.parsers.DocumentBuilder)59 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)58 IOException (java.io.IOException)53 SAXException (org.xml.sax.SAXException)41 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)40 List (java.util.List)36 Map (java.util.Map)33 File (java.io.File)27 InputStream (java.io.InputStream)26 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)25 DOMException (org.w3c.dom.DOMException)25 ByteArrayInputStream (java.io.ByteArrayInputStream)19