Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpNoopMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpNoopMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpNoopMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpNoopMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,136 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpNoop;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpNoopMarshaller implements DescribedTypeMarshaller<AmqpNoop>{
+
+ static final AmqpNoopMarshaller SINGLETON = new AmqpNoopMarshaller();
+ private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+ public static final String SYMBOLIC_ID = "amqp:noop:list";
+ //Format code: 0x00000001:0x00000301:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 769;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294968065L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x01 // DESCRIPTOR ID CODE
+ }), 0);
+
+ private static final ListDecoder DECODER = new ListDecoder() {
+ public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+ switch(pos) {
+ case 0: {
+ return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.unmarshalType(in);
+ }
+ }
+ }
+
+ public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+ switch(pos) {
+ case 0: {
+ return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.decodeType(buffer);
+ }
+ }
+ }
+ };
+
+ public static class AmqpNoopEncoded extends DescribedEncoded<IAmqpList> {
+
+ public AmqpNoopEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpNoopEncoded(AmqpNoop value) {
+ super(AmqpListMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpListMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpListMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<IAmqpList> encode(AmqpNoop value) throws AmqpEncodingError {
+ return new AmqpNoopEncoded(value);
+ }
+
+ static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpNoopEncoded(db);
+ }
+
+ public final AmqpNoop.AmqpNoopBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpNoop.AmqpNoopBuffer.create(new AmqpNoopEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpNullMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpNullMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpNullMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpNullMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.Object;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpNull;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpNullMarshaller {
+
+ private static final Encoder ENCODER = Encoder.SINGLETON;
+ private static final Encoded<Object> NULL_ENCODED = new Encoder.NullEncoded<Object>();
+
+ public static final byte FORMAT_CODE = (byte) 0x40;
+ public static final FormatSubCategory FORMAT_CATEGORY = FormatSubCategory.getCategory(FORMAT_CODE);
+
+ public static class AmqpNullEncoded extends AbstractEncoded<Object> {
+
+ public AmqpNullEncoded (EncodedBuffer encoded) {
+ super(encoded);
+ }
+
+ public AmqpNullEncoded (Object value) throws AmqpEncodingError {
+ super(FORMAT_CODE, value);
+ }
+
+ public final void encode(Object value, Buffer encoded, int offset) throws AmqpEncodingError{
+
+ }
+
+ public final Object decode(EncodedBuffer encoded) throws AmqpEncodingError{
+ return ENCODER.valueOfNull();
+ }
+
+ public final void marshalData(DataOutput out) throws IOException {
+
+ }
+
+ public final Object unmarshalData(DataInput in) throws IOException {
+ return ENCODER.valueOfNull();
+ }
+ }
+
+ public static final Encoded<Object> encode(AmqpNull data) throws AmqpEncodingError {
+ if(data == null) {
+ return NULL_ENCODED;
+ }
+ return new AmqpNullEncoded(data.getValue());
+ }
+
+ static final Encoded<Object> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<Object> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<Object> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+ return new Encoder.NullEncoded<Object>();
+ }
+ if(buffer.getEncodingFormatCode() != FORMAT_CODE) {
+ throw new AmqpEncodingError("Unexpected format for AmqpNull expected: " + FORMAT_CODE);
+ }
+ return new AmqpNullEncoded(buffer);
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpOpenMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpOpenMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpOpenMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpOpenMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,201 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpList;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpOpen;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpString;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUint;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.AmqpUshort;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpOpenMarshaller implements DescribedTypeMarshaller<AmqpOpen>{
+
+ static final AmqpOpenMarshaller SINGLETON = new AmqpOpenMarshaller();
+ private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+ public static final String SYMBOLIC_ID = "amqp:open:list";
+ //Format code: 0x00000001:0x00000201:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 513;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294967809L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x01 // DESCRIPTOR ID CODE
+ }), 0);
+
+ private static final ListDecoder DECODER = new ListDecoder() {
+ public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+ switch(pos) {
+ case 0: {
+ return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ case 1: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(in));
+ }
+ case 2: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(in));
+ }
+ case 3: {
+ return AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(in));
+ }
+ case 4: {
+ return AmqpUshort.AmqpUshortBuffer.create(AmqpUshortMarshaller.createEncoded(in));
+ }
+ case 5: {
+ return AmqpUshort.AmqpUshortBuffer.create(AmqpUshortMarshaller.createEncoded(in));
+ }
+ case 6: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(in));
+ }
+ case 7: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(in));
+ }
+ case 8: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ case 9: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(in));
+ }
+ case 10: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(in));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.unmarshalType(in);
+ }
+ }
+ }
+
+ public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+ switch(pos) {
+ case 0: {
+ return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ case 1: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(buffer));
+ }
+ case 2: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(buffer));
+ }
+ case 3: {
+ return AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(buffer));
+ }
+ case 4: {
+ return AmqpUshort.AmqpUshortBuffer.create(AmqpUshortMarshaller.createEncoded(buffer));
+ }
+ case 5: {
+ return AmqpUshort.AmqpUshortBuffer.create(AmqpUshortMarshaller.createEncoded(buffer));
+ }
+ case 6: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(buffer));
+ }
+ case 7: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(buffer));
+ }
+ case 8: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ case 9: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(buffer));
+ }
+ case 10: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(buffer));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.decodeType(buffer);
+ }
+ }
+ }
+ };
+
+ public static class AmqpOpenEncoded extends DescribedEncoded<IAmqpList> {
+
+ public AmqpOpenEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpOpenEncoded(AmqpOpen value) {
+ super(AmqpListMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpListMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpListMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<IAmqpList> encode(AmqpOpen value) throws AmqpEncodingError {
+ return new AmqpOpenEncoded(value);
+ }
+
+ static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpOpenEncoded(db);
+ }
+
+ public final AmqpOpen.AmqpOpenBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpOpen.AmqpOpenBuffer.create(new AmqpOpenEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpPropertiesMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpPropertiesMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpPropertiesMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpPropertiesMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,173 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBinary;
+import org.apache.activemq.amqp.protocol.types.AmqpProperties;
+import org.apache.activemq.amqp.protocol.types.AmqpString;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpPropertiesMarshaller implements DescribedTypeMarshaller<AmqpProperties>{
+
+ static final AmqpPropertiesMarshaller SINGLETON = new AmqpPropertiesMarshaller();
+ private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+ public static final String SYMBOLIC_ID = "amqp:properties:list";
+ //Format code: 0x00000001:0x00009802:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 38914;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4295006210L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x98, (byte) 0x02 // DESCRIPTOR ID CODE
+ }), 0);
+
+ private static final ListDecoder DECODER = new ListDecoder() {
+ public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+ switch(pos) {
+ case 0: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+ }
+ case 1: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+ }
+ case 2: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(in));
+ }
+ case 3: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(in));
+ }
+ case 4: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+ }
+ case 5: {
+ return AmqpUlong.AmqpUlongBuffer.create(AmqpUlongMarshaller.createEncoded(in));
+ }
+ case 6: {
+ return AmqpSymbol.AmqpSymbolBuffer.create(AmqpSymbolMarshaller.createEncoded(in));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.unmarshalType(in);
+ }
+ }
+ }
+
+ public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+ switch(pos) {
+ case 0: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+ }
+ case 1: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+ }
+ case 2: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(buffer));
+ }
+ case 3: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(buffer));
+ }
+ case 4: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+ }
+ case 5: {
+ return AmqpUlong.AmqpUlongBuffer.create(AmqpUlongMarshaller.createEncoded(buffer));
+ }
+ case 6: {
+ return AmqpSymbol.AmqpSymbolBuffer.create(AmqpSymbolMarshaller.createEncoded(buffer));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.decodeType(buffer);
+ }
+ }
+ }
+ };
+
+ public static class AmqpPropertiesEncoded extends DescribedEncoded<IAmqpList> {
+
+ public AmqpPropertiesEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpPropertiesEncoded(AmqpProperties value) {
+ super(AmqpListMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpListMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpListMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<IAmqpList> encode(AmqpProperties value) throws AmqpEncodingError {
+ return new AmqpPropertiesEncoded(value);
+ }
+
+ static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpPropertiesEncoded(db);
+ }
+
+ public final AmqpProperties.AmqpPropertiesBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpProperties.AmqpPropertiesBuffer.create(new AmqpPropertiesEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpRejectedMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpRejectedMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpRejectedMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpRejectedMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBoolean;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpRejected;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpRejectedMarshaller implements DescribedTypeMarshaller<AmqpRejected>{
+
+ static final AmqpRejectedMarshaller SINGLETON = new AmqpRejectedMarshaller();
+ private static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> NULL_ENCODED = new Encoder.NullEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>>();
+
+ public static final String SYMBOLIC_ID = "amqp:rejected:map";
+ //Format code: 0x00000001:0x00009805:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 38917;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4295006213L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x98, (byte) 0x05 // DESCRIPTOR ID CODE
+ }), 0);
+
+ //Accessor keys for field mapped fields:
+ private static final AmqpSymbol.AmqpSymbolBuffer TRUNCATE_KEY = new AmqpSymbol.AmqpSymbolBean("truncate").getBuffer(AmqpMarshaller.SINGLETON);
+ private static final AmqpSymbol.AmqpSymbolBuffer REJECT_PROPERTIES_KEY = new AmqpSymbol.AmqpSymbolBean("reject-properties").getBuffer(AmqpMarshaller.SINGLETON);
+
+
+ private static final MapDecoder DECODER = new MapDecoder() {
+ public void decodeToMap(EncodedBuffer encodedKey, EncodedBuffer encodedValue, Map<AmqpType<?, ?>,AmqpType<?, ?>> map) throws AmqpEncodingError {
+ AmqpSymbol key = AmqpSymbol.AmqpSymbolBuffer.create(AmqpSymbolMarshaller.createEncoded(encodedKey));
+ if (key == null) {
+ throw new AmqpEncodingError("Null Key for " + SYMBOLIC_ID);
+ }
+
+ if (key.getValue().equals(TRUNCATE_KEY.getValue())){
+ map.put(TRUNCATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(encodedValue)));
+ }
+ if (key.getValue().equals(REJECT_PROPERTIES_KEY.getValue())){
+ map.put(REJECT_PROPERTIES_KEY, AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(encodedValue)));
+ }
+ else {
+ throw new UnexpectedTypeException("Invalid Key for " + SYMBOLIC_ID + " : " + key);
+ }
+ }
+ public void unmarshalToMap(DataInput in, Map<AmqpType<?, ?>,AmqpType<?, ?>> map) throws AmqpEncodingError, IOException {
+ AmqpSymbol key = AmqpSymbol.AmqpSymbolBuffer.create(AmqpSymbolMarshaller.createEncoded(in));
+ if (key == null) {
+ throw new AmqpEncodingError("Null Key for " + SYMBOLIC_ID);
+ }
+
+ if (key.getValue().equals(TRUNCATE_KEY.getValue())){
+ map.put(TRUNCATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in)));
+ }
+ if (key.getValue().equals(REJECT_PROPERTIES_KEY.getValue())){
+ map.put(REJECT_PROPERTIES_KEY, AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in)));
+ }
+ else {
+ throw new UnexpectedTypeException("Invalid Key for " + SYMBOLIC_ID + " : " + key);
+ }
+ }
+ };
+
+ public static class AmqpRejectedEncoded extends DescribedEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> {
+
+ public AmqpRejectedEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpRejectedEncoded(AmqpRejected value) {
+ super(AmqpMapMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpMapMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpMapMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> encode(AmqpRejected value) throws AmqpEncodingError {
+ return new AmqpRejectedEncoded(value);
+ }
+
+ static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpRejectedEncoded(db);
+ }
+
+ public final AmqpRejected.AmqpRejectedBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpRejected.AmqpRejectedBuffer.create(new AmqpRejectedEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpReleasedMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpReleasedMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpReleasedMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpReleasedMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBoolean;
+import org.apache.activemq.amqp.protocol.types.AmqpMessageAttributes;
+import org.apache.activemq.amqp.protocol.types.AmqpReleased;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpReleasedMarshaller implements DescribedTypeMarshaller<AmqpReleased>{
+
+ static final AmqpReleasedMarshaller SINGLETON = new AmqpReleasedMarshaller();
+ private static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> NULL_ENCODED = new Encoder.NullEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>>();
+
+ public static final String SYMBOLIC_ID = "amqp:released:map";
+ //Format code: 0x00000001:0x00009804:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 38916;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4295006212L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x98, (byte) 0x04 // DESCRIPTOR ID CODE
+ }), 0);
+
+ //Accessor keys for field mapped fields:
+ private static final AmqpSymbol.AmqpSymbolBuffer TRUNCATE_KEY = new AmqpSymbol.AmqpSymbolBean("truncate").getBuffer(AmqpMarshaller.SINGLETON);
+ private static final AmqpSymbol.AmqpSymbolBuffer DELIVERY_FAILED_KEY = new AmqpSymbol.AmqpSymbolBean("delivery-failed").getBuffer(AmqpMarshaller.SINGLETON);
+ private static final AmqpSymbol.AmqpSymbolBuffer DELIVER_ELSEWHERE_KEY = new AmqpSymbol.AmqpSymbolBean("deliver-elsewhere").getBuffer(AmqpMarshaller.SINGLETON);
+ private static final AmqpSymbol.AmqpSymbolBuffer MESSAGE_ATTRS_KEY = new AmqpSymbol.AmqpSymbolBean("message-attrs").getBuffer(AmqpMarshaller.SINGLETON);
+ private static final AmqpSymbol.AmqpSymbolBuffer DELIVERY_ATTRS_KEY = new AmqpSymbol.AmqpSymbolBean("delivery-attrs").getBuffer(AmqpMarshaller.SINGLETON);
+
+
+ private static final MapDecoder DECODER = new MapDecoder() {
+ public void decodeToMap(EncodedBuffer encodedKey, EncodedBuffer encodedValue, Map<AmqpType<?, ?>,AmqpType<?, ?>> map) throws AmqpEncodingError {
+ AmqpSymbol key = AmqpSymbol.AmqpSymbolBuffer.create(AmqpSymbolMarshaller.createEncoded(encodedKey));
+ if (key == null) {
+ throw new AmqpEncodingError("Null Key for " + SYMBOLIC_ID);
+ }
+
+ if (key.getValue().equals(TRUNCATE_KEY.getValue())){
+ map.put(TRUNCATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(encodedValue)));
+ }
+ if (key.getValue().equals(DELIVERY_FAILED_KEY.getValue())){
+ map.put(DELIVERY_FAILED_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(encodedValue)));
+ }
+ if (key.getValue().equals(DELIVER_ELSEWHERE_KEY.getValue())){
+ map.put(DELIVER_ELSEWHERE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(encodedValue)));
+ }
+ if (key.getValue().equals(MESSAGE_ATTRS_KEY.getValue())){
+ map.put(MESSAGE_ATTRS_KEY, AmqpMessageAttributes.AmqpMessageAttributesBuffer.create(AmqpMapMarshaller.createEncoded(encodedValue)));
+ }
+ if (key.getValue().equals(DELIVERY_ATTRS_KEY.getValue())){
+ map.put(DELIVERY_ATTRS_KEY, AmqpMessageAttributes.AmqpMessageAttributesBuffer.create(AmqpMapMarshaller.createEncoded(encodedValue)));
+ }
+ else {
+ throw new UnexpectedTypeException("Invalid Key for " + SYMBOLIC_ID + " : " + key);
+ }
+ }
+ public void unmarshalToMap(DataInput in, Map<AmqpType<?, ?>,AmqpType<?, ?>> map) throws AmqpEncodingError, IOException {
+ AmqpSymbol key = AmqpSymbol.AmqpSymbolBuffer.create(AmqpSymbolMarshaller.createEncoded(in));
+ if (key == null) {
+ throw new AmqpEncodingError("Null Key for " + SYMBOLIC_ID);
+ }
+
+ if (key.getValue().equals(TRUNCATE_KEY.getValue())){
+ map.put(TRUNCATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in)));
+ }
+ if (key.getValue().equals(DELIVERY_FAILED_KEY.getValue())){
+ map.put(DELIVERY_FAILED_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in)));
+ }
+ if (key.getValue().equals(DELIVER_ELSEWHERE_KEY.getValue())){
+ map.put(DELIVER_ELSEWHERE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in)));
+ }
+ if (key.getValue().equals(MESSAGE_ATTRS_KEY.getValue())){
+ map.put(MESSAGE_ATTRS_KEY, AmqpMessageAttributes.AmqpMessageAttributesBuffer.create(AmqpMapMarshaller.createEncoded(in)));
+ }
+ if (key.getValue().equals(DELIVERY_ATTRS_KEY.getValue())){
+ map.put(DELIVERY_ATTRS_KEY, AmqpMessageAttributes.AmqpMessageAttributesBuffer.create(AmqpMapMarshaller.createEncoded(in)));
+ }
+ else {
+ throw new UnexpectedTypeException("Invalid Key for " + SYMBOLIC_ID + " : " + key);
+ }
+ }
+ };
+
+ public static class AmqpReleasedEncoded extends DescribedEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> {
+
+ public AmqpReleasedEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpReleasedEncoded(AmqpReleased value) {
+ super(AmqpMapMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpMapMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpMapMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> encode(AmqpReleased value) throws AmqpEncodingError {
+ return new AmqpReleasedEncoded(value);
+ }
+
+ static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpReleasedEncoded(db);
+ }
+
+ public final AmqpReleased.AmqpReleasedBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpReleased.AmqpReleasedBuffer.create(new AmqpReleasedEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpRelinkMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpRelinkMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpRelinkMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpRelinkMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,156 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpHandle;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpRelink;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpRelinkMarshaller implements DescribedTypeMarshaller<AmqpRelink>{
+
+ static final AmqpRelinkMarshaller SINGLETON = new AmqpRelinkMarshaller();
+ private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+ public static final String SYMBOLIC_ID = "amqp:relink:list";
+ //Format code: 0x00000001:0x00000305:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 773;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294968069L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x05 // DESCRIPTOR ID CODE
+ }), 0);
+
+ private static final ListDecoder DECODER = new ListDecoder() {
+ public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+ switch(pos) {
+ case 0: {
+ return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ case 1: {
+ return AmqpHandle.AmqpHandleBuffer.create(AmqpUintMarshaller.createEncoded(in));
+ }
+ case 2: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ case 3: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.unmarshalType(in);
+ }
+ }
+ }
+
+ public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+ switch(pos) {
+ case 0: {
+ return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ case 1: {
+ return AmqpHandle.AmqpHandleBuffer.create(AmqpUintMarshaller.createEncoded(buffer));
+ }
+ case 2: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ case 3: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.decodeType(buffer);
+ }
+ }
+ }
+ };
+
+ public static class AmqpRelinkEncoded extends DescribedEncoded<IAmqpList> {
+
+ public AmqpRelinkEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpRelinkEncoded(AmqpRelink value) {
+ super(AmqpListMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpListMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpListMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<IAmqpList> encode(AmqpRelink value) throws AmqpEncodingError {
+ return new AmqpRelinkEncoded(value);
+ }
+
+ static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpRelinkEncoded(db);
+ }
+
+ public final AmqpRelink.AmqpRelinkBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpRelink.AmqpRelinkBuffer.create(new AmqpRelinkEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslChallengeMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslChallengeMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslChallengeMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslChallengeMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,143 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBinary;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpSaslChallenge;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpSaslChallengeMarshaller implements DescribedTypeMarshaller<AmqpSaslChallenge>{
+
+ static final AmqpSaslChallengeMarshaller SINGLETON = new AmqpSaslChallengeMarshaller();
+ private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+ public static final String SYMBOLIC_ID = "amqp:sasl-challenge:list";
+ //Format code: 0x00000001:0x00000703:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 1795;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294969091L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0x03 // DESCRIPTOR ID CODE
+ }), 0);
+
+ private static final ListDecoder DECODER = new ListDecoder() {
+ public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+ switch(pos) {
+ case 0: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ case 1: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.unmarshalType(in);
+ }
+ }
+ }
+
+ public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+ switch(pos) {
+ case 0: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ case 1: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.decodeType(buffer);
+ }
+ }
+ }
+ };
+
+ public static class AmqpSaslChallengeEncoded extends DescribedEncoded<IAmqpList> {
+
+ public AmqpSaslChallengeEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpSaslChallengeEncoded(AmqpSaslChallenge value) {
+ super(AmqpListMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpListMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpListMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<IAmqpList> encode(AmqpSaslChallenge value) throws AmqpEncodingError {
+ return new AmqpSaslChallengeEncoded(value);
+ }
+
+ static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpSaslChallengeEncoded(db);
+ }
+
+ public final AmqpSaslChallenge.AmqpSaslChallengeBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpSaslChallenge.AmqpSaslChallengeBuffer.create(new AmqpSaslChallengeEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslInitMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslInitMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslInitMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslInitMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBinary;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpSaslInit;
+import org.apache.activemq.amqp.protocol.types.AmqpString;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpSaslInitMarshaller implements DescribedTypeMarshaller<AmqpSaslInit>{
+
+ static final AmqpSaslInitMarshaller SINGLETON = new AmqpSaslInitMarshaller();
+ private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+ public static final String SYMBOLIC_ID = "amqp:sasl-init:list";
+ //Format code: 0x00000001:0x00000702:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 1794;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294969090L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0x02 // DESCRIPTOR ID CODE
+ }), 0);
+
+ private static final ListDecoder DECODER = new ListDecoder() {
+ public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+ switch(pos) {
+ case 0: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ case 1: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(in));
+ }
+ case 2: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.unmarshalType(in);
+ }
+ }
+ }
+
+ public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+ switch(pos) {
+ case 0: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ case 1: {
+ return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(buffer));
+ }
+ case 2: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.decodeType(buffer);
+ }
+ }
+ }
+ };
+
+ public static class AmqpSaslInitEncoded extends DescribedEncoded<IAmqpList> {
+
+ public AmqpSaslInitEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpSaslInitEncoded(AmqpSaslInit value) {
+ super(AmqpListMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpListMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpListMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<IAmqpList> encode(AmqpSaslInit value) throws AmqpEncodingError {
+ return new AmqpSaslInitEncoded(value);
+ }
+
+ static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpSaslInitEncoded(db);
+ }
+
+ public final AmqpSaslInit.AmqpSaslInitBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpSaslInit.AmqpSaslInitBuffer.create(new AmqpSaslInitEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslMechanismsMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslMechanismsMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslMechanismsMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslMechanismsMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,143 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpList;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpSaslMechanisms;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpSaslMechanismsMarshaller implements DescribedTypeMarshaller<AmqpSaslMechanisms>{
+
+ static final AmqpSaslMechanismsMarshaller SINGLETON = new AmqpSaslMechanismsMarshaller();
+ private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+ public static final String SYMBOLIC_ID = "amqp:sasl-mechanisms:list";
+ //Format code: 0x00000001:0x00000701:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 1793;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294969089L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0x01 // DESCRIPTOR ID CODE
+ }), 0);
+
+ private static final ListDecoder DECODER = new ListDecoder() {
+ public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+ switch(pos) {
+ case 0: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ case 1: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(in));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.unmarshalType(in);
+ }
+ }
+ }
+
+ public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+ switch(pos) {
+ case 0: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ case 1: {
+ return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(buffer));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.decodeType(buffer);
+ }
+ }
+ }
+ };
+
+ public static class AmqpSaslMechanismsEncoded extends DescribedEncoded<IAmqpList> {
+
+ public AmqpSaslMechanismsEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpSaslMechanismsEncoded(AmqpSaslMechanisms value) {
+ super(AmqpListMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpListMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpListMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<IAmqpList> encode(AmqpSaslMechanisms value) throws AmqpEncodingError {
+ return new AmqpSaslMechanismsEncoded(value);
+ }
+
+ static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpSaslMechanismsEncoded(db);
+ }
+
+ public final AmqpSaslMechanisms.AmqpSaslMechanismsBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpSaslMechanisms.AmqpSaslMechanismsBuffer.create(new AmqpSaslMechanismsEncoded(encoded));
+ }
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslOutcomeMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslOutcomeMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslOutcomeMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslOutcomeMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his 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.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBinary;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpSaslOutcome;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUbyte;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpSaslOutcomeMarshaller implements DescribedTypeMarshaller<AmqpSaslOutcome>{
+
+ static final AmqpSaslOutcomeMarshaller SINGLETON = new AmqpSaslOutcomeMarshaller();
+ private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+ public static final String SYMBOLIC_ID = "amqp:sasl-outcome:list";
+ //Format code: 0x00000001:0x00000705:
+ public static final long CATEGORY = 1;
+ public static final long DESCRIPTOR_ID = 1797;
+ public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294969093L)
+ //Hard coded descriptor:
+ public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+ (byte) 0x80, // ulong descriptor encoding)
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // CATEGORY CODE
+ (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0x05 // DESCRIPTOR ID CODE
+ }), 0);
+
+ private static final ListDecoder DECODER = new ListDecoder() {
+ public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+ switch(pos) {
+ case 0: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+ }
+ case 1: {
+ return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(in));
+ }
+ case 2: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.unmarshalType(in);
+ }
+ }
+ }
+
+ public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+ switch(pos) {
+ case 0: {
+ return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+ }
+ case 1: {
+ return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(buffer));
+ }
+ case 2: {
+ return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+ }
+ default: {
+ return AmqpMarshaller.SINGLETON.decodeType(buffer);
+ }
+ }
+ }
+ };
+
+ public static class AmqpSaslOutcomeEncoded extends DescribedEncoded<IAmqpList> {
+
+ public AmqpSaslOutcomeEncoded(DescribedBuffer buffer) {
+ super(buffer);
+ }
+
+ public AmqpSaslOutcomeEncoded(AmqpSaslOutcome value) {
+ super(AmqpListMarshaller.encode(value));
+ }
+
+ protected final String getSymbolicId() {
+ return SYMBOLIC_ID;
+ }
+
+ protected final long getNumericId() {
+ return NUMERIC_ID;
+ }
+
+ protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+ return AmqpListMarshaller.createEncoded(encoded, DECODER);
+ }
+
+ protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+ return AmqpListMarshaller.createEncoded(in, DECODER);
+ }
+
+ protected final EncodedBuffer getDescriptor() {
+ return DESCRIPTOR;
+ }
+ }
+
+ public static final Encoded<IAmqpList> encode(AmqpSaslOutcome value) throws AmqpEncodingError {
+ return new AmqpSaslOutcomeEncoded(value);
+ }
+
+ static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(source, offset));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+ return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+ }
+
+ static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+ byte fc = buffer.getEncodingFormatCode();
+ if (fc == Encoder.NULL_FORMAT_CODE) {
+ return NULL_ENCODED;
+ }
+
+ DescribedBuffer db = buffer.asDescribed();
+ AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+ if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+ descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+ throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+ }
+ return new AmqpSaslOutcomeEncoded(db);
+ }
+
+ public final AmqpSaslOutcome.AmqpSaslOutcomeBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+ return AmqpSaslOutcome.AmqpSaslOutcomeBuffer.create(new AmqpSaslOutcomeEncoded(encoded));
+ }
+}
|