activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmacn...@apache.org
Subject svn commit: r908857 [15/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/AmqpSaslInit.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslInit.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslInit.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslInit.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,395 @@
+/**
+ * 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 initiate sasl exchange
+ * <p>
+ * Selects the sasl mechanism and provides the initial response if needed.
+ * </p>
+ */
+public interface AmqpSaslInit extends AmqpList {
+
+
+
+    /**
+     * options map
+     */
+    public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options);
+
+    /**
+     * options map
+     */
+    public void setOptions(AmqpMap options);
+
+    /**
+     * options map
+     */
+    public HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions();
+
+    /**
+     * selected security mechanism
+     * <p>
+     * The name of the SASL mechanism used for the SASL exchange. If the selected mechanism is
+     * not supported by the receiving peer, it MUST close the Connection with the
+     * authentication-failure close-code. Each peer MUST authenticate using the highest-level
+     * security profile it can handle from the list provided by the partner.
+     * </p>
+     */
+    public void setMechanism(String mechanism);
+
+    /**
+     * selected security mechanism
+     * <p>
+     * The name of the SASL mechanism used for the SASL exchange. If the selected mechanism is
+     * not supported by the receiving peer, it MUST close the Connection with the
+     * authentication-failure close-code. Each peer MUST authenticate using the highest-level
+     * security profile it can handle from the list provided by the partner.
+     * </p>
+     */
+    public void setMechanism(AmqpString mechanism);
+
+    /**
+     * selected security mechanism
+     * <p>
+     * The name of the SASL mechanism used for the SASL exchange. If the selected mechanism is
+     * not supported by the receiving peer, it MUST close the Connection with the
+     * authentication-failure close-code. Each peer MUST authenticate using the highest-level
+     * security profile it can handle from the list provided by the partner.
+     * </p>
+     */
+    public String getMechanism();
+
+    /**
+     * security response data
+     * <p>
+     * A block of opaque data passed to the security mechanism. The contents of this data are
+     * defined by the SASL security mechanism.
+     * </p>
+     */
+    public void setInitialResponse(Buffer initialResponse);
+
+    /**
+     * security response data
+     * <p>
+     * A block of opaque data passed to the security mechanism. The contents of this data are
+     * defined by the SASL security mechanism.
+     * </p>
+     */
+    public void setInitialResponse(AmqpBinary initialResponse);
+
+    /**
+     * security response data
+     * <p>
+     * A block of opaque data passed to the security mechanism. The contents of this data are
+     * defined by the SASL security mechanism.
+     * </p>
+     */
+    public Buffer getInitialResponse();
+
+    public static class AmqpSaslInitBean implements AmqpSaslInit{
+
+        private AmqpSaslInitBuffer buffer;
+        private AmqpSaslInitBean bean = this;
+        private AmqpMap options;
+        private AmqpString mechanism;
+        private AmqpBinary initialResponse;
+
+        public AmqpSaslInitBean() {
+        }
+
+        public AmqpSaslInitBean(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 AmqpSaslInitBean(AmqpSaslInit.AmqpSaslInitBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpSaslInitBean copy() {
+            return new AmqpSaslInit.AmqpSaslInitBean(bean);
+        }
+
+        public final AmqpSaslInit.AmqpSaslInitBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpSaslInitBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options) {
+            setOptions(new AmqpMap.AmqpMapBean(options));
+        }
+
+
+        public final void setOptions(AmqpMap options) {
+            copyCheck();
+            bean.options = options;
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions() {
+            return bean.options.getValue();
+        }
+
+        public void setMechanism(String mechanism) {
+            setMechanism(new AmqpString.AmqpStringBean(mechanism));
+        }
+
+
+        public final void setMechanism(AmqpString mechanism) {
+            copyCheck();
+            bean.mechanism = mechanism;
+        }
+
+        public final String getMechanism() {
+            return bean.mechanism.getValue();
+        }
+
+        public void setInitialResponse(Buffer initialResponse) {
+            setInitialResponse(new AmqpBinary.AmqpBinaryBean(initialResponse));
+        }
+
+
+        public final void setInitialResponse(AmqpBinary initialResponse) {
+            copyCheck();
+            bean.initialResponse = initialResponse;
+        }
+
+        public final Buffer getInitialResponse() {
+            return bean.initialResponse.getValue();
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            switch(index) {
+            case 0: {
+                setOptions((AmqpMap) value);
+                break;
+            }
+            case 1: {
+                setMechanism((AmqpString) value);
+                break;
+            }
+            case 2: {
+                setInitialResponse((AmqpBinary) 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.mechanism;
+            }
+            case 2: {
+                return bean.initialResponse;
+            }
+            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(AmqpSaslInit.AmqpSaslInitBean other) {
+            this.options= other.options;
+            this.mechanism= other.mechanism;
+            this.initialResponse= other.initialResponse;
+            bean = this;
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpSaslInit)) {
+                return false;
+            }
+
+            return equivalent((AmqpSaslInit) t);
+        }
+
+        public boolean equivalent(AmqpSaslInit b) {
+
+            if(b.getOptions() == null ^ getOptions() == null) {
+                return false;
+            }
+            if(b.getOptions() != null && !b.getOptions().equals(getOptions())){ 
+                return false;
+            }
+
+            if(b.getMechanism() == null ^ getMechanism() == null) {
+                return false;
+            }
+            if(b.getMechanism() != null && !b.getMechanism().equals(getMechanism())){ 
+                return false;
+            }
+
+            if(b.getInitialResponse() == null ^ getInitialResponse() == null) {
+                return false;
+            }
+            if(b.getInitialResponse() != null && !b.getInitialResponse().equals(getInitialResponse())){ 
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static class AmqpSaslInitBuffer extends AmqpList.AmqpListBuffer implements AmqpSaslInit{
+
+        private AmqpSaslInitBean bean;
+
+        protected AmqpSaslInitBuffer(Encoded<IAmqpList> encoded) {
+            super(encoded);
+        }
+
+    public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options) {
+            bean().setOptions(options);
+        }
+
+        public final void setOptions(AmqpMap options) {
+            bean().setOptions(options);
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions() {
+            return bean().getOptions();
+        }
+
+    public void setMechanism(String mechanism) {
+            bean().setMechanism(mechanism);
+        }
+
+        public final void setMechanism(AmqpString mechanism) {
+            bean().setMechanism(mechanism);
+        }
+
+        public final String getMechanism() {
+            return bean().getMechanism();
+        }
+
+    public void setInitialResponse(Buffer initialResponse) {
+            bean().setInitialResponse(initialResponse);
+        }
+
+        public final void setInitialResponse(AmqpBinary initialResponse) {
+            bean().setInitialResponse(initialResponse);
+        }
+
+        public final Buffer getInitialResponse() {
+            return bean().getInitialResponse();
+        }
+
+        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 AmqpSaslInit.AmqpSaslInitBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpSaslInit bean() {
+            if(bean == null) {
+                bean = new AmqpSaslInit.AmqpSaslInitBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpSaslInit.AmqpSaslInitBuffer create(Encoded<IAmqpList> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpSaslInit.AmqpSaslInitBuffer(encoded);
+        }
+
+        public static AmqpSaslInit.AmqpSaslInitBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpSaslInit(in));
+        }
+
+        public static AmqpSaslInit.AmqpSaslInitBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpSaslInit(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/AmqpSaslMechanisms.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslMechanisms.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslMechanisms.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslMechanisms.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,322 @@
+/**
+ * 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.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 advertise available sasl mechanisms
+ * <p>
+ * Advertises the available SASL mechanisms that may be used for authentication.
+ * </p>
+ */
+public interface AmqpSaslMechanisms extends AmqpList {
+
+
+
+    /**
+     * options map
+     */
+    public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options);
+
+    /**
+     * options map
+     */
+    public void setOptions(AmqpMap options);
+
+    /**
+     * options map
+     */
+    public HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions();
+
+    /**
+     * supported sasl mechanisms
+     * <p>
+     * A list of the sasl security mechanisms supported by the sending peer. If the sending
+     * peer does not require its partner to authenticate with it, this list may be empty or
+     * absent. The server mechanisms are ordered in decreasing level of preference.
+     * </p>
+     */
+    public void setSaslServerMechanisms(IAmqpList saslServerMechanisms);
+
+    /**
+     * supported sasl mechanisms
+     * <p>
+     * A list of the sasl security mechanisms supported by the sending peer. If the sending
+     * peer does not require its partner to authenticate with it, this list may be empty or
+     * absent. The server mechanisms are ordered in decreasing level of preference.
+     * </p>
+     */
+    public void setSaslServerMechanisms(AmqpList saslServerMechanisms);
+
+    /**
+     * supported sasl mechanisms
+     * <p>
+     * A list of the sasl security mechanisms supported by the sending peer. If the sending
+     * peer does not require its partner to authenticate with it, this list may be empty or
+     * absent. The server mechanisms are ordered in decreasing level of preference.
+     * </p>
+     */
+    public IAmqpList getSaslServerMechanisms();
+
+    public static class AmqpSaslMechanismsBean implements AmqpSaslMechanisms{
+
+        private AmqpSaslMechanismsBuffer buffer;
+        private AmqpSaslMechanismsBean bean = this;
+        private AmqpMap options;
+        private AmqpList saslServerMechanisms;
+
+        public AmqpSaslMechanismsBean() {
+        }
+
+        public AmqpSaslMechanismsBean(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 AmqpSaslMechanismsBean(AmqpSaslMechanisms.AmqpSaslMechanismsBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpSaslMechanismsBean copy() {
+            return new AmqpSaslMechanisms.AmqpSaslMechanismsBean(bean);
+        }
+
+        public final AmqpSaslMechanisms.AmqpSaslMechanismsBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpSaslMechanismsBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options) {
+            setOptions(new AmqpMap.AmqpMapBean(options));
+        }
+
+
+        public final void setOptions(AmqpMap options) {
+            copyCheck();
+            bean.options = options;
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions() {
+            return bean.options.getValue();
+        }
+
+        public void setSaslServerMechanisms(IAmqpList saslServerMechanisms) {
+            setSaslServerMechanisms(new AmqpList.AmqpListBean(saslServerMechanisms));
+        }
+
+
+        public final void setSaslServerMechanisms(AmqpList saslServerMechanisms) {
+            copyCheck();
+            bean.saslServerMechanisms = saslServerMechanisms;
+        }
+
+        public final IAmqpList getSaslServerMechanisms() {
+            return bean.saslServerMechanisms.getValue();
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            switch(index) {
+            case 0: {
+                setOptions((AmqpMap) value);
+                break;
+            }
+            case 1: {
+                setSaslServerMechanisms((AmqpList) 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.saslServerMechanisms;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public int getListCount() {
+            return 2;
+        }
+
+        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(AmqpSaslMechanisms.AmqpSaslMechanismsBean other) {
+            this.options= other.options;
+            this.saslServerMechanisms= other.saslServerMechanisms;
+            bean = this;
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpSaslMechanisms)) {
+                return false;
+            }
+
+            return equivalent((AmqpSaslMechanisms) t);
+        }
+
+        public boolean equivalent(AmqpSaslMechanisms b) {
+
+            if(b.getOptions() == null ^ getOptions() == null) {
+                return false;
+            }
+            if(b.getOptions() != null && !b.getOptions().equals(getOptions())){ 
+                return false;
+            }
+
+            if(b.getSaslServerMechanisms() == null ^ getSaslServerMechanisms() == null) {
+                return false;
+            }
+            if(b.getSaslServerMechanisms() != null && !b.getSaslServerMechanisms().equals(getSaslServerMechanisms())){ 
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static class AmqpSaslMechanismsBuffer extends AmqpList.AmqpListBuffer implements AmqpSaslMechanisms{
+
+        private AmqpSaslMechanismsBean bean;
+
+        protected AmqpSaslMechanismsBuffer(Encoded<IAmqpList> encoded) {
+            super(encoded);
+        }
+
+    public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options) {
+            bean().setOptions(options);
+        }
+
+        public final void setOptions(AmqpMap options) {
+            bean().setOptions(options);
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions() {
+            return bean().getOptions();
+        }
+
+    public void setSaslServerMechanisms(IAmqpList saslServerMechanisms) {
+            bean().setSaslServerMechanisms(saslServerMechanisms);
+        }
+
+        public final void setSaslServerMechanisms(AmqpList saslServerMechanisms) {
+            bean().setSaslServerMechanisms(saslServerMechanisms);
+        }
+
+        public final IAmqpList getSaslServerMechanisms() {
+            return bean().getSaslServerMechanisms();
+        }
+
+        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 AmqpSaslMechanisms.AmqpSaslMechanismsBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpSaslMechanisms bean() {
+            if(bean == null) {
+                bean = new AmqpSaslMechanisms.AmqpSaslMechanismsBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpSaslMechanisms.AmqpSaslMechanismsBuffer create(Encoded<IAmqpList> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpSaslMechanisms.AmqpSaslMechanismsBuffer(encoded);
+        }
+
+        public static AmqpSaslMechanisms.AmqpSaslMechanismsBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpSaslMechanisms(in));
+        }
+
+        public static AmqpSaslMechanisms.AmqpSaslMechanismsBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpSaslMechanisms(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/AmqpSaslOutcome.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslOutcome.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslOutcome.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslOutcome.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,376 @@
+/**
+ * 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.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 indicates the outcome of the sasl dialog
+ * <p>
+ * This control indicates the outcome of the SASL dialog. Upon successful completion of the
+ * SASL dialog the Security Layer has been established, and the peers must exchange protocol
+ * headers to either start a nested Security Layer, or to establish the AMQP Connection.
+ * </p>
+ */
+public interface AmqpSaslOutcome extends AmqpList {
+
+
+
+    /**
+     * options map
+     */
+    public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options);
+
+    /**
+     * options map
+     */
+    public void setOptions(AmqpMap options);
+
+    /**
+     * options map
+     */
+    public HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions();
+
+    /**
+     * indicates the outcome of the sasl dialog
+     * <p>
+     * A reply-code indicating the outcome of the SASL dialog.
+     * </p>
+     */
+    public void setCode(AmqpSaslCode code);
+
+    /**
+     * indicates the outcome of the sasl dialog
+     * <p>
+     * A reply-code indicating the outcome of the SASL dialog.
+     * </p>
+     */
+    public AmqpSaslCode getCode();
+
+    /**
+     * additional data as specified in RFC-4422
+     * <p>
+     * The additional-data field carries additional data on successful authentication outcome
+     * as specified by the SASL specification (RFC-4422). If the authentication is
+     * unsuccessful, this field is not set.
+     * </p>
+     */
+    public void setAdditionalData(Buffer additionalData);
+
+    /**
+     * additional data as specified in RFC-4422
+     * <p>
+     * The additional-data field carries additional data on successful authentication outcome
+     * as specified by the SASL specification (RFC-4422). If the authentication is
+     * unsuccessful, this field is not set.
+     * </p>
+     */
+    public void setAdditionalData(AmqpBinary additionalData);
+
+    /**
+     * additional data as specified in RFC-4422
+     * <p>
+     * The additional-data field carries additional data on successful authentication outcome
+     * as specified by the SASL specification (RFC-4422). If the authentication is
+     * unsuccessful, this field is not set.
+     * </p>
+     */
+    public Buffer getAdditionalData();
+
+    public static class AmqpSaslOutcomeBean implements AmqpSaslOutcome{
+
+        private AmqpSaslOutcomeBuffer buffer;
+        private AmqpSaslOutcomeBean bean = this;
+        private AmqpMap options;
+        private AmqpSaslCode code;
+        private AmqpBinary additionalData;
+
+        public AmqpSaslOutcomeBean() {
+        }
+
+        public AmqpSaslOutcomeBean(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 AmqpSaslOutcomeBean(AmqpSaslOutcome.AmqpSaslOutcomeBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpSaslOutcomeBean copy() {
+            return new AmqpSaslOutcome.AmqpSaslOutcomeBean(bean);
+        }
+
+        public final AmqpSaslOutcome.AmqpSaslOutcomeBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpSaslOutcomeBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options) {
+            setOptions(new AmqpMap.AmqpMapBean(options));
+        }
+
+
+        public final void setOptions(AmqpMap options) {
+            copyCheck();
+            bean.options = options;
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions() {
+            return bean.options.getValue();
+        }
+
+        public final void setCode(AmqpSaslCode code) {
+            copyCheck();
+            bean.code = code;
+        }
+
+        public final AmqpSaslCode getCode() {
+            return bean.code;
+        }
+
+        public void setAdditionalData(Buffer additionalData) {
+            setAdditionalData(new AmqpBinary.AmqpBinaryBean(additionalData));
+        }
+
+
+        public final void setAdditionalData(AmqpBinary additionalData) {
+            copyCheck();
+            bean.additionalData = additionalData;
+        }
+
+        public final Buffer getAdditionalData() {
+            return bean.additionalData.getValue();
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            switch(index) {
+            case 0: {
+                setOptions((AmqpMap) value);
+                break;
+            }
+            case 1: {
+                setCode(AmqpSaslCode.get((AmqpUbyte)value));
+                break;
+            }
+            case 2: {
+                setAdditionalData((AmqpBinary) value);
+                break;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public AmqpType<?, ?> get(int index) {
+            switch(index) {
+            case 0: {
+                return bean.options;
+            }
+            case 1: {
+                if(code == null) {
+                    return null;
+                }
+                return code.getValue();
+            }
+            case 2: {
+                return bean.additionalData;
+            }
+            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(AmqpSaslOutcome.AmqpSaslOutcomeBean other) {
+            this.options= other.options;
+            this.code= other.code;
+            this.additionalData= other.additionalData;
+            bean = this;
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpSaslOutcome)) {
+                return false;
+            }
+
+            return equivalent((AmqpSaslOutcome) t);
+        }
+
+        public boolean equivalent(AmqpSaslOutcome b) {
+
+            if(b.getOptions() == null ^ getOptions() == null) {
+                return false;
+            }
+            if(b.getOptions() != null && !b.getOptions().equals(getOptions())){ 
+                return false;
+            }
+
+            if(b.getCode() == null ^ getCode() == null) {
+                return false;
+            }
+            if(b.getCode() != null && !b.getCode().equals(getCode())){ 
+                return false;
+            }
+
+            if(b.getAdditionalData() == null ^ getAdditionalData() == null) {
+                return false;
+            }
+            if(b.getAdditionalData() != null && !b.getAdditionalData().equals(getAdditionalData())){ 
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static class AmqpSaslOutcomeBuffer extends AmqpList.AmqpListBuffer implements AmqpSaslOutcome{
+
+        private AmqpSaslOutcomeBean bean;
+
+        protected AmqpSaslOutcomeBuffer(Encoded<IAmqpList> encoded) {
+            super(encoded);
+        }
+
+    public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options) {
+            bean().setOptions(options);
+        }
+
+        public final void setOptions(AmqpMap options) {
+            bean().setOptions(options);
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions() {
+            return bean().getOptions();
+        }
+
+        public final void setCode(AmqpSaslCode code) {
+            bean().setCode(code);
+        }
+
+        public final AmqpSaslCode getCode() {
+            return bean().getCode();
+        }
+
+    public void setAdditionalData(Buffer additionalData) {
+            bean().setAdditionalData(additionalData);
+        }
+
+        public final void setAdditionalData(AmqpBinary additionalData) {
+            bean().setAdditionalData(additionalData);
+        }
+
+        public final Buffer getAdditionalData() {
+            return bean().getAdditionalData();
+        }
+
+        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 AmqpSaslOutcome.AmqpSaslOutcomeBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpSaslOutcome bean() {
+            if(bean == null) {
+                bean = new AmqpSaslOutcome.AmqpSaslOutcomeBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpSaslOutcome.AmqpSaslOutcomeBuffer create(Encoded<IAmqpList> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpSaslOutcome.AmqpSaslOutcomeBuffer(encoded);
+        }
+
+        public static AmqpSaslOutcome.AmqpSaslOutcomeBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpSaslOutcome(in));
+        }
+
+        public static AmqpSaslOutcome.AmqpSaslOutcomeBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpSaslOutcome(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/AmqpSaslResponse.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslResponse.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslResponse.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSaslResponse.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,319 @@
+/**
+ * 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.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 security mechanism response
+ * <p>
+ * Send the SASL response data as defined by the SASL specification.
+ * </p>
+ */
+public interface AmqpSaslResponse extends AmqpList {
+
+
+
+    /**
+     * options map
+     */
+    public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options);
+
+    /**
+     * options map
+     */
+    public void setOptions(AmqpMap options);
+
+    /**
+     * options map
+     */
+    public HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions();
+
+    /**
+     * security response data
+     * <p>
+     * A block of opaque data passed to the security mechanism. The contents of this data are
+     * defined by the SASL security mechanism.
+     * </p>
+     */
+    public void setResponse(Buffer response);
+
+    /**
+     * security response data
+     * <p>
+     * A block of opaque data passed to the security mechanism. The contents of this data are
+     * defined by the SASL security mechanism.
+     * </p>
+     */
+    public void setResponse(AmqpBinary response);
+
+    /**
+     * security response data
+     * <p>
+     * A block of opaque data passed to the security mechanism. The contents of this data are
+     * defined by the SASL security mechanism.
+     * </p>
+     */
+    public Buffer getResponse();
+
+    public static class AmqpSaslResponseBean implements AmqpSaslResponse{
+
+        private AmqpSaslResponseBuffer buffer;
+        private AmqpSaslResponseBean bean = this;
+        private AmqpMap options;
+        private AmqpBinary response;
+
+        public AmqpSaslResponseBean() {
+        }
+
+        public AmqpSaslResponseBean(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 AmqpSaslResponseBean(AmqpSaslResponse.AmqpSaslResponseBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpSaslResponseBean copy() {
+            return new AmqpSaslResponse.AmqpSaslResponseBean(bean);
+        }
+
+        public final AmqpSaslResponse.AmqpSaslResponseBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpSaslResponseBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options) {
+            setOptions(new AmqpMap.AmqpMapBean(options));
+        }
+
+
+        public final void setOptions(AmqpMap options) {
+            copyCheck();
+            bean.options = options;
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions() {
+            return bean.options.getValue();
+        }
+
+        public void setResponse(Buffer response) {
+            setResponse(new AmqpBinary.AmqpBinaryBean(response));
+        }
+
+
+        public final void setResponse(AmqpBinary response) {
+            copyCheck();
+            bean.response = response;
+        }
+
+        public final Buffer getResponse() {
+            return bean.response.getValue();
+        }
+
+        public void set(int index, AmqpType<?, ?> value) {
+            switch(index) {
+            case 0: {
+                setOptions((AmqpMap) value);
+                break;
+            }
+            case 1: {
+                setResponse((AmqpBinary) 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.response;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public int getListCount() {
+            return 2;
+        }
+
+        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(AmqpSaslResponse.AmqpSaslResponseBean other) {
+            this.options= other.options;
+            this.response= other.response;
+            bean = this;
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpSaslResponse)) {
+                return false;
+            }
+
+            return equivalent((AmqpSaslResponse) t);
+        }
+
+        public boolean equivalent(AmqpSaslResponse b) {
+
+            if(b.getOptions() == null ^ getOptions() == null) {
+                return false;
+            }
+            if(b.getOptions() != null && !b.getOptions().equals(getOptions())){ 
+                return false;
+            }
+
+            if(b.getResponse() == null ^ getResponse() == null) {
+                return false;
+            }
+            if(b.getResponse() != null && !b.getResponse().equals(getResponse())){ 
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static class AmqpSaslResponseBuffer extends AmqpList.AmqpListBuffer implements AmqpSaslResponse{
+
+        private AmqpSaslResponseBean bean;
+
+        protected AmqpSaslResponseBuffer(Encoded<IAmqpList> encoded) {
+            super(encoded);
+        }
+
+    public void setOptions(HashMap<AmqpType<?,?>, AmqpType<?,?>> options) {
+            bean().setOptions(options);
+        }
+
+        public final void setOptions(AmqpMap options) {
+            bean().setOptions(options);
+        }
+
+        public final HashMap<AmqpType<?,?>, AmqpType<?,?>> getOptions() {
+            return bean().getOptions();
+        }
+
+    public void setResponse(Buffer response) {
+            bean().setResponse(response);
+        }
+
+        public final void setResponse(AmqpBinary response) {
+            bean().setResponse(response);
+        }
+
+        public final Buffer getResponse() {
+            return bean().getResponse();
+        }
+
+        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 AmqpSaslResponse.AmqpSaslResponseBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpSaslResponse bean() {
+            if(bean == null) {
+                bean = new AmqpSaslResponse.AmqpSaslResponseBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpSaslResponse.AmqpSaslResponseBuffer create(Encoded<IAmqpList> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpSaslResponse.AmqpSaslResponseBuffer(encoded);
+        }
+
+        public static AmqpSaslResponse.AmqpSaslResponseBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpSaslResponse(in));
+        }
+
+        public static AmqpSaslResponse.AmqpSaslResponseBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpSaslResponse(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/AmqpScope.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpScope.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpScope.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpScope.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.Short;
+import java.util.HashMap;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.types.AmqpUbyte;
+
+/**
+ * Represents a defined scopes
+ */
+public enum AmqpScope {
+
+    SESSION(new Short("0")),
+    CONTAINER(new Short("1"));
+
+    private static final HashMap<Short, AmqpScope> LOOKUP = new HashMap<Short, AmqpScope>(2);
+    static {
+        for (AmqpScope scope : AmqpScope.values()) {
+            LOOKUP.put(scope.value.getValue(), scope);
+        }
+    }
+
+    private final AmqpUbyte value;
+
+    private AmqpScope(Short value) {
+        this.value = new AmqpUbyte.AmqpUbyteBean(value);
+    }
+
+    public final AmqpUbyte getValue() {
+        return value;
+    }
+
+    public static final AmqpScope get(AmqpUbyte value) throws AmqpEncodingError{
+        AmqpScope scope= LOOKUP.get(value.getValue());
+        if (scope == null) {
+            //TODO perhaps this should be an IllegalArgumentException?
+            throw new AmqpEncodingError("Unknown scope: " + value + " expected one of " + LOOKUP.keySet());
+        }
+        return scope;
+    }
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSectionCodes.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSectionCodes.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSectionCodes.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSectionCodes.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,88 @@
+/**
+ * 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.Long;
+import java.util.HashMap;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.types.AmqpUint;
+
+public enum AmqpSectionCodes {
+
+    /**
+     * <p>
+     * type.
+     * </p>
+     */
+    HEADER(new Long("0")),
+    /**
+     * <p>
+     * type.
+     * </p>
+     */
+    PROPERTIES(new Long("1")),
+    /**
+     * <p>
+     * type.
+     * </p>
+     */
+    FOOTER(new Long("2")),
+    /**
+     * <p>
+     * .
+     * </p>
+     */
+    MAP_DATA(new Long("3")),
+    /**
+     * <p>
+     * .
+     * </p>
+     */
+    LIST_DATA(new Long("4")),
+    /**
+     * <p>
+     * type).
+     * </p>
+     */
+    DATA(new Long("5"));
+
+    private static final HashMap<Long, AmqpSectionCodes> LOOKUP = new HashMap<Long, AmqpSectionCodes>(2);
+    static {
+        for (AmqpSectionCodes sectionCodes : AmqpSectionCodes.values()) {
+            LOOKUP.put(sectionCodes.value.getValue(), sectionCodes);
+        }
+    }
+
+    private final AmqpUint value;
+
+    private AmqpSectionCodes(Long value) {
+        this.value = new AmqpUint.AmqpUintBean(value);
+    }
+
+    public final AmqpUint getValue() {
+        return value;
+    }
+
+    public static final AmqpSectionCodes get(AmqpUint value) throws AmqpEncodingError{
+        AmqpSectionCodes sectionCodes= LOOKUP.get(value.getValue());
+        if (sectionCodes == null) {
+            //TODO perhaps this should be an IllegalArgumentException?
+            throw new AmqpEncodingError("Unknown sectionCodes: " + value + " expected one of " + LOOKUP.keySet());
+        }
+        return sectionCodes;
+    }
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSequenceNo.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSequenceNo.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSequenceNo.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSequenceNo.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,169 @@
+/**
+ * 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.Long;
+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.AmqpSequenceNo;
+import org.apache.activemq.amqp.protocol.types.AmqpUint;
+import org.apache.activemq.util.buffer.Buffer;
+
+/**
+ * Represents a 32-bit RFC-1982 serial number
+ * <p>
+ * A sequence-no encodes a serial number as defined in RFC-1982. The arithmetic, and
+ * operators for these numbers are defined by RFC-1982.
+ * </p>
+ */
+public interface AmqpSequenceNo extends AmqpUint {
+
+
+    public static class AmqpSequenceNoBean implements AmqpSequenceNo{
+
+        private AmqpSequenceNoBuffer buffer;
+        private AmqpSequenceNoBean bean = this;
+        private Long value;
+
+        protected AmqpSequenceNoBean() {
+        }
+
+        public AmqpSequenceNoBean(Long value) {
+            this.value = value;
+        }
+
+        public AmqpSequenceNoBean(AmqpSequenceNo.AmqpSequenceNoBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpSequenceNoBean copy() {
+            return bean;
+        }
+
+        public final AmqpSequenceNo.AmqpSequenceNoBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpSequenceNoBuffer(marshaller.encode(this));
+            }
+            return buffer;
+        }
+
+        public final void marshal(DataOutput out, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError{
+            getBuffer(marshaller).marshal(out, marshaller);
+        }
+
+
+        public Long getValue() {
+            return bean.value;
+        }
+
+
+        public boolean equals(Object o){
+            if(this == o) {
+                return true;
+            }
+
+            if(o == null || !(o instanceof AmqpSequenceNo)) {
+                return false;
+            }
+
+            return equivalent((AmqpSequenceNo) o);
+        }
+
+        public int hashCode() {
+            if(getValue() == null) {
+                return AmqpSequenceNo.AmqpSequenceNoBean.class.hashCode();
+            }
+            return getValue().hashCode();
+        }
+
+        public boolean equivalent(AmqpType<?,?> t){
+            if(this == t) {
+                return true;
+            }
+
+            if(t == null || !(t instanceof AmqpSequenceNo)) {
+                return false;
+            }
+
+            return equivalent((AmqpSequenceNo) t);
+        }
+
+        public boolean equivalent(AmqpSequenceNo 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 AmqpSequenceNoBuffer extends AmqpUint.AmqpUintBuffer implements AmqpSequenceNo{
+
+        private AmqpSequenceNoBean bean;
+
+        protected AmqpSequenceNoBuffer() {
+            super();
+        }
+
+        protected AmqpSequenceNoBuffer(Encoded<Long> encoded) {
+            super(encoded);
+        }
+
+        public Long getValue() {
+            return bean().getValue();
+        }
+
+        public AmqpSequenceNo.AmqpSequenceNoBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpSequenceNo bean() {
+            if(bean == null) {
+                bean = new AmqpSequenceNo.AmqpSequenceNoBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpSequenceNo.AmqpSequenceNoBuffer create(Encoded<Long> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpSequenceNo.AmqpSequenceNoBuffer(encoded);
+        }
+
+        public static AmqpSequenceNo.AmqpSequenceNoBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpUint(in));
+        }
+
+        public static AmqpSequenceNo.AmqpSequenceNoBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpUint(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/AmqpSessionError.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSessionError.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSessionError.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSessionError.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,548 @@
+/**
+ * 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.Short;
+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 Session error
+ * <p>
+ * This struct carries information on an exception which has occurred on the Session. The
+ * command-id, when given, correlates the error to a specific command.
+ * </p>
+ */
+public interface AmqpSessionError extends AmqpList {
+
+
+
+    /**
+     * error code indicating the type of error
+     */
+    public void setErrorCode(AmqpSessionErrorCode errorCode);
+
+    /**
+     * error code indicating the type of error
+     */
+    public AmqpSessionErrorCode getErrorCode();
+
+    /**
+     * exceptional command
+     * <p>
+     * The command-id of the command which caused the exception. If the exception was not
+     * caused by a specific command, this value is not set.
+     * </p>
+     */
+    public void setCommandId(AmqpSequenceNo commandId);
+
+    /**
+     * exceptional command
+     * <p>
+     * The command-id of the command which caused the exception. If the exception was not
+     * caused by a specific command, this value is not set.
+     * </p>
+     */
+    public AmqpSequenceNo getCommandId();
+
+    /**
+     * the class code of the command whose execution gave rise to the error (if appropriate)
+     */
+    public void setCommandCode(Short commandCode);
+
+    /**
+     * the class code of the command whose execution gave rise to the error (if appropriate)
+     */
+    public void setCommandCode(AmqpUbyte commandCode);
+
+    /**
+     * the class code of the command whose execution gave rise to the error (if appropriate)
+     */
+    public Short getCommandCode();
+
+    /**
+     * index of the exceptional field
+     * <p>
+     * The zero based index of the exceptional field within the arguments to the exceptional
+     * command. If the exception was not caused by a specific field, this value is not set.
+     * </p>
+     */
+    public void setFieldIndex(Short fieldIndex);
+
+    /**
+     * index of the exceptional field
+     * <p>
+     * The zero based index of the exceptional field within the arguments to the exceptional
+     * command. If the exception was not caused by a specific field, this value is not set.
+     * </p>
+     */
+    public void setFieldIndex(AmqpUbyte fieldIndex);
+
+    /**
+     * index of the exceptional field
+     * <p>
+     * The zero based index of the exceptional field within the arguments to the exceptional
+     * command. If the exception was not caused by a specific field, this value is not set.
+     * </p>
+     */
+    public Short getFieldIndex();
+
+    /**
+     * descriptive 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);
+
+    /**
+     * descriptive 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);
+
+    /**
+     * descriptive 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 AmqpSessionErrorBean implements AmqpSessionError{
+
+        private AmqpSessionErrorBuffer buffer;
+        private AmqpSessionErrorBean bean = this;
+        private AmqpSessionErrorCode errorCode;
+        private AmqpSequenceNo commandId;
+        private AmqpUbyte commandCode;
+        private AmqpUbyte fieldIndex;
+        private AmqpString description;
+        private AmqpMap errorInfo;
+
+        public AmqpSessionErrorBean() {
+        }
+
+        public AmqpSessionErrorBean(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 AmqpSessionErrorBean(AmqpSessionError.AmqpSessionErrorBean other) {
+            this.bean = other;
+        }
+
+        public final AmqpSessionErrorBean copy() {
+            return new AmqpSessionError.AmqpSessionErrorBean(bean);
+        }
+
+        public final AmqpSessionError.AmqpSessionErrorBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            if(buffer == null) {
+                buffer = new AmqpSessionErrorBuffer(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(AmqpSessionErrorCode errorCode) {
+            copyCheck();
+            bean.errorCode = errorCode;
+        }
+
+        public final AmqpSessionErrorCode getErrorCode() {
+            return bean.errorCode;
+        }
+
+        public final void setCommandId(AmqpSequenceNo commandId) {
+            copyCheck();
+            bean.commandId = commandId;
+        }
+
+        public final AmqpSequenceNo getCommandId() {
+            return bean.commandId;
+        }
+
+        public void setCommandCode(Short commandCode) {
+            setCommandCode(new AmqpUbyte.AmqpUbyteBean(commandCode));
+        }
+
+
+        public final void setCommandCode(AmqpUbyte commandCode) {
+            copyCheck();
+            bean.commandCode = commandCode;
+        }
+
+        public final Short getCommandCode() {
+            return bean.commandCode.getValue();
+        }
+
+        public void setFieldIndex(Short fieldIndex) {
+            setFieldIndex(new AmqpUbyte.AmqpUbyteBean(fieldIndex));
+        }
+
+
+        public final void setFieldIndex(AmqpUbyte fieldIndex) {
+            copyCheck();
+            bean.fieldIndex = fieldIndex;
+        }
+
+        public final Short getFieldIndex() {
+            return bean.fieldIndex.getValue();
+        }
+
+        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(AmqpSessionErrorCode.get((AmqpUshort)value));
+                break;
+            }
+            case 1: {
+                setCommandId((AmqpSequenceNo) value);
+                break;
+            }
+            case 2: {
+                setCommandCode((AmqpUbyte) value);
+                break;
+            }
+            case 3: {
+                setFieldIndex((AmqpUbyte) value);
+                break;
+            }
+            case 4: {
+                setDescription((AmqpString) value);
+                break;
+            }
+            case 5: {
+                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.commandId;
+            }
+            case 2: {
+                return bean.commandCode;
+            }
+            case 3: {
+                return bean.fieldIndex;
+            }
+            case 4: {
+                return bean.description;
+            }
+            case 5: {
+                return bean.errorInfo;
+            }
+            default : {
+                throw new IndexOutOfBoundsException(String.valueOf(index));
+            }
+            }
+        }
+
+        public int getListCount() {
+            return 6;
+        }
+
+        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(AmqpSessionError.AmqpSessionErrorBean other) {
+            this.errorCode= other.errorCode;
+            this.commandId= other.commandId;
+            this.commandCode= other.commandCode;
+            this.fieldIndex= other.fieldIndex;
+            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 AmqpSessionError)) {
+                return false;
+            }
+
+            return equivalent((AmqpSessionError) t);
+        }
+
+        public boolean equivalent(AmqpSessionError b) {
+
+            if(b.getErrorCode() == null ^ getErrorCode() == null) {
+                return false;
+            }
+            if(b.getErrorCode() != null && !b.getErrorCode().equals(getErrorCode())){ 
+                return false;
+            }
+
+            if(b.getCommandId() == null ^ getCommandId() == null) {
+                return false;
+            }
+            if(b.getCommandId() != null && !b.getCommandId().equals(getCommandId())){ 
+                return false;
+            }
+
+            if(b.getCommandCode() == null ^ getCommandCode() == null) {
+                return false;
+            }
+            if(b.getCommandCode() != null && !b.getCommandCode().equals(getCommandCode())){ 
+                return false;
+            }
+
+            if(b.getFieldIndex() == null ^ getFieldIndex() == null) {
+                return false;
+            }
+            if(b.getFieldIndex() != null && !b.getFieldIndex().equals(getFieldIndex())){ 
+                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 AmqpSessionErrorBuffer extends AmqpList.AmqpListBuffer implements AmqpSessionError{
+
+        private AmqpSessionErrorBean bean;
+
+        protected AmqpSessionErrorBuffer(Encoded<IAmqpList> encoded) {
+            super(encoded);
+        }
+
+        public final void setErrorCode(AmqpSessionErrorCode errorCode) {
+            bean().setErrorCode(errorCode);
+        }
+
+        public final AmqpSessionErrorCode getErrorCode() {
+            return bean().getErrorCode();
+        }
+
+        public final void setCommandId(AmqpSequenceNo commandId) {
+            bean().setCommandId(commandId);
+        }
+
+        public final AmqpSequenceNo getCommandId() {
+            return bean().getCommandId();
+        }
+
+    public void setCommandCode(Short commandCode) {
+            bean().setCommandCode(commandCode);
+        }
+
+        public final void setCommandCode(AmqpUbyte commandCode) {
+            bean().setCommandCode(commandCode);
+        }
+
+        public final Short getCommandCode() {
+            return bean().getCommandCode();
+        }
+
+    public void setFieldIndex(Short fieldIndex) {
+            bean().setFieldIndex(fieldIndex);
+        }
+
+        public final void setFieldIndex(AmqpUbyte fieldIndex) {
+            bean().setFieldIndex(fieldIndex);
+        }
+
+        public final Short getFieldIndex() {
+            return bean().getFieldIndex();
+        }
+
+    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 AmqpSessionError.AmqpSessionErrorBuffer getBuffer(AmqpMarshaller marshaller) throws AmqpEncodingError{
+            return this;
+        }
+
+        protected AmqpSessionError bean() {
+            if(bean == null) {
+                bean = new AmqpSessionError.AmqpSessionErrorBean(encoded.getValue());
+                bean.buffer = this;
+            }
+            return bean;
+        }
+
+        public boolean equivalent(AmqpType<?, ?> t) {
+            return bean().equivalent(t);
+        }
+
+        public static AmqpSessionError.AmqpSessionErrorBuffer create(Encoded<IAmqpList> encoded) {
+            if(encoded.isNull()) {
+                return null;
+            }
+            return new AmqpSessionError.AmqpSessionErrorBuffer(encoded);
+        }
+
+        public static AmqpSessionError.AmqpSessionErrorBuffer create(DataInput in, AmqpMarshaller marshaller) throws IOException, AmqpEncodingError {
+            return create(marshaller.unmarshalAmqpSessionError(in));
+        }
+
+        public static AmqpSessionError.AmqpSessionErrorBuffer create(Buffer buffer, int offset, AmqpMarshaller marshaller) throws AmqpEncodingError {
+            return create(marshaller.decodeAmqpSessionError(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/AmqpSessionErrorCode.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSessionErrorCode.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSessionErrorCode.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/types/AmqpSessionErrorCode.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,200 @@
+/**
+ * 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 error code used to identify the nature of an exception
+ */
+public enum AmqpSessionErrorCode {
+
+    /**
+     * <p>
+     * The client attempted to work with a server entity to which it has no access due to
+     * security settings.
+     * </p>
+     */
+    UNAUTHORIZED_ACCESS(new Integer("4003")),
+    /**
+     * <p>
+     * The client attempted to work with a server entity that does not exist.
+     * </p>
+     */
+    NOT_FOUND(new Integer("4004")),
+    /**
+     * <p>
+     * The client attempted to work with a server entity to which it has no access because
+     * another client is working with it.
+     * </p>
+     */
+    RESOURCE_LOCKED(new Integer("4005")),
+    /**
+     * <p>
+     * The client requested a command that was not allowed because some precondition failed.
+     * </p>
+     */
+    PRECONDITION_FAILED(new Integer("4006")),
+    /**
+     * <p>
+     * A server entity the client is working with has been deleted.
+     * </p>
+     */
+    RESOURCE_DELETED(new Integer("4008")),
+    /**
+     * <p>
+     * The peer sent a command that is not permitted in the current state of the Session.
+     * </p>
+     */
+    ILLEGAL_STATE(new Integer("4009")),
+    /**
+     * <p>
+     * The peer sent more Message transfers than currently allowed on the Link.
+     * </p>
+     */
+    TRANSFER_LIMIT_EXCEEDED(new Integer("4010")),
+    /**
+     * <p>
+     * The command segments could not be decoded.
+     * </p>
+     */
+    COMMAND_INVALID(new Integer("5003")),
+    /**
+     * <p>
+     * The client exceeded its resource allocation.
+     * </p>
+     */
+    RESOURCE_LIMIT_EXCEEDED(new Integer("5006")),
+    /**
+     * <p>
+     * The peer tried to use a command a manner that is inconsistent with the semantics defined
+     * in the specification.
+     * </p>
+     */
+    NOT_ALLOWED(new Integer("5030")),
+    /**
+     * <p>
+     * The command argument is malformed, i.e. it does not match the specified type. The
+     * illegal-argument exception can be raised on execution of any command.
+     * </p>
+     */
+    ILLEGAL_ARGUMENT(new Integer("5031")),
+    /**
+     * <p>
+     * The peer tried to use functionality that is not implemented in its partner.
+     * </p>
+     */
+    NOT_IMPLEMENTED(new Integer("5040")),
+    /**
+     * <p>
+     * The peer could not complete the command because of an internal error. The peer may
+     * require intervention by an operator in order to resume normal operations.
+     * </p>
+     */
+    INTERNAL_ERROR(new Integer("5041")),
+    /**
+     * <p>
+     * An invalid argument was passed to a command, and the operation could not proceed. An
+     * invalid argument is not illegal (see illegal-argument), i.e. it matches the type
+     * definition; however the particular value is invalid in this context.
+     * </p>
+     */
+    INVALID_ARGUMENT(new Integer("5042")),
+    /**
+     * <p>
+     * The rollback was caused for an unspecified reason.
+     * </p>
+     * <p>
+     * Note that the AMQP container acting as the Transaction Resource may at any time decide
+     * that the current transaction branch must be rolled back. In this case the peer acting
+     * as the Transactional Resource may decide to spontaneously detach the Session with this
+     * error code.
+     * </p>
+     * <p>
+     * If the AMQP container acting as the Transaction Controller attempts to re-attach to the
+     * Session after receiving this exception from the Resource spontaneously rolling back then
+     * the Controller MUST manually rollback the current transaction before attempting any
+     * further transactional work.
+     * </p>
+     */
+    XA_RBROLLBACK(new Integer("6001")),
+    /**
+     * <p>
+     * A transaction branch took too long.
+     * </p>
+     */
+    XA_RBTIMEOUT(new Integer("6002")),
+    /**
+     * <p>
+     * The transaction branch may have been heuristically completed.
+     * </p>
+     */
+    XA_HEURHAZ(new Integer("6003")),
+    /**
+     * <p>
+     * The transaction branch has been heuristically committed.
+     * </p>
+     */
+    XA_HEURCOM(new Integer("6004")),
+    /**
+     * <p>
+     * The transaction branch has been heuristically rolled back.
+     * </p>
+     */
+    XA_HEURRB(new Integer("6005")),
+    /**
+     * <p>
+     * The transaction branch has been heuristically committed and rolled back.
+     * </p>
+     */
+    XA_HEURMIX(new Integer("6006")),
+    /**
+     * <p>
+     * The transaction branch was read-only and has been committed.
+     * </p>
+     */
+    XA_RDONLY(new Integer("6007"));
+
+    private static final HashMap<Integer, AmqpSessionErrorCode> LOOKUP = new HashMap<Integer, AmqpSessionErrorCode>(2);
+    static {
+        for (AmqpSessionErrorCode sessionErrorCode : AmqpSessionErrorCode.values()) {
+            LOOKUP.put(sessionErrorCode.value.getValue(), sessionErrorCode);
+        }
+    }
+
+    private final AmqpUshort value;
+
+    private AmqpSessionErrorCode(Integer value) {
+        this.value = new AmqpUshort.AmqpUshortBean(value);
+    }
+
+    public final AmqpUshort getValue() {
+        return value;
+    }
+
+    public static final AmqpSessionErrorCode get(AmqpUshort value) throws AmqpEncodingError{
+        AmqpSessionErrorCode sessionErrorCode= LOOKUP.get(value.getValue());
+        if (sessionErrorCode == null) {
+            //TODO perhaps this should be an IllegalArgumentException?
+            throw new AmqpEncodingError("Unknown sessionErrorCode: " + value + " expected one of " + LOOKUP.keySet());
+        }
+        return sessionErrorCode;
+    }
+}
\ No newline at end of file



Mime
View raw message