CVS update: JGroups/src/org/jgroups/conf ProtocolConfiguration.java PlainConfigurator.java XmlConfigurator.java ProtocolStackConfigurator.java ConfiguratorFactory.java ProtocolData.java
"Bela Ban" <[email protected]> Thu, 16 Sep 2010 11:55:33 +0000
| Newsgroups | gmane.comp.java.javagroups.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: belaban
Date: 10/09/16 11:55:32
Modified: src/org/jgroups/conf ProtocolConfiguration.java
PlainConfigurator.java XmlConfigurator.java
ProtocolStackConfigurator.java
ConfiguratorFactory.java
Removed: src/org/jgroups/conf ProtocolData.java
Log:
replaced ProtocolData with ProtocolConfiguration
Revision Changes Path
1.4 +7 -1 JGroups/src/org/jgroups/conf/ProtocolConfiguration.java
Index: ProtocolConfiguration.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/conf/ProtocolConfiguration.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ProtocolConfiguration.java 16 Sep 2010 07:42:12 -0000 1.3
+++ ProtocolConfiguration.java 16 Sep 2010 11:55:31 -0000 1.4
@@ -13,7 +13,7 @@
* Parses and encapsulates the specification for 1 protocol of the protocol stack, e.g.
* <code>UNICAST(timeout=5000)</code>
* @author Bela Ban
- * @version $Id: ProtocolConfiguration.java,v 1.3 2010/09/16 07:42:12 belaban Exp $
+ * @version $Id: ProtocolConfiguration.java,v 1.4 2010/09/16 11:55:31 belaban Exp $
*/
public class ProtocolConfiguration {
private final String protocol_name;
@@ -49,6 +49,12 @@
parsePropertiesString(properties);
}
+ public ProtocolConfiguration(String protocol_name, Map<String,String> properties) {
+ this.protocol_name=protocol_name;
+ if(!properties.isEmpty())
+ this.properties.putAll(properties);
+ }
+
public String getProtocolName() {
return protocol_name;
}
1.3 +12 -14 JGroups/src/org/jgroups/conf/PlainConfigurator.java
Index: PlainConfigurator.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/conf/PlainConfigurator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PlainConfigurator.java 23 Sep 2004 16:29:14 -0000 1.2
+++ PlainConfigurator.java 16 Sep 2010 11:55:32 -0000 1.3
@@ -1,43 +1,41 @@
-// $Id: PlainConfigurator.java,v 1.2 2004/09/23 16:29:14 belaban Exp $
+// $Id: PlainConfigurator.java,v 1.3 2010/09/16 11:55:32 belaban Exp $
package org.jgroups.conf;
+import java.util.List;
+
/**
* A ProtocolStackConfigurator for the old style properties.
* <BR>
* Old style properties are referred to as the property string used by channel earlier
* they look like this PROTOCOL(param=value;param=value):PROTOCOL:PROTOCOL<BR>
* All it does is that it holds the string, it currently doesn't parse it at all.
- *
* @author Filip Hanik (<a href="mailto:[email protected]">[email protected])
+ * @author Bela Ban
* @version 1.0
*/
-public class PlainConfigurator implements ProtocolStackConfigurator
-{
+public class PlainConfigurator implements ProtocolStackConfigurator {
private final String mProperties;
-
+
/**
* Instantiates a PlainConfigurator with old style properties
*/
- public PlainConfigurator(String properties)
- {
- mProperties = properties;
+ public PlainConfigurator(String properties) {
+ mProperties=properties;
}
-
+
/**
* returns the old style protocol string
*/
- public String getProtocolStackString()
- {
+ public String getProtocolStackString() {
return mProperties;
}
-
+
/**
* Throws a UnsupportedOperationException all the time. No parsing implemented.
*/
- public ProtocolData[] getProtocolStack()
- {
+ public List<ProtocolConfiguration> getProtocolStack() {
/**todo: Implement this org.jgroups.conf.ProtocolStackConfigurator method*/
throw new java.lang.UnsupportedOperationException("Method getProtocolStack() not yet implemented.");
}
1.32 +19 -69 JGroups/src/org/jgroups/conf/XmlConfigurator.java
Index: XmlConfigurator.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/conf/XmlConfigurator.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- XmlConfigurator.java 16 Sep 2010 07:42:12 -0000 1.31
+++ XmlConfigurator.java 16 Sep 2010 11:55:32 -0000 1.32
@@ -4,7 +4,7 @@
/**
* Uses XML to configure a protocol stack
* @author Vladimir Blagojevic
- * @version $Id: XmlConfigurator.java,v 1.31 2010/09/16 07:42:12 belaban Exp $
+ * @version $Id: XmlConfigurator.java,v 1.32 2010/09/16 11:55:32 belaban Exp $
*/
import org.jgroups.Global;
@@ -30,24 +30,14 @@
import java.util.concurrent.atomic.AtomicReference;
public class XmlConfigurator implements ProtocolStackConfigurator {
-
- private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
- private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
- public static final String ATTR_NAME="name";
- public static final String ATTR_VALUE="value";
+ private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+ private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+ private final List<ProtocolConfiguration> configuration=new ArrayList<ProtocolConfiguration>();
+ protected static final Log log=LogFactory.getLog(XmlConfigurator.class);
-
- private final ArrayList<ProtocolData> mProtocolStack=new ArrayList<ProtocolData>();
- private final String mStackName;
- protected static final Log log=LogFactory.getLog(XmlConfigurator.class);
-
- protected XmlConfigurator(String stackName,ProtocolData[] protocols) {
- mStackName=stackName;
- mProtocolStack.addAll(Arrays.asList(protocols));
- }
-
- protected XmlConfigurator(String stackName) {
- this(stackName, new ProtocolData[0]);
+
+ protected XmlConfigurator(List<ProtocolConfiguration> protocols) {
+ configuration.addAll(protocols);
}
public static XmlConfigurator getInstance(URL url) throws java.io.IOException {
@@ -88,11 +78,11 @@
*/
public String getProtocolStackString(boolean convert) {
StringBuilder buf=new StringBuilder();
- Iterator<ProtocolData> it=mProtocolStack.iterator();
+ Iterator<ProtocolConfiguration> it=configuration.iterator();
if(convert)
buf.append("<config>\n");
while(it.hasNext()) {
- ProtocolData d=it.next();
+ ProtocolConfiguration d=it.next();
if(convert)
buf.append(" <");
buf.append(d.getProtocolString(convert));
@@ -114,17 +104,8 @@
return getProtocolStackString(false);
}
- public ProtocolData[] getProtocolStack() {
- return mProtocolStack.toArray(new ProtocolData[mProtocolStack.size()]);
- }
-
- public String getName() {
- return mStackName;
- }
-
-
- public void add(ProtocolData data) {
- mProtocolStack.add(data);
+ public List<ProtocolConfiguration> getProtocolStack() {
+ return configuration;
}
@@ -220,14 +201,11 @@
protected static XmlConfigurator parse(Element root_element) throws java.io.IOException {
XmlConfigurator configurator=null;
-
- /** LinkedList<ProtocolData> */
- LinkedList<ProtocolData> prot_data=new LinkedList<ProtocolData>();
+ final LinkedList<ProtocolConfiguration> prot_data=new LinkedList<ProtocolConfiguration>();
/**
- * CAUTION: crappy code ahead ! I (bela) am not an XML expert, so the
- * code below is pretty amateurish... But it seems to work, and it is
- * executed only on startup, so no perf loss on the critical path. If
+ * CAUTION: crappy code ahead ! I (bela) am not an XML expert, so the code below is pretty amateurish...
+ * But it seems to work, and it is executed only on startup, so no perf loss on the critical path. If
* somebody wants to improve this, please be my guest.
*/
try {
@@ -245,7 +223,7 @@
continue;
Element tag=(Element)node;
- String protocol=tag.getTagName();
+ String protocol=tag.getTagName();
Map<String,String> params=new HashMap<String,String>();
NamedNodeMap attrs=tag.getAttributes();
@@ -256,14 +234,10 @@
String value=attr.getValue();
params.put(name, value);
}
- ProtocolData data=new ProtocolData(protocol, protocol, params);
- prot_data.add(data);
+ ProtocolConfiguration cfg=new ProtocolConfiguration(protocol, params);
+ prot_data.add(cfg);
}
-
- ProtocolData[] data=new ProtocolData[(prot_data.size())];
- for(int k=0;k < prot_data.size();k++)
- data[k]=prot_data.get(k);
- configurator=new XmlConfigurator("bla", data);
+ configurator=new XmlConfigurator(prot_data);
}
catch(Exception x) {
if(x instanceof java.io.IOException)
@@ -279,30 +253,6 @@
- /* protected static ProtocolParameter[] parseProtocolParameters(Element protparams) throws IOException {
- try {
- Vector<ProtocolParameter> v=new Vector<ProtocolParameter>();
- protparams.normalize();
- NodeList parameters=protparams.getChildNodes();
- for(int i=0;i < parameters.getLength();i++) {
- if(parameters.item(i).getNodeType() == Node.ELEMENT_NODE) {
- String pname=parameters.item(i).getAttributes().getNamedItem(ATTR_NAME).getNodeValue();
- String pvalue=parameters.item(i).getAttributes().getNamedItem(ATTR_VALUE).getNodeValue();
- ProtocolParameter p=new ProtocolParameter(pname, pvalue);
- v.addElement(p);
- }//end if
- }//for
- ProtocolParameter[] result=new ProtocolParameter[v.size()];
- v.copyInto(result);
- return result;
- }
- catch(Exception x) {
- IOException tmp=new IOException();
- tmp.initCause(x);
- throw tmp;
- }
- }*/
-
public static void main(String[] args) throws Exception {
String input_file=null;
XmlConfigurator conf;
1.2 +7 -5 JGroups/src/org/jgroups/conf/ProtocolStackConfigurator.java
Index: ProtocolStackConfigurator.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/conf/ProtocolStackConfigurator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProtocolStackConfigurator.java 9 Sep 2003 01:24:08 -0000 1.1
+++ ProtocolStackConfigurator.java 16 Sep 2010 11:55:32 -0000 1.2
@@ -1,14 +1,16 @@
-// $Id: ProtocolStackConfigurator.java,v 1.1 2003/09/09 01:24:08 belaban Exp $
+// $Id: ProtocolStackConfigurator.java,v 1.2 2010/09/16 11:55:32 belaban Exp $
package org.jgroups.conf;
+import java.util.List;
+
/**
* @author Filip Hanik (<a href="mailto:[email protected]">[email protected])
+ * @author Bela Ban
* @version 1.0
*/
-public interface ProtocolStackConfigurator
-{
- String getProtocolStackString();
- ProtocolData[] getProtocolStack();
+public interface ProtocolStackConfigurator {
+ String getProtocolStackString();
+ List<ProtocolConfiguration> getProtocolStack();
}
1.31 +5 -4 JGroups/src/org/jgroups/conf/ConfiguratorFactory.java
Index: ConfiguratorFactory.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/conf/ConfiguratorFactory.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ConfiguratorFactory.java 16 Sep 2010 07:30:08 -0000 1.30
+++ ConfiguratorFactory.java 16 Sep 2010 11:55:32 -0000 1.31
@@ -12,6 +12,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessControlException;
+import java.util.List;
import java.util.Map;
/**
@@ -25,7 +26,7 @@
*
* @author Filip Hanik (<a href="mailto:[email protected]">[email protected])
* @author Bela Ban
- * @version $Id: ConfiguratorFactory.java,v 1.30 2010/09/16 07:30:08 belaban Exp $
+ * @version $Id: ConfiguratorFactory.java,v 1.31 2010/09/16 11:55:32 belaban Exp $
*/
public class ConfiguratorFactory {
public static final String JAXP_MISSING_ERROR_MSG=
@@ -408,10 +409,10 @@
* @param configurator
*/
public static void substituteVariables(ProtocolStackConfigurator configurator) {
- ProtocolData[] protocols=configurator.getProtocolStack();
- for(ProtocolData data: protocols) {
+ List<ProtocolConfiguration> protocols=configurator.getProtocolStack();
+ for(ProtocolConfiguration data: protocols) {
if(data != null) {
- Map<String,String> parms=data.getParameters();
+ Map<String,String> parms=data.getProperties();
for(Map.Entry<String,String> entry:parms.entrySet()) {
String val=entry.getValue();
String replacement=Util.substituteVariable(val);
------------------------------------------------------------------------------
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