CVS update: JGroups/src/org/jgroups/stack Configurator.java
"Bela Ban" <[email protected]> Wed, 15 Sep 2010 15:49:42 +0000
| Newsgroups | gmane.comp.java.javagroups.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: belaban
Date: 10/09/15 15:49:42
Modified: src/org/jgroups/stack Configurator.java
Log:
moved ProtocolConfiguration from Configurator into its own class
Revision Changes Path
1.84 +3 -111 JGroups/src/org/jgroups/stack/Configurator.java
Index: Configurator.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/stack/Configurator.java,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- Configurator.java 15 Sep 2010 15:42:48 -0000 1.83
+++ Configurator.java 15 Sep 2010 15:49:42 -0000 1.84
@@ -6,6 +6,7 @@
import org.jgroups.annotations.DeprecatedProperty;
import org.jgroups.annotations.Property;
import org.jgroups.conf.PropertyHelper;
+import org.jgroups.conf.ProtocolConfiguration;
import org.jgroups.logging.Log;
import org.jgroups.logging.LogFactory;
import org.jgroups.protocols.TP;
@@ -36,7 +37,7 @@
* of the protocol stack and the properties of each layer.
* @author Bela Ban
* @author Richard Achmatowicz
- * @version $Id: Configurator.java,v 1.83 2010/09/15 15:42:48 belaban Exp $
+ * @version $Id: Configurator.java,v 1.84 2010/09/15 15:49:42 belaban Exp $
*/
public class Configurator implements ProtocolStackFactory {
@@ -1196,116 +1197,7 @@
}
- /**
- * Parses and encapsulates the specification for 1 protocol of the protocol stack, e.g.
- * <code>UNICAST(timeout=5000)</code>
- */
- public static class ProtocolConfiguration {
- private final String protocol_name;
- private String properties_str;
- private final Map<String,String> properties=new HashMap<String,String>();
- public static final String protocol_prefix="org.jgroups.protocols";
-
-
- /**
- * Creates a new ProtocolConfiguration.
- * @param config_str The configuration specification for the protocol, e.g.
- * <pre>VERIFY_SUSPECT(timeout=1500)</pre>
- */
- public ProtocolConfiguration(String config_str) throws Exception {
- int index=config_str.indexOf('('); // e.g. "UDP(in_port=3333)"
- int end_index=config_str.lastIndexOf(')');
-
- if(index == -1) {
- protocol_name=config_str;
- properties_str="";
- }
- else {
- if(end_index == -1) {
- throw new Exception("Configurator.ProtocolConfiguration(): closing ')' " +
- "not found in " + config_str + ": properties cannot be set !");
- }
- else {
- properties_str=config_str.substring(index + 1, end_index);
- protocol_name=config_str.substring(0, index);
- }
- }
- parsePropertiesString(properties_str, properties) ;
- }
-
- public String getProtocolName() {
- return protocol_name;
- }
-
- public Map<String, String> getProperties() {
- return properties;
- }
-
- public Map<String, String> getOriginalProperties() throws Exception {
- Map<String,String> props = new HashMap<String,String>();
- parsePropertiesString(properties_str, props) ;
- return props ;
- }
-
- private void parsePropertiesString(String properties_str, Map<String, String> properties) throws Exception {
- int index = 0 ;
-
- /* "in_port=5555;out_port=6666" */
- if(properties_str.length() > 0) {
- String[] components=properties_str.split(";");
- for(String property : components) {
- String name, value;
- index=property.indexOf('=');
- if(index == -1) {
- throw new Exception("Configurator.ProtocolConfiguration(): '=' not found in " + property
- + " of " + protocol_name);
- }
- name=property.substring(0, index);
- value=property.substring(index + 1, property.length());
- properties.put(name, value);
- }
- }
- }
-
- public void substituteVariables() {
- for(Iterator<Map.Entry<String,String>> it=properties.entrySet().iterator(); it.hasNext();) {
- Map.Entry<String,String> entry=it.next();
- String key=entry.getKey();
- String val=entry.getValue();
- String tmp=Util.substituteVariable(val);
- if(!val.equals(tmp)) {
- properties.put(key,tmp);
- }
- else {
- if(tmp.contains("${")) {
- if(log.isWarnEnabled())
- log.warn("variable \"" + val + "\" in " + protocol_name + " could not be substituted; " +
- key + " is removed from properties");
- it.remove();
- }
- }
- }
- properties_str=propertiesToString();
- }
-
-
- public String toString() {
- StringBuilder retval=new StringBuilder();
- if(protocol_name == null)
- retval.append("<unknown>");
- else
- retval.append(protocol_name);
- if(properties != null)
- retval.append("(" + Util.print(properties) + ')');
- return retval.toString();
- }
-
- public String propertiesToString() {
- return Util.printMapWithDelimiter(properties, ";");
- }
-
-
- }
+
public static class InetAddressInfo {
Protocol protocol ;
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev