You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2007/01/16 16:16:55 UTC

svn commit: r496725 [2/11] - in /incubator/qpid/branches/perftesting/qpid: gentools/ gentools/src/org/apache/qpid/gentools/ gentools/templ.cpp/ gentools/templ.java/ java/ java/broker/ java/broker/etc/ java/broker/src/main/java/org/apache/qpid/server/ j...

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethod.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethod.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethod.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethod.java Tue Jan 16 07:16:39 2007
@@ -21,7 +21,6 @@
 package org.apache.qpid.gentools;
 
 import java.io.PrintStream;
-import java.util.Iterator;
 
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -47,21 +46,21 @@
 		serverMethodFlagMap = new AmqpFlagMap();
 	}
 
-	public void addFromNode(Node methodNode, int ordinal, AmqpVersion version)
+	public boolean addFromNode(Node methodNode, int ordinal, AmqpVersion version)
 		throws AmqpParseException, AmqpTypeMappingException
 	{
+		versionSet.add(version);
 		boolean serverChassisFlag = false;
 		boolean clientChassisFlag = false;
-		versionSet.add(version);
 		int index = Utils.getNamedIntegerAttribute(methodNode, "index");
-		AmqpVersionSet versionSet = indexMap.get(index);
-		if (versionSet != null)
-			versionSet.add(version);
+		AmqpVersionSet indexVersionSet = indexMap.get(index);
+		if (indexVersionSet != null)
+			indexVersionSet.add(version);
 		else
 		{
-			versionSet = new AmqpVersionSet();
-			versionSet.add(version);
-			indexMap.put(index, versionSet);
+			indexVersionSet = new AmqpVersionSet();
+			indexVersionSet.add(version);
+			indexMap.put(index, indexVersionSet);
 		}
 		NodeList nList = methodNode.getChildNodes();
 		int fieldCntr = 0;
@@ -70,16 +69,27 @@
 			Node child = nList.item(i);
 			if (child.getNodeName().compareTo(Utils.ELEMENT_FIELD) == 0)
 			{
-				String fieldName = converter.prepareDomainName(Utils.getNamedAttribute(child, Utils.ATTRIBUTE_NAME));
+				String fieldName = converter.prepareDomainName(Utils.getNamedAttribute(child,
+						Utils.ATTRIBUTE_NAME));
 				AmqpField thisField = fieldMap.get(fieldName);
 				if (thisField == null)
 				{
 					thisField = new AmqpField(fieldName, converter);
 					fieldMap.put(fieldName, thisField);
 				}
-				thisField.addFromNode(child, fieldCntr++, version);				
+				if (!thisField.addFromNode(child, fieldCntr++, version))
+				{
+					String className = converter.prepareClassName(Utils.getNamedAttribute(methodNode.getParentNode(),
+							Utils.ATTRIBUTE_NAME));
+					String methodName = converter.prepareMethodName(Utils.getNamedAttribute(methodNode,
+							Utils.ATTRIBUTE_NAME));
+					System.out.println("INFO: Generation supression tag found for field " +
+							className + "." + methodName + "." + fieldName + " - removing.");
+					thisField.removeVersion(version);
+					fieldMap.remove(fieldName);
+				}
 			}
-			if (child.getNodeName().compareTo(Utils.ELEMENT_CHASSIS) == 0)
+			else if (child.getNodeName().compareTo(Utils.ELEMENT_CHASSIS) == 0)
 			{
 				String chassisName = Utils.getNamedAttribute(child, Utils.ATTRIBUTE_NAME);
 				if (chassisName.compareTo("server") == 0)
@@ -87,8 +97,24 @@
 				else if (chassisName.compareTo("client") == 0)
 					clientChassisFlag = true;
 			}
+			else if (child.getNodeName().compareTo(Utils.ELEMENT_CODEGEN) == 0)
+			{
+				String value = Utils.getNamedAttribute(child, Utils.ATTRIBUTE_VALUE);
+				if (value.compareTo("no-gen") == 0)
+					return false;
+			}
 		}
 		processChassisFlags(serverChassisFlag, clientChassisFlag, version);
+		return true;
+	}
+	
+	public void removeVersion(AmqpVersion version)
+	{
+		clientMethodFlagMap.removeVersion(version);
+		serverMethodFlagMap.removeVersion(version);
+		indexMap.removeVersion(version);
+		fieldMap.removeVersion(version);
+		versionSet.remove(version);
 	}
 	
 	public void print(PrintStream out, int marginSize, int tabSize)
@@ -97,20 +123,18 @@
 		String tab = Utils.createSpaces(tabSize);
 		out.println(margin + "[M] " + name + " {" + (serverMethodFlagMap.isSet() ? "S " +
 			serverMethodFlagMap + (clientMethodFlagMap.isSet() ? ", " : "") : "") +
-			(clientMethodFlagMap.isSet() ? "C " + clientMethodFlagMap : "") + "}" + ": " + versionSet);
+			(clientMethodFlagMap.isSet() ? "C " + clientMethodFlagMap : "") + "}" + ": " +
+			versionSet);
 		
-		Iterator<Integer> iItr = indexMap.keySet().iterator();
-		while (iItr.hasNext())
+		for (Integer thisIndex : indexMap.keySet())
 		{
-			int index = iItr.next();
-			AmqpVersionSet indexVersionSet = indexMap.get(index);
-			out.println(margin + tab + "[I] " + index + indexVersionSet);
+			AmqpVersionSet indexVersionSet = indexMap.get(thisIndex);
+			out.println(margin + tab + "[I] " + thisIndex + indexVersionSet);
 		}
 		
-		Iterator<String> sItr = fieldMap.keySet().iterator();
-		while (sItr.hasNext())
+		for (String thisFieldName : fieldMap.keySet())
 		{
-			AmqpField thisField = fieldMap.get(sItr.next());
+			AmqpField thisField = fieldMap.get(thisFieldName);
 			thisField.print(out, marginSize + tabSize, tabSize);
 		}
 	}
@@ -143,21 +167,19 @@
 		throws AmqpTypeMappingException
 	{
 		AmqpOverloadedParameterMap parameterVersionMap = new AmqpOverloadedParameterMap();
-		Iterator<AmqpVersion> vItr = globalVersionSet.iterator();
-		while (vItr.hasNext())
+		for (AmqpVersion thisVersion : globalVersionSet)
 		{
-			AmqpVersion version = vItr.next();
-			AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, true, generator);
+			AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(thisVersion, true, generator);
 			AmqpVersionSet methodVersionSet = parameterVersionMap.get(ordinalFieldMap);
 			if (methodVersionSet == null)
 			{
 				methodVersionSet = new AmqpVersionSet();
-				methodVersionSet.add(version);
+				methodVersionSet.add(thisVersion);
 				parameterVersionMap.put(ordinalFieldMap, methodVersionSet);
 			}
 			else
 			{
-				methodVersionSet.add(version);
+				methodVersionSet.add(thisVersion);
 			}
 		}
 		return parameterVersionMap;

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethodMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethodMap.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethodMap.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpMethodMap.java Tue Jan 16 07:16:39 2007
@@ -25,5 +25,12 @@
 @SuppressWarnings("serial")
 public class AmqpMethodMap extends TreeMap<String, AmqpMethod>
 {
+	public void removeVersion(AmqpVersion version)
+	{
+		for (String methodName : keySet())
+		{
+			get(methodName).removeVersion(version);
+		}
+	}
 
 }

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpModel.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpModel.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpModel.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpModel.java Tue Jan 16 07:16:39 2007
@@ -21,7 +21,6 @@
 package org.apache.qpid.gentools;
 
 import java.io.PrintStream;
-import java.util.Iterator;
 
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -38,7 +37,7 @@
 		classMap = new AmqpClassMap();
 	}
 
-	public void addFromNode(Node n, int o, AmqpVersion v)
+	public boolean addFromNode(Node n, int o, AmqpVersion v)
 		throws AmqpParseException, AmqpTypeMappingException
 	{
 		NodeList nList = n.getChildNodes();
@@ -55,9 +54,15 @@
 					thisClass = new AmqpClass(className, converter);
 					classMap.put(className, thisClass);
 				}
-				thisClass.addFromNode(c, eCntr++, v);				
+				if (!thisClass.addFromNode(c, eCntr++, v))
+				{
+					System.out.println("INFO: Generation supression tag found for class " + className + " - removing.");
+					thisClass.removeVersion(v);
+					classMap.remove(className);
+				}
 			}
-		}	
+		}
+		return true;
 	}
 	
 	public void print(PrintStream out, int marginSize, int tabSize)
@@ -66,11 +71,9 @@
 			"[C]=class; [M]=method; [F]=field; [D]=domain; [I]=index; [O]=ordinal" + Utils.lineSeparator);
 		out.println(Utils.createSpaces(marginSize) + "Model:");
 
-		Iterator<String> i = classMap.keySet().iterator();
-		while (i.hasNext())
+		for (String thisClassName : classMap.keySet())
 		{
-			String className = i.next();
-			AmqpClass thisClass = classMap.get(className);
+			AmqpClass thisClass = classMap.get(thisClassName);
 			thisClass.print(out, marginSize + tabSize, tabSize);
 		}
 	}

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java Tue Jan 16 07:16:39 2007
@@ -79,12 +79,10 @@
 	public String toString()
 	{
 		StringBuffer sb = new StringBuffer();
-		Iterator<Integer> itr = keySet().iterator();
-		while (itr.hasNext())
+		for (Integer thisOrdinal : keySet())
 		{
-			int ordinal = itr.next();
-			String[] pair = get(ordinal);
-			sb.append("[" + ordinal + "] " + pair[0] + " : " + pair[1] + Utils.lineSeparator);
+			String[] pair = get(thisOrdinal);
+			sb.append("[" + thisOrdinal + "] " + pair[0] + " : " + pair[1] + Utils.lineSeparator);
 		}
 		return sb.toString();
 	}

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalVersionMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalVersionMap.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalVersionMap.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpOrdinalVersionMap.java Tue Jan 16 07:16:39 2007
@@ -20,7 +20,7 @@
  */
 package org.apache.qpid.gentools;
 
