You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2007/01/08 21:01:56 UTC
svn commit: r494181 - in /incubator/qpid/branches/qpid.0-9/java/common: ./
src/main/java/org/apache/qpid/framing/ src/test/java/org/apache/qpid/framing/
Author: kpvdr
Date: Mon Jan 8 12:01:50 2007
New Revision: 494181
URL: http://svn.apache.org/viewvc?view=rev&rev=494181
Log:
Completed first version of new Content class and the two new framing classes AMQRequest and AMQResponse. Removed old Basic* and Content* classes.
Removed:
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/ContentBodyFactory.java
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBodyFactory.java
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
incubator/qpid/branches/qpid.0-9/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
Modified:
incubator/qpid/branches/qpid.0-9/java/common/pom.xml
incubator/qpid/branches/qpid.0-9/java/common/protocol-version.xml
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/Content.java
incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
Modified: incubator/qpid/branches/qpid.0-9/java/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/java/common/pom.xml?view=diff&rev=494181&r1=494180&r2=494181
==============================================================================
--- incubator/qpid/branches/qpid.0-9/java/common/pom.xml (original)
+++ incubator/qpid/branches/qpid.0-9/java/common/pom.xml Mon Jan 8 12:01:50 2007
@@ -36,12 +36,11 @@
<properties>
<topDirectoryLocation>..</topDirectoryLocation>
<gentools.home>${topDirectoryLocation}/../gentools</gentools.home>
- <generated.path>${project.build.directory}/generated-sources/xsl</generated.path>
+ <generated.path>${project.build.directory}/generated-sources/gentools</generated.path>
<generated.package>org/apache/qpid/framing</generated.package>
<generated.dir>${generated.path}/${generated.package}</generated.dir>
<generated.timestamp>${generated.dir}/timestamp</generated.timestamp>
<specs.dir>${topDirectoryLocation}/../specs</specs.dir>
- <cluster.asl>${basedir}/src/main/xsl/cluster.asl</cluster.asl>
</properties>
<build>
@@ -55,14 +54,7 @@
<phase>generate-sources</phase>
<configuration>
<tasks>
- <ant antfile="protocol-version.xml">
- <property name="gentools.home" value="${gentools.home}"/>
- <property name="generated.dir" value="${generated.dir}"/>
- <property name="generated.timestamp" value="${generated.timestamp}"/>
- <property name="xml.spec.dir" value="${specs.dir}"/>
- <property name="xml.spec.deps" value="amqp.0-9.xml cluster.0-9.xml amqp-nogen.0-9.xml"/>
- <property name="xml.spec.list" value="${specs.dir}/amqp.0-9.xml ${specs.dir}/cluster.0-9.xml ${specs.dir}/amqp-nogen.0-9.xml"/>
- </ant>
+ <ant antfile="protocol-version.xml" />
</tasks>
<sourceRoot>${generated.path}</sourceRoot>
</configuration>
Modified: incubator/qpid/branches/qpid.0-9/java/common/protocol-version.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/java/common/protocol-version.xml?view=diff&rev=494181&r1=494180&r2=494181
==============================================================================
--- incubator/qpid/branches/qpid.0-9/java/common/protocol-version.xml (original)
+++ incubator/qpid/branches/qpid.0-9/java/common/protocol-version.xml Mon Jan 8 12:01:50 2007
@@ -19,11 +19,24 @@
-
-->
<project name="Qpid Common Protocol Versions" default="generate">
+ <property name="topDirectoryLocation" location=".." />
+ <property name="project.build.directory" location="target" />
+ <property name="gentools.home" location="${topDirectoryLocation}/../gentools" />
+ <property name="generated.path" location="${project.build.directory}/generated-sources/gentools" />
+ <property name="generated.package" value="org/apache/qpid/framing" />
+ <property name="generated.dir" location="${generated.path}/${generated.package}" />
+ <property name="generated.timestamp" location="${generated.dir}/timestamp" />
+ <property name="xml.spec.dir" location="${topDirectoryLocation}/../specs" />
+ <property name="xml.spec.deps" value="amqp.0-9.xml cluster.0-9.xml amqp-nogen.0-9.xml" />
+ <property name="xml.spec.list" value="${xml.spec.dir}/amqp.0-9.xml ${xml.spec.dir}/cluster.0-9.xml ${xml.spec.dir}/amqp-nogen.0-9.xml" />
<target name="generate" depends="compile_generator,check_generate_deps" unless="generation.notRequired">
<mkdir dir="${generated.dir}"/>
- <java classname="org.apache.qpid.gentools.Main" fork="true" dir="${gentools.home}/src">
+ <java classname="org.apache.qpid.gentools.Main" fork="true" dir="${gentools.home}/src" failonerror="true">
<arg line="-j -o ${generated.dir} -t ${gentools.home}/templ.java ${xml.spec.list}" />
+ <classpath>
+ <pathelement path="${gentools.home}/src" />
+ </classpath>
</java>
<touch file="${generated.timestamp}" />
</target>
@@ -39,5 +52,9 @@
</target>
<target name="precompile" depends="generate"/>
+
+ <target name="clean">
+ <delete dir="${generated.path}" />
+ </target>
</project>
Modified: incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java?view=diff&rev=494181&r1=494180&r2=494181
==============================================================================
--- incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java (original)
+++ incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java Mon Jan 8 12:01:50 2007
@@ -37,8 +37,6 @@
public AMQDataBlockDecoder()
{
_supportedBodies.put(new Byte(AMQMethodBody.TYPE), AMQMethodBodyFactory.getInstance());
- _supportedBodies.put(new Byte(ContentHeaderBody.TYPE), ContentHeaderBodyFactory.getInstance());
- _supportedBodies.put(new Byte(ContentBody.TYPE), ContentBodyFactory.getInstance());
_supportedBodies.put(new Byte(HeartbeatBody.TYPE), new HeartbeatBodyFactory());
}
Modified: incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/Content.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/Content.java?view=diff&rev=494181&r1=494180&r2=494181
==============================================================================
--- incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/Content.java (original)
+++ incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/Content.java Mon Jan 8 12:01:50 2007
@@ -20,7 +20,94 @@
*/
package org.apache.qpid.framing;
-public interface Content
+import org.apache.mina.common.ByteBuffer;
+
+public class Content
{
- // TODO: New Content class required for AMQP 0-9.
+ enum ContentTypeEnum
+ {
+ CONTENT_TYPE_INLINE((byte)0), CONTENT_TYPE_REFERENCE((byte)1);
+ private byte type;
+ ContentTypeEnum(byte type) { this.type = type; }
+ public byte toByte() { return type; }
+ public static ContentTypeEnum toContentEnum(byte b)
+ {
+ switch (b)
+ {
+ case 0: return CONTENT_TYPE_INLINE;
+ case 1: return CONTENT_TYPE_REFERENCE;
+ default: throw new IllegalArgumentException("Illegal value " + b +
+ ", not represented in ContentTypeEnum.");
+ }
+ }
+ }
+
+ public ContentTypeEnum contentType;
+ public byte[] content;
+
+ // Constructors
+
+ public Content()
+ {
+ contentType = ContentTypeEnum.CONTENT_TYPE_INLINE; // default
+ content = null;
+ }
+
+ public Content(ContentTypeEnum contentType, byte[] content)
+ {
+ if (contentType == ContentTypeEnum.CONTENT_TYPE_REFERENCE)
+ {
+ if (content == null)
+ throw new IllegalArgumentException("Content cannot be null for a ref type.");
+ if (content.length == 0)
+ throw new IllegalArgumentException("Content cannot be empty for a ref type.");
+ }
+ this.contentType = contentType;
+ this.content = content;
+ }
+
+ public Content(ContentTypeEnum contentType, String content)
+ {
+ if (contentType == ContentTypeEnum.CONTENT_TYPE_REFERENCE)
+ {
+ if (content == null)
+ throw new IllegalArgumentException("Content cannot be null for a ref type.");
+ if (content.length() == 0)
+ throw new IllegalArgumentException("Content cannot be empty for a ref type.");
+ }
+ this.contentType = contentType;
+ this.content = content.getBytes();
+ }
+
+ // Get functions
+
+ public ContentTypeEnum getContentType() { return contentType; }
+ public byte[] getContent() { return content; }
+ public String getContentAsString()
+ {
+ if (content == null)
+ return null;
+ return new String(content);
+ }
+
+ // Wire functions
+
+ public long getEncodedSize()
+ {
+ if (content == null)
+ return 1 + 4;
+ return 1 + 4 + content.length;
+ }
+
+ public void writePayload(ByteBuffer buffer)
+ {
+ EncodingUtils.writeUnsignedByte(buffer, contentType.toByte());
+ EncodingUtils.writeLongStringBytes(buffer, content);
+ }
+
+ public void populateFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException
+ {
+ contentType = ContentTypeEnum.toContentEnum(buffer.get());
+ content = EncodingUtils.readLongstr(buffer);
+ }
}
Modified: incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java?view=diff&rev=494181&r1=494180&r2=494181
==============================================================================
--- incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java (original)
+++ incubator/qpid/branches/qpid.0-9/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java Mon Jan 8 12:01:50 2007
@@ -97,13 +97,11 @@
return (int) table.getEncodedSize() + 4;
}
}
-
- public static int encodedContentLength(Content table)
+
+ public static int encodedContentLength(Content content)
{
- // TODO: New Content class required for AMQP 0-9.
- return 0;
+ return (int)content.getEncodedSize();
}
-
public static void writeShortStringBytes(ByteBuffer buffer, String s)
{
@@ -240,7 +238,7 @@
public static void writeContentBytes(ByteBuffer buffer, Content content)
{
- // TODO: New Content class required for AMQP 0-9.
+ content.writePayload(buffer);
}
public static void writeBooleans(ByteBuffer buffer, boolean[] values)
@@ -309,8 +307,10 @@
public static Content readContent(ByteBuffer buffer) throws AMQFrameDecodingException
{
- // TODO: New Content class required for AMQP 0-9.
- return null;
+ long length = buffer.getUnsignedInt();
+ Content content = new Content();
+ content.populateFromBuffer(buffer, length);
+ return content;
}
public static String readShortString(ByteBuffer buffer)