Skip to content

Commit 9f98609

Browse files
author
Steve Powell
committed
Made getMethodClass private to AMQImpl;
added getProtocolMethodName(classId,methodId) to AMQImpl; used getProtocolMethodName(.,.) in appendArgumentDebugStringTo() so that reason in Connection/Channel.Close announces the protocolMethodName as well.
1 parent e8994e2 commit 9f98609

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

codegen.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ def printHeader():
417417
print "import java.io.IOException;"
418418
print "import java.io.DataInputStream;"
419419
print "import java.lang.reflect.Constructor;"
420+
print "import java.lang.reflect.Field;"
420421
print "import java.util.Collections;"
421422
print "import java.util.HashMap;"
422423
print "import java.util.Map;"
@@ -480,9 +481,12 @@ def trueOrFalse(truthVal):
480481
return "false"
481482

482483
def argument_debug_string():
484+
anames = [a.name for a in m.arguments]
483485
appendList = [ "%s=\")\n .append(this.%s)\n .append(\""
484-
% (a.name, java_field_name(a.name))
485-
for a in m.arguments ]
486+
% (name, java_field_name(name))
487+
for name in anames ]
488+
if "class-id" in anames and "method-id" in anames:
489+
appendList.append("protocol-name='\")\n .append(getProtocolMethodName(this.classId, this.methodId))\n .append(\"'")
486490
print
487491
print " public void appendArgumentDebugStringTo(StringBuilder acc) {"
488492
print " acc.append(\"(%s)\");" % ", ".join(appendList)
@@ -535,9 +539,22 @@ def printMethodVisitor():
535539
print " public Object visit(%s.%s x) throws IOException { throw new UnexpectedMethodError(x); }" % (java_class_name(c.name), java_class_name(m.name))
536540
print " }"
537541

542+
def printGetProtocolMethodNameMethod():
543+
print
544+
print " public static String getProtocolMethodName(int classId, int methodId) {"
545+
print " Class<? extends Method> clazz = getMethodClass(classId, methodId);"
546+
print " if (clazz != null) {"
547+
print " try {"
548+
print " Field pmnField = clazz.getField(\"PROTOCOL_METHOD_NAME\");"
549+
print " return (String)pmnField.get(null);"
550+
print " } catch (Exception e) { /*ignore*/ }"
551+
print " }"
552+
print " return null;"
553+
print " }"
554+
538555
def printGetMethodClassMethod():
539556
print
540-
print " public static Class<? extends Method> getMethodClass(int classId, int methodId) {"
557+
print " private static Class<? extends Method> getMethodClass(int classId, int methodId) {"
541558
print " switch (classId) {"
542559
for c in spec.allClasses():
543560
print " case %s:" % (c.index)
@@ -590,6 +607,7 @@ def printContentHeaderReader():
590607
for c in spec.allClasses(): printClassMethods(spec,c)
591608

592609
printMethodVisitor()
610+
printGetProtocolMethodNameMethod()
593611
printGetMethodClassMethod()
594612
printMethodArgumentReader()
595613
printContentHeaderReader()

0 commit comments

Comments
 (0)