You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2015/08/14 21:07:36 UTC

[03/50] [abbrv] qpid-proton git commit: Worked on the AMQP Performatives. Validation is not added yet. work-in-progress. More modifications to the performatives are expected.

Worked on the AMQP Performatives. Validation is not added yet.
work-in-progress. More modifications to the performatives are expected.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/bae93545
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/bae93545
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/bae93545

Branch: refs/heads/rajith-codec
Commit: bae935457927af02ec80c46145412e3fa525f0a6
Parents: 06ab7d1
Author: Rajith Attapattu <ra...@apache.org>
Authored: Fri Feb 6 16:48:18 2015 -0500
Committer: Rajith Attapattu <ra...@apache.org>
Committed: Thu Jul 9 09:12:37 2015 -0400

----------------------------------------------------------------------
 .../qpid/proton/codec2/PerformativeFactory.java |  26 --
 .../apache/qpid/proton/codec2/TypeRegistry.java |  63 ----
 .../apache/qpid/proton/transport/Attach.java    | 324 +++++++++++++++++++
 .../org/apache/qpid/proton/transport/Begin.java | 216 +++++++++++++
 .../org/apache/qpid/proton/transport/Close.java |  81 +++++
 .../apache/qpid/proton/transport/Detach.java    | 113 +++++++
 .../qpid/proton/transport/ErrorCondition.java   | 181 +++++++++++
 .../org/apache/qpid/proton/transport/Flow.java  |  63 ++--
 .../org/apache/qpid/proton/transport/Open.java  |  40 +--
 9 files changed, 968 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/codec2/PerformativeFactory.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec2/PerformativeFactory.java b/proton-j/src/main/java/org/apache/qpid/proton/codec2/PerformativeFactory.java
