summaryrefslogtreecommitdiff
path: root/Final/gentools/templ.java
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2007-10-31 18:29:09 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2007-10-31 18:29:09 +0000
commitacaf7d59a7c287d0f06a18973b3487a515fa6ff8 (patch)
treeb642d1805bd567a157f390f9766e8246a3af251d /Final/gentools/templ.java
parente0651286d49afecdf9fc7daa55f2f5d48c7d33b0 (diff)
downloadqpid-python-acaf7d59a7c287d0f06a18973b3487a515fa6ff8.tar.gz
Creating a tag for the latest java RC. This will be promoted as the Final release if the RC is good
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/tags/M2@590781 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'Final/gentools/templ.java')
-rw-r--r--Final/gentools/templ.java/AmqpConstantsClass.tmpl37
-rw-r--r--Final/gentools/templ.java/MethodBodyClass.tmpl183
-rw-r--r--Final/gentools/templ.java/MethodRegistryClass.tmpl159
-rw-r--r--Final/gentools/templ.java/PropertyContentHeaderClass.tmpl208
-rw-r--r--Final/gentools/templ.java/ProtocolVersionListClass.tmpl127
5 files changed, 714 insertions, 0 deletions
diff --git a/Final/gentools/templ.java/AmqpConstantsClass.tmpl b/Final/gentools/templ.java/AmqpConstantsClass.tmpl
new file mode 100644
index 0000000000..8d459f2977
--- /dev/null
+++ b/Final/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/Final/gentools/templ.java/MethodBodyClass.tmpl b/Final/gentools/templ.java/MethodBodyClass.tmpl
new file mode 100644
index 0000000000..eb730fd891
--- /dev/null
+++ b/Final/gentools/templ.java/MethodBodyClass.tmpl
@@ -0,0 +1,183 @@
+&{${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}
+
+ protected 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 AMQFrame createAMQFrame(int channelId, byte major, byte minor
+%{FLIST} ${mb_field_parameter_list}
+ )
+ {
+ return createAMQFrame(channelId, major, minor, getClazz(major,minor), getMethod(major,minor)
+%{FLIST} ${mb_field_passed_parameter_list}
+ );
+
+
+
+ }
+
+ public static AMQFrame createAMQFrame(int channelId, byte major, byte minor, int clazzID, int methodID
+%{FLIST} ${mb_field_parameter_list}
+ )
+ {
+ ${CLASS}${METHOD}Body body = new ${CLASS}${METHOD}Body(major, minor, clazzID, methodID
+%{FLIST} ${mb_field_passed_parameter_list}
+ );
+
+
+ AMQFrame frame = new AMQFrame(channelId, body);
+ return frame;
+ }
+
+}
diff --git a/Final/gentools/templ.java/MethodRegistryClass.tmpl b/Final/gentools/templ.java/MethodRegistryClass.tmpl
new file mode 100644
index 0000000000..01e440e209
--- /dev/null
+++ b/Final/gentools/templ.java/MethodRegistryClass.tmpl
@@ -0,0 +1,159 @@
+&{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 java.util.HashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.mina.common.ByteBuffer;
+
+public class MainRegistry
+{
+ private static final HashMap<Long, AMQMethodBodyInstanceFactory> classIDMethodIDVersionBodyMap = new HashMap<Long, AMQMethodBodyInstanceFactory>();
+
+
+ private static final Logger _log = LoggerFactory.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}
+
+ configure();
+ }
+
+ 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(null,
+ "Unable to find a suitable decoder for class " + classID + " and method " +
+ methodID + " in AMQP version " + major + "-" + minor + ".", null);
+ }
+ return bodyFactory.newInstance(major, minor, in, size);
+
+
+ }
+
+
+ public static VersionSpecificRegistry getVersionSpecificRegistry(ProtocolVersion pv)
+ {
+ return getVersionSpecificRegistry(pv.getMajorVersion(), pv.getMinorVersion());
+ }
+ 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);
+
+ }
+
+
+ private static void configure()
+ {
+ for(int i = 0 ; i < _specificRegistries.length; i++)
+ {
+ VersionSpecificRegistry[] registries = _specificRegistries[i];
+ if(registries != null)
+ {
+ for(int j = 0 ; j < registries.length; j++)
+ {
+ VersionSpecificRegistry registry = registries[j];
+
+ if(registry != null)
+ {
+ registry.configure();
+ }
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/Final/gentools/templ.java/PropertyContentHeaderClass.tmpl b/Final/gentools/templ.java/PropertyContentHeaderClass.tmpl
new file mode 100644
index 0000000000..ab6406b1fe
--- /dev/null
+++ b/Final/gentools/templ.java/PropertyContentHeaderClass.tmpl
@@ -0,0 +1,208 @@
+&{${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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.mina.common.ByteBuffer;
+
+public class ${CLASS}ContentHeaderProperties implements ContentHeaderProperties
+{
+ private static final Logger logger = LoggerFactory.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/Final/gentools/templ.java/ProtocolVersionListClass.tmpl b/Final/gentools/templ.java/ProtocolVersionListClass.tmpl
new file mode 100644
index 0000000000..4a2592d11b
--- /dev/null
+++ b/Final/gentools/templ.java/ProtocolVersionListClass.tmpl
@@ -0,0 +1,127 @@
+&{ProtocolVersion.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.SortedSet;
+import java.util.Collections;
+import java.util.TreeSet;
+
+
+public class ProtocolVersion implements Comparable
+{
+ private final byte _majorVersion;
+ private final byte _minorVersion;
+
+
+ public ProtocolVersion(byte majorVersion, byte minorVersion)
+ {
+ _majorVersion = majorVersion;
+ _minorVersion = minorVersion;
+ }
+
+ public byte getMajorVersion()
+ {
+ return _majorVersion;
+ }
+
+ public byte getMinorVersion()
+ {
+ return _minorVersion;
+ }
+
+
+ public int compareTo(Object o)
+ {
+ ProtocolVersion pv = (ProtocolVersion) o;
+ if(getMajorVersion() > pv.getMajorVersion())
+ {
+ return 1;
+ }
+ else if(getMajorVersion() < pv.getMajorVersion())
+ {
+ return -1;
+ }
+ else if(getMajorVersion() > pv.getMajorVersion())
+ {
+ return 1;
+ }
+ else if(getMinorVersion() < pv.getMinorVersion())
+ {
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+
+ }
+
+ public boolean equals(Object o)
+ {
+ return o != null && (o == this || (compareTo(o) == 0));
+ }
+
+ public int hashCode()
+ {
+ return (0xFF & (int)_minorVersion) | ((0xFF & (int)_majorVersion) << 8);
+ }
+
+
+ public boolean isSupported()
+ {
+ return _supportedVersions.contains(this);
+ }
+
+ public static ProtocolVersion getLatestSupportedVersion()
+ {
+ return _supportedVersions.last();
+ }
+
+ private static final SortedSet<ProtocolVersion> _supportedVersions;
+
+ static
+ {
+ SortedSet<ProtocolVersion> versions = new TreeSet<ProtocolVersion>();
+
+%{VLIST} versions.add(new ProtocolVersion((byte)${major},(byte)${minor}));
+
+ _supportedVersions = Collections.unmodifiableSortedSet(versions);
+ }
+
+
+ public static SortedSet<ProtocolVersion> getSupportedProtocolVersions()
+ {
+ return _supportedVersions;
+ }
+
+
+
+
+
+}