activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmacn...@apache.org
Subject svn commit: r908857 [12/17] - in /activemq/sandbox/activemq-apollo-actor/activemq-amqp: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/activemq/ src/main/java/org/apache/activemq/amqp/ src/main/ja...
Date Thu, 11 Feb 2010 07:04:46 GMT
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpHeader.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpHeader.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpHeader.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpHeader.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,936 @@
+/**
+ * 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.types;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.Boolean;
+import java.lang.Long;
+import java.lang.Short;
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.Iterator;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpMarshaller;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+/**
+ * Represents a transport headers for a Message
+ * <p>
+ * The header struct carries information about the transfer of a Message over a specific
+ * Link.
+ * </p>
+ */
+public interface AmqpHeader extends AmqpList {
+
+
+
+    /**
+     * specify durability requirements
+     * <p>
+     * Durable Messages MUST NOT be lost even if an intermediary is unexpectedly terminated and
+     * restarted.
+     * </p>
+     */
+    public void setDurable(Boolean durable);
+
+    /**
+     * specify durability requirements
+     * <p>
+     * Durable Messages MUST NOT be lost even if an intermediary is unexpectedly terminated and
+     * restarted.
+     * </p>
+     */
+    public void setDurable(AmqpBoolean durable);
+
+    /**
+     * specify durability requirements
+     * <p>
+     * Durable Messages MUST NOT be lost even if an intermediary is unexpectedly terminated and
+     * restarted.
+     * </p>
+     */
+    public Boolean getDurable();
+
+    /**
+     * relative Message priority
+     * <p>
+     * This field contains the relative Message priority. Higher numbers indicate higher
+     * priority Messages. Messages with higher priorities MAY be delivered before those with
+     * lower priorities.
+     * </p>
+     * <p>
+     * An AMQP intermediary implementing distinct priority levels MUST do so in the following
+     * manner:
+     * </p>
+     * <ul>
+     * <li>
+     * <p>
+     * If n distinct priorities are implemented and n is less than 10 -- priorities 0 to
+     * (5 - ceiling(n/2)) MUST be treated equivalently and MUST be the lowest effective
+     * priority. The priorities (4 + floor(n/2)) and above MUST be treated equivalently
+     * and MUST be the highest effective priority. The priorities (5 - ceiling(n/2)) to (4
+     * + floor(n/2)) inclusive MUST be treated as distinct priorities.
+     * </p>
+     * <
+     * ></li>
+     * <li>
+     * <p>
+     * If n distinct priorities are implemented and n is 10 or greater -- priorities 0 to
+     * (n - 1) MUST be distinct, and priorities n and above MUST be equivalent to priority
+     * (n - 1).
+     * </p>
+     * <
+     * ></li>
+     * <
+     * ></ul>
+     * <p>
+     * Thus, for example, if 2 distinct priorities are implemented, then levels 0 to 4 are
+     * equivalent, and levels 5 to 9 are equivalent and levels 4 and 5 are distinct. If 3
+     * distinct priorities are implements the 0 to 3 are equivalent, 5 to 9 are equivalent and
+     * 3, 4 and 5 are distinct.
+     * </p>
+     * <p>
+     * This scheme ensures that if two priorities are distinct for a server which implements m
+     * separate priority levels they are also distinct for a server which implements n
+     * different priority levels where n > m.
+     * </p>
+     */
+    public void setPriority(Short priority);
+
+    /**
+     * relative Message priority
+     * <p>
+     * This field contains the relative Message priority. Higher numbers indicate higher
+     * priority Messages. Messages with higher priorities MAY be delivered before those with
+     * lower priorities.
+     * </p>
+     * <p>
+     * An AMQP intermediary implementing distinct priority levels MUST do so in the following
+     * manner:
+     * </p>
+     * <ul>
+     * <li>
+     * <p>
+     * If n distinct priorities are implemented and n is less than 10 -- priorities 0 to
+     * (5 - ceiling(n/2)) MUST be treated equivalently and MUST be the lowest effective
+     * priority. The priorities (4 + floor(n/2)) and above MUST be treated equivalently
+     * and MUST be the highest effective priority. The priorities (5 - ceiling(n/2)) to (4
+     * + floor(n/2)) inclusive MUST be treated as distinct priorities.
+     * </p>
+     * <
+     * ></li>
+     * <li>
+     * <p>
+     * If n distinct priorities are implemented and n is 10 or greater -- priorities 0 to
+     * (n - 1) MUST be distinct, and priorities n and above MUST be equivalent to priority
+     * (n - 1).
+     * </p>
+     * <
+     * ></li>
+     * <
+     * ></ul>
+     * <p>
+     * Thus, for example, if 2 distinct priorities are implemented, then levels 0 to 4 are
+     * equivalent, and levels 5 to 9 are equivalent and levels 4 and 5 are distinct. If 3
+     * distinct priorities are implements the 0 to 3 are equivalent, 5 to 9 are equivalent and
+     * 3, 4 and 5 are distinct.
+     * </p>
+     * <p>
+     * This scheme ensures that if two priorities are distinct for a server which implements m
+     * separate priority levels they are also distinct for a server which implements n
+     * different priority levels where n > m.
+     * </p>
+     */
+    public void setPriority(AmqpUbyte priority);
+
+    /**
+     * relative Message priority
+     * <p>
+     * This field contains the relative Message priority. Higher numbers indicate higher
+     * priority Messages. Messages with higher priorities MAY be delivered before those with
+     * lower priorities.
+     * </p>
+     * <p>
+     * An AMQP intermediary implementing distinct priority levels MUST do so in the following
+     * manner:
+     * </p>
+     * <ul>
+     * <li>
+     * <p>
+     * If n distinct priorities are implemented and n is less than 10 -- priorities 0 to
+     * (5 - ceiling(n/2)) MUST be treated equivalently and MUST be the lowest effective
+     * priority. The priorities (4 + floor(n/2)) and above MUST be treated equivalently
+     * and MUST be the highest effective priority. The priorities (5 - ceiling(n/2)) to (4
+     * + floor(n/2)) inclusive MUST be treated as distinct priorities.
+     * </p>
+     * <
+     * ></li>
+     * <li>
+     * <p>
+     * If n distinct priorities are implemented and n is 10 or greater -- priorities 0 to
+     * (n - 1) MUST be distinct, and priorities n and above MUST be equivalent to priority
+     * (n - 1).
+     * </p>
+     * <
+     * ></li>
+     * <
+     * ></ul>
+     * <p>
+     * Thus, for example, if 2 distinct priorities are implemented, then levels 0 to 4 are
+     * equivalent, and levels 5 to 9 are equivalent and levels 4 and 5 are distinct. If 3
+     * distinct priorities are implements the 0 to 3 are equivalent, 5 to 9 are equivalent and
+     * 3, 4 and 5 are distinct.
+     * </p>
+     * <p>
+     * This scheme ensures that if two priorities are distinct for a server which implements m
+     * separate priority levels they are also distinct for a server which implements n
+     * different priority levels where n > m.
+     * </p>
+     */
+    public Short getPriority();
+
+    /**
+     * the time of Message transmit
+     * <p>
+     * The point in time at which the sender considers the Message to be transmitted. The ttl
+     * field, if set by the sender, is relative to this point in time.
+     * </p>
+     */
+    public void setTransmitTime(Date transmitTime);
+
+    /**
+     * the time of Message transmit
+     * <p>
+     * The point in time at which the sender considers the Message to be transmitted. The ttl
+     * field, if set by the sender, is relative to this point in time.
+     * </p>
+     */
+    public void setTransmitTime(AmqpTimestamp transmitTime);
+
+    /**
+     * the time of Message transmit
+     * <p>
+     * The point in time at which the sender considers the Message to be transmitted. The ttl
+     * field, if set by the sender, is relative to this point in time.
+     * </p>
+     */
+    public Date getTransmitTime();
+
+    /**
+     * time to live in ms
+     * <p>
+     * Duration in milliseconds for which the Message should be considered "live". If this is
+     * set then a Message expiration time will be computed based on the transmit-time plus this
+     * value. Messages that live longer than their expiration time will be discarded (or dead
+     * lettered). If the transmit-time is not set, then the expiration is computed relative to
+     * the Message arrival time.
+     * </p>
+     */
+    public void setTtl(BigInteger ttl);
+
+    /**
+     * time to live in ms
+     * <p>
+     * Duration in milliseconds for which the Message should be considered "live". If this is
+     * set then a Message expiration time will be computed based on the transmit-time plus this
+     * value. Messages that live longer than their expiration time will be discarded (or dead
+     * lettered). If the transmit-time is not set, then the expiration is computed relative to
+     * the Message arrival time.
+     * </p>
+     */
+    public void setTtl(AmqpUlong ttl);
+
+    /**
+     * time to live in ms
+     * <p>
+     * Duration in milliseconds for which the Message should be considered "live". If this is
+     * set then a Message expiration time will be computed based on the transmit-time plus this
+     * value. Messages that live longer than their expiration time will be discarded (or dead
+     * lettered). If the transmit-time is not set, then the expiration is computed relative to
+     * the Message arrival time.
+     * </p>
+     */
+    public BigInteger getTtl();
+
+    /**
+     * <p>
+     * The number of other DESTRUCTIVE Links to which delivery of this Message was previously
+     * attempted unsuccessfully. This does not include the current Link even if delivery to the
+     * current Link has been previously attempted.
+     * </p>
+     */
+    public void setFormerAcquirers(Long formerAcquirers);
+
+    /**
+     * <p>
+     * The number of other DESTRUCTIVE Links to which delivery of this Message was previously
+     * attempted unsuccessfully. This does not include the current Link even if delivery to the
+     * current Link has been previously attempted.
+     * </p>
+     */
+    public void setFormerAcquirers(AmqpUint formerAcquirers);
+
+    /**
+     * <p>
+     * The number of other DESTRUCTIVE Links to which delivery of this Message was previously
+     * attempted unsuccessfully. This does not include the current Link even if delivery to the
+     * current Link has been previously attempted.
+     * </p>
+     */
+    public Long getFormerAcquirers();
+
+    /**
+     * the number of prior unsuccessful delivery attempts
+     * <p>
+     * The number of unsuccessful previous attempts to deliver this message. If this value is
+     * non-zero it may be taken as an indication that the Message may be a duplicate. The
+     * delivery-failures value is initially set to the same value as the Message has when it
+     * arrived at the source. It is incremented When:
+     * </p>
+     * <ol>
+     * <li>
+     * <p>
+     * the Message has previously been sent from this Node using a Source with a
+     * distribution-mode of DESTRUCTIVE which closed without the Message being acknowledged
+     * </p>
+     * </li>
+     * <li>
+     * <p>
+     * and the delivery-failed field set to true.
+     * </p>
+     * </li>
+     * </ol>
+     */
+    public void setDeliveryFailures(Long deliveryFailures);
+
+    /**
+     * the number of prior unsuccessful delivery attempts
+     * <p>
+     * The number of unsuccessful previous attempts to deliver this message. If this value is
+     * non-zero it may be taken as an indication that the Message may be a duplicate. The
+     * delivery-failures value is initially set to the same value as the Message has when it
+     * arrived at the source. It is incremented When:
+     * </p>
+     * <ol>
+     * <li>
+     * <p>
+     * the Message has previously been sent from this Node using a Source with a
+     * distribution-mode of DESTRUCTIVE which closed without the Message being acknowledged
+     * </p>
+     * </li>
+     * <li>
+     * <p>
+     * and the delivery-failed field set to true.
+     * </p>
+     * </li>
+     * </ol>
+     */
+    public void setDeliveryFailures(AmqpUint deliveryFailures);
+
+    /**
+     * the number of prior unsuccessful delivery attempts
+     * <p>
+     * The number of unsuccessful previous attempts to deliver this message. If this value is
+     * non-zero it may be taken as an indication that the Message may be a duplicate. The
+     * delivery-failures value is initially set to the same value as the Message has when it
+     * arrived at the source. It is incremented When:
+     * </p>
+     * <ol>
+     * <li>
+     * <p>
+     * the Message has previously been sent from this Node using a Source with a
+     * distribution-mode of DESTRUCTIVE which closed without the Message being acknowledged
+     * </p>
+     * </li>
+     * <li>
+     * <p>
+     * and the delivery-failed field set to true.
+     * </p>
+     * </li>
+     * </ol>
+     */
+    public Long getDeliveryFailures();
+
+    /**
+     * indicates the format of the Message
+     */
+    public void setFormatCode(Long formatCode);
+
+    /**
+     * indicates the format of the Message
+     */
+    public void setFormatCode(AmqpUint formatCode);
+
+    /**
+     * indicates the format of the Message
+     */
+    public Long getFormatCode();
+
+    /**
+     * message attributes
+     * <p>
+     * command and
+     * dispositions which allow for updates to the message-attrs.
+     * </p>
+     */
+    public void setMessageAttrs(AmqpMessageAttributes messageAttrs);
+
+    /**
+     * message attributes
+     * <p>
+     * command and
+     * dispositions which allow for updates to the message-attrs.
+     * </p>
+     */
+    public AmqpMessageAttributes getMessageAttrs();
+
+    /**
+     * delivery attributes
+     * <p>
+     * command
+     * and dispositions which allow for updates to the delivery-attrs.
+     * </p>
+     */
+    public void setDeliveryAttrs(AmqpMessageAttributes deliveryAttrs);
+
+    /**
+     * delivery attributes
+     * <p>
+     * command
+     * and dispositions which allow for updates to the delivery-attrs.
+     * </p>
+     */
+    public AmqpMessageAttributes getDeliveryAttrs();
+
+    public static class AmqpHeaderBean implements AmqpHeader{
+
+        private AmqpHeaderBuffer buffer;
+        private AmqpHeaderBean bean = this;
+        private AmqpBoolean durable;
+        private AmqpUbyte priority;
+        private AmqpTimestamp transmitTime;
+        private AmqpUlong ttl;
+        private AmqpUint formerAcquirers;
+        private AmqpUint deliveryFailures;
+        private AmqpUint formatCode;
+        private AmqpMessageAttributes messageAttrs;
+        private AmqpMessageAttributes deliveryAttrs;
+
+        public AmqpHeaderBean() {
+        }
+
+        public AmqpHeaderBean(IAmqpList value) {
+            //TODO we should defer decoding of the described type:
+            for(int i = 0; i < value.getListCount(); i++) {
+                set(i, value.get(i));
+            }
+        }
+
+        public AmqpHeaderBean(AmqpHeader.AmqpHeaderBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpHeaderBean copy() {
+            return new AmqpHeader.AmqpHeaderBean(bean);
+        }
+
+        public final AmqpHeader.AmqpHeaderBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpHeaderBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public void setDurable(Boolean durable) {
+            setDurable(new AmqpBoolean.AmqpBooleanBean(durable));
+        }
+
+
+        public final void setDurable(AmqpBoolean durable) {
+            copyCheck();
+            bean.durable = durable;
+        }
+
+        public final Boolean getDurable() {
+            return bean.durable.getValue();
+        }
+
+        public void setPriority(Short priority) {
+            setPriority(new AmqpUbyte.AmqpUbyteBean(priority));
+        }
+
+
+        public final void setPriority(AmqpUbyte priority) {
+            copyCheck();
+            bean.priority = priority;
+        }
+
+        public final Short getPriority() {
+            return bean.priority.getValue();
+        }
+
+        public void setTransmitTime(Date transmitTime) {
+            setTransmitTime(new AmqpTimestamp.AmqpTimestampBean(transmitTime));
+        }
+
+
+        public final void setTransmitTime(AmqpTimestamp transmitTime) {
+            copyCheck();
+            bean.transmitTime = transmitTime;
+        }
+
+        public final Date getTransmitTime() {
+            return bean.transmitTime.getValue();
+        }
+
+        public void setTtl(BigInteger ttl) {
+            setTtl(new AmqpUlong.AmqpUlongBean(ttl));
+        }
+
+
+        public final void setTtl(AmqpUlong ttl) {
+            copyCheck();
+            bean.ttl = ttl;
+        }
+
+        public final BigInteger getTtl() {
+            return bean.ttl.getValue();
+        }
+
+        public void setFormerAcquirers(Long formerAcquirers) {
+            setFormerAcquirers(new AmqpUint.AmqpUintBean(formerAcquirers));
+        }
+
+
+        public final void setFormerAcquirers(AmqpUint formerAcquirers) {
+            copyCheck();
+            bean.formerAcquirers = formerAcquirers;
+        }
+
+        public final Long getFormerAcquirers() {
+            return bean.formerAcquirers.getValue();
+        }
+
+        public void setDeliveryFailures(Long deliveryFailures) {
+            setDeliveryFailures(new AmqpUint.AmqpUintBean(deliveryFailures));
+        }
+
+
+        public final void setDeliveryFailures(AmqpUint deliveryFailures) {
+            copyCheck();
+            bean.deliveryFailures = deliveryFailures;
+        }
+
+        public final Long getDeliveryFailures() {
+            return bean.deliveryFailures.getValue();
+        }
+
+        public void setFormatCode(Long formatCode) {
+            setFormatCode(new AmqpUint.AmqpUintBean(formatCode));
+        }
+
+
+        public final void setFormatCode(AmqpUint formatCode) {
+            copyCheck();
+            bean.formatCode = formatCode;
+        }
+
+        public final Long getFormatCode() {
+            return bean.formatCode.getValue();
+        }
+
+        public final void setMessageAttrs(AmqpMessageAttributes messageAttrs) {
+            copyCheck();
+            bean.messageAttrs = messageAttrs;
+        }
+
+        public final AmqpMessageAttributes getMessageAttrs() {
+            return bean.messageAttrs;
+        }
+
+        public final void setDeliveryAttrs(AmqpMessageAttributes deliveryAttrs) {
+            copyCheck();
+            bean.deliveryAttrs = deliveryAttrs;
+        }
+
+        public final AmqpMessageAttributes getDeliveryAttrs() {
+            return bean.deliveryAttrs;
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            switch(index) {
+            case 0: {
+                setDurable((AmqpBoolean) value);
+                break;
+            }
+            case 1: {
+                setPriority((AmqpUbyte) value);
+                break;
+            }
+            case 2: {
+                setTransmitTime((AmqpTimestamp) value);
+                break;
+            }
+            case 3: {
+                setTtl((AmqpUlong) value);
+                break;
+            }
+            case 4: {
+                setFormerAcquirers((AmqpUint) value);
+                break;
+            }
+            case 5: {
+                setDeliveryFailures((AmqpUint) value);
+                break;
+            }
+            case 6: {
+                setFormatCode((AmqpUint) value);
+                break;
+            }
+            case 7: {
+                setMessageAttrs((AmqpMessageAttributes) value);
+                break;
+            }
+            case 8: {
+                setDeliveryAttrs((AmqpMessageAttributes) value);
+                break;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public AmqpType<?, ?> get(int index) {
+            switch(index) {
+            case 0: {
+                return bean.durable;
+            }
+            case 1: {
+                return bean.priority;
+            }
+            case 2: {
+                return bean.transmitTime;
+            }
+            case 3: {
+                return bean.ttl;
+            }
+            case 4: {
+                return bean.formerAcquirers;
+            }
+            case 5: {
+                return bean.deliveryFailures;
+            }
+            case 6: {
+                return bean.formatCode;
+            }
+            case 7: {
+                return bean.messageAttrs;
+            }
+            case 8: {
+                return bean.deliveryAttrs;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public int getListCount() {
+            return 9;
+        }
+
+        public IAmqpList getValue() {
+            return bean;
+        }
+
+        public Iterator<AmqpType<?, ?>> iterator() {
+            return new AmqpListIterator(bean);
+        }
+
+
+        private final void copyCheck() {
+            if(buffer != null) {;
+                throw new IllegalStateException("unwriteable");
+            }
+            if(bean != this) {;
+                copy(bean);
+            }
+        }
+
+        private final void copy(AmqpHeader.AmqpHeaderBean other) {
+            this.durable= other.durable;
+            this.priority= other.priority;
+            this.transmitTime= other.transmitTime;
+            this.ttl= other.ttl;
+            this.formerAcquirers= other.formerAcquirers;
+            this.deliveryFailures= other.deliveryFailures;
+            this.formatCode= other.formatCode;
+            this.messageAttrs= other.messageAttrs;
+            this.deliveryAttrs= other.deliveryAttrs;
+            bean = this;
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpHeader)) {
+                return false;
+            }
+
+            return equivalent((AmqpHeader) t);
+        }
+
+        public boolean equivalent(AmqpHeader b) {
+
+            if(b.getDurable() == null ^ getDurable() == null) {
+                return false;
+            }
+            if(b.getDurable() != null && !b.getDurable().equals(getDurable())){ 
+                return false;
+            }
+
+            if(b.getPriority() == null ^ getPriority() == null) {
+                return false;
+            }
+            if(b.getPriority() != null && !b.getPriority().equals(getPriority())){ 
+                return false;
+            }
+
+            if(b.getTransmitTime() == null ^ getTransmitTime() == null) {
+                return false;
+            }
+            if(b.getTransmitTime() != null && !b.getTransmitTime().equals(getTransmitTime())){ 
+                return false;
+            }
+
+            if(b.getTtl() == null ^ getTtl() == null) {
+                return false;
+            }
+            if(b.getTtl() != null && !b.getTtl().equals(getTtl())){ 
+                return false;
+            }
+
+            if(b.getFormerAcquirers() == null ^ getFormerAcquirers() == null) {
+                return false;
+            }
+            if(b.getFormerAcquirers() != null && !b.getFormerAcquirers().equals(getFormerAcquirers())){ 
+                return false;
+            }
+
+            if(b.getDeliveryFailures() == null ^ getDeliveryFailures() == null) {
+                return false;
+            }
+            if(b.getDeliveryFailures() != null && !b.getDeliveryFailures().equals(getDeliveryFailures())){ 
+                return false;
+            }
+
+            if(b.getFormatCode() == null ^ getFormatCode() == null) {
+                return false;
+            }
+            if(b.getFormatCode() != null && !b.getFormatCode().equals(getFormatCode())){ 
+                return false;
+            }
+
+            if(b.getMessageAttrs() == null ^ getMessageAttrs() == null) {
+                return false;
+            }
+            if(b.getMessageAttrs() != null && !b.getMessageAttrs().equals(getMessageAttrs())){ 
+                return false;
+            }
+
+            if(b.getDeliveryAttrs() == null ^ getDeliveryAttrs() == null) {
+                return false;
+            }
+            if(b.getDeliveryAttrs() != null && !b.getDeliveryAttrs().equals(getDeliveryAttrs())){ 
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static class AmqpHeaderBuffer extends AmqpList.AmqpListBuffer implements AmqpHeader{
+
+        private AmqpHeaderBean bean;
+
+        protected AmqpHeaderBuffer(Encoded<IAmqpList> encoded) {
+            super(encoded);
+        }
+
+    public void setDurable(Boolean durable) {
+            bean().setDurable(durable);
+        }
+
+        public final void setDurable(AmqpBoolean durable) {
+            bean().setDurable(durable);
+        }
+
+        public final Boolean getDurable() {
+            return bean().getDurable();
+        }
+
+    public void setPriority(Short priority) {
+            bean().setPriority(priority);
+        }
+
+        public final void setPriority(AmqpUbyte priority) {
+            bean().setPriority(priority);
+        }
+
+        public final Short getPriority() {
+            return bean().getPriority();
+        }
+
+    public void setTransmitTime(Date transmitTime) {
+            bean().setTransmitTime(transmitTime);
+        }
+
+        public final void setTransmitTime(AmqpTimestamp transmitTime) {
+            bean().setTransmitTime(transmitTime);
+        }
+
+        public final Date getTransmitTime() {
+            return bean().getTransmitTime();
+        }
+
+    public void setTtl(BigInteger ttl) {
+            bean().setTtl(ttl);
+        }
+
+        public final void setTtl(AmqpUlong ttl) {
+            bean().setTtl(ttl);
+        }
+
+        public final BigInteger getTtl() {
+            return bean().getTtl();
+        }
+
+    public void setFormerAcquirers(Long formerAcquirers) {
+            bean().setFormerAcquirers(formerAcquirers);
+        }
+
+        public final void setFormerAcquirers(AmqpUint formerAcquirers) {
+            bean().setFormerAcquirers(formerAcquirers);
+        }
+
+        public final Long getFormerAcquirers() {
+            return bean().getFormerAcquirers();
+        }
+
+    public void setDeliveryFailures(Long deliveryFailures) {
+            bean().setDeliveryFailures(deliveryFailures);
+        }
+
+        public final void setDeliveryFailures(AmqpUint deliveryFailures) {
+            bean().setDeliveryFailures(deliveryFailures);
+        }
+
+        public final Long getDeliveryFailures() {
+            return bean().getDeliveryFailures();
+        }
+
+    public void setFormatCode(Long formatCode) {
+            bean().setFormatCode(formatCode);
+        }
+
+        public final void setFormatCode(AmqpUint formatCode) {
+            bean().setFormatCode(formatCode);
+        }
+
+        public final Long getFormatCode() {
+            return bean().getFormatCode();
+        }
+
+        public final void setMessageAttrs(AmqpMessageAttributes messageAttrs) {
+            bean().setMessageAttrs(messageAttrs);
+        }
+
+        public final AmqpMessageAttributes getMessageAttrs() {
+            return bean().getMessageAttrs();
+        }
+
+        public final void setDeliveryAttrs(AmqpMessageAttributes deliveryAttrs) {
+            bean().setDeliveryAttrs(deliveryAttrs);
+        }
+
+        public final AmqpMessageAttributes getDeliveryAttrs() {
+            return bean().getDeliveryAttrs();
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            bean().set(index, value);
+        }
+
+        public AmqpType<?, ?> get(int index) {
+            return bean().get(index);
+        }
+
+        public int getListCount() {
+            return bean().getListCount();
+        }
+
+        public Iterator<AmqpType<?, ?>> iterator() {
+            return bean().iterator();
+        }
+
+        public IAmqpList getValue() {
+            return bean().getValue();
+        }
+
+        public AmqpHeader.AmqpHeaderBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpHeader bean() {
+            if(bean == null) {
+                bean = new AmqpHeader.AmqpHeaderBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpHeader.AmqpHeaderBuffer create(Encoded<IAmqpList> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpHeader.AmqpHeaderBuffer(encoded);
+        }
+
+        public static AmqpHeader.AmqpHeaderBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpHeader(in));
+        }
+
+        public static AmqpHeader.AmqpHeaderBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpHeader(buffer, offset));
+        }
+    }
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpInt.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpInt.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpInt.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpInt.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,181 @@
+/**
+ * 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.types;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.Integer;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpMarshaller;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.util.buffer.Buffer;
+
+/**
+ * Represents a integer in the range -(2^31) to 2^31 - 1
+ */
+public interface AmqpInt extends AmqpType<AmqpInt.AmqpIntBean, AmqpInt.AmqpIntBuffer> {
+
+
+    public Integer getValue();
+
+    public static class AmqpIntBean implements AmqpInt{
+
+        private AmqpIntBuffer buffer;
+        private AmqpIntBean bean = this;
+        private Integer value;
+
+        protected AmqpIntBean() {
+        }
+
+        public AmqpIntBean(Integer value) {
+            this.value = value;
+        }
+
+        public AmqpIntBean(AmqpInt.AmqpIntBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpIntBean copy() {
+            return bean;
+        }
+
+        public final AmqpInt.AmqpIntBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpIntBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public Integer getValue() {
+            return bean.value;
+        }
+
+
+        public boolean equals(Object o){
+            if(this == o) {
+                return true;
+            }
+
+            if(o == null || !(o instanceof AmqpInt)) {
+                return false;
+            }
+
+            return equivalent((AmqpInt) o);
+        }
+
+        public int hashCode() {
+            if(getValue() == null) {
+                return AmqpInt.AmqpIntBean.class.hashCode();
+            }
+            return getValue().hashCode();
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpInt)) {
+                return false;
+            }
+
+            return equivalent((AmqpInt) t);
+        }
+
+        public boolean equivalent(AmqpInt b) {
+            if(b == null) {
+                return false;
+            }
+
+            if(b.getValue() == null ^ getValue() == null) {
+                return false;
+            }
+
+            return b.getValue() == null || b.getValue().equals(getValue());
+        }
+    }
+
+    public static class AmqpIntBuffer implements AmqpInt, AmqpBuffer< Integer> {
+
+        private AmqpIntBean bean;
+        protected Encoded<Integer> encoded;
+
+        protected AmqpIntBuffer() {
+        }
+
+        protected AmqpIntBuffer(Encoded<Integer> encoded) {
+            this.encoded = encoded;
+        }
+
+        public final Encoded<Integer> getEncoded() throws AmqpEncodingError{
+            return encoded;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            encoded.marshal(out);
+        }
+
+        public Integer getValue() {
+            return bean().getValue();
+        }
+
+        public AmqpInt.AmqpIntBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpInt bean() {
+            if(bean == null) {
+                bean = new AmqpInt.AmqpIntBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equals(Object o){
+            return bean().equals(o);
+        }
+
+        public int hashCode() {
+            return bean().hashCode();
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpInt.AmqpIntBuffer create(Encoded<Integer> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpInt.AmqpIntBuffer(encoded);
+        }
+
+        public static AmqpInt.AmqpIntBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpInt(in));
+        }
+
+        public static AmqpInt.AmqpIntBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpInt(buffer, offset));
+        }
+    }
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLink.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLink.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLink.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLink.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,839 @@
+/**
+ * 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.types;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.String;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.Iterator;
+import org.apache.activemq.amqp.protocol.AmqpCommand;
+import org.apache.activemq.amqp.protocol.AmqpCommandHandler;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpMarshaller;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+/**
+ * Represents a carries the local state and desired remote state of a Link
+ * <p>
+ * command confirming the state update.
+ * </p>
+ */
+public interface AmqpLink extends AmqpList, AmqpCommand {
+
+
+
+    /**
+     * options map
+     */
+    public void setOptions(AmqpOptions options);
+
+    /**
+     * options map
+     */
+    public AmqpOptions getOptions();
+
+    /**
+     * the name of the Link
+     * <p>
+     * field. Link commands with the same name but differing scope refer to
+     * distinct Links.
+     * </p>
+     */
+    public void setName(String name);
+
+    /**
+     * the name of the Link
+     * <p>
+     * field. Link commands with the same name but differing scope refer to
+     * distinct Links.
+     * </p>
+     */
+    public void setName(AmqpString name);
+
+    /**
+     * the name of the Link
+     * <p>
+     * field. Link commands with the same name but differing scope refer to
+     * distinct Links.
+     * </p>
+     */
+    public String getName();
+
+    /**
+     * indicates the scope and lifespan of the Link
+     * <p>
+     * Container-scoped Links must be established with a container-unique name. When a
+     * container-scoped Link's Session is closed, the Link endpoints will continue to exist
+     * while the source and/or target continues to exist. A session-scoped Link will be closed
+     * automatically when the Session terminates. A session-scoped Link name need only be
+     * unique within the Session.
+     * </p>
+     */
+    public void setScope(AmqpScope scope);
+
+    /**
+     * indicates the scope and lifespan of the Link
+     * <p>
+     * Container-scoped Links must be established with a container-unique name. When a
+     * container-scoped Link's Session is closed, the Link endpoints will continue to exist
+     * while the source and/or target continues to exist. A session-scoped Link will be closed
+     * automatically when the Session terminates. A session-scoped Link name need only be
+     * unique within the Session.
+     * </p>
+     */
+    public AmqpScope getScope();
+
+    /**
+     * the Link handle
+     * <p>
+     * This field establishes the handle this endpoint will use to refer to the Link in all
+     * subsequent outgoing commands.
+     * </p>
+     */
+    public void setHandle(AmqpHandle handle);
+
+    /**
+     * the Link handle
+     * <p>
+     * This field establishes the handle this endpoint will use to refer to the Link in all
+     * subsequent outgoing commands.
+     * </p>
+     */
+    public AmqpHandle getHandle();
+
+    /**
+     * direction of the Link
+     */
+    public void setDirection(AmqpDirection direction);
+
+    /**
+     * direction of the Link
+     */
+    public AmqpDirection getDirection();
+
+    /**
+     * the source for Messages
+     * <p>
+     * If no source is specified on an outgoing Link, then there is no source currently
+     * attached to the Link. A Link with no source will never produce outgoing Messages.
+     * </p>
+     */
+    public void setSource(HashMap<AmqpType<?,?>, AmqpType<?,?>> source);
+
+    /**
+     * the source for Messages
+     * <p>
+     * If no source is specified on an outgoing Link, then there is no source currently
+     * attached to the Link. A Link with no source will never produce outgoing Messages.
+     * </p>
+     */
+    public void setSource(AmqpMap source);
+
+    /**
+     * the source for Messages
+     * <p>
+     * If no source is specified on an outgoing Link, then there is no source currently
+     * attached to the Link. A Link with no source will never produce outgoing Messages.
+     * </p>
+     */
+    public HashMap<AmqpType<?,?>, AmqpType<?,?>> getSource();
+
+    /**
+     * the target for Messages
+     * <p>
+     * If no target is specified on an incoming Link, then there is no target currently
+     * attached to the Link. A Link with no target will never permit incoming Messages.
+     * </p>
+     */
+    public void setTarget(HashMap<AmqpType<?,?>, AmqpType<?,?>> target);
+
+    /**
+     * the target for Messages
+     * <p>
+     * If no target is specified on an incoming Link, then there is no target currently
+     * attached to the Link. A Link with no target will never permit incoming Messages.
+     * </p>
+     */
+    public void setTarget(AmqpMap target);
+
+    /**
+     * the target for Messages
+     * <p>
+     * If no target is specified on an incoming Link, then there is no target currently
+     * attached to the Link. A Link with no target will never permit incoming Messages.
+     * </p>
+     */
+    public HashMap<AmqpType<?,?>, AmqpType<?,?>> getTarget();
+
+    /**
+     * the transfer unit
+     * <p>
+     * The transfer-unit defines how the transfer-count is incremented as message data is sent.
+     * </p>
+     * <p>
+     * the encoded
+     * representation of the payload field.)
+     * </p>
+     * <p>
+     * The transfer-count is incremented each time a complete message is sent.
+     * </p>
+     * <p>
+     * The transfer-count is incremented for every transfer-unit bytes of incomplete message
+     * payload sent.
+     * </p>
+     * <p>
+     * This means a message with a payload size of S on a link with a transfer-unit of T will
+     * increment the transfer-count (when completely transferred) by S/T rounded up to the
+     * nearest integer.
+     * </p>
+     * <p>
+     * If the transfer-unit is zero or unset, it is taken to be infinitely large, i.e. the
+     * transfer-count is only incremented each time a complete message is sent.
+     * </p>
+     * <p>
+     * The transfer-unit need only be set by the incoming link endpoint. Any value set by an
+     * outgoing link endpoint is ignored.
+     * </p>
+     */
+    public void setTransferUnit(BigInteger transferUnit);
+
+    /**
+     * the transfer unit
+     * <p>
+     * The transfer-unit defines how the transfer-count is incremented as message data is sent.
+     * </p>
+     * <p>
+     * the encoded
+     * representation of the payload field.)
+     * </p>
+     * <p>
+     * The transfer-count is incremented each time a complete message is sent.
+     * </p>
+     * <p>
+     * The transfer-count is incremented for every transfer-unit bytes of incomplete message
+     * payload sent.
+     * </p>
+     * <p>
+     * This means a message with a payload size of S on a link with a transfer-unit of T will
+     * increment the transfer-count (when completely transferred) by S/T rounded up to the
+     * nearest integer.
+     * </p>
+     * <p>
+     * If the transfer-unit is zero or unset, it is taken to be infinitely large, i.e. the
+     * transfer-count is only incremented each time a complete message is sent.
+     * </p>
+     * <p>
+     * The transfer-unit need only be set by the incoming link endpoint. Any value set by an
+     * outgoing link endpoint is ignored.
+     * </p>
+     */
+    public void setTransferUnit(AmqpUlong transferUnit);
+
+    /**
+     * the transfer unit
+     * <p>
+     * The transfer-unit defines how the transfer-count is incremented as message data is sent.
+     * </p>
+     * <p>
+     * the encoded
+     * representation of the payload field.)
+     * </p>
+     * <p>
+     * The transfer-count is incremented each time a complete message is sent.
+     * </p>
+     * <p>
+     * The transfer-count is incremented for every transfer-unit bytes of incomplete message
+     * payload sent.
+     * </p>
+     * <p>
+     * This means a message with a payload size of S on a link with a transfer-unit of T will
+     * increment the transfer-count (when completely transferred) by S/T rounded up to the
+     * nearest integer.
+     * </p>
+     * <p>
+     * If the transfer-unit is zero or unset, it is taken to be infinitely large, i.e. the
+     * transfer-count is only incremented each time a complete message is sent.
+     * </p>
+     * <p>
+     * The transfer-unit need only be set by the incoming link endpoint. Any value set by an
+     * outgoing link endpoint is ignored.
+     * </p>
+     */
+    public BigInteger getTransferUnit();
+
+    /**
+     * the suggested point to resume delivery
+     * <p>
+     * On resuming a link, both the outgoing and incoming endpoints may have retained state.
+     * The outgoing link endpoint may retain the state of deliveries that have not been
+     * finalized, and the incoming link endpoint may retain the state of deliveries that have
+     * not been settled. In this case the outgoing endpoint sets the resume-tag to the oldest
+     * non-finalized delivery, and the incoming endpoint sets the resume-tag to the newest
+     * unsettled delivery.
+     * </p>
+     * <p>
+     * If the outgoing endpoint sets the resume-tag then it MUST also set its barrier to the
+     * same value.
+     * </p>
+     * <p>
+     * If the resume-tag supplied by the incoming endpoint is among the non-finalized
+     * deliveries which the outgoing endpoint retains, then the outgoing endpoint MUST resume
+     * sending at the point after the delivery specified by the incoming resume-tag. Otherwise
+     * the outgoing endpoint MUST resume from the delivery indicated by the outgoing
+     * resume-tag.
+     * </p>
+     * <p>
+     * The default presumptive disposition MUST be restored before resending deliveries with a
+     * non-default presumptive disposition.
+     * </p>
+     */
+    public void setResumeTag(AmqpDeliveryTag resumeTag);
+
+    /**
+     * the suggested point to resume delivery
+     * <p>
+     * On resuming a link, both the outgoing and incoming endpoints may have retained state.
+     * The outgoing link endpoint may retain the state of deliveries that have not been
+     * finalized, and the incoming link endpoint may retain the state of deliveries that have
+     * not been settled. In this case the outgoing endpoint sets the resume-tag to the oldest
+     * non-finalized delivery, and the incoming endpoint sets the resume-tag to the newest
+     * unsettled delivery.
+     * </p>
+     * <p>
+     * If the outgoing endpoint sets the resume-tag then it MUST also set its barrier to the
+     * same value.
+     * </p>
+     * <p>
+     * If the resume-tag supplied by the incoming endpoint is among the non-finalized
+     * deliveries which the outgoing endpoint retains, then the outgoing endpoint MUST resume
+     * sending at the point after the delivery specified by the incoming resume-tag. Otherwise
+     * the outgoing endpoint MUST resume from the delivery indicated by the outgoing
+     * resume-tag.
+     * </p>
+     * <p>
+     * The default presumptive disposition MUST be restored before resending deliveries with a
+     * non-default presumptive disposition.
+     * </p>
+     */
+    public AmqpDeliveryTag getResumeTag();
+
+    public static class AmqpLinkBean implements AmqpLink{
+
+        private AmqpLinkBuffer buffer;
+        private AmqpLinkBean bean = this;
+        private AmqpOptions options;
+        private AmqpString name;
+        private AmqpScope scope;
+        private AmqpHandle handle;
+        private AmqpDirection direction;
+        private AmqpMap source;
+        private AmqpMap target;
+        private AmqpUlong transferUnit;
+        private AmqpDeliveryTag resumeTag;
+
+        public AmqpLinkBean() {
+        }
+
+        public AmqpLinkBean(IAmqpList value) {
+            //TODO we should defer decoding of the described type:
+            for(int i = 0; i < value.getListCount(); i++) {
+                set(i, value.get(i));
+            }
+        }
+
+        public AmqpLinkBean(AmqpLink.AmqpLinkBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpLinkBean copy() {
+            return new AmqpLink.AmqpLinkBean(bean);
+        }
+
+        public final void handle(AmqpCommandHandler handler) throws Exception {
+            handler.handleLink(this);
+        }
+
+        public final AmqpLink.AmqpLinkBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpLinkBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public final void setOptions(AmqpOptions options) {
+            copyCheck();
+            bean.options = options;
+        }
+
+        public final AmqpOptions getOptions() {
+            return bean.options;
+        }
+
+        public void setName(String name) {
+            setName(new AmqpString.AmqpStringBean(name));
+        }
+
+
+        public final void setName(AmqpString name) {
+            copyCheck();
+            bean.name = name;
+        }
+
+        public final String getName() {
+            return bean.name.getValue();
+        }
+
+        public final void setScope(AmqpScope scope) {
+            copyCheck();
+            bean.scope = scope;
+        }
+
+        public final AmqpScope getScope() {
+            return bean.scope;
+        }
+
+        public final void setHandle(AmqpHandle handle) {
+            copyCheck();
+            bean.handle = handle;
+        }
+
+        public final AmqpHandle getHandle() {
+            return bean.handle;
+        }
+
+        public final void setDirection(AmqpDirection direction) {
+            copyCheck();
+            bean.direction = direction;
+        }
+
+        public final AmqpDirection getDirection() {
+            return bean.direction;
+        }
+
+        public void setSource(HashMap<AmqpType<?,?>, AmqpType<?,?>> source) {
+            setSource(new AmqpMap.AmqpMapBean(source));
+        }
+
+
+        public final void setSource(AmqpMap source) {
+            copyCheck();
+            bean.source = source;
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getSource() {
+            return bean.source.getValue();
+        }
+
+        public void setTarget(HashMap<AmqpType<?,?>, AmqpType<?,?>> target) {
+            setTarget(new AmqpMap.AmqpMapBean(target));
+        }
+
+
+        public final void setTarget(AmqpMap target) {
+            copyCheck();
+            bean.target = target;
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getTarget() {
+            return bean.target.getValue();
+        }
+
+        public void setTransferUnit(BigInteger transferUnit) {
+            setTransferUnit(new AmqpUlong.AmqpUlongBean(transferUnit));
+        }
+
+
+        public final void setTransferUnit(AmqpUlong transferUnit) {
+            copyCheck();
+            bean.transferUnit = transferUnit;
+        }
+
+        public final BigInteger getTransferUnit() {
+            return bean.transferUnit.getValue();
+        }
+
+        public final void setResumeTag(AmqpDeliveryTag resumeTag) {
+            copyCheck();
+            bean.resumeTag = resumeTag;
+        }
+
+        public final AmqpDeliveryTag getResumeTag() {
+            return bean.resumeTag;
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            switch(index) {
+            case 0: {
+                setOptions((AmqpOptions) value);
+                break;
+            }
+            case 1: {
+                setName((AmqpString) value);
+                break;
+            }
+            case 2: {
+                setScope(AmqpScope.get((AmqpUbyte)value));
+                break;
+            }
+            case 3: {
+                setHandle((AmqpHandle) value);
+                break;
+            }
+            case 4: {
+                setDirection(AmqpDirection.get((AmqpUbyte)value));
+                break;
+            }
+            case 5: {
+                setSource((AmqpMap) value);
+                break;
+            }
+            case 6: {
+                setTarget((AmqpMap) value);
+                break;
+            }
+            case 7: {
+                setTransferUnit((AmqpUlong) value);
+                break;
+            }
+            case 8: {
+                setResumeTag((AmqpDeliveryTag) value);
+                break;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public AmqpType<?, ?> get(int index) {
+            switch(index) {
+            case 0: {
+                return bean.options;
+            }
+            case 1: {
+                return bean.name;
+            }
+            case 2: {
+                if(scope == null) {
+                    return null;
+                }
+                return scope.getValue();
+            }
+            case 3: {
+                return bean.handle;
+            }
+            case 4: {
+                if(direction == null) {
+                    return null;
+                }
+                return direction.getValue();
+            }
+            case 5: {
+                return bean.source;
+            }
+            case 6: {
+                return bean.target;
+            }
+            case 7: {
+                return bean.transferUnit;
+            }
+            case 8: {
+                return bean.resumeTag;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public int getListCount() {
+            return 9;
+        }
+
+        public IAmqpList getValue() {
+            return bean;
+        }
+
+        public Iterator<AmqpType<?, ?>> iterator() {
+            return new AmqpListIterator(bean);
+        }
+
+
+        private final void copyCheck() {
+            if(buffer != null) {;
+                throw new IllegalStateException("unwriteable");
+            }
+            if(bean != this) {;
+                copy(bean);
+            }
+        }
+
+        private final void copy(AmqpLink.AmqpLinkBean other) {
+            this.options= other.options;
+            this.name= other.name;
+            this.scope= other.scope;
+            this.handle= other.handle;
+            this.direction= other.direction;
+            this.source= other.source;
+            this.target= other.target;
+            this.transferUnit= other.transferUnit;
+            this.resumeTag= other.resumeTag;
+            bean = this;
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpLink)) {
+                return false;
+            }
+
+            return equivalent((AmqpLink) t);
+        }
+
+        public boolean equivalent(AmqpLink b) {
+
+            if(b.getOptions() == null ^ getOptions() == null) {
+                return false;
+            }
+            if(b.getOptions() != null && !b.getOptions().equals(getOptions())){ 
+                return false;
+            }
+
+            if(b.getName() == null ^ getName() == null) {
+                return false;
+            }
+            if(b.getName() != null && !b.getName().equals(getName())){ 
+                return false;
+            }
+
+            if(b.getScope() == null ^ getScope() == null) {
+                return false;
+            }
+            if(b.getScope() != null && !b.getScope().equals(getScope())){ 
+                return false;
+            }
+
+            if(b.getHandle() == null ^ getHandle() == null) {
+                return false;
+            }
+            if(b.getHandle() != null && !b.getHandle().equals(getHandle())){ 
+                return false;
+            }
+
+            if(b.getDirection() == null ^ getDirection() == null) {
+                return false;
+            }
+            if(b.getDirection() != null && !b.getDirection().equals(getDirection())){ 
+                return false;
+            }
+
+            if(b.getSource() == null ^ getSource() == null) {
+                return false;
+            }
+            if(b.getSource() != null && !b.getSource().equals(getSource())){ 
+                return false;
+            }
+
+            if(b.getTarget() == null ^ getTarget() == null) {
+                return false;
+            }
+            if(b.getTarget() != null && !b.getTarget().equals(getTarget())){ 
+                return false;
+            }
+
+            if(b.getTransferUnit() == null ^ getTransferUnit() == null) {
+                return false;
+            }
+            if(b.getTransferUnit() != null && !b.getTransferUnit().equals(getTransferUnit())){ 
+                return false;
+            }
+
+            if(b.getResumeTag() == null ^ getResumeTag() == null) {
+                return false;
+            }
+            if(b.getResumeTag() != null && !b.getResumeTag().equals(getResumeTag())){ 
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static class AmqpLinkBuffer extends AmqpList.AmqpListBuffer implements AmqpLink{
+
+        private AmqpLinkBean bean;
+
+        protected AmqpLinkBuffer(Encoded<IAmqpList> encoded) {
+            super(encoded);
+        }
+
+        public final void setOptions(AmqpOptions options) {
+            bean().setOptions(options);
+        }
+
+        public final AmqpOptions getOptions() {
+            return bean().getOptions();
+        }
+
+    public void setName(String name) {
+            bean().setName(name);
+        }
+
+        public final void setName(AmqpString name) {
+            bean().setName(name);
+        }
+
+        public final String getName() {
+            return bean().getName();
+        }
+
+        public final void setScope(AmqpScope scope) {
+            bean().setScope(scope);
+        }
+
+        public final AmqpScope getScope() {
+            return bean().getScope();
+        }
+
+        public final void setHandle(AmqpHandle handle) {
+            bean().setHandle(handle);
+        }
+
+        public final AmqpHandle getHandle() {
+            return bean().getHandle();
+        }
+
+        public final void setDirection(AmqpDirection direction) {
+            bean().setDirection(direction);
+        }
+
+        public final AmqpDirection getDirection() {
+            return bean().getDirection();
+        }
+
+    public void setSource(HashMap<AmqpType<?,?>, AmqpType<?,?>> source) {
+            bean().setSource(source);
+        }
+
+        public final void setSource(AmqpMap source) {
+            bean().setSource(source);
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getSource() {
+            return bean().getSource();
+        }
+
+    public void setTarget(HashMap<AmqpType<?,?>, AmqpType<?,?>> target) {
+            bean().setTarget(target);
+        }
+
+        public final void setTarget(AmqpMap target) {
+            bean().setTarget(target);
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getTarget() {
+            return bean().getTarget();
+        }
+
+    public void setTransferUnit(BigInteger transferUnit) {
+            bean().setTransferUnit(transferUnit);
+        }
+
+        public final void setTransferUnit(AmqpUlong transferUnit) {
+            bean().setTransferUnit(transferUnit);
+        }
+
+        public final BigInteger getTransferUnit() {
+            return bean().getTransferUnit();
+        }
+
+        public final void setResumeTag(AmqpDeliveryTag resumeTag) {
+            bean().setResumeTag(resumeTag);
+        }
+
+        public final AmqpDeliveryTag getResumeTag() {
+            return bean().getResumeTag();
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            bean().set(index, value);
+        }
+
+        public AmqpType<?, ?> get(int index) {
+            return bean().get(index);
+        }
+
+        public int getListCount() {
+            return bean().getListCount();
+        }
+
+        public Iterator<AmqpType<?, ?>> iterator() {
+            return bean().iterator();
+        }
+
+        public IAmqpList getValue() {
+            return bean().getValue();
+        }
+
+        public AmqpLink.AmqpLinkBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpLink bean() {
+            if(bean == null) {
+                bean = new AmqpLink.AmqpLinkBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public final void handle(AmqpCommandHandler handler) throws Exception {
+            handler.handleLink(this);
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpLink.AmqpLinkBuffer create(Encoded<IAmqpList> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpLink.AmqpLinkBuffer(encoded);
+        }
+
+        public static AmqpLink.AmqpLinkBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpLink(in));
+        }
+
+        public static AmqpLink.AmqpLinkBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpLink(buffer, offset));
+        }
+    }
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLinkError.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLinkError.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLinkError.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLinkError.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,372 @@
+/**
+ * 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.types;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.String;
+import java.util.HashMap;
+import java.util.Iterator;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpMarshaller;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+/**
+ * Represents a details of a Link error
+ */
+public interface AmqpLinkError extends AmqpList {
+
+
+
+    /**
+     * Link error code
+     * <p>
+     * A numeric code indicating the reason for the Link unlink.
+     * </p>
+     */
+    public void setErrorCode(AmqpLinkErrorCode errorCode);
+
+    /**
+     * Link error code
+     * <p>
+     * A numeric code indicating the reason for the Link unlink.
+     * </p>
+     */
+    public AmqpLinkErrorCode getErrorCode();
+
+    /**
+     * description text about the exception
+     * <p>
+     * The description provided is implementation defined, but MUST be in the language
+     * appropriate for the selected locale. The intention is that this description is suitable
+     * for logging or alerting output.
+     * </p>
+     */
+    public void setDescription(String description);
+
+    /**
+     * description text about the exception
+     * <p>
+     * The description provided is implementation defined, but MUST be in the language
+     * appropriate for the selected locale. The intention is that this description is suitable
+     * for logging or alerting output.
+     * </p>
+     */
+    public void setDescription(AmqpString description);
+
+    /**
+     * description text about the exception
+     * <p>
+     * The description provided is implementation defined, but MUST be in the language
+     * appropriate for the selected locale. The intention is that this description is suitable
+     * for logging or alerting output.
+     * </p>
+     */
+    public String getDescription();
+
+    /**
+     * map to carry additional information about the error
+     */
+    public void setErrorInfo(HashMap<AmqpType<?,?>, AmqpType<?,?>> errorInfo);
+
+    /**
+     * map to carry additional information about the error
+     */
+    public void setErrorInfo(AmqpMap errorInfo);
+
+    /**
+     * map to carry additional information about the error
+     */
+    public HashMap<AmqpType<?,?>, AmqpType<?,?>> getErrorInfo();
+
+    public static class AmqpLinkErrorBean implements AmqpLinkError{
+
+        private AmqpLinkErrorBuffer buffer;
+        private AmqpLinkErrorBean bean = this;
+        private AmqpLinkErrorCode errorCode;
+        private AmqpString description;
+        private AmqpMap errorInfo;
+
+        public AmqpLinkErrorBean() {
+        }
+
+        public AmqpLinkErrorBean(IAmqpList value) {
+            //TODO we should defer decoding of the described type:
+            for(int i = 0; i < value.getListCount(); i++) {
+                set(i, value.get(i));
+            }
+        }
+
+        public AmqpLinkErrorBean(AmqpLinkError.AmqpLinkErrorBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpLinkErrorBean copy() {
+            return new AmqpLinkError.AmqpLinkErrorBean(bean);
+        }
+
+        public final AmqpLinkError.AmqpLinkErrorBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpLinkErrorBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public final void setErrorCode(AmqpLinkErrorCode errorCode) {
+            copyCheck();
+            bean.errorCode = errorCode;
+        }
+
+        public final AmqpLinkErrorCode getErrorCode() {
+            return bean.errorCode;
+        }
+
+        public void setDescription(String description) {
+            setDescription(new AmqpString.AmqpStringBean(description));
+        }
+
+
+        public final void setDescription(AmqpString description) {
+            copyCheck();
+            bean.description = description;
+        }
+
+        public final String getDescription() {
+            return bean.description.getValue();
+        }
+
+        public void setErrorInfo(HashMap<AmqpType<?,?>, AmqpType<?,?>> errorInfo) {
+            setErrorInfo(new AmqpMap.AmqpMapBean(errorInfo));
+        }
+
+
+        public final void setErrorInfo(AmqpMap errorInfo) {
+            copyCheck();
+            bean.errorInfo = errorInfo;
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getErrorInfo() {
+            return bean.errorInfo.getValue();
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            switch(index) {
+            case 0: {
+                setErrorCode(AmqpLinkErrorCode.get((AmqpUshort)value));
+                break;
+            }
+            case 1: {
+                setDescription((AmqpString) value);
+                break;
+            }
+            case 2: {
+                setErrorInfo((AmqpMap) value);
+                break;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public AmqpType<?, ?> get(int index) {
+            switch(index) {
+            case 0: {
+                if(errorCode == null) {
+                    return null;
+                }
+                return errorCode.getValue();
+            }
+            case 1: {
+                return bean.description;
+            }
+            case 2: {
+                return bean.errorInfo;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public int getListCount() {
+            return 3;
+        }
+
+        public IAmqpList getValue() {
+            return bean;
+        }
+
+        public Iterator<AmqpType<?, ?>> iterator() {
+            return new AmqpListIterator(bean);
+        }
+
+
+        private final void copyCheck() {
+            if(buffer != null) {;
+                throw new IllegalStateException("unwriteable");
+            }
+            if(bean != this) {;
+                copy(bean);
+            }
+        }
+
+        private final void copy(AmqpLinkError.AmqpLinkErrorBean other) {
+            this.errorCode= other.errorCode;
+            this.description= other.description;
+            this.errorInfo= other.errorInfo;
+            bean = this;
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpLinkError)) {
+                return false;
+            }
+
+            return equivalent((AmqpLinkError) t);
+        }
+
+        public boolean equivalent(AmqpLinkError b) {
+
+            if(b.getErrorCode() == null ^ getErrorCode() == null) {
+                return false;
+            }
+            if(b.getErrorCode() != null && !b.getErrorCode().equals(getErrorCode())){ 
+                return false;
+            }
+
+            if(b.getDescription() == null ^ getDescription() == null) {
+                return false;
+            }
+            if(b.getDescription() != null && !b.getDescription().equals(getDescription())){ 
+                return false;
+            }
+
+            if(b.getErrorInfo() == null ^ getErrorInfo() == null) {
+                return false;
+            }
+            if(b.getErrorInfo() != null && !b.getErrorInfo().equals(getErrorInfo())){ 
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static class AmqpLinkErrorBuffer extends AmqpList.AmqpListBuffer implements AmqpLinkError{
+
+        private AmqpLinkErrorBean bean;
+
+        protected AmqpLinkErrorBuffer(Encoded<IAmqpList> encoded) {
+            super(encoded);
+        }
+
+        public final void setErrorCode(AmqpLinkErrorCode errorCode) {
+            bean().setErrorCode(errorCode);
+        }
+
+        public final AmqpLinkErrorCode getErrorCode() {
+            return bean().getErrorCode();
+        }
+
+    public void setDescription(String description) {
+            bean().setDescription(description);
+        }
+
+        public final void setDescription(AmqpString description) {
+            bean().setDescription(description);
+        }
+
+        public final String getDescription() {
+            return bean().getDescription();
+        }
+
+    public void setErrorInfo(HashMap<AmqpType<?,?>, AmqpType<?,?>> errorInfo) {
+            bean().setErrorInfo(errorInfo);
+        }
+
+        public final void setErrorInfo(AmqpMap errorInfo) {
+            bean().setErrorInfo(errorInfo);
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getErrorInfo() {
+            return bean().getErrorInfo();
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            bean().set(index, value);
+        }
+
+        public AmqpType<?, ?> get(int index) {
+            return bean().get(index);
+        }
+
+        public int getListCount() {
+            return bean().getListCount();
+        }
+
+        public Iterator<AmqpType<?, ?>> iterator() {
+            return bean().iterator();
+        }
+
+        public IAmqpList getValue() {
+            return bean().getValue();
+        }
+
+        public AmqpLinkError.AmqpLinkErrorBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpLinkError bean() {
+            if(bean == null) {
+                bean = new AmqpLinkError.AmqpLinkErrorBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpLinkError.AmqpLinkErrorBuffer create(Encoded<IAmqpList> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpLinkError.AmqpLinkErrorBuffer(encoded);
+        }
+
+        public static AmqpLinkError.AmqpLinkErrorBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpLinkError(in));
+        }
+
+        public static AmqpLinkError.AmqpLinkErrorBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpLinkError(buffer, offset));
+        }
+    }
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLinkErrorCode.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLinkErrorCode.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLinkErrorCode.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpLinkErrorCode.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,93 @@
+/**
+ * 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.types;
+
+import java.lang.Integer;
+import java.util.HashMap;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.types.AmqpUshort;
+
+/**
+ * Represents a codes used to indicate the reason for unlink
+ */
+public enum AmqpLinkErrorCode {
+
+    /**
+     * <p>
+     * An operator intervened to unlink for some reason.
+     * </p>
+     */
+    UNLINK_FORCED(new Integer("320")),
+    /**
+     * <p>
+     * The source with which the link was associated has been destroyed.
+     * </p>
+     */
+    SOURCE_DESTROYED(new Integer("321")),
+    /**
+     * <p>
+     * The target with which the link was associated has been destroyed.
+     * </p>
+     */
+    TARGET_DESTROYED(new Integer("322")),
+    NOT_ALLOWED(new Integer("401")),
+    /**
+     * <p>
+     * The source with which the link was requested to associated does not exist.
+     * </p>
+     */
+    SOURCE_NOT_FOUND(new Integer("404")),
+    /**
+     * <p>
+     * The target with which the link was requested to associated does not exist.
+     * </p>
+     */
+    TARGET_NOT_FOUND(new Integer("405")),
+    /**
+     * <p>
+     * The error condition which caused the unlink was is cannot be described by any other
+     * existing link-error-code.
+     * </p>
+     */
+    OTHER_ERROR(new Integer("599"));
+
+    private static final HashMap<Integer, AmqpLinkErrorCode> LOOKUP = new HashMap<Integer, AmqpLinkErrorCode>(2);
+    static {
+        for (AmqpLinkErrorCode linkErrorCode : AmqpLinkErrorCode.values()) {
+            LOOKUP.put(linkErrorCode.value.getValue(), linkErrorCode);
+        }
+    }
+
+    private final AmqpUshort value;
+
+    private AmqpLinkErrorCode(Integer value) {
+        this.value = new AmqpUshort.AmqpUshortBean(value);
+    }
+
+    public final AmqpUshort getValue() {
+        return value;
+    }
+
+    public static final AmqpLinkErrorCode get(AmqpUshort value) throws AmqpEncodingError{
+        AmqpLinkErrorCode linkErrorCode= LOOKUP.get(value.getValue());
+        if (linkErrorCode == null) {
+            //TODO perhaps this should be an IllegalArgumentException?
+            throw new AmqpEncodingError("Unknown linkErrorCode: " + value + " expected one of " + LOOKUP.keySet());
+        }
+        return linkErrorCode;
+    }
+}
\ No newline at end of file



Mime
View raw message