-import java.util.Iterator;
+import java.util.ArrayList;
 import java.util.TreeMap;
 
 @SuppressWarnings("serial")
@@ -36,14 +36,37 @@
     public int getOrdinal(AmqpVersion version)
     throws AmqpTypeMappingException
     {
-        Iterator<Integer> itr = keySet().iterator();
-        while (itr.hasNext())
+    	for (Integer thisOrdinal : keySet())
         {
-            int ordinal = itr.next();
-            AmqpVersionSet versionSet = get(ordinal);
+            AmqpVersionSet versionSet = get(thisOrdinal);
             if (versionSet.contains(version))
-                return ordinal;
+                return thisOrdinal;
         }
         throw new AmqpTypeMappingException("Unable to locate version " + version + " in ordianl version map.");
     }
+	
+	public boolean removeVersion(AmqpVersion version)
+	{
+		Boolean res = false;
+		ArrayList<Integer> removeList = new ArrayList<Integer>();
+		for (Integer ordinal : keySet())
+		{
+			AmqpVersionSet versionSet = get(ordinal);
+			if (versionSet.contains(version))
+			{
+				versionSet.remove(version);
+				if (versionSet.isEmpty())
+				{
+					removeList.add(ordinal);
+				}
+				res = true;
+			}
+		}
+		// Get rid of ordinals no longer in use
+		for (Integer ordinal : removeList)
+		{
+			remove(ordinal);
+		}
+		return res;
+	}
 }

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersion.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersion.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersion.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersion.java Tue Jan 16 07:16:39 2007
@@ -30,6 +30,12 @@
 		this.major = major;
 		this.minor = minor;
 	}
