public String getProtocolStackString() { return ProtocolStackUtil.getProtocolStackString(configuration); } }
/** * {@link #parse(Element) Parses <code>properties</code>} and then adds * the resulting protocol stack configurations to the set available for use. * * @param properties document root node for XML content in the JGroups * <code>stacks.xml</code> format * @param replace <code>true</code> if a configuration with the same * stack name as an already registered configuration should * replace that configuration; <code>false</code> if it * should be discarded. */ public void setMultiplexerConfig(Element properties, boolean replace) throws Exception { Map<String, ProtocolStackConfigInfo> map = ProtocolStackUtil.parse(properties); for (Map.Entry<String, ProtocolStackConfigInfo> entry : map.entrySet()) { addConfig(entry.getKey(), entry.getValue(), replace); } }
public static ProtocolData[] parseSingleConfig(InputStream input) throws Exception { if (input == null) { throw new IllegalArgumentException("null input"); } DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); factory.setValidating(false); //for now DocumentBuilder builder=factory.newDocumentBuilder(); Document document=builder.parse(input); // The root element of the document should be the "config" element, // but the parser(Element) method checks this so a check is not // needed here. Element configElement = document.getDocumentElement(); return parseConfig(configElement); }
private static ProtocolData[] parseProtocolStackString(String configuration) throws Exception { List<ProtocolData> retval = new ArrayList<ProtocolData>(); List<String> protocol_string = parseProtocols(configuration); if (protocol_string == null) return null; for (String component_string : protocol_string) { retval.add(parseProtocol(component_string)); } return retval.toArray(new ProtocolData[retval.size()]); }
return parseSingleConfig(input); return parseConfig((Element)properties); return parseProtocolStackString((String)properties);
ProtocolData[] protocolData = parseConfig(cfg); substituteVariables(protocolData);
ProtocolData[] protocolData = CONFIG_MAPPER.unwrapMetaValue(protocolsValue); ProtocolStackUtil.substituteVariables(protocolData); // replace vars with system props
private static ProtocolData parseProtocol(String protocolConfig) throws Exception { String protocol_name = null; String properties_str = null; int index = protocolConfig.indexOf('('); // e.g. "UDP(in_port=3333)" int end_index = protocolConfig.lastIndexOf(')'); if (index == -1) { protocol_name = protocolConfig; properties_str = ""; } else { if (end_index == -1) { throw new Exception("Configurator.ProtocolConfiguration(): closing ')' " + "not found in " + protocolConfig + ": properties cannot be set !"); } else { properties_str = protocolConfig.substring(index + 1, end_index); protocol_name = protocolConfig.substring(0, index); } } List<ProtocolParameter> params = parsePropertiesString(protocol_name, properties_str); return new ProtocolData(protocol_name, protocol_name, params); }
config = ProtocolStackUtil.getProtocolData(properties);
/** * Parses the contents of <code>input</code> into a map of the * protocol stack configurations contained in the XML. * * @param input stream which must contain XML content in the JGroups * <code>stacks.xml</code> format * * @return a map of the protocol stack configurations contained in the XML * * @throws IllegalArgumentException if <code>input</code> is <code>null</code> * @throws Exception */ public static Map<String, ProtocolStackConfigInfo> parse(InputStream input) throws Exception { if (input == null) { throw new IllegalArgumentException("null input"); } DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); factory.setValidating(false); //for now DocumentBuilder builder=factory.newDocumentBuilder(); Document document=builder.parse(input); // The root element of the document should be the "protocol_stacks" element, // but the parser(Element) method checks this so a check is not // needed here. Element configElement = document.getDocumentElement(); return parse(configElement); }
String stackString = ProtocolStackUtil.getProtocolStackString(config); log.debugf("Stack config after adding singleton_name is %s", stackString); JChannel channel = new MuxChannel(stackString);
private void addConfigs(InputStream input, String source, boolean replace) throws Exception { if(input == null) { throw new FileNotFoundException(source); } Map<String, ProtocolStackConfigInfo> map = null; try { map = ProtocolStackUtil.parse(input); } catch(Exception ex) { throw new Exception("failed parsing " + source, ex); } finally { Util.close(input); } for (Map.Entry<String, ProtocolStackConfigInfo> entry : map.entrySet()) { addConfig(entry.getKey(), entry.getValue(), replace); } }