use of org.jgroups.conf.XmlNode in project JGroups by belaban.
the class RelayConfig method parse.
/**
* Parses site names and their configuration (e.g. "nyc" --> SiteConfig) into the map passed as argument
*/
public static void parse(InputStream input, final Map<String, SiteConfig> map) throws Exception {
XmlNode root = XmlConfigurator.parseXmlDocument(input);
parse(root, map);
}
use of org.jgroups.conf.XmlNode in project JGroups by belaban.
the class RelayConfig method parseForwards.
protected static void parseForwards(SiteConfig site_config, XmlNode root) throws Exception {
List<XmlNode> children = root.getChildren();
if (children == null || children.isEmpty())
return;
for (XmlNode node : children) {
match(FORWARD, node.getName());
Map<String, String> attrs = node.getAttributes();
if (attrs == null || attrs.isEmpty())
continue;
String to = attrs.get("to");
String gateway = attrs.get("gateway");
ForwardConfig forward_config = new ForwardConfig(to, gateway);
site_config.addForward(forward_config);
}
}
use of org.jgroups.conf.XmlNode in project JGroups by belaban.
the class Configurator method initializeAttrs.
/**
* Sets the attributes in a given protocol from properties
*/
public static void initializeAttrs(Protocol prot, ProtocolConfiguration config, StackType ip_version) throws Exception {
String protocol_name = config.getProtocolName();
if (protocol_name == null)
return;
Map<String, String> properties = new HashMap<>(config.getProperties());
initializeAttrs(prot, properties, ip_version);
// don't yet initialize attrs of components, but later (after init() has been called); therefore remove all
// properties belonging to components
Util.forAllComponentTypes(prot.getClass(), (obj, prefix) -> {
String key = prefix + ".";
properties.keySet().removeIf(s -> s.startsWith(key));
});
if (!properties.isEmpty())
throw new IllegalArgumentException(String.format(Util.getMessage("ConfigurationError"), protocol_name, properties));
// if we have protocol-specific XML configuration, pass it to the protocol
List<XmlNode> subtrees = config.getSubtrees();
if (subtrees != null) {
for (XmlNode node : subtrees) prot.parse(node);
}
}
Aggregations