+
+	public AmqpVersion(AmqpVersion version)
+	{
+		this.major = version.major;
+		this.minor = version.minor;
+	}
 	
 	public int getMajor()
 	{

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersionSet.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersionSet.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersionSet.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/AmqpVersionSet.java Tue Jan 16 07:16:39 2007
@@ -30,11 +30,23 @@
 {
     public AmqpVersionSet()
     {
+    	super();
     }
     
     public AmqpVersionSet(AmqpVersion version)
     {
+    	super();
         add(version);
+    }
+    
+    public AmqpVersion find(AmqpVersion version)
+    {
+    	for (AmqpVersion v : this)
+    	{
+    		if (v.compareTo(version) == 0)
+    			return v;
+    	}
+    	return null;
     }
     
 	public void print(PrintStream out, int marginSize, int tabSize)

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/CppGenerator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/CppGenerator.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/CppGenerator.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/CppGenerator.java Tue Jan 16 07:16:39 2007
@@ -31,8 +31,10 @@
 {
 	protected static final String versionNamespaceStartToken = "${version_namespace_start}";
 	protected static final String versionNamespaceEndToken = "${version_namespace_end}";
+	
+	// TODO: Move this to parent class
 	protected static final int FIELD_NAME = 0;
-	protected static final int FIELD_DOMAIN = 1;
+	protected static final int FIELD_CODE_TYPE = 1;
     
     /**
      * A complete list of C++ reserved words. The names of varous XML elements within the AMQP
@@ -558,7 +560,7 @@
     protected void processConstantList(StringBuffer sb, int listMarkerStartIndex, int listMarkerEndIndex,
         AmqpConstantSet constantSet)
         throws AmqpTemplateException, AmqpTypeMappingException
-        {
+    {
         String codeSnippet;
         int lend = sb.indexOf(cr, listMarkerStartIndex) + 1; // Include cr at end of line
         String tline = sb.substring(listMarkerEndIndex, lend); // Line excluding line marker, including cr
@@ -575,8 +577,8 @@
         {
             throw new AmqpTemplateException("Template token " + token + " unknown.");
         }
-       sb.insert(listMarkerStartIndex, codeSnippet);
-        }
+        sb.insert(listMarkerStartIndex, codeSnippet);
+    }
 		
 	// === Protected and private helper functions unique to C++ implementation ===
     
@@ -588,34 +590,32 @@
     {
         String indent = Utils.createSpaces(indentSize);
         StringBuffer sb = new StringBuffer();
-        Iterator<AmqpConstant> cItr = constantSet.iterator();
-        while (cItr.hasNext())
+        for (AmqpConstant thisConstant : constantSet)
         {
-            AmqpConstant constant = cItr.next();
-            if (constant.isVersionConsistent(globalVersionSet))
+            if (thisConstant.isVersionConsistent(globalVersionSet))
             {
                 // return a constant
-                String value = constant.firstKey();
-                sb.append(indent + "static const char* " + constant.name + "() { return \"" +
-                    constant.firstKey() + "\"; }" + cr);
+                String value = thisConstant.firstKey();
+                sb.append(indent + "static const char* " + thisConstant.name + "() { return \"" +
+                    thisConstant.firstKey() + "\"; }" + cr);
                 if (Utils.containsOnlyDigits(value))
                 {
-                    sb.append(indent + "static int " + constant.name + "AsInt() { return " +
-                        constant.firstKey() + "; }" + cr);
+                    sb.append(indent + "static int " + thisConstant.name + "AsInt() { return " +
+                        thisConstant.firstKey() + "; }" + cr);
                 }
                 if (Utils.containsOnlyDigitsAndDecimal(value))
                 {
-                    sb.append(indent + "static double " + constant.name + "AsDouble() { return (double)" +
-                        constant.firstKey() + "; }" + cr);
+                    sb.append(indent + "static double " + thisConstant.name + "AsDouble() { return (double)" +
+                        thisConstant.firstKey() + "; }" + cr);
                 }
                 sb.append(cr);
-           }
+            }
             else
             {
                 // Return version-specific constant
-                sb.append(generateVersionDependentGet(constant, "const char*", "", "\"", "\"", indentSize, tabSize));
-                sb.append(generateVersionDependentGet(constant, "int", "AsInt", "", "", indentSize, tabSize));
-                sb.append(generateVersionDependentGet(constant, "double", "AsDouble", "(double)", "", indentSize, tabSize));
+                sb.append(generateVersionDependentGet(thisConstant, "const char*", "", "\"", "\"", indentSize, tabSize));
+                sb.append(generateVersionDependentGet(thisConstant, "int", "AsInt", "", "", indentSize, tabSize));
+                sb.append(generateVersionDependentGet(thisConstant, "double", "AsDouble", "(double)", "", indentSize, tabSize));
                 sb.append(cr);
             }
         }        
@@ -633,27 +633,25 @@
             "() const" + cr);
         sb.append(indent + "{" + cr);
         boolean first = true;
-        Iterator<String> sItr = constant.keySet().iterator();
-        while (sItr.hasNext())
+        for (String thisValue : constant.keySet())
         {
-            String value = sItr.next();
-            AmqpVersionSet versionSet = constant.get(value);
+            AmqpVersionSet versionSet = constant.get(thisValue);
             sb.append(indent + tab + (first ? "" : "else ") + "if (" + generateVersionCheck(versionSet) +
                 ")" + cr);
             sb.append(indent + tab + "{" + cr);
-            if (methodReturnType.compareTo("int") == 0 && !Utils.containsOnlyDigits(value))
+            if (methodReturnType.compareTo("int") == 0 && !Utils.containsOnlyDigits(thisValue))
             {
                 sb.append(generateConstantDeclarationException(constant.name, methodReturnType,
                     indentSize + (2*tabSize), tabSize));
             }
-            else if (methodReturnType.compareTo("double") == 0 && !Utils.containsOnlyDigitsAndDecimal(value))
+            else if (methodReturnType.compareTo("double") == 0 && !Utils.containsOnlyDigitsAndDecimal(thisValue))
             {
                 sb.append(generateConstantDeclarationException(constant.name, methodReturnType,
                     indentSize + (2*tabSize), tabSize));                            
             }
             else
             {
-                sb.append(indent + tab + tab + "return " + returnPrefix + value + returnPostfix + ";" + cr);
+                sb.append(indent + tab + tab + "return " + returnPrefix + thisValue + returnPostfix + ";" + cr);
             }
             sb.append(indent + tab + "}" + cr);
             first = false;
@@ -681,7 +679,7 @@
             methodReturnType + " for AMQP version \" <<" + cr);        
         sb.append(indent + tab + "version.toString() << \".\";" + cr);        
         sb.append(indent + "throw ProtocolVersionException(ss.str());" + cr);        
-       return sb.toString();       
+        return sb.toString();       
     }
 	
 	// Methods used for generation of code snippets for Server/ClientOperations class generation
@@ -690,25 +688,25 @@
 	{
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
-		Iterator<String> cItr = model.classMap.keySet().iterator();
-		while (cItr.hasNext())
+		for (String thisClassName : model.classMap.keySet())
 		{
-			AmqpClass thisClass = model.classMap.get(cItr.next());
+			AmqpClass thisClass = model.classMap.get(thisClassName);
 			// Only generate for this class if there is at least one method of the
 			// required chassis (server/client flag).
 			boolean chassisFoundFlag = false;
-			Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
-			while (mItr.hasNext() && !chassisFoundFlag)
+			for (String thisMethodName : thisClass.methodMap.keySet())
 			{
-				AmqpMethod method = thisClass.methodMap.get(mItr.next());
+				AmqpMethod method = thisClass.methodMap.get(thisMethodName);
 				boolean clientChassisFlag = method.clientMethodFlagMap.isSet();
 				boolean serverChassisFlag = method.serverMethodFlagMap.isSet();
 				if ((serverFlag && serverChassisFlag) || (!serverFlag && clientChassisFlag))
 					chassisFoundFlag = true;
 			}
 			if (chassisFoundFlag)
+			{
 				sb.append(indent + "virtual AMQP_" + (serverFlag ? "Server" : "Client") + "Operations::" +
 				    thisClass.name + "Handler* get" + thisClass.name + "Handler() = 0;" + cr);
+			}
 		}
 		return sb.toString();
 	}
@@ -716,43 +714,42 @@
 	protected String generateOpsInnerClasses(AmqpModel model, boolean serverFlag, int indentSize, int tabSize)
 		throws AmqpTypeMappingException
 	{
+		
+		String proxyClassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Proxy";
 		String indent = Utils.createSpaces(indentSize);
 		String tab = Utils.createSpaces(tabSize);
 		StringBuffer sb = new StringBuffer();
 		boolean first = true;
-		Iterator<String> cItr = model.classMap.keySet().iterator();
-		while (cItr.hasNext())
+		for (String thisClassName : model.classMap.keySet())
 		{
-			AmqpClass thisClass = model.classMap.get(cItr.next());
-			String className = thisClass.name + "Handler";
+			AmqpClass thisClass = model.classMap.get(thisClassName);
+			String handlerClassName = thisClass.name + "Handler";
 			if (!first)
 				sb.append(cr);
-			sb.append(indent + "// ==================== class " + className +
+			sb.append(indent + "// ==================== class " + handlerClassName +
 				" ====================" + cr);
-			sb.append(indent + "class " + className);
+			sb.append(indent + "class " + handlerClassName);
 			if (thisClass.versionSet.size() != globalVersionSet.size())
 				sb.append(" // AMQP Version(s) " + thisClass.versionSet + cr);
 			else
 				sb.append(cr);
 			sb.append(indent + "{" + cr);
 			sb.append(indent + "private:" + cr);
-			sb.append(indent + tab + "ProtocolVersion version;" + cr);
+			sb.append(indent + tab + proxyClassName+ "* parent;" + cr);
             sb.append(cr);
             sb.append(indent + tab + "// Constructors and destructors" + cr);
             sb.append(cr);
 			sb.append(indent + "protected:" + cr);
-            sb.append(indent + tab + className + "() {}" + cr);
+            sb.append(indent + tab + handlerClassName + "() {}" + cr);
 			sb.append(indent + "public:" + cr);
-			sb.append(indent + tab + className +
-				"(u_int8_t major, u_int8_t minor) : version(major, minor) {}" + cr);
-			sb.append(indent + tab + className +
-					"(ProtocolVersion version) : version(version) {}" + cr);
-			sb.append(indent + tab + "virtual ~" + className + "() {}" + cr);
+			sb.append(indent + tab + handlerClassName +
+				"(" + proxyClassName + "* _parent) {parent = _parent;}" + cr);
+			sb.append(indent + tab + "virtual ~" + handlerClassName + "() {}" + cr);
 			sb.append(cr);
 			sb.append(indent + tab + "// Protocol methods" + cr);
 			sb.append(cr);
 			sb.append(generateInnerClassMethods(thisClass, serverFlag, true, indentSize + tabSize, tabSize));
-			sb.append(indent + "}; // class " + className + cr);
+			sb.append(indent + "}; // class " + handlerClassName + cr);
 			first = false;
 		}
 		return sb.toString();		
@@ -766,10 +763,9 @@
 		StringBuffer sb = new StringBuffer();
         String outerClassName = "AMQP_" + (serverFlag ? "Server" : "Client") + (abstractMethodFlag ? "Operations" : "Proxy");
 		boolean first = true;
-		Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
-		while (mItr.hasNext())
+		for (String thisMethodName : thisClass.methodMap.keySet())
 		{
-			AmqpMethod method = thisClass.methodMap.get(mItr.next());
+			AmqpMethod method = thisClass.methodMap.get(thisMethodName);
 			boolean clientChassisFlag = method.clientMethodFlagMap.isSet();
 			boolean serverChassisFlag = method.serverMethodFlagMap.isSet();
 			if ((serverFlag && serverChassisFlag) || (!serverFlag && clientChassisFlag))
@@ -777,15 +773,13 @@
 				String methodName = parseForReservedWords(method.name, outerClassName + "." + thisClass.name);				
 				AmqpOverloadedParameterMap overloadededParameterMap =
 					method.getOverloadedParameterLists(thisClass.versionSet, this);
-				Iterator<AmqpOrdinalFieldMap> ofmItr = overloadededParameterMap.keySet().iterator();
-				while (ofmItr.hasNext())
+				for (AmqpOrdinalFieldMap thisFieldMap : overloadededParameterMap.keySet())
 				{
-					AmqpOrdinalFieldMap fieldMap = ofmItr.next();
-					AmqpVersionSet versionSet = overloadededParameterMap.get(fieldMap);
+					AmqpVersionSet versionSet = overloadededParameterMap.get(thisFieldMap);
 					if (!first)
 						sb.append(cr);
 					sb.append(indent + "virtual void " + methodName + "( u_int16_t channel");
-					sb.append(generateMethodParameterList(fieldMap, indentSize + (5*tabSize), true, true, true));
+					sb.append(generateMethodParameterList(thisFieldMap, indentSize + (5*tabSize), true, true, true));
 					sb.append(" )");
 					if (abstractMethodFlag)
 						sb.append(" = 0");
@@ -808,10 +802,9 @@
         String indent = Utils.createSpaces(indentSize);
         StringBuffer sb = new StringBuffer();
         String outerClassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Operations";
-        Iterator<String> cItr = model.classMap.keySet().iterator();
-        while (cItr.hasNext())
+        for (String thisClassName : model.classMap.keySet())
         {
-            AmqpClass thisClass = model.classMap.get(cItr.next());
+            AmqpClass thisClass = model.classMap.get(thisClassName);
             sb.append(indent + outerClassName + "::" + thisClass.name + "Handler* " +
                 thisClass.name + "HandlerPtr;" + cr);
         }
@@ -824,10 +817,9 @@
         String indent = Utils.createSpaces(indentSize);
         StringBuffer sb = new StringBuffer();
         String outerClassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Operations";
-        Iterator<String> cItr = model.classMap.keySet().iterator();
-        while (cItr.hasNext())
+        for (String thisClassName : model.classMap.keySet())
         {
-            AmqpClass thisClass = model.classMap.get(cItr.next());
+            AmqpClass thisClass = model.classMap.get(thisClassName);
             sb.append(indent + "virtual inline " + outerClassName + "::" + thisClass.name + "Handler* get" +
                 thisClass.name + "Handler() { return &" + Utils.firstLower(thisClass.name) + ";}" + cr);
         }
@@ -840,10 +832,9 @@
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
         String outerClassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Proxy";
-		Iterator<String> cItr = model.classMap.keySet().iterator();
-		while (cItr.hasNext())
+        for (String thisClassName : model.classMap.keySet())
 		{
-			AmqpClass thisClass = model.classMap.get(cItr.next());
+			AmqpClass thisClass = model.classMap.get(thisClassName);
 			String instanceName = parseForReservedWords(Utils.firstLower(thisClass.name), outerClassName);
 			String className = parseForReservedWords(thisClass.name, null);
 			sb.append(indent + className + " " + instanceName + ";");
@@ -861,10 +852,9 @@
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
         String outerClassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Proxy";
-		Iterator<String> cItr = model.classMap.keySet().iterator();
-		while (cItr.hasNext())
+        for (String thisClassName : model.classMap.keySet())
 		{
-			AmqpClass thisClass = model.classMap.get(cItr.next());
+			AmqpClass thisClass = model.classMap.get(thisClassName);
 			String className = parseForReservedWords(thisClass.name, outerClassName);
 			sb.append(indent + className + "& get" + className + "();");
 			if (thisClass.versionSet.size() != globalVersionSet.size())
@@ -879,14 +869,14 @@
 		int indentSize, int tabSize)
 		throws AmqpTypeMappingException
 	{
+		String proxyClassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Proxy";
 		String indent = Utils.createSpaces(indentSize);
 		String tab = Utils.createSpaces(tabSize);
 		StringBuffer sb = new StringBuffer();
 		boolean first = true;
-		Iterator<String> cItr = model.classMap.keySet().iterator();
-		while (cItr.hasNext())
+        for (String thisClassName : model.classMap.keySet())
 		{
-			AmqpClass thisClass = model.classMap.get(cItr.next());
+			AmqpClass thisClass = model.classMap.get(thisClassName);
 			String className = thisClass.name;
 			String superclassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Operations::" +
 				thisClass.name + "Handler";
@@ -902,15 +892,13 @@
 			sb.append(indent + "{" + cr);
 			sb.append(indent + "private:" + cr);
             sb.append(indent + tab + "OutputHandler* out;" + cr);
-			sb.append(indent + tab + "ProtocolVersion version;" + cr);
+			sb.append(indent + tab + proxyClassName + "* parent;" + cr);
 			sb.append(cr);
 			sb.append(indent + "public:" + cr);
 			sb.append(indent + tab + "// Constructors and destructors" + cr);
 			sb.append(cr);
-			sb.append(indent + tab + className + "(OutputHandler* out, u_int8_t major, u_int8_t minor) : " + cr);
-			sb.append(indent + tab + tab + "out(out), version(major, minor) {}" + cr);
-			sb.append(indent + tab + className + "(OutputHandler* out, ProtocolVersion version) : " + cr);
-			sb.append(indent + tab + tab + "out(out), version(version) {}" + cr);
+			sb.append(indent + tab + className + "(OutputHandler* out, " + proxyClassName + "* _parent) : " + cr);
+			sb.append(indent + tab + tab + "out(out) {parent = _parent;}" + cr);
 			sb.append(indent + tab + "virtual ~" + className + "() {}" + cr);
 			sb.append(cr);
 			sb.append(indent + tab + "// Protocol methods" + cr);
@@ -929,6 +917,7 @@
         String superclassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Operations";
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer(indent + superclassName + "(major, minor)," + cr);
+		sb.append(indent + "version(major, minor)," + cr);
         sb.append(indent + "out(out)");
 		Iterator<String> cItr = model.classMap.keySet().iterator();
 		while (cItr.hasNext())
@@ -936,7 +925,7 @@
 			AmqpClass thisClass = model.classMap.get(cItr.next());
 			String instanceName = parseForReservedWords(Utils.firstLower(thisClass.name), outerClassName);
 			sb.append("," + cr);
-			sb.append(indent + instanceName + "(out, major, minor)");
+			sb.append(indent + instanceName + "(out, this)");
 			if (!cItr.hasNext())
 				sb.append(cr);
 		}
@@ -980,10 +969,9 @@
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
 		boolean firstClassFlag = true;
-		Iterator<String> cItr = model.classMap.keySet().iterator();
-		while (cItr.hasNext())
+        for (String thisClassName : model.classMap.keySet())
 		{
-			AmqpClass thisClass = model.classMap.get(cItr.next());
+			AmqpClass thisClass = model.classMap.get(thisClassName);
 			String className = thisClass.name;
 			if (!firstClassFlag)
 				sb.append(cr);
@@ -1003,10 +991,9 @@
 		StringBuffer sb = new StringBuffer();
 		String outerclassName = "AMQP_" + (serverFlag ? "Server" : "Client") + "Proxy";
 		boolean first = true;
-		Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
-		while (mItr.hasNext())
+		for (String thisMethodName : thisClass.methodMap.keySet())
 		{
-			AmqpMethod method = thisClass.methodMap.get(mItr.next());
+			AmqpMethod method = thisClass.methodMap.get(thisMethodName);
 			String methodBodyClassName = thisClass.name + Utils.firstUpper(method.name) + "Body";
 			boolean clientChassisFlag = method.clientMethodFlagMap.isSet();
 			boolean serverChassisFlag = method.serverMethodFlagMap.isSet();
@@ -1016,22 +1003,20 @@
 				String methodName = parseForReservedWords(method.name, outerclassName + "." + thisClass.name);
 				AmqpOverloadedParameterMap overloadededParameterMap =
 					method.getOverloadedParameterLists(thisClass.versionSet, this);
-				Iterator<AmqpOrdinalFieldMap> ofmItr = overloadededParameterMap.keySet().iterator();
-				while (ofmItr.hasNext())
+				for (AmqpOrdinalFieldMap thisFieldMap : overloadededParameterMap.keySet())
 				{
-					AmqpOrdinalFieldMap fieldMap = ofmItr.next();
-					AmqpVersionSet versionSet = overloadededParameterMap.get(fieldMap);
+					AmqpVersionSet versionSet = overloadededParameterMap.get(thisFieldMap);
 					if (!first)
 						sb.append(cr);
 					sb.append(indent + "void " + outerclassName + "::" + thisClass.name + "::" +
                         methodName + "( u_int16_t channel");
-					sb.append(generateMethodParameterList(fieldMap, indentSize + (5*tabSize), true, true, true));
+					sb.append(generateMethodParameterList(thisFieldMap, indentSize + (5*tabSize), true, true, true));
 					sb.append(" )");
 					if (versionSet.size() != globalVersionSet.size())
 						sb.append(" // AMQP Version(s) " + versionSet);
 					sb.append(cr);
 					sb.append(indent + "{" + cr);
-					sb.append(generateMethodBodyCallContext(fieldMap, outerclassName, methodBodyClassName,
+					sb.append(generateMethodBodyCallContext(thisFieldMap, outerclassName, methodBodyClassName,
                         versionConsistentFlag, versionSet, indentSize + tabSize, tabSize));
 					sb.append(indent + "}" + cr);
 					sb.append(cr);
@@ -1057,16 +1042,14 @@
 		else
 		{
 			boolean firstOverloadedMethodFlag = true;
-			Iterator<AmqpVersion> vItr = versionSet.iterator();
-			while (vItr.hasNext())
+			for (AmqpVersion thisVersion : versionSet)
 			{
-				AmqpVersion version = vItr.next();
 				sb.append(indent);
 				if (!firstOverloadedMethodFlag)
 					sb.append("else ");
-				sb.append("if (" + generateVersionCheck(version) + ")" + cr);
+				sb.append("if (" + generateVersionCheck(thisVersion) + ")" + cr);
 				sb.append(indent + "{" + cr);
-				sb.append(generateMethodBodyCall(fieldMap, methodBodyClassName, version,
+				sb.append(generateMethodBodyCall(fieldMap, methodBodyClassName, thisVersion,
 					indentSize + tabSize, tabSize));
 				sb.append(indent + "}" + cr);
 				firstOverloadedMethodFlag = false;
@@ -1091,7 +1074,7 @@
 		String tab = Utils.createSpaces(tabSize);
 		String namespace = version != null ? version.namespace() + "::" : "";
 		StringBuffer sb = new StringBuffer(indent + "out->send( new AMQFrame( channel," + cr);
-		sb.append(indent + tab + "new " + namespace + methodBodyClassName + "( version");
+		sb.append(indent + tab + "new " + namespace + methodBodyClassName + "( parent->getProtocolVersion()");
 		sb.append(generateMethodParameterList(fieldMap, indentSize + (5*tabSize), true, false, true));
 		sb.append(" )));" + cr);	
 		return sb.toString();		
@@ -1106,10 +1089,9 @@
         }
         else
         {
-            Iterator<String> cItr = model.classMap.keySet().iterator();
-            while (cItr.hasNext())
+        	for (String thisClassName : model.classMap.keySet())
             {
-                thisClass = model.classMap.get(cItr.next());
+                thisClass = model.classMap.get(thisClassName);
                 sb.append(generateClassMethodBodyInclude(thisClass, indentSize));
            }
         }
@@ -1120,10 +1102,9 @@
     {
         StringBuffer sb = new StringBuffer();
         String indent = Utils.createSpaces(indentSize);
-        Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
-        while (mItr.hasNext())
+        for (String thisMethodName : thisClass.methodMap.keySet())
         {
-            AmqpMethod method = thisClass.methodMap.get(mItr.next());
+            AmqpMethod method = thisClass.methodMap.get(thisMethodName);
             sb.append(indent + "#include <" + thisClass.name +
                 Utils.firstUpper(method.name) + "Body.h>" + cr);
         }
@@ -1135,13 +1116,11 @@
 	protected String getIndex(AmqpOrdinalVersionMap indexMap, AmqpVersion version)
 		throws AmqpTemplateException
 	{
-		Iterator<Integer> iItr = indexMap.keySet().iterator();
-		while (iItr.hasNext())
+		for (Integer thisIndex : indexMap.keySet())
 		{
-			int index = iItr.next();
-			AmqpVersionSet versionSet = indexMap.get(index);
+			AmqpVersionSet versionSet = indexMap.get(thisIndex);
 			if (versionSet.contains(version))
-				return String.valueOf(index);
+				return String.valueOf(thisIndex);			
 		}
 		throw new AmqpTemplateException("Unable to find index for version " + version); 
 	}
@@ -1155,38 +1134,11 @@
         if (version == null)
             version = globalVersionSet.first();
         AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, true, this);
-        Iterator<Integer> oItr = ordinalFieldMap.keySet().iterator();
-        while (oItr.hasNext())
+        for (Integer thisOrdinal : ordinalFieldMap.keySet())
         {
-            String[] fieldDomainPair = ordinalFieldMap.get(oItr.next());
-            sb.append(indent + fieldDomainPair[FIELD_DOMAIN] + " " + fieldDomainPair[FIELD_NAME] + ";" + cr);
+            String[] fieldDomainPair = ordinalFieldMap.get(thisOrdinal);
+            sb.append(indent + fieldDomainPair[FIELD_CODE_TYPE] + " " + fieldDomainPair[FIELD_NAME] + ";" + cr);        	
         }
-        // TODO: Replace the pattern below with that above in the JavaGenerator and elsewhere here.
-//		Iterator<String> fItr = fieldMap.keySet().iterator();
-//		while(fItr.hasNext())
-//		{
-//			AmqpField fieldDetails = fieldMap.get(fItr.next());
-//			if (version == null) // Version consistent - there *should* be only one domain
-//			{
-//				String domainName =  fieldDetails.domainMap.firstKey();
-//				String codeType = getGeneratedType(domainName, globalVersionSet.first());
-//				sb.append(indent + codeType + " " + fieldDetails.name + ";" + cr);
-//			}
-//			else
-//			{
-//				Iterator<String> dItr = fieldDetails.domainMap.keySet().iterator();
-//				while (dItr.hasNext())
-//				{
-//					String domainName = dItr.next();
-//					AmqpVersionSet versionSet = fieldDetails.domainMap.get(domainName);
-//					if (versionSet.contains(version))
-//					{
-//						String codeType = getGeneratedType(domainName, version);
-//						sb.append(indent + codeType + " " + fieldDetails.name + ";" + cr);
-//					}
-//				}
-//			}
-//		}
 		return sb.toString();
 	}
 	
@@ -1195,35 +1147,17 @@
 	{
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
-		Iterator<String> fItr = fieldMap.keySet().iterator();
-		while(fItr.hasNext())
-		{
-			AmqpField fieldDetails = fieldMap.get(fItr.next());
-			if (version == null) // Version consistent - there *should* be only one domain
-			{
-				String domainName =  fieldDetails.domainMap.firstKey();
-				String codeType = getGeneratedType(domainName, globalVersionSet.first());
-				sb.append(indent + "inline " + setRef(codeType) + " get" +
-					Utils.firstUpper(fieldDetails.name) + "() { return " +
-					fieldDetails.name + "; }" + cr);
-			}
-			else
-			{
-				Iterator<String> dItr = fieldDetails.domainMap.keySet().iterator();
-				while (dItr.hasNext())
-				{
-					String domainName = dItr.next();
-					AmqpVersionSet versionSet = fieldDetails.domainMap.get(domainName);
-					if (versionSet.contains(version))
-					{
-						String codeType = getGeneratedType(domainName, version);
-						sb.append(indent + "inline " + setRef(codeType) + " get" +
-								Utils.firstUpper(fieldDetails.name) + "() { return " +
-								fieldDetails.name + "; }" + cr);
-					}
-				}
-			}
-		}
+		
+        if (version == null)
+            version = globalVersionSet.first();
+        AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, true, this);
+        for (Integer thisOrdinal : ordinalFieldMap.keySet())
+        {
+            String[] fieldDomainPair = ordinalFieldMap.get(thisOrdinal);
+			sb.append(indent + "inline " + setRef(fieldDomainPair[FIELD_CODE_TYPE]) + " get" +
+				Utils.firstUpper(fieldDomainPair[FIELD_NAME]) + "() { return " +
+				fieldDomainPair[FIELD_NAME] + "; }" + cr);
+        }
 		return sb.toString();
 	}
 	
@@ -1232,42 +1166,21 @@
 	{
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
-		Iterator<String> fItr = fieldMap.keySet().iterator();
-		boolean firstFlag = true;
-		while(fItr.hasNext())
-		{
-			AmqpField fieldDetails = fieldMap.get(fItr.next());
-            if (version == null) // Version consistent - there *should* be only one domain
-            {
-                String domainName =  fieldDetails.domainMap.firstKey();
-                String codeType = getGeneratedType(domainName, globalVersionSet.first());
-                String cast = codeType.compareTo("u_int8_t") == 0 ? "(int)" : "";
-                sb.append(indent + "out << \"");
-                if (!firstFlag)
-                    sb.append("; ");
-                sb.append(fieldDetails.name + "=\" << " + cast + fieldDetails.name + ";" + cr);
-               firstFlag = false;
-            }
-            else
-            {
-                Iterator<String> dItr = fieldDetails.domainMap.keySet().iterator();
-                while (dItr.hasNext())
-                {
-                    String domainName = dItr.next();
-                    AmqpVersionSet versionSet = fieldDetails.domainMap.get(domainName);
-                    if (versionSet.contains(version))
-                    {
-                        String codeType = getGeneratedType(domainName, version);
-                        String cast = codeType.compareTo("u_int8_t") == 0 ? "(int)" : "";
-                        sb.append(indent + "out << \"");
-                        if (!firstFlag)
-                            sb.append("; ");
-                        sb.append(fieldDetails.name + "=\" << " + cast + fieldDetails.name + ";" + cr);                    
-                        firstFlag = false;
-                    }
-                }
-            }
-		}
+		
+        if (version == null)
+            version = globalVersionSet.first();
+        AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, true, this);
+        boolean firstFlag = true;
+        for (Integer thisOrdinal : ordinalFieldMap.keySet())
+        {
+            String[] fieldDomainPair = ordinalFieldMap.get(thisOrdinal);
+            String cast = fieldDomainPair[FIELD_CODE_TYPE].compareTo("u_int8_t") == 0 ? "(int)" : "";
+            sb.append(indent + "out << \"");
+            if (!firstFlag)
+                sb.append("; ");
+            sb.append(fieldDomainPair[FIELD_NAME] + "=\" << " + cast + fieldDomainPair[FIELD_NAME] + ";" + cr);
+            firstFlag = false;
+        }
 		return sb.toString();		
 	}
 	
@@ -1286,7 +1199,7 @@
 			ordinal = oItr.next();
 			String[] fieldDomainPair = ordinalFieldMap.get(ordinal);
 			AmqpVersion thisVersion = version == null ? globalVersionSet.first() : version;
-			String domainType = getDomainType(fieldDomainPair[FIELD_DOMAIN], thisVersion);
+			String domainType = getDomainType(fieldDomainPair[FIELD_CODE_TYPE], thisVersion);
 			
 			// Defer bit types by adding them to an array. When the first subsequent non-bit
 			// type is encountered, then handle the bits. This allows consecutive bits to be
@@ -1345,7 +1258,7 @@
 			ordinal = oItr.next();
 			String[] fieldDomainPair = ordinalFieldMap.get(ordinal);
 			AmqpVersion thisVersion = version == null ? globalVersionSet.first() : version;
-			String domainType = getDomainType(fieldDomainPair[FIELD_DOMAIN], thisVersion);
+			String domainType = getDomainType(fieldDomainPair[FIELD_CODE_TYPE], thisVersion);
 			
 			// Defer bit types by adding them to an array. When the first subsequent non-bit
 			// type is encountered, then handle the bits. This allows consecutive bits to be
@@ -1413,7 +1326,7 @@
 			ordinal = oItr.next();
 			String[] fieldDomainPair = ordinalFieldMap.get(ordinal);
 			AmqpVersion thisVersion = version == null ? globalVersionSet.first() : version;
-			String domainType = getDomainType(fieldDomainPair[FIELD_DOMAIN], thisVersion);
+			String domainType = getDomainType(fieldDomainPair[FIELD_CODE_TYPE], thisVersion);
 			
 			// Defer bit types by adding them to an array. When the first subsequent non-bit
 			// type is encountered, then handle the bits. This allows consecutive bits to be
@@ -1477,7 +1390,7 @@
 		{
 			int ordinal = oItr.next();
 			String[] fieldDomainPair = ordinalFieldMap.get(ordinal);
-			sb.append(indent + (defineFlag ? setRef(fieldDomainPair[FIELD_DOMAIN]) + " " : "") +
+			sb.append(indent + (defineFlag ? setRef(fieldDomainPair[FIELD_CODE_TYPE]) + " " : "") +
 				fieldDomainPair[FIELD_NAME] + (initializerFlag ? "(" + fieldDomainPair[FIELD_NAME] + ")" : "") +
 				(oItr.hasNext() ? "," : "") + cr);
 		}
@@ -1504,7 +1417,7 @@
 				sb.append(indent);
 			}
 			sb.append(
-                (fieldTypeFlag ? setRef(field[FIELD_DOMAIN]) : "") +
+                (fieldTypeFlag ? setRef(field[FIELD_CODE_TYPE]) : "") +
 				(fieldNameFlag ? " " + field[FIELD_NAME] : "") +
 				(pItr.hasNext() ? "," + (fieldNameFlag ? cr : " ") : ""));
 			first = false;
@@ -1521,7 +1434,7 @@
         StringBuffer sb = new StringBuffer();
         if (method.fieldMap.size() > 0)
         {
-            sb.append(indent + thisClass.name + Utils.firstUpper(method.name) + "Body(ProtocolVersion version," + cr);
+            sb.append(indent + thisClass.name + Utils.firstUpper(method.name) + "Body(ProtocolVersion& version," + cr);
             sb.append(generateFieldList(method.fieldMap, version, true, false, 8));
             sb.append(indent + tab + ") :" + cr);
             sb.append(indent + tab + "AMQMethodBody(version)," + cr);
@@ -1573,14 +1486,12 @@
         String indent = Utils.createSpaces(indentSize);
         StringBuffer sb = new StringBuffer();
         
-        Iterator<String> cItr = model.classMap.keySet().iterator();
-        while (cItr.hasNext())
+        for (String thisClassName : model.classMap.keySet())
         {
-            AmqpClass thisClass = model.classMap.get(cItr.next());
-            Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
-            while (mItr.hasNext())
+            AmqpClass thisClass = model.classMap.get(thisClassName);
+            for (String thisMethodName : thisClass.methodMap.keySet())
             {
-                AmqpMethod method = thisClass.methodMap.get(mItr.next());
+                AmqpMethod method = thisClass.methodMap.get(thisMethodName);
                 sb.append(indent + "#include \"" + thisClass.name + Utils.firstUpper(method.name) + "Body.h\"" + cr);
             }
         }
@@ -1593,14 +1504,12 @@
         String indent = Utils.createSpaces(indentSize);
         StringBuffer sb = new StringBuffer();
         
-        Iterator<String> cItr = model.classMap.keySet().iterator();
-        while (cItr.hasNext())
+        for (String thisClassName : model.classMap.keySet())
         {
-            AmqpClass thisClass = model.classMap.get(cItr.next());
-            Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
-            while (mItr.hasNext())
+            AmqpClass thisClass = model.classMap.get(thisClassName);
+            for (String thisMethodName : thisClass.methodMap.keySet())
             {
-                AmqpMethod method = thisClass.methodMap.get(mItr.next());
+                AmqpMethod method = thisClass.methodMap.get(thisMethodName);
                 sb.append(indent + "const " + thisClass.name + Utils.firstUpper(method.name) + "Body " +
                     Utils.firstLower(thisClass.name) + "_" + method.name + ";" + cr);
             }
@@ -1617,14 +1526,12 @@
         
         for (AmqpVersion version : globalVersionSet)
         {
-            Iterator<String> cItr = model.classMap.keySet().iterator();
-            while (cItr.hasNext())
+            for (String thisClassName : model.classMap.keySet())
             {
-                AmqpClass thisClass = model.classMap.get(cItr.next());
-                Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
-                while (mItr.hasNext())
+                AmqpClass thisClass = model.classMap.get(thisClassName);
+                for (String thisMethodName : thisClass.methodMap.keySet())
                 {
-                    AmqpMethod method = thisClass.methodMap.get(mItr.next());
+                    AmqpMethod method = thisClass.methodMap.get(thisMethodName);
                     String namespace = method.isVersionConsistent(globalVersionSet) ? "" : version.namespace() + "::";
                     try
                     {

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Generator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Generator.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Generator.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Generator.java Tue Jan 16 07:16:39 2007
@@ -28,7 +28,6 @@
 import java.io.LineNumberReader;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
-import java.util.Iterator;
 
 public abstract class Generator implements LanguageConverter
 {
@@ -185,38 +184,29 @@
 		}
 		
 		// Cycle through classes
-		Iterator<String> citr = model.classMap.keySet().iterator();
-		while (citr.hasNext())
+		for (String className : model.classMap.keySet())
 		{
-			String className = citr.next();
 			AmqpClass thisClass = model.classMap.get(className);
-			
 			// Use all class-level templates
 			for (String[] ct : classTemplateList)
 			{
 				processTemplateB(ct, thisClass);
 			}
-			
+
 			// Cycle through all methods
-			Iterator<String> mitr = thisClass.methodMap.keySet().iterator();
-			while (mitr.hasNext())
+			for (String methodName : thisClass.methodMap.keySet())
 			{
-				String methodName = mitr.next();
 				AmqpMethod method = thisClass.methodMap.get(methodName);
-				
 				// Use all method-level templates
 				for (String[] mt : methodTemplateList)
 				{
 					processTemplateC(mt, thisClass, method);
 				}
-				
+
 				// Cycle through all fields
-				Iterator<String> fitr = method.fieldMap.keySet().iterator();
-				while (fitr.hasNext())
+				for (String fieldName : method.fieldMap.keySet())
 				{
-					String fieldName = fitr.next();
 					AmqpField field = method.fieldMap.get(fieldName);
-					
 					// Use all field-level templates
 					for (String[] ft : fieldTemplateList)
 					{

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/JavaGenerator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/JavaGenerator.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/JavaGenerator.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/JavaGenerator.java Tue Jan 16 07:16:39 2007
@@ -30,6 +30,10 @@
 
 public class JavaGenerator extends Generator
 {
+	// TODO: Move this to parent class
+	protected static final int FIELD_NAME = 0;
+	protected static final int FIELD_CODE_TYPE = 1;
+	
 	private class DomainInfo
 	{
 		public String type;
@@ -301,15 +305,15 @@
 			"buffer.putLong(#)", 							// encode expression
 			"# = buffer.getLong()")); 						// decode expression
 		typeMap.put("longstr", new DomainInfo(
-			"String",										// Java code type
-			"EncodingUtils.encodedLongStringLength(#)", 	// size
+			"byte[]",										// Java code type
+			"EncodingUtils.encodedLongstrLength(#)", 		// size
 			"EncodingUtils.writeLongStringBytes(buffer, #)", // encode expression
-			"# = EncodingUtils.readLongString(buffer)"));	// decode expression
+			"# = EncodingUtils.readLongstr(buffer)"));		// decode expression
 		typeMap.put("octet", new DomainInfo(
-			"char",											// Java code type
+			"short",										// Java code type
 			"1",											// size
-			"buffer.putChar(#)",								// encode expression
-			"# = buffer.getChar()")); 							// decode expression
+			"EncodingUtils.writeUnsignedByte(buffer, #)",	// encode expression
+			"# = buffer.getUnsigned()")); 					// decode expression
 		typeMap.put("short", new DomainInfo(
 			"int",											// Java code type
 			"2",											// size
@@ -428,20 +432,20 @@
 	}
 	
 	protected void processTemplate(StringBuffer sb, AmqpClass thisClass, AmqpMethod method,
-			AmqpField field, String templateFileName, AmqpVersion version)
-			throws InvocationTargetException, IllegalAccessException, AmqpTypeMappingException
+		AmqpField field, String templateFileName, AmqpVersion version)
+		throws InvocationTargetException, IllegalAccessException, AmqpTypeMappingException
+	{
+		try { processAllLists(sb, thisClass, method, version); }
+		catch (AmqpTemplateException e)
 		{
-			try { processAllLists(sb, thisClass, method, version); }
-			catch (AmqpTemplateException e)
-			{
-				System.out.println("WARNING: " + templateFileName + ": " + e.getMessage());
-			}
-			try { processAllTokens(sb, thisClass, method, field, version); }
-			catch (AmqpTemplateException e)
-			{
-				System.out.println("WARNING: " + templateFileName + ": " + e.getMessage());
-			}
+			System.out.println("WARNING: " + templateFileName + ": " + e.getMessage());
+		}
+		try { processAllTokens(sb, thisClass, method, field, version); }
+		catch (AmqpTemplateException e)
+		{
+			System.out.println("WARNING: " + templateFileName + ": " + e.getMessage());
 		}
+	}
 
 	@Override
 	protected String processToken(String token, AmqpClass thisClass, AmqpMethod method, AmqpField field,
@@ -562,8 +566,10 @@
 		}
 		else if (token.compareTo("${mb_field_parameter_list}") == 0)
 		{
-			// This is klunky... (cringe) TODO: Find a more elegant solution here sometime...
+			// <cringe> The code generated by this is ugly... It puts a comma on a line by itself!
+			// TODO: Find a more elegant solution here sometime...
 			codeSnippet = fieldMap.size() > 0 ? Utils.createSpaces(42) + "," + cr : "";
+			// </cringe>
 			codeSnippet += fieldMap.parseFieldMap(mbParamListGenerateMethod,
 				mbMangledParamListGenerateMethod, 42, 4, this);
 		}
@@ -727,55 +733,27 @@
 		String tab = Utils.createSpaces(tabSize);
 		StringBuffer sb = new StringBuffer();
 		
-		Iterator<String> cItr = model.classMap.keySet().iterator();
-		while (cItr.hasNext())
+		for (String className : model.classMap.keySet())
 		{
-			AmqpClass thisClass = model.classMap.get(cItr.next());
-			AmqpVersionSet firstVersionSet = thisClass.indexMap.get(thisClass.indexMap.firstKey());
-			boolean classVersionConsistentFlag = firstVersionSet.equals(globalVersionSet);
-			Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
-			while (mItr.hasNext())
+			AmqpClass thisClass = model.classMap.get(className);
+			for (String methodName : thisClass.methodMap.keySet())
 			{
-				AmqpMethod method = thisClass.methodMap.get(mItr.next());
-				firstVersionSet = method.indexMap.get(method.indexMap.firstKey());
-				boolean methodVersionConsistentFlag = firstVersionSet.equals(globalVersionSet);
-				if (classVersionConsistentFlag && methodVersionConsistentFlag)
-				{
-					// Both class and method with consistent indeces for all known versions
-					int classIndex = thisClass.indexMap.firstKey();
-					int methodIndex = method.indexMap.firstKey();
-					sb.append(indent + "map.put(" + classIndex + "*1000 + " + methodIndex +
-						", " + thisClass.name + Utils.firstUpper(method.name) + "Body.class);" + cr);
-				}
-				else
+				AmqpMethod method = thisClass.methodMap.get(methodName);
+				for (AmqpVersion version : globalVersionSet)
 				{
-					// Non-consistent indeces for all known versions - version-specific code required
-					sb.append(cr);
-					
-					Iterator<AmqpVersion> vItr = globalVersionSet.iterator();
-					while (vItr.hasNext())
+					// Find class and method index for this version (if it exists)
+					try
 					{
-						boolean first = true;
-						AmqpVersion version = vItr.next();
-						
-						// Find class and method index for this version (if it exists)
-						try
-						{
-							int classIndex = findIndex(thisClass.indexMap, version);
-							int methodIndex = findIndex(method.indexMap, version);
-							sb.append(indent);
-							if (!first)
-								sb.append("else ");
-							sb.append("if ( major == " + version.getMajor() + " && minor == " +
-								version.getMinor() + " )" + cr);
-							sb.append(indent + tab + "map.put(" + classIndex + "*1000 + " +
-								methodIndex + ", " + thisClass.name + Utils.firstUpper(method.name) +
-								"Body.class);" + cr);
-							first = false;
-						}
-						catch (Exception e) {} // Ignore
+						int classIndex = findIndex(thisClass.indexMap, version);
+						int methodIndex = findIndex(method.indexMap, version);
+						sb.append(indent + "classIDMethodIDVersionBodyMap.put(" + cr);
+						sb.append(indent + tab + "createMapKey((short)" + classIndex +
+								", (short)" + methodIndex + ", (byte)" + version.getMajor() +
+								", (byte)" + version.getMinor() + "), " + cr);
+						sb.append(indent + tab + Utils.firstUpper(thisClass.name) +
+								Utils.firstUpper(method.name) + "Body.class);" + cr);
 					}
-					sb.append(cr);
+					catch (Exception e) {} // Ignore
 				}
 			}
 		}

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Main.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Main.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Main.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Main.java Tue Jan 16 07:16:39 2007
@@ -174,7 +174,7 @@
         };
         classTemplateFiles = new File[]
         {
-            new File(tmplDir + Utils.fileSeparator + "PropertyContentHeaderClass.tmpl")
+//            new File(tmplDir + Utils.fileSeparator + "PropertyContentHeaderClass.tmpl")
         };
         methodTemplateFiles = new File[]
         {
@@ -202,7 +202,7 @@
             new File(tmplDir + Utils.fileSeparator + "AMQP_Constants.h.tmpl"),
             new File(tmplDir + Utils.fileSeparator + "AMQP_MethodVersionMap.h.tmpl"),
             new File(tmplDir + Utils.fileSeparator + "AMQP_MethodVersionMap.cpp.tmpl"),
-           new File(tmplDir + Utils.fileSeparator + "AMQP_HighestVersion.cpp.tmpl")
+           new File(tmplDir + Utils.fileSeparator + "AMQP_HighestVersion.h.tmpl")
         };
         methodTemplateFiles = new File[]
         {
@@ -261,19 +261,30 @@
     
 	public static void main(String[] args)
 	{
+		int exitCode = 1;
 		// TODO: This is a simple and klunky way of hangling command-line args, and could be improved upon.
 		if (args.length < 2)
+		{
 			usage();
-		try { new Main().run(args); }
-		catch (IOException e) { e.printStackTrace(); }
-		catch (ParserConfigurationException e) { e.printStackTrace(); }
-		catch (SAXException e) { e.printStackTrace(); }
-		catch (AmqpParseException e) { e.printStackTrace(); }
-		catch (AmqpTypeMappingException e) { e.printStackTrace(); }
-		catch (AmqpTemplateException e) { e.printStackTrace(); }
-		catch (TargetDirectoryException e) { e.printStackTrace(); }
-		catch (IllegalAccessException e) { e.printStackTrace(); }
-		catch (InvocationTargetException e) { e.printStackTrace(); }
+		}
+		else
+		{
+			try
+			{
+				new Main().run(args);
+				exitCode = 0;
+			}
+			catch (IOException e) { e.printStackTrace(); }
+			catch (ParserConfigurationException e) { e.printStackTrace(); }
+			catch (SAXException e) { e.printStackTrace(); }
+			catch (AmqpParseException e) { e.printStackTrace(); }
+			catch (AmqpTypeMappingException e) { e.printStackTrace(); }
+			catch (AmqpTemplateException e) { e.printStackTrace(); }
+			catch (TargetDirectoryException e) { e.printStackTrace(); }
+			catch (IllegalAccessException e) { e.printStackTrace(); }
+			catch (InvocationTargetException e) { e.printStackTrace(); }
+		}
+		System.exit(exitCode);
 	}
 
 	public static void usage()
@@ -287,7 +298,6 @@
         System.out.println("                         Defaults: \"" + defaultCppTemplateDir + "\" for C++;");
         System.out.println("                                   \"" + defaultJavaTemplateDir + "\" for java.");
 		System.out.println("             XMLfile is a space-separated list of AMQP XML files to be parsed.");
-		System.exit(0);
 	}
 	
 	public static String ListTemplateList(File[] list)

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/NodeAware.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/NodeAware.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/NodeAware.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/NodeAware.java Tue Jan 16 07:16:39 2007
@@ -39,7 +39,8 @@
 	 * @param v Verion of the DOM from which the node comes.
 	 * @throws AmqpParseException
 	 * @throws AmqpTypeMappingException
+	 * @returns true if a node was added, false if not
 	 */
-	public void addFromNode(Node n, int o, AmqpVersion v)
+	public boolean addFromNode(Node n, int o, AmqpVersion v)
 		throws AmqpParseException, AmqpTypeMappingException;
 }

Modified: incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Utils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Utils.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Utils.java (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/src/org/apache/qpid/gentools/Utils.java Tue Jan 16 07:16:39 2007
@@ -46,6 +46,7 @@
 	public final static String ELEMENT_AMQP = "amqp";
 	public final static String ELEMENT_CHASSIS = "chassis";
 	public final static String ELEMENT_CLASS = "class";
+	public final static String ELEMENT_CODEGEN = "codegen";
     public final static String ELEMENT_CONSTANT = "constant";
 	public final static String ELEMENT_DOMAIN = "domain";
 	public final static String ELEMENT_METHOD = "method";

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl Tue Jan 16 07:16:39 2007
@@ -38,6 +38,8 @@
 namespace qpid {
 namespace framing {
 
+class AMQP_ClientProxy;
+
 class AMQP_ClientOperations
 {
 protected:
@@ -46,7 +48,7 @@
 
 public:
     AMQP_ClientOperations(u_int8_t major, u_int8_t minor) : version(major, minor) {}
-    AMQP_ClientOperations(ProtocolVersion version) : version(version) {}
+    AMQP_ClientOperations(ProtocolVersion& version) : version(version) {}
     virtual ~AMQP_ClientOperations() {}
 
     inline u_int8_t getMajor() const { return version.getMajor(); }

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl Tue Jan 16 07:16:39 2007
@@ -37,6 +37,7 @@
 
 AMQP_ClientProxy::AMQP_ClientProxy(OutputHandler* out, u_int8_t major, u_int8_t minor) :
 %{CLIST} ${cpc_constructor_initializer}
+        
 {}
 
 	// Inner class instance get methods

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl Tue Jan 16 07:16:39 2007
@@ -36,14 +36,17 @@
 namespace qpid {
 namespace framing {
 
-class AMQP_ClientProxy : virtual public AMQP_ClientOperations
+class AMQP_ClientProxy : public AMQP_ClientOperations
 {
 private:
+    
+    ProtocolVersion version;
     OutputHandler* out;
 %{CLIST} ${cph_handler_pointer_defn}
 
 public:
     AMQP_ClientProxy(OutputHandler* out, u_int8_t major, u_int8_t minor);
+    ProtocolVersion& getProtocolVersion() {return version;}
     virtual ~AMQP_ClientProxy() {}
 
 	// Get methods for handlers

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl Tue Jan 16 07:16:39 2007
@@ -38,6 +38,9 @@
 namespace qpid {
 namespace framing {
 
+class AMQP_ServerProxy;
+class AMQP_ClientProxy;
+
 class AMQP_ServerOperations
 {
 protected:
@@ -46,7 +49,7 @@
 
 public:
     AMQP_ServerOperations(u_int8_t major, u_int8_t minor) : version(major, minor) {}
-    AMQP_ServerOperations(ProtocolVersion version) : version(version) {}
+    AMQP_ServerOperations(ProtocolVersion& version) : version(version) {}
     virtual ~AMQP_ServerOperations() {}
 
     inline u_int8_t getMajor() const { return version.getMajor(); }

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl Tue Jan 16 07:16:39 2007
@@ -36,14 +36,16 @@
 namespace qpid {
 namespace framing {
 
-class AMQP_ServerProxy : virtual public AMQP_ServerOperations
+class AMQP_ServerProxy : public AMQP_ServerOperations
 {
 private:
+    ProtocolVersion version;
     OutputHandler* out;
 %{CLIST} ${sph_handler_pointer_defn}
 
 public:
     AMQP_ServerProxy(OutputHandler* out, u_int8_t major, u_int8_t minor);
+    ProtocolVersion& getProtocolVersion() {return version;}
     virtual ~AMQP_ServerProxy() {}
 
 	// Get methods for handlers

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/MethodBodyClass.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/MethodBodyClass.h.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/MethodBodyClass.h.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.cpp/MethodBodyClass.h.tmpl Tue Jan 16 07:16:39 2007
@@ -43,7 +43,7 @@
 {
 ${version_namespace_start}
  
-class ${CLASS}${METHOD}Body : virtual public AMQMethodBody
+class ${CLASS}${METHOD}Body : public AMQMethodBody
 {
 	// Method field declarations
 
@@ -58,7 +58,7 @@
 ${mb_constructor_with_initializers}
 
     inline ${CLASS}${METHOD}Body(u_int8_t major, u_int8_t minor): AMQMethodBody(major, minor) {}
-    inline ${CLASS}${METHOD}Body(ProtocolVersion version): AMQMethodBody(version) {}
+    inline ${CLASS}${METHOD}Body(ProtocolVersion& version): AMQMethodBody(version) {}
     virtual ~${CLASS}${METHOD}Body() {}
     
     // Attribute get methods

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.java/MethodBodyClass.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.java/MethodBodyClass.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.java/MethodBodyClass.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.java/MethodBodyClass.tmpl Tue Jan 16 07:16:39 2007
@@ -54,6 +54,8 @@
 
     public int getClazz() { return classIdMap.get(major + "-" + minor); }
     public int getMethod() { return methodIdMap.get(major + "-" + minor); }
+    public static int getClazz(byte major, byte minor) { return classIdMap.get(major + "-" + minor); }
+    public static int getMethod(byte major, byte minor) { return methodIdMap.get(major + "-" + minor); }
     
     // Field methods		
 %{FLIST}    ${mb_field_get_method}
@@ -82,7 +84,7 @@
         return buf.toString();
     }
 
-    public static AMQFrame createAMQFrame(int channelId, byte major, byte minor
+    public static AMQFrame createAMQFrame(int _channelId, byte major, byte minor
 %{FLIST}    ${mb_field_parameter_list}
                                          )
     {
@@ -90,7 +92,7 @@
 %{FLIST}    ${mb_field_body_initialize}
         		 
         AMQFrame frame = new AMQFrame();
-        frame.channel = channelId;
+        frame.channel = _channelId;
         frame.bodyFrame = body;
         return frame;
     }

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.java/MethodRegistryClass.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.java/MethodRegistryClass.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.java/MethodRegistryClass.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.java/MethodRegistryClass.tmpl Tue Jan 16 07:16:39 2007
@@ -28,12 +28,53 @@
  
 package org.apache.qpid.framing;
 
-import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Constructor;
+import org.apache.log4j.Logger;
 
 class MainRegistry
 {
-    static void register(Map map, byte major, byte minor)
+    private static final Logger _log = Logger.getLogger(MainRegistry.class);
+	private static HashMap<Long, Class> classIDMethodIDVersionBodyMap = new HashMap<Long, Class>();
+	
+    static
     {
 %{CLIST}	${reg_map_put_method}
+    }
+    
+    public static AMQMethodBody get(short classID, short methodID, byte major, byte minor)
+        throws AMQFrameDecodingException
+    {
+		Class bodyClass = classIDMethodIDVersionBodyMap.get(
+		    createMapKey(classID, methodID, major, minor));
+		if (bodyClass == null)
+		{
+	    	throw new AMQFrameDecodingException(_log,
+	    	    "Unable to find a suitable decoder for class " + classID + " and method " +
+	    	    methodID + " in AMQP version " + major + "-" + minor + ".");
+	    }
+	    try
+	    {
+	    	Constructor initFn = bodyClass.getConstructor(byte.class, byte.class);
+	        return (AMQMethodBody) initFn.newInstance(major, minor);
+	    }
+	    catch (Exception e)
+	    {
+	    	throw new AMQFrameDecodingException(_log,
+	    	    "Unable to instantiate body class for class " + classID + " and method " +
+	    	    methodID + " in AMQP version " + major + "-" + minor + " : " + e, e);
+	    }
+    }
+    
+    private static Long createMapKey(short classID, short methodID, byte major, byte minor)
+    {
+    	/**
+         *	Mapping of 4 components into a guaranteed unique key:
+         *  MSB                                     LSB
+         *  +----+----+----+----+----+----+-----+-----+
+         *  |    0    | classID |methodID |major|minor|
+         *  +----+----+----+----+----+----+-----+-----+
+         */
+    	return new Long(((long)classID << 32) + ((long)methodID << 16) + ((long)major << 8) + minor);
     }
 }

Modified: incubator/qpid/branches/perftesting/qpid/gentools/templ.java/PropertyContentHeaderClass.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/gentools/templ.java/PropertyContentHeaderClass.tmpl?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/gentools/templ.java/PropertyContentHeaderClass.tmpl (original)
+++ incubator/qpid/branches/perftesting/qpid/gentools/templ.java/PropertyContentHeaderClass.tmpl Tue Jan 16 07:16:39 2007
@@ -1,4 +1,4 @@
-&{${CLASS}PropertyContentHeader.java}
+&{${CLASS}ContentHeaderProperties.java}
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -31,7 +31,7 @@
 import org.apache.log4j.Logger;
 import org.apache.mina.common.ByteBuffer;
 
-class ${CLASS}ContentHeaderProperties implements ContentHeaderProperties
+public class ${CLASS}ContentHeaderProperties implements ContentHeaderProperties
 {
     private static final Logger logger = Logger.getLogger(BasicContentHeaderProperties.class);
 

Modified: incubator/qpid/branches/perftesting/qpid/java/broker/etc/config.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/java/broker/etc/config.xml?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/java/broker/etc/config.xml (original)
+++ incubator/qpid/branches/perftesting/qpid/java/broker/etc/config.xml Tue Jan 16 07:16:39 2007
@@ -69,7 +69,7 @@
                         <class>org.apache.qpid.server.security.auth.amqplain.AmqPlainInitialiser</class>
                         <principal-database>passwordfile</principal-database>
                     </initialiser>
-                </mechanism>-->
+                </mechanism>
                 <mechanism>
                     <initialiser>
                         <class>org.apache.qpid.server.security.auth.plain.PlainInitialiser</class>

Modified: incubator/qpid/branches/perftesting/qpid/java/broker/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/java/broker/pom.xml?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/java/broker/pom.xml (original)
+++ incubator/qpid/branches/perftesting/qpid/java/broker/pom.xml Tue Jan 16 07:16:39 2007
@@ -34,7 +34,6 @@
 
     <properties>
         <topDirectoryLocation>..</topDirectoryLocation>
-        <amqj.logging.level>warn</amqj.logging.level>
     </properties>
 
     <dependencies>
@@ -87,6 +86,11 @@
     <build>
         <plugins>
             <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+            </plugin>
+
+            <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>javacc-maven-plugin</artifactId>
                 <version>2.0</version>
@@ -95,7 +99,7 @@
                         <phase>generate-sources</phase>
                         <configuration>
                             <sourceDirectory>${basedir}/src/main/grammar</sourceDirectory>
-                            <outputDirectory>${basedir}/target/generated</outputDirectory>
+                            <outputDirectory>${basedir}/target/generated-sources</outputDirectory>
                             <packageName>org.apache.qpid.server.filter.jms.selector</packageName>
                         </configuration>
                         <goals>
@@ -104,7 +108,6 @@
                     </execution>
                 </executions>
             </plugin>
-
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>

Modified: incubator/qpid/branches/perftesting/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java (original)
+++ incubator/qpid/branches/perftesting/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java Tue Jan 16 07:16:39 2007
@@ -40,29 +40,16 @@
 import org.apache.qpid.framing.ProtocolVersionList;
 import org.apache.qpid.pool.ReadWriteThreadModel;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.exchange.ExchangeFactory;
-import org.apache.qpid.server.exchange.ExchangeRegistry;
-import org.apache.qpid.server.management.AMQManagedObject;
-import org.apache.qpid.server.management.MBeanConstructor;
-import org.apache.qpid.server.management.MBeanDescription;
-import org.apache.qpid.server.management.ManagedBroker;
+import org.apache.qpid.server.management.Managable;
 import org.apache.qpid.server.management.ManagedObject;
 import org.apache.qpid.server.protocol.AMQPFastProtocolHandler;
 import org.apache.qpid.server.protocol.AMQPProtocolProvider;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
-import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.transport.ConnectorConfiguration;
 import org.apache.qpid.url.URLSyntaxException;
 
 import javax.management.JMException;
-import javax.management.MBeanException;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
 import java.io.File;
 import java.io.IOException;
 import java.net.InetAddress;
@@ -75,7 +62,7 @@
  * Main entry point for AMQPD.
  *
  */
-public class Main implements ProtocolVersionList
+public class Main implements ProtocolVersionList, Managable
 {
     private static final Logger _logger = Logger.getLogger(Main.class);
 
@@ -83,6 +70,8 @@
 
     private static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
 
+    private AMQBrokerManagerMBean _mbean = null;
+
     protected static class InitException extends Exception
     {
         InitException(String msg)
@@ -445,7 +434,8 @@
     {
         try
         {
-            new AMQBrokerManager().register();
+            _mbean = new AMQBrokerManagerMBean();
+            _mbean.register();
         }
         catch (JMException ex)
         {
@@ -453,156 +443,8 @@
         }
     }
 
-    /**
-     * AMQPBrokerMBean implements the broker management interface and exposes the
-     * Broker level management features like creating and deleting exchanges and queue.
-     */
-    @MBeanDescription("This MBean exposes the broker level management features")
-    private final class AMQBrokerManager extends AMQManagedObject implements ManagedBroker
-    {
-        private final QueueRegistry    _queueRegistry;
-        private final ExchangeRegistry _exchangeRegistry;
-        private final ExchangeFactory  _exchangeFactory;
-        private final MessageStore     _messageStore;
-
-        @MBeanConstructor("Creates the Broker Manager MBean")
-        protected AMQBrokerManager()  throws JMException
-        {
-            super(ManagedBroker.class, ManagedBroker.TYPE);
-            IApplicationRegistry appRegistry = ApplicationRegistry.getInstance();
-            _queueRegistry    = appRegistry.getQueueRegistry();
-            _exchangeRegistry = appRegistry.getExchangeRegistry();
-            _exchangeFactory  = ApplicationRegistry.getInstance().getExchangeFactory();
-            _messageStore     = ApplicationRegistry.getInstance().getMessageStore();
-       }
-
-        public String getObjectInstanceName()
-        {
-            return this.getClass().getName();
-        }
-
-        /**
-         * Creates new exchange and registers it with the registry.
-         * @param exchangeName
-         * @param type
-         * @param durable
-         * @param autoDelete
-         * @throws JMException
-         */
-        public void createNewExchange(String exchangeName, String type, boolean durable, boolean autoDelete)
-            throws JMException
-        {
-            try
-            {
-                synchronized(_exchangeRegistry)
-                {
-                    Exchange exchange = _exchangeRegistry.getExchange(exchangeName);
-                    if (exchange == null)
-                    {
-                        exchange = _exchangeFactory.createExchange(exchangeName, type, durable, autoDelete, 0);
-                        _exchangeRegistry.registerExchange(exchange);
-                    }
-                    else
-                    {
-                        throw new JMException("The exchange \"" + exchangeName + "\" already exists.");
-                    }
-                }
-            }
-            catch(AMQException ex)
-            {
-                _logger.error("Error in creating exchange " + exchangeName, ex);
-                throw new MBeanException(ex, ex.toString());
-            }
-        }
-
-        /**
-         * Unregisters the exchange from registry.
-         * @param exchangeName
-         * @throws JMException
-         */
-        public void unregisterExchange(String exchangeName) throws JMException
-        {
-            // TODO
-            // Check if the exchange is in use.
-        	// boolean inUse = false;
-            // Check if there are queue-bindings with the exchange and unregister
-            // when there are no bindings.
-            try
-            {
-                _exchangeRegistry.unregisterExchange(exchangeName, false);
-            }
-            catch(AMQException ex)
-            {
-                _logger.error("Error in unregistering exchange " + exchangeName, ex);
-                throw new MBeanException(ex, ex.toString());
-            }
-        }
-
-        /**
-         * Creates a new queue and registers it with the registry and puts it
-         * in persistance storage if durable queue.
-         * @param queueName
-         * @param durable
-         * @param owner
-         * @param autoDelete
-         * @throws JMException
-         */
-        public void createNewQueue(String queueName, boolean durable, String owner, boolean autoDelete)
-            throws JMException
-        {
-            AMQQueue queue = _queueRegistry.getQueue(queueName);
-            if (queue != null)
-            {
-                throw new JMException("The queue \"" + queueName + "\" already exists.");
-            }
-            
-            try
-            {
-                queue = new AMQQueue(queueName, durable, owner, autoDelete, _queueRegistry);
-                if (queue.isDurable() && !queue.isAutoDelete())
-                {
-                    _messageStore.createQueue(queue);
-                }
-                _queueRegistry.registerQueue(queue);
-            }
-            catch (AMQException ex)
-            {
-                _logger.error("Error in creating queue " + queueName, ex);
-                throw new MBeanException(ex, ex.toString());
-            }
-        }
-
-        /**
-         * Deletes the queue from queue registry and persistant storage.
-         * @param queueName
-         * @throws JMException
-         */
-        public void deleteQueue(String queueName) throws JMException
-        {
-            AMQQueue queue = _queueRegistry.getQueue(queueName);
-            if (queue == null)
-            {
-                throw new JMException("The Queue " + queueName + " is not a registerd queue.");
-            }
-
-            try
-            {
-                queue.delete();
-                _messageStore.removeQueue(queueName);
-
-            }
-            catch (AMQException ex)
-            {
-                throw new MBeanException(ex, ex.toString());
-            }
-        }
-
-        public ObjectName getObjectName() throws MalformedObjectNameException
-        {
-            StringBuffer objectName = new StringBuffer(ManagedObject.DOMAIN);
-            objectName.append(":type=").append(getType());
-
-            return new ObjectName(objectName.toString());
-        }
-    } // End of MBean class
+    public ManagedObject getManagedObject()
+    {
+        return _mbean;
+    }    
 }

Modified: incubator/qpid/branches/perftesting/qpid/java/broker/src/main/java/org/apache/qpid/server/RequiredDeliveryException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/perftesting/qpid/java/broker/src/main/java/org/apache/qpid/server/RequiredDeliveryException.java?view=diff&rev=496725&r1=496724&r2=496725
==============================================================================
--- incubator/qpid/branches/perftesting/qpid/java/broker/src/main/java/org/apache/qpid/server/RequiredDeliveryException.java (original)
+++ incubator/qpid/branches/perftesting/qpid/java/broker/src/main/java/org/apache/qpid/server/RequiredDeliveryException.java Tue Jan 16 07:16:39 2007
@@ -81,7 +81,11 @@
 
     public CompositeAMQDataBlock getReturnMessage(int channel)
     {
-        BasicReturnBody returnBody = new BasicReturnBody();
+	    // AMQP version change: All generated *Body classes are now version-aware.
+        // Shortcut: hardwire version to 0-8 (major=8, minor=0) for now.
+        // TODO: Connect the version to that returned by the ProtocolInitiation
+        // for this session.
+        BasicReturnBody returnBody = new BasicReturnBody((byte)8, (byte)0);
         returnBody.exchange = _publishBody.exchange;
         returnBody.replyCode = getReplyCode();
         returnBody.replyText = _message;