summaryrefslogtreecommitdiff
path: root/cpp/gentools/templ.java
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/gentools/templ.java')
-rw-r--r--cpp/gentools/templ.java/AmqpConstantsClass.tmpl37
-rw-r--r--cpp/gentools/templ.java/MethodBodyClass.tmpl180
-rw-r--r--cpp/gentools/templ.java/MethodRegistryClass.tmpl125
-rw-r--r--cpp/gentools/templ.java/PropertyContentHeaderClass.tmpl207
-rw-r--r--cpp/gentools/templ.java/ProtocolVersionListClass.tmpl38
5 files changed, 587 insertions, 0 deletions
diff --git a/cpp/gentools/templ.java/AmqpConstantsClass.tmpl b/cpp/gentools/templ.java/AmqpConstantsClass.tmpl
new file mode 100644
index 0000000000..8d459f2977
--- /dev/null
+++ b/cpp/gentools/templ.java/AmqpConstantsClass.tmpl
@@ -0,0 +1,37 @@
+&{AmqpConstants.java}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by ${GENERATOR} - do not modify.
+ * Supported AMQP versions:
+%{VLIST} * ${major}-${minor}
+ */
+
+package org.apache.qpid.framing;
+
+class AmqpConstants
+{
+ // Constant getValue methods
+
+%{TLIST} ${const_get_method}
+
+}
diff --git a/cpp/gentools/templ.java/MethodBodyClass.tmpl b/cpp/gentools/templ.java/MethodBodyClass.tmpl
new file mode 100644
index 0000000000..42582fcb7c
--- /dev/null
+++ b/cpp/gentools/templ.java/MethodBodyClass.tmpl
@@ -0,0 +1,180 @@
+&{${CLASS}${METHOD}Body.java}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by ${GENERATOR} - do not modify.
+ * Supported AMQP versions:
+%{VLIST} * ${major}-${minor}
+ */
+
+package org.apache.qpid.framing;
+
+import java.util.HashMap;
+
+import org.apache.mina.common.ByteBuffer;
+
+public class ${CLASS}${METHOD}Body extends AMQMethodBody implements EncodableAMQDataBlock
+{
+ private static final AMQMethodBodyInstanceFactory factory = new AMQMethodBodyInstanceFactory()
+ {
+ public AMQMethodBody newInstance(byte major, byte minor, ByteBuffer in, long size) throws AMQFrameDecodingException
+ {
+ return new ${CLASS}${METHOD}Body(major, minor, in);
+ }
+
+ public AMQMethodBody newInstance(byte major, byte minor, int clazzID, int methodID, ByteBuffer in, long size) throws AMQFrameDecodingException
+ {
+ return new ${CLASS}${METHOD}Body(major, minor, clazzID, methodID, in);
+ }
+
+ };
+
+ public static AMQMethodBodyInstanceFactory getFactory()
+ {
+ return factory;
+ }
+
+ public static HashMap<Integer, Integer> classIdMap = new HashMap<Integer, Integer>();
+ public static HashMap<Integer, Integer> methodIdMap = new HashMap<Integer, Integer>();
+
+ private static void registerMethodId(byte major, byte minor, int methodId)
+ {
+ methodIdMap.put((0xff & (int) major) | ((0xff & (int) minor)<<8), methodId);
+ }
+
+ private static void registerClassId(byte major, byte minor, int classId)
+ {
+ classIdMap.put((0xff & (int) major) | ((0xff & (int) minor)<<8), classId);
+ }
+
+
+ static
+ {
+ ${CLASS_ID_INIT}
+ ${METHOD_ID_INIT}
+ }
+
+ // Fields declared in specification
+%{FLIST} ${field_declaration}
+
+ private final int _clazz;
+ private final int _method;
+
+
+ // Constructor
+
+ public ${CLASS}${METHOD}Body(byte major, byte minor, ByteBuffer buffer) throws AMQFrameDecodingException
+ {
+ this(major, minor, getClazz(major,minor), getMethod(major,minor), buffer);
+ }
+
+ public ${CLASS}${METHOD}Body(byte major, byte minor, int clazzID, int methodID, ByteBuffer buffer) throws AMQFrameDecodingException
+ {
+ super(major, minor);
+ _clazz = clazzID;
+ _method = methodID;
+%{FLIST} ${mb_field_decode}
+ }
+
+ public ${CLASS}${METHOD}Body(byte major, byte minor, int clazzID, int methodID
+%{FLIST} ${mb_field_parameter_list}
+ )
+ {
+ super(major, minor);
+ _clazz = getClazz(major,minor);
+ _method = getMethod(major,minor);
+%{FLIST} ${mb_field_body_initialize}
+ }
+
+ public int getClazz()
+ {
+ return _clazz;
+ }
+
+ public int getMethod()
+ {
+ return _method;
+ }
+
+ public static int getClazz(byte major, byte minor)
+ {
+ return classIdMap.get((0xff & (int) major) | ((0xff & (int) minor)<<8));
+ }
+
+ public static int getMethod(byte major, byte minor)
+ {
+ return methodIdMap.get((0xff & (int) major) | ((0xff & (int) minor)<<8));
+ }
+
+
+ // Field methods
+%{FLIST} ${mb_field_get_method}
+
+ public int getBodySize()
+ {
+ int size = 0;
+%{FLIST} ${mb_field_size}
+ return size;
+ }
+
+ protected void writeMethodPayload(ByteBuffer buffer)
+ {
+%{FLIST} ${mb_field_encode}
+ }
+
+ public void populateMethodBodyFromBuffer(ByteBuffer buffer) throws AMQFrameDecodingException
+ {
+%{FLIST} ${mb_field_decode}
+ }
+
+ public String toString()
+ {
+ StringBuffer buf = new StringBuffer(super.toString());
+%{FLIST} ${mb_field_to_string}
+ return buf.toString();
+ }
+
+ public static ${CLASS}${METHOD}Body createMethodBody(byte major, byte minor
+%{FLIST} ${mb_field_parameter_list}
+ )
+ {
+ return createMethodBody(major, minor, getClazz(major, minor), getMethod(major, minor)
+%{FLIST} ${mb_field_passed_parameter_list}
+ );
+ }
+
+ public static ${CLASS}${METHOD}Body createMethodBody(byte major, byte minor, int clazzID, int methodID
+%{FLIST} ${mb_field_parameter_list}
+ )
+ {
+ return new ${CLASS}${METHOD}Body(major, minor, clazzID, methodID
+%{FLIST} ${mb_field_passed_parameter_list}
+ );
+ }
+
+ public ${CLASS}${METHOD}Body copy()
+ {
+ return new ${CLASS}${METHOD}Body(major, minor, getClazz(major, minor), getMethod(major, minor)
+%{FLIST} ${mb_field_passed_parameter_list}
+ );
+ }
+}
diff --git a/cpp/gentools/templ.java/MethodRegistryClass.tmpl b/cpp/gentools/templ.java/MethodRegistryClass.tmpl
new file mode 100644
index 0000000000..12e6fe250e
--- /dev/null
+++ b/cpp/gentools/templ.java/MethodRegistryClass.tmpl
@@ -0,0 +1,125 @@
+&{MainRegistry.java}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by ${GENERATOR} - do not modify.
+ * Supported AMQP versions:
+%{VLIST} * ${major}-${minor}
+ */
+
+package org.apache.qpid.framing;
+
+import org.apache.log4j.Logger;
+import org.apache.mina.common.ByteBuffer;
+
+public class MainRegistry
+{
+ private static final Logger _log = Logger.getLogger(MainRegistry.class);
+
+ private static final int DEFAULT_MINOR_VERSION_COUNT = 10;
+ private static final int DEFAULT_MAJOR_VERSION_COUNT = 10;
+
+ private static VersionSpecificRegistry[][] _specificRegistries = new VersionSpecificRegistry[DEFAULT_MAJOR_VERSION_COUNT][];
+
+ static
+ {
+%{CLIST} ${reg_map_put_method}
+ }
+
+ public static AMQMethodBody get(short classID, short methodID, byte major, byte minor, ByteBuffer in, long size)
+ throws AMQFrameDecodingException
+ {
+ VersionSpecificRegistry registry = getVersionSpecificRegistry(major, minor);
+ AMQMethodBodyInstanceFactory bodyFactory = registry.getMethodBody(classID,methodID);
+
+ 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);
+
+
+ }
+
+ public static VersionSpecificRegistry getVersionSpecificRegistry(byte major, byte minor)
+ {
+ try
+ {
+ return _specificRegistries[(int)major][(int)minor];
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ return null;
+ }
+ catch (NullPointerException e)
+ {
+ return null;
+ }
+
+
+ }
+
+ private static VersionSpecificRegistry addVersionSpecificRegistry(byte major, byte minor)
+ {
+ VersionSpecificRegistry[][] registries = _specificRegistries;
+ if(major >= registries.length)
+ {
+ _specificRegistries = new VersionSpecificRegistry[(int)major + 1][];
+ System.arraycopy(registries, 0, _specificRegistries, 0, registries.length);
+ registries = _specificRegistries;
+ }
+ if(registries[major] == null)
+ {
+ registries[major] = new VersionSpecificRegistry[ minor >= DEFAULT_MINOR_VERSION_COUNT ? minor + 1 : DEFAULT_MINOR_VERSION_COUNT ];
+ }
+ else if(registries[major].length <= minor)
+ {
+ VersionSpecificRegistry[] minorArray = registries[major];
+ registries[major] = new VersionSpecificRegistry[ minor + 1 ];
+ System.arraycopy(minorArray, 0, registries[major], 0, minorArray.length);
+
+ }
+
+ VersionSpecificRegistry newRegistry = new VersionSpecificRegistry(major,minor);
+
+ registries[major][minor] = newRegistry;
+
+ return newRegistry;
+ }
+
+ private static void registerMethod(short classID, short methodID, byte major, byte minor, AMQMethodBodyInstanceFactory instanceFactory )
+ {
+ VersionSpecificRegistry registry = getVersionSpecificRegistry(major,minor);
+ if(registry == null)
+ {
+ registry = addVersionSpecificRegistry(major,minor);
+
+ }
+
+ registry.registerMethod(classID, methodID, instanceFactory);
+
+ }
+
+
+}
diff --git a/cpp/gentools/templ.java/PropertyContentHeaderClass.tmpl b/cpp/gentools/templ.java/PropertyContentHeaderClass.tmpl
new file mode 100644
index 0000000000..3c147cf6b6
--- /dev/null
+++ b/cpp/gentools/templ.java/PropertyContentHeaderClass.tmpl
@@ -0,0 +1,207 @@
+&{${CLASS}ContentHeaderProperties.java}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by ${GENERATOR} - do not modify.
+ * Supported AMQP versions:
+%{VLIST} * ${major}-${minor}
+ */
+
+package org.apache.qpid.framing;
+
+import org.apache.log4j.Logger;
+import org.apache.mina.common.ByteBuffer;
+
+public class ${CLASS}ContentHeaderProperties implements ContentHeaderProperties
+{
+ private static final Logger logger = Logger.getLogger(BasicContentHeaderProperties.class);
+
+ /**
+ * We store the encoded form when we decode the content header so that if we need to
+ * write it out without modifying it we can do so without incurring the expense of
+ * reencoding it.
+ */
+ private byte[] encodedBuffer;
+
+ /**
+ * Flag indicating whether the entire content header has been decoded yet.
+ */
+ private boolean decodedFlag = true;
+
+ /**
+ * We have some optimisations for partial decoding for maximum performance. The
+ * headers are used in the broker for routing in some cases so we can decode that
+ * separately.
+ */
+ private boolean decodedHeadersFlag = true;
+
+ /**
+ * We have some optimisations for partial decoding for maximum performance. The
+ * content type is used by all clients to determine the message type.
+ */
+ private boolean decodedContentTypeFlag = true;
+
+ /**
+ * AMQP major and minor version of this instance.
+ */
+ private byte major;
+ private byte minor;
+
+ /**
+ * Property flags.
+ */
+ ${pch_property_flags_declare}
+
+ // Header fields from specification
+%{FLIST} ${field_declaration}
+
+ /**
+ * Constructor
+ */
+ public ${CLASS}ContentHeaderProperties(byte major, byte minor)
+ {
+ this.major = major;
+ this.minor = minor;
+
+ // Although one flag is initialized per property, the flags are used
+ // in ordinal order of the AMQP version represented by this instance,
+ // thus the number of flags actually used may be less than the total
+ // number defined.
+ ${pch_property_flags_initializer}
+ }
+
+ public int getPropertyListSize()
+ {
+ if (encodedBuffer != null)
+ {
+ return encodedBuffer.length;
+ }
+ else
+ {
+ int size = 0;
+%{FLIST} ${pch_field_list_size}
+ return size;
+ }
+ }
+
+ private void clearEncodedForm()
+ {
+ if (!decodedFlag && encodedBuffer != null)
+ {
+ //decode();
+ }
+ encodedBuffer = null;
+ }
+
+ public void setPropertyFlags(int[] compactPropertyFlags)
+ throws AMQProtocolVersionException
+ {
+ clearEncodedForm();
+${pch_compact_property_flags_check}
+%{FLIST} ${pch_set_compact_property_flags}
+ }
+
+ public int[] getPropertyFlags()
+ {
+ int[] compactPropertyFlags = new int[] { 0 };
+${pch_compact_property_flags_initializer}
+%{FLIST} ${pch_get_compact_property_flags}
+ return compactPropertyFlags;
+ }
+
+ public void writePropertyListPayload(ByteBuffer buffer)
+ {
+ if (encodedBuffer != null)
+ {
+ buffer.put(encodedBuffer);
+ }
+ else
+ {
+%{FLIST} ${pch_field_list_payload}
+ }
+ }
+
+ public void populatePropertiesFromBuffer(ByteBuffer buffer, int[] propertyFlags, int size)
+ throws AMQFrameDecodingException, AMQProtocolVersionException
+ {
+ setPropertyFlags(propertyFlags);
+
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("Property flags: " + propertyFlags);
+ }
+ decode(buffer);
+ /*encodedBuffer = new byte[size];
+ buffer.get(encodedBuffer, 0, size);
+ decodedFlag = false;
+ decodedHeadersFlag = false;
+ decodedContentTypeFlag = false;*/
+ }
+
+ private void decode(ByteBuffer buffer)
+ {
+ //ByteBuffer buffer = ByteBuffer.wrap(encodedBuffer);
+ int pos = buffer.position();
+ try
+ {
+%{FLIST} ${pch_field_list_decode}
+ // This line does nothing, but prevents a compiler error (Exception not thrown)
+ // if this block is empty.
+ if (false) throw new AMQFrameDecodingException("");
+ }
+ catch (AMQFrameDecodingException e)
+ {
+ throw new RuntimeException("Error in content header data: " + e);
+ }
+
+ final int endPos = buffer.position();
+ buffer.position(pos);
+ final int len = endPos - pos;
+ encodedBuffer = new byte[len];
+ final int limit = buffer.limit();
+ buffer.limit(endPos);
+ buffer.get(encodedBuffer, 0, len);
+ buffer.limit(limit);
+ buffer.position(endPos);
+ decodedFlag = true;
+ }
+
+ private void decodeIfNecessary()
+ {
+ if (!decodedFlag)
+ {
+ //decode();
+ }
+ }
+
+ // Field clear methods
+
+%{FLIST} ${pch_field_clear_methods}
+
+ // Field get methods
+
+%{FLIST} ${pch_field_get_methods}
+
+ // Field set methods
+
+%{FLIST} ${pch_field_set_methods}
+}
diff --git a/cpp/gentools/templ.java/ProtocolVersionListClass.tmpl b/cpp/gentools/templ.java/ProtocolVersionListClass.tmpl
new file mode 100644
index 0000000000..bc98e0c1ea
--- /dev/null
+++ b/cpp/gentools/templ.java/ProtocolVersionListClass.tmpl
@@ -0,0 +1,38 @@
+&{ProtocolVersionList.java}
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by ${GENERATOR} - do not modify.
+ * Supported AMQP versions:
+%{VLIST} * ${major}-${minor}
+ */
+
+package org.apache.qpid.framing;
+
+public interface ProtocolVersionList
+{
+ public final int PROTOCOL_MAJOR = 0;
+ public final int PROTOCOL_MINOR = 1;
+ public final byte pv[][] = {
+%{VLIST} ${protocol-version-list-entry}
+ };
+}