deleted file mode 100644
index e428207..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec2/PerformativeFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec2;
-
-public interface PerformativeFactory
-{
-    public Object create(Object in) throws DecodeException;
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/codec2/TypeRegistry.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec2/TypeRegistry.java b/proton-j/src/main/java/org/apache/qpid/proton/codec2/TypeRegistry.java
deleted file mode 100644
index 85eb4aa..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec2/TypeRegistry.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec2;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class TypeRegistry
-{
-    private static Map<String, PerformativeFactory> _typeRegByStrCode = new HashMap<String, PerformativeFactory>();
-
-    private static Map<Long, PerformativeFactory> _typeRegByLongCode = new HashMap<Long, PerformativeFactory>();
-
-    public static void registerType(long longCode, String strCode, PerformativeFactory factory)
-    {
-        _typeRegByStrCode.put(strCode, factory);
-        _typeRegByLongCode.put(longCode, factory);
-    }
-
-    public static PerformativeFactory lookup(Object code)
-    {
-        if (code instanceof Long)
-        {
-            return lookup((Long) code);
-        }
-        else if (code instanceof String)
-        {
-            return lookup((String) code);
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-    static PerformativeFactory lookup(long code)
-    {
-        return _typeRegByLongCode.get(code);
-    }
-
-    static PerformativeFactory lookup(String code)
-    {
-        return _typeRegByStrCode.get(code);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/transport/Attach.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Attach.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Attach.java
new file mode 100644
index 0000000..46539ef
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Attach.java
@@ -0,0 +1,324 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.proton.transport;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.proton.codec2.CodecHelper;
+import org.apache.qpid.proton.codec2.DecodeException;
+import org.apache.qpid.proton.codec2.DescribedTypeFactory;
+import org.apache.qpid.proton.codec2.Encodable;
+import org.apache.qpid.proton.codec2.Encoder;
+
+public final class Attach implements Encodable
+{
+    public final static long DESCRIPTOR_LONG = 0x0000000000000012L;
+
+    public final static String DESCRIPTOR_STRING = "amqp:attach:list";
+
+    private String _name;
+
+    private int _handle;
+
+    private Role _role = Role.SENDER;
+
+    private SenderSettleMode _sndSettleMode = SenderSettleMode.MIXED;
+
+    private ReceiverSettleMode _rcvSettleMode = ReceiverSettleMode.FIRST;
+
+    private Source _source;
+
+    private Target _target;
+
+    private Map<Object, Object> _unsettled;
+
+    private boolean _incompleteUnsettled;
+
+    private int _initialDeliveryCount;
+
+    private long _maxMessageSize;
+
+    private String[] _offeredCapabilities;
+
+    private String[] _desiredCapabilities;
+
+    private Map<Object, Object> _properties;
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public void setName(String name)
+    {
+        if (name == null)
+        {
+            throw new NullPointerException("the name field is mandatory");
+        }
+
+        _name = name;
+    }
+
+    public int getHandle()
+    {
+        return _handle;
+    }
+
+    public void setHandle(int handle)
+    {
+        _handle = handle;
+    }
+
+    public Role getRole()
+    {
+        return _role;
+    }
+
+    public void setRole(Role role)
+    {
+        if (role == null)
+        {
+            throw new NullPointerException("Role cannot be null");
+        }
+        _role = role;
+    }
+
+    public SenderSettleMode getSndSettleMode()
+    {
+        return _sndSettleMode;
+    }
+
+    public void setSndSettleMode(SenderSettleMode sndSettleMode)
+    {
+        _sndSettleMode = sndSettleMode == null ? SenderSettleMode.MIXED : sndSettleMode;
+    }
+
+    public ReceiverSettleMode getRcvSettleMode()
+    {
+        return _rcvSettleMode;
+    }
+
+    public void setRcvSettleMode(ReceiverSettleMode rcvSettleMode)
+    {
+        _rcvSettleMode = rcvSettleMode == null ? ReceiverSettleMode.FIRST : rcvSettleMode;
+    }
+
+    public Source getSource()
+    {
+        return _source;
+    }
+
+    public void setSource(Source source)
+    {
+        _source = source;
+    }
+
+    public Target getTarget()
+    {
+        return _target;
+    }
+
+    public void setTarget(Target target)
+    {
+        _target = target;
+    }
+
+    public Map<Object, Object> getUnsettled()
+    {
+        return _unsettled;
+    }
+
+    public void setUnsettled(Map<Object, Object> unsettled)
+    {
+        _unsettled = unsettled;
+    }
+
+    public boolean getIncompleteUnsettled()
+    {
+        return _incompleteUnsettled;
+    }
+
+    public void setIncompleteUnsettled(boolean incompleteUnsettled)
+    {
+        _incompleteUnsettled = incompleteUnsettled;
+    }
+
+    public int getInitialDeliveryCount()
+    {
+        return _initialDeliveryCount;
+    }
+
+    public void setInitialDeliveryCount(int initialDeliveryCount)
+    {
+        _initialDeliveryCount = initialDeliveryCount;
+    }
+
+    public long getMaxMessageSize()
+    {
+        return _maxMessageSize;
+    }
+
+    public void setMaxMessageSize(long maxMessageSize)
+    {
+        _maxMessageSize = maxMessageSize;
+    }
+
+    public String[] getOfferedCapabilities()
+    {
+        return _offeredCapabilities;
+    }
+
+    public void setOfferedCapabilities(String... offeredCapabilities)
+    {
+        _offeredCapabilities = offeredCapabilities;
+    }
+
+    public String[] getDesiredCapabilities()
+    {
+        return _desiredCapabilities;
+    }
+
+    public void setDesiredCapabilities(String... desiredCapabilities)
+    {
+        _desiredCapabilities = desiredCapabilities;
+    }
+
+    public Map<Object, Object> getProperties()
+    {
+        return _properties;
+    }
+
+    public void setProperties(Map<Object, Object> properties)
+    {
+        _properties = properties;
+    }
+
+    @Override
+    public void encode(Encoder encoder)
+    {
+        encoder.putDescriptor();
+        encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
+        encoder.putString(_name);
+        encoder.putLong(_handle);
+        encoder.putBoolean(_role.getValue());
+        encoder.putUbyte(_sndSettleMode.getValue());
+        encoder.putUbyte(_rcvSettleMode.getValue());
+        _source.encode(encoder);
+        _target.encode(encoder);
+        CodecHelper.encodeMap(encoder, _unsettled);
+        encoder.putBoolean(_incompleteUnsettled);
+        encoder.putLong(_initialDeliveryCount);
+        encoder.putLong(_maxMessageSize);
+        CodecHelper.encodeSymbolArray(encoder, _offeredCapabilities);
+        CodecHelper.encodeSymbolArray(encoder, _desiredCapabilities);
+        CodecHelper.encodeMap(encoder, _properties);
+        encoder.end();
+    }
+
+    public static final class Factory implements DescribedTypeFactory
+    {
+        @SuppressWarnings("unchecked")
+        public Object create(Object in) throws DecodeException
+        {
+            List<Object> l = (List<Object>) in;
+            Attach attach = new Attach();
+
+            switch (14 - l.size())
+            {
+
+            case 0:
+                attach.setProperties((Map<Object, Object>) l.get(13));
+            case 1:
+                Object val1 = l.get(12);
+                if (val1 == null || val1.getClass().isArray())
+                {
+                    attach.setDesiredCapabilities((String[]) val1);
+                }
+                else
+                {
+                    attach.setDesiredCapabilities((String) val1);
+                }
+            case 2:
+                Object val2 = l.get(11);
+                if (val2 == null || val2.getClass().isArray())
+                {
+                    attach.setOfferedCapabilities((String[]) val2);
+                }
+                else
+                {
+                    attach.setOfferedCapabilities((String) val2);
+                }
+            case 3:
+                attach.setMaxMessageSize((long) l.get(10));
+            case 4:
+                attach.setInitialDeliveryCount((int) l.get(9));
+            case 5:
+                Boolean incompleteUnsettled = (Boolean) l.get(8);
+                attach.setIncompleteUnsettled(incompleteUnsettled == null ? false : incompleteUnsettled);
+            case 6:
+                attach.setUnsettled((Map<Object, Object>) l.get(7));
+            case 7:
+                attach.setTarget((Target) l.get(6));
+            case 8:
+                attach.setSource((Source) l.get(5));
+            case 9:
+                attach.setRcvSettleMode(l.get(4) == null ? ReceiverSettleMode.FIRST
+                        : ReceiverSettleMode.values()[(int) l.get(4)]);
+            case 10:
+                attach.setSndSettleMode(l.get(3) == null ? SenderSettleMode.MIXED : SenderSettleMode.values()[(int) l
+                        .get(3)]);
+            case 11:
+                attach.setRole(Boolean.TRUE.equals(l.get(2)) ? Role.RECEIVER : Role.SENDER);
+            case 12:
+                attach.setHandle((int) l.get(1));
+            case 13:
+                attach.setName((String) l.get(0));
+            }
+
+            return attach;
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Attach{" +
+               "name='" + _name + '\'' +
+               ", handle=" + _handle +
+               ", role=" + _role +
+               ", sndSettleMode=" + _sndSettleMode +
+               ", rcvSettleMode=" + _rcvSettleMode +
+               ", source=" + _source +
+               ", target=" + _target +
+               ", unsettled=" + _unsettled +
+               ", incompleteUnsettled=" + _incompleteUnsettled +
+               ", initialDeliveryCount=" + _initialDeliveryCount +
+               ", maxMessageSize=" + _maxMessageSize +
+               ", offeredCapabilities=" + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities)) +
+               ", desiredCapabilities=" + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) +
+               ", properties=" + _properties +
+               '}';
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/transport/Begin.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Begin.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Begin.java
new file mode 100644
index 0000000..2a2c120
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Begin.java
@@ -0,0 +1,216 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.proton.transport;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.proton.codec2.CodecHelper;
+import org.apache.qpid.proton.codec2.DecodeException;
+import org.apache.qpid.proton.codec2.DescribedTypeFactory;
+import org.apache.qpid.proton.codec2.Encodable;
+import org.apache.qpid.proton.codec2.Encoder;
+
+public final class Begin implements Encodable
+{
+    public final static long DESCRIPTOR_LONG = 0x0000000000000012L;
+
+    public final static String DESCRIPTOR_STRING = "amqp:begin:list";
+
+    private int _remoteChannel;
+
+    private long _nextOutgoingId;
+
+    private long _incomingWindow;
+
+    private long _outgoingWindow;
+
+    private int _handleMax = 0xffffffff;
+
+    private String[] _offeredCapabilities;
+
+    private String[] _desiredCapabilities;
+
+    private Map<Object, Object> _properties;
+
+    public int getRemoteChannel()
+    {
+        return _remoteChannel;
+    }
+
+    public void setRemoteChannel(int remoteChannel)
+    {
+        _remoteChannel = remoteChannel;
+    }
+
+    public long getNextOutgoingId()
+    {
+        return _nextOutgoingId;
+    }
+
+    public void setNextOutgoingId(long nextOutgoingId)
+    {
+        _nextOutgoingId = nextOutgoingId;
+    }
+
+    public long getIncomingWindow()
+    {
+        return _incomingWindow;
+    }
+
+    public void setIncomingWindow(long incomingWindow)
+    {
+        _incomingWindow = incomingWindow;
+    }
+
+    public long getOutgoingWindow()
+    {
+        return _outgoingWindow;
+    }
+
+    public void setOutgoingWindow(long outgoingWindow)
+    {
+        _outgoingWindow = outgoingWindow;
+    }
+
+    public int getHandleMax()
+    {
+        return _handleMax;
+    }
+
+    public void setHandleMax(int handleMax)
+    {
+        _handleMax = handleMax;
+    }
+
+    public String[] getOfferedCapabilities()
+    {
+        return _offeredCapabilities;
+    }
+
+    public void setOfferedCapabilities(String... offeredCapabilities)
+    {
+        _offeredCapabilities = offeredCapabilities;
+    }
+
+    public String[] getDesiredCapabilities()
+    {
+        return _desiredCapabilities;
+    }
+
+    public void setDesiredCapabilities(String... desiredCapabilities)
+    {
+        _desiredCapabilities = desiredCapabilities;
+    }
+
+    public Map<Object, Object> getProperties()
+    {
+        return _properties;
+    }
+
+    public void setProperties(Map<Object, Object> properties)
+    {
+        _properties = properties;
+    }
+
+    @Override
+    public void encode(Encoder encoder)
+    {
+        encoder.putDescriptor();
+        encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
+        encoder.putInt(_remoteChannel);
+        encoder.putLong(_nextOutgoingId);
+        encoder.putLong(_incomingWindow);
+        encoder.putLong(_outgoingWindow);
+        encoder.putLong(_handleMax);
+        CodecHelper.encodeSymbolArray(encoder, _offeredCapabilities);
+        CodecHelper.encodeSymbolArray(encoder, _desiredCapabilities);
+        CodecHelper.encodeMap(encoder, _properties);
+        encoder.end();
+    }
+
+    public static final class Factory implements DescribedTypeFactory
+    {
+        @SuppressWarnings("unchecked")
+        public Object create(Object in) throws DecodeException
+        {
+            List<Object> l = (List<Object>) in;
+            Begin begin = new Begin();
+
+            switch (8 - l.size())
+            {
+
+            case 0:
+                begin.setProperties((Map<Object, Object>) l.get(7));
+            case 1:
+                Object val1 = l.get(6);
+                if (val1 == null || val1.getClass().isArray())
+                {
+                    begin.setDesiredCapabilities((String[]) val1);
+                }
+                else
+                {
+                    begin.setDesiredCapabilities((String) val1);
+                }
+            case 2:
+                Object val2 = l.get(5);
+                if (val2 == null || val2.getClass().isArray())
+                {
+                    begin.setOfferedCapabilities((String[]) val2);
+                }
+                else
+                {
+                    begin.setOfferedCapabilities((String) val2);
+                }
+            case 3:
+                begin.setHandleMax(l.get(4) == null ? 0xffffffff : (int) l.get(4));
+            case 4:
+                begin.setOutgoingWindow((long) l.get(3));
+            case 5:
+                begin.setIncomingWindow((long) l.get(2));
+            case 6:
+                begin.setNextOutgoingId((long) l.get(1));
+            case 7:
+                begin.setRemoteChannel((int) l.get(0));
+            }
+
+            return begin;
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Begin{" +
+               "remoteChannel=" + _remoteChannel +
+               ", nextOutgoingId=" + _nextOutgoingId +
+               ", incomingWindow=" + _incomingWindow +
+               ", outgoingWindow=" + _outgoingWindow +
+               ", handleMax=" + _handleMax +
+               ", offeredCapabilities=" + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities)) +
+               ", desiredCapabilities=" + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) +
+               ", properties=" + _properties +
+               '}';
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/transport/Close.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Close.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Close.java
new file mode 100644
index 0000000..2a07aa0
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Close.java
@@ -0,0 +1,81 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.proton.transport;
+
+import java.util.List;
+
+import org.apache.qpid.proton.codec2.DecodeException;
+import org.apache.qpid.proton.codec2.DescribedTypeFactory;
+import org.apache.qpid.proton.codec2.Encodable;
+import org.apache.qpid.proton.codec2.Encoder;
+
+public final class Close implements Encodable
+{
+    public final static long DESCRIPTOR_LONG = 0x0000000000000018L;
+
+    public final static String DESCRIPTOR_STRING = "amqp:close:list";
+
+    private ErrorCondition _error;
+
+    public ErrorCondition getError()
+    {
+        return _error;
+    }
+
+    public void setError(ErrorCondition error)
+    {
+        _error = error;
+    }
+
+    @Override
+    public void encode(Encoder encoder)
+    {
+        encoder.putDescriptor();
+        encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
+        _error.encode(encoder);
+        encoder.end();
+    }
+
+    public static final class Factory implements DescribedTypeFactory
+    {
+        @SuppressWarnings("unchecked")
+        public Object create(Object in) throws DecodeException
+        {
+            List<Object> l = (List<Object>) in;
+            Close close = new Close();
+
+            if (!l.isEmpty())
+            {
+                close.setError((ErrorCondition) l.get(0));
+            }
+
+            return close;
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Close{" + "error=" + _error + '}';
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/transport/Detach.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Detach.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Detach.java
new file mode 100644
index 0000000..babd694
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Detach.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.proton.transport;
+
+import java.util.List;
+
+import org.apache.qpid.proton.codec2.DecodeException;
+import org.apache.qpid.proton.codec2.DescribedTypeFactory;
+import org.apache.qpid.proton.codec2.Encodable;
+import org.apache.qpid.proton.codec2.Encoder;
+
+public final class Detach implements Encodable
+{
+    public final static long DESCRIPTOR_LONG = 0x0000000000000016L;
+
+    public final static String DESCRIPTOR_STRING = "amqp:detach:list";
+
+    private int _handle;
+
+    private boolean _closed;
+
+    private ErrorCondition _error;
+
+    public int getHandle()
+    {
+        return _handle;
+    }
+
+    public void setHandle(int handle)
+    {
+        _handle = handle;
+    }
+
+    public boolean getClosed()
+    {
+        return _closed;
+    }
+
+    public void setClosed(boolean closed)
+    {
+        _closed = closed;
+    }
+
+    public ErrorCondition getError()
+    {
+        return _error;
+    }
+
+    public void setError(ErrorCondition error)
+    {
+        _error = error;
+    }
+
+    @Override
+    public void encode(Encoder encoder)
+    {
+        encoder.putDescriptor();
+        encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
+        encoder.putInt(_handle);
+        encoder.putBoolean(_closed);
+        _error.encode(encoder);
+        encoder.end();
+    }
+
+    public static final class Factory implements DescribedTypeFactory
+    {
+        @SuppressWarnings("unchecked")
+        public Object create(Object in) throws DecodeException
+        {
+            List<Object> l = (List<Object>) in;
+            Detach detach = new Detach();
+
+            switch (3 - l.size())
+            {
+
+            case 0:
+                detach.setError((ErrorCondition) l.get(2));
+            case 1:
+                detach.setClosed(l.get(1) == null ? false : (boolean) l.get(1));
+            case 2:
+                detach.setHandle((int) l.get(0));
+            }
+
+            return detach;
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Detach{" + "handle=" + _handle + ", closed=" + _closed + ", error=" + _error + '}';
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/transport/ErrorCondition.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/ErrorCondition.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/ErrorCondition.java
new file mode 100644
index 0000000..bb8f062
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/ErrorCondition.java
@@ -0,0 +1,181 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.proton.transport;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.proton.codec2.CodecHelper;
+import org.apache.qpid.proton.codec2.DecodeException;
+import org.apache.qpid.proton.codec2.DescribedTypeFactory;
+import org.apache.qpid.proton.codec2.Encodable;
+import org.apache.qpid.proton.codec2.Encoder;
+
+public final class ErrorCondition implements Encodable
+{
+    public final static long DESCRIPTOR_LONG = 0x000000000000001dL;
+
+    public final static String DESCRIPTOR_STRING = "amqp:error:list";
+
+    private String _condition;
+
+    private String _description;
+
+    private Map<Object, Object> _info;
+
+    public ErrorCondition()
+    {
+    }
+
+    public ErrorCondition(String condition, String description)
+    {
+        _condition = condition;
+        _description = description;
+    }
+
+    public String getCondition()
+    {
+        return _condition;
+    }
+
+    public void setCondition(String condition)
+    {
+        if (condition == null)
+        {
+            throw new NullPointerException("the condition field is mandatory");
+        }
+
+        _condition = condition;
+    }
+
+    public String getDescription()
+    {
+        return _description;
+    }
+
+    public void setDescription(String description)
+    {
+        _description = description;
+    }
+
+    public Map<Object, Object> getInfo()
+    {
+        return _info;
+    }
+
+    public void setInfo(Map<Object, Object> info)
+    {
+        _info = info;
+    }
+
+    public void clear()
+    {
+        _condition = null;
+        _description = null;
+        _info = null;
+    }
+
+    @Override
+    public void encode(Encoder encoder)
+    {
+        encoder.putDescriptor();
+        encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
+        encoder.putSymbol(_condition);
+        encoder.putString(_description);
+        CodecHelper.encodeMap(encoder, _info);
+        encoder.end();
+    }
+
+    public static final class Factory implements DescribedTypeFactory
+    {
+        @SuppressWarnings("unchecked")
+        public Object create(Object in) throws DecodeException
+        {
+            List<Object> l = (List<Object>) in;
+            ErrorCondition error = new ErrorCondition();
+
+            switch (3 - l.size())
+            {
+            case 0:
+                error.setInfo((Map<Object, Object>) l.get(2));
+            case 1:
+                error.setDescription((String) l.get(1));
+            case 2:
+                error.setCondition((String) l.get(0));
+            }
+            return error;
+        }
+    }
+
+    public void copyFrom(ErrorCondition condition)
+    {
+        _condition = condition._condition;
+        _description = condition._description;
+        _info = condition._info;
+    }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o)
+        {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass())
+        {
+            return false;
+        }
+
+        ErrorCondition that = (ErrorCondition) o;
+
+        if (_condition != null ? !_condition.equals(that._condition) : that._condition != null)
+        {
+            return false;
+        }
+        if (_description != null ? !_description.equals(that._description) : that._description != null)
+        {
+            return false;
+        }
+        if (_info != null ? !_info.equals(that._info) : that._info != null)
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int result = _condition != null ? _condition.hashCode() : 0;
+        result = 31 * result + (_description != null ? _description.hashCode() : 0);
+        result = 31 * result + (_info != null ? _info.hashCode() : 0);
+        return result;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Error{" + "condition=" + _condition + ", description='" + _description + '\'' + ", info=" + _info + '}';
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/transport/Flow.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Flow.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Flow.java
index bc5eafb..d228c62 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/transport/Flow.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Flow.java
@@ -19,7 +19,7 @@
  *
  */
 
-package org.apache.qpid.proton.amqp.transport2;
+package org.apache.qpid.proton.transport;
 
 import java.util.List;
 import java.util.Map;
@@ -30,7 +30,7 @@ import org.apache.qpid.proton.codec2.Encodable;
 import org.apache.qpid.proton.codec2.Encoder;
 import org.apache.qpid.proton.codec2.DescribedTypeFactory;
 
-public class Flow implements Encodable
+public final class Flow implements Encodable
 {
     public final static long DESCRIPTOR_LONG = 0x0000000000000013L;
 
@@ -169,15 +169,6 @@ public class Flow implements Encodable
     }
 
     @Override
-    public String toString()
-    {
-        return "Flow{" + "nextIncomingId=" + _nextIncomingId + ", incomingWindow=" + _incomingWindow
-                + ", nextOutgoingId=" + _nextOutgoingId + ", outgoingWindow=" + _outgoingWindow + ", handle=" + _handle
-                + ", deliveryCount=" + _deliveryCount + ", linkCredit=" + _linkCredit + ", available=" + _available
-                + ", drain=" + _drain + ", echo=" + _echo + ", properties=" + _properties + '}';
-    }
-
-    @Override
     public void encode(Encoder encoder)
     {
         encoder.putDescriptor();
@@ -191,23 +182,15 @@ public class Flow implements Encodable
         encoder.putLong(_deliveryCount);
         encoder.putLong(_linkCredit);
         encoder.putLong(_available);
-        if (_drain)
-        {
-            encoder.putBoolean(true);
-        }
-        if (_echo)
-        {
-            encoder.putBoolean(true);
-        }
-        if (_properties != null && _properties.size() > 0)
-        {
-            CodecHelper.encodeMap(encoder, _properties);
-        }
+        encoder.putBoolean(_drain);
+        encoder.putBoolean(_echo);
+        CodecHelper.encodeMap(encoder, _properties);
         encoder.end();
     }
 
     public static final class Factory implements DescribedTypeFactory
     {
+        @SuppressWarnings("unchecked")
         public Object create(Object in) throws DecodeException
         {
             List<Object> l = (List<Object>) in;
@@ -224,24 +207,42 @@ public class Flow implements Encodable
             case 2:
                 flow.setDrain(l.get(8) == null ? false : (Boolean) l.get(8));
             case 3:
-                flow.setAvailable((int) l.get(7));
+                flow.setAvailable((long) l.get(7));
             case 4:
-                flow.setLinkCredit((int) l.get(6));
+                flow.setLinkCredit((long) l.get(6));
             case 5:
-                flow.setDeliveryCount((int) l.get(5));
+                flow.setDeliveryCount((long) l.get(5));
             case 6:
-                flow.setHandle((int) l.get(4));
+                flow.setHandle((long) l.get(4));
             case 7:
-                flow.setOutgoingWindow((int) l.get(3));
+                flow.setOutgoingWindow((long) l.get(3));
             case 8:
-                flow.setNextOutgoingId((int) l.get(2));
+                flow.setNextOutgoingId((long) l.get(2));
             case 9:
-                flow.setIncomingWindow((int) l.get(1));
+                flow.setIncomingWindow((long) l.get(1));
             case 10:
-                flow.setNextIncomingId((int) l.get(0));
+                flow.setNextIncomingId((long) l.get(0));
             }
 
             return flow;
         }
     }
+
+    @Override
+    public String toString()
+    {
+        return "Flow{" +
+               "nextIncomingId=" + _nextIncomingId +
+               ", incomingWindow=" + _incomingWindow +
+               ", nextOutgoingId=" + _nextOutgoingId +
+               ", outgoingWindow=" + _outgoingWindow +
+               ", handle=" + _handle +
+               ", deliveryCount=" + _deliveryCount +
+               ", linkCredit=" + _linkCredit +
+               ", available=" + _available +
+               ", drain=" + _drain +
+               ", echo=" + _echo +
+               ", properties=" + _properties +
+               '}';
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bae93545/proton-j/src/main/java/org/apache/qpid/proton/transport/Open.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Open.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Open.java
index fdb05d4..9db7be1 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/transport/Open.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Open.java
@@ -19,7 +19,7 @@
  *
  */
 
-package org.apache.qpid.proton.amqp.transport2;
+package org.apache.qpid.proton.transport;
 
 import java.util.Arrays;
 import java.util.List;
@@ -30,7 +30,6 @@ import org.apache.qpid.proton.codec2.DecodeException;
 import org.apache.qpid.proton.codec2.DescribedTypeFactory;
 import org.apache.qpid.proton.codec2.Encodable;
 import org.apache.qpid.proton.codec2.Encoder;
-import org.apache.qpid.proton.codec2.Type;
 
 public final class Open implements Encodable
 {
@@ -164,20 +163,6 @@ public final class Open implements Encodable
     }
 
     @Override
-    public String toString()
-    {
-        return "Open{" + " containerId='" + _containerId + '\'' + ", hostname='" + _hostname + '\'' + ", maxFrameSize="
-                + _maxFrameSize + ", channelMax=" + _channelMax + ", idleTimeOut=" + _idleTimeOut
-                + ", outgoingLocales=" + (_outgoingLocales == null ? null : Arrays.asList(_outgoingLocales))
-                + ", incomingLocales=" + (_incomingLocales == null ? null : Arrays.asList(_incomingLocales))
-                + ", offeredCapabilities="
-                + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities))
-                + ", desiredCapabilities="
-                + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) + ", properties="
-                + _properties + '}';
-    }
-
-    @Override
     public void encode(Encoder encoder)
     {
         encoder.putDescriptor();
@@ -188,7 +173,6 @@ public final class Open implements Encodable
         encoder.putUint(_maxFrameSize);
         encoder.putUint(_channelMax);
         encoder.putLong(_idleTimeOut);
-        encoder.putArray(Type.STRING);
         CodecHelper.encodeSymbolArray(encoder, _outgoingLocales);
         CodecHelper.encodeSymbolArray(encoder, _incomingLocales);
         CodecHelper.encodeSymbolArray(encoder, _offeredCapabilities);
@@ -198,6 +182,7 @@ public final class Open implements Encodable
 
     public static final class Factory implements DescribedTypeFactory
     {
+        @SuppressWarnings("unchecked")
         public Object create(Object in) throws DecodeException
         {
             List<Object> l = (List<Object>) in;
@@ -207,7 +192,7 @@ public final class Open implements Encodable
             switch (10 - l.size())
             {
             case 0:
-                open.setProperties((Map) l.get(9));
+                open.setProperties((Map<Object, Object>) l.get(9));
             case 1:
                 Object val1 = l.get(8);
                 if (val1 == null || val1.getClass().isArray())
@@ -263,4 +248,21 @@ public final class Open implements Encodable
             return open;
         }
     }
-}
+
+    @Override
+    public String toString()
+    {
+        return "Open{" +
+               " containerId='" + _containerId + '\'' +
+               ", hostname='" + _hostname + '\'' +
+               ", maxFrameSize=" + _maxFrameSize +
+               ", channelMax=" + _channelMax +
+               ", idleTimeOut=" + _idleTimeOut +
+               ", outgoingLocales=" + (_outgoingLocales == null ? null : Arrays.asList(_outgoingLocales)) +
+               ", incomingLocales=" + (_incomingLocales == null ? null : Arrays.asList(_incomingLocales)) +
+               ", offeredCapabilities=" + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities)) +
+               ", desiredCapabilities=" + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) +
+               ", properties=" + _properties +
+               '}';
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org