summaryrefslogtreecommitdiff
path: root/gentools/templ.java/MethodRegistryClass.tmpl
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-01-09 23:22:52 +0000
committerRobert Greig <rgreig@apache.org>2007-01-09 23:22:52 +0000
commit70f32b028e2395d5a9097a1f897e7ded54b7fb88 (patch)
tree2d415e281da8c842bb0e2bec78dd3c1047a7db9a /gentools/templ.java/MethodRegistryClass.tmpl
parentf214abfececda76c2bf10b7fde18d2eab72ad749 (diff)
downloadqpid-python-70f32b028e2395d5a9097a1f897e7ded54b7fb88.tar.gz
QPID-268 : (Patch supplied by Rob Godfrey) Improvements to performance of generated code
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@494650 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'gentools/templ.java/MethodRegistryClass.tmpl')
-rw-r--r--gentools/templ.java/MethodRegistryClass.tmpl43
1 files changed, 22 insertions, 21 deletions
diff --git a/gentools/templ.java/MethodRegistryClass.tmpl b/gentools/templ.java/MethodRegistryClass.tmpl
index 0f15918f90..a243ace00e 100644
--- a/gentools/templ.java/MethodRegistryClass.tmpl
+++ b/gentools/templ.java/MethodRegistryClass.tmpl
@@ -31,41 +31,41 @@ package org.apache.qpid.framing;
import java.util.HashMap;
import java.lang.reflect.Constructor;
import org.apache.log4j.Logger;
+import org.apache.mina.common.ByteBuffer;
class MainRegistry
{
+ private static final HashMap<Long, AMQMethodBodyInstanceFactory> classIDMethodIDVersionBodyMap = new HashMap<Long, AMQMethodBodyInstanceFactory>();
+
+
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)
+ public static AMQMethodBody get(short classID, short methodID, byte major, byte minor, ByteBuffer in, long size)
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);
- }
+ AMQMethodBodyInstanceFactory bodyFactory = classIDMethodIDVersionBodyMap.get(createMapKey(classID,methodID,major,minor));
+ if (bodyFactory == null)
+ {
+ throw new AMQFrameDecodingException(_log,
+ "Unable to find a suitable decoder for class " + classID + " and method " +
+ methodID + " in AMQP version " + major + "-" + minor + ".");
+ }
+ return bodyFactory.newInstance(major, minor, in, size);
+
+
}
+ private static void registerMethod(short classID, short methodID, byte major, byte minor, AMQMethodBodyInstanceFactory instanceFactory )
+ {
+ classIDMethodIDVersionBodyMap.put(createMapKey(classID,methodID,major,minor), instanceFactory);
+ }
+
+
private static Long createMapKey(short classID, short methodID, byte major, byte minor)
{
/**
@@ -77,4 +77,5 @@ class MainRegistry
*/
return new Long(((long)classID << 32) + ((long)methodID << 16) + ((long)major << 8) + minor);
}
+
}