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:08:12 UTC
[39/50] [abbrv] qpid-proton git commit: Adding the suffix '2' to the
new transport package to easily distinguish it from the older code.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport/Transfer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Transfer.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Transfer.java
deleted file mode 100644
index 1723782..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/transport/Transfer.java
+++ /dev/null
@@ -1,253 +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.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 Transfer implements Encodable
-{
- public final static long DESCRIPTOR_LONG = 0x0000000000000014L;
-
- public final static String DESCRIPTOR_STRING = "amqp:transfer:list";
-
- public final static Factory FACTORY = new Factory();
-
- private int _handle;
-
- private int _deliveryId;
-
- private byte[] _deliveryTag;
-
- private int _messageFormat;
-
- private boolean _settled;
-
- private boolean _more;
-
- private ReceiverSettleMode _rcvSettleMode;
-
- private DeliveryState _state;
-
- private boolean _resume;
-
- private boolean _aborted;
-
- private boolean _batchable;
-
- public int getHandle()
- {
- return _handle;
- }
-
- public void setHandle(int handle)
- {
- _handle = handle;
- }
-
- public int getDeliveryId()
- {
- return _deliveryId;
- }
-
- public void setDeliveryId(int deliveryId)
- {
- _deliveryId = deliveryId;
- }
-
- public byte[] getDeliveryTag()
- {
- return _deliveryTag;
- }
-
- public void setDeliveryTag(byte[] deliveryTag)
- {
- _deliveryTag = deliveryTag;
- }
-
- public int getMessageFormat()
- {
- return _messageFormat;
- }
-
- public void setMessageFormat(int messageFormat)
- {
- _messageFormat = messageFormat;
- }
-
- public Boolean getSettled()
- {
- return _settled;
- }
-
- public void setSettled(Boolean settled)
- {
- _settled = settled;
- }
-
- public boolean getMore()
- {
- return _more;
- }
-
- public void setMore(boolean more)
- {
- _more = more;
- }
-
- public ReceiverSettleMode getRcvSettleMode()
- {
- return _rcvSettleMode;
- }
-
- public void setRcvSettleMode(ReceiverSettleMode rcvSettleMode)
- {
- _rcvSettleMode = rcvSettleMode;
- }
-
- public DeliveryState getState()
- {
- return _state;
- }
-
- public void setState(DeliveryState state)
- {
- _state = state;
- }
-
- public boolean getResume()
- {
- return _resume;
- }
-
- public void setResume(boolean resume)
- {
- _resume = resume;
- }
-
- public boolean getAborted()
- {
- return _aborted;
- }
-
- public void setAborted(boolean aborted)
- {
- _aborted = aborted;
- }
-
- public boolean getBatchable()
- {
- return _batchable;
- }
-
- public void setBatchable(boolean batchable)
- {
- _batchable = batchable;
- }
-
- @Override
- public void encode(Encoder encoder)
- {
- encoder.putDescriptor();
- encoder.putUlong(DESCRIPTOR_LONG);
- encoder.putList();
- encoder.putUint(_handle);
- encoder.putUint(_deliveryId);
- encoder.putBinary(_deliveryTag, 0, _deliveryTag.length);
- encoder.putUint(_messageFormat);
- encoder.putBoolean(_settled);
- encoder.putBoolean(_more);
- encoder.putUbyte(_rcvSettleMode.getValue());
- if (_state == null)
- {
- encoder.putNull();
- }
- else
- {
- _state.encode(encoder);
- }
- encoder.putBoolean(_resume);
- encoder.putBoolean(_aborted);
- encoder.putBoolean(_batchable);
- encoder.end();
- }
-
- public static final class Factory implements DescribedTypeFactory
- {
- @SuppressWarnings("unchecked")
- public Object create(Object in) throws DecodeException
- {
- List<Object> l = (List<Object>) in;
- Transfer transfer = new Transfer();
-
- switch (11 - l.size())
- {
- case 0:
- transfer.setBatchable(l.get(10) == null ? false : (Boolean) l.get(10));
- case 1:
- transfer.setAborted(l.get(9) == null ? false : (Boolean) l.get(9));
- case 2:
- transfer.setResume(l.get(8) == null ? false : (Boolean) l.get(8));
- case 3:
- transfer.setState((DeliveryState) l.get(7));
- case 4:
- transfer.setRcvSettleMode(l.get(6) == null ? null : ReceiverSettleMode.values()[(Integer) l.get(6)]);
- case 5:
- transfer.setMore(l.get(5) == null ? false : (Boolean) l.get(5));
- case 6:
- transfer.setSettled((Boolean) l.get(4));
- case 7:
- transfer.setMessageFormat((Integer) l.get(3));
- case 8:
- transfer.setDeliveryTag((byte[]) l.get(2));
- case 9:
- transfer.setDeliveryId((Integer) l.get(1));
- case 10:
- transfer.setHandle((Integer) l.get(0));
- }
-
- return transfer;
- }
- }
-
- @Override
- public String toString()
- {
- return "Transfer{" +
- "handle=" + _handle +
- ", deliveryId=" + _deliveryId +
- ", deliveryTag=" + _deliveryTag +
- ", messageFormat=" + _messageFormat +
- ", settled=" + _settled +
- ", more=" + _more +
- ", rcvSettleMode=" + _rcvSettleMode +
- ", state=" + _state +
- ", resume=" + _resume +
- ", aborted=" + _aborted +
- ", batchable=" + _batchable +
- '}';
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Attach.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Attach.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Attach.java
new file mode 100644
index 0000000..f0d4390
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Attach.java
@@ -0,0 +1,340 @@
+/*
+ *
+ * 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.transport2;
+
+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";
+
+ public final static Factory FACTORY = new Factory();
+
+ 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.putUint(_handle);
+ encoder.putBoolean(_role.getValue());
+ encoder.putUbyte(_sndSettleMode.getValue());
+ encoder.putUbyte(_rcvSettleMode.getValue());
+ if (_source == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _source.encode(encoder);
+ }
+ if (_target == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _target.encode(encoder);
+ }
+ CodecHelper.encodeMap(encoder, _unsettled);
+ encoder.putBoolean(_incompleteUnsettled);
+ encoder.putUint(_initialDeliveryCount);
+ encoder.putUlong(_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((Integer) 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()[(Integer) l.get(4)]);
+ case 10:
+ attach.setSndSettleMode(l.get(3) == null ? SenderSettleMode.MIXED : SenderSettleMode.values()[(Integer) l
+ .get(3)]);
+ case 11:
+ attach.setRole(Boolean.TRUE.equals(l.get(2)) ? Role.RECEIVER : Role.SENDER);
+ case 12:
+ attach.setHandle((Integer) 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/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Begin.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Begin.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Begin.java
new file mode 100644
index 0000000..b5547bb
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Begin.java
@@ -0,0 +1,218 @@
+/*
+ *
+ * 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.transport2;
+
+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";
+
+ public final static Factory FACTORY = new Factory();
+
+ private int _remoteChannel = -1;
+
+ private int _nextOutgoingId;
+
+ private int _incomingWindow;
+
+ private int _outgoingWindow;
+
+ private int _handleMax = 0xffffffff;
+
+ private String[] _offeredCapabilities;
+
+ private String[] _desiredCapabilities;
+
+ private Map<String, Object> _properties;
+
+ public int getRemoteChannel()
+ {
+ return _remoteChannel;
+ }
+
+ public void setRemoteChannel(int remoteChannel)
+ {
+ _remoteChannel = remoteChannel;
+ }
+
+ public long getNextOutgoingId()
+ {
+ return _nextOutgoingId;
+ }
+
+ public void setNextOutgoingId(int nextOutgoingId)
+ {
+ _nextOutgoingId = nextOutgoingId;
+ }
+
+ public int getIncomingWindow()
+ {
+ return _incomingWindow;
+ }
+
+ public void setIncomingWindow(int incomingWindow)
+ {
+ _incomingWindow = incomingWindow;
+ }
+
+ public int getOutgoingWindow()
+ {
+ return _outgoingWindow;
+ }
+
+ public void setOutgoingWindow(int 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<String, Object> getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperties(Map<String, Object> properties)
+ {
+ _properties = properties;
+ }
+
+ @Override
+ public void encode(Encoder encoder)
+ {
+ encoder.putDescriptor();
+ encoder.putUlong(DESCRIPTOR_LONG);
+ encoder.putList();
+ encoder.putUshort(_remoteChannel);
+ encoder.putUint(_nextOutgoingId);
+ encoder.putUint(_incomingWindow);
+ encoder.putUint(_outgoingWindow);
+ encoder.putUint(_handleMax);
+ CodecHelper.encodeSymbolArray(encoder, _offeredCapabilities);
+ CodecHelper.encodeSymbolArray(encoder, _desiredCapabilities);
+ CodecHelper.encodeMapWithKeyAsSymbol(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<String, 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 : (Integer) l.get(4));
+ case 4:
+ begin.setOutgoingWindow((Integer) l.get(3));
+ case 5:
+ begin.setIncomingWindow((Integer) l.get(2));
+ case 6:
+ begin.setNextOutgoingId((Integer) l.get(1));
+ case 7:
+ begin.setRemoteChannel((Integer) 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/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Close.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Close.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Close.java
new file mode 100644
index 0000000..a3318f5
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Close.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.transport2;
+
+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";
+
+ public final static Factory FACTORY = new Factory();
+
+ 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();
+ if (_error == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _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/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/DeliveryState.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/DeliveryState.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/DeliveryState.java
new file mode 100644
index 0000000..ce56451
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/DeliveryState.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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.transport2;
+
+import org.apache.qpid.proton.codec2.Encodable;
+
+/**
+ * Describes the state of a delivery at a link end-point.
+ *
+ * Note that the the sender is the owner of the state. The receiver merely
+ * influences the state. TODO clarify the concept of ownership? how is link
+ * recovery involved?
+ */
+public interface DeliveryState extends Encodable
+{
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Detach.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Detach.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Detach.java
new file mode 100644
index 0000000..310e249
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Detach.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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.transport2;
+
+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";
+
+ public final static Factory FACTORY = new Factory();
+
+ 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.putUint(_handle);
+ encoder.putBoolean(_closed);
+ if (_error == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _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((Integer) 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/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Disposition.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Disposition.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Disposition.java
new file mode 100644
index 0000000..cc1ae97
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Disposition.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.transport2;
+
+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 Disposition implements Encodable
+{
+ public final static long DESCRIPTOR_LONG = 0x0000000000000015L;
+
+ public final static String DESCRIPTOR_STRING = "amqp:disposition:list";
+
+ public final static Factory FACTORY = new Factory();
+
+ private Role _role = Role.SENDER;
+
+ private int _first;
+
+ private int _last;
+
+ private boolean _settled;
+
+ private DeliveryState _state;
+
+ private boolean _batchable;
+
+ public Role getRole()
+ {
+ return _role;
+ }
+
+ public void setRole(Role role)
+ {
+ if (role == null)
+ {
+ throw new NullPointerException("Role cannot be null");
+ }
+ _role = role;
+ }
+
+ public int getFirst()
+ {
+ return _first;
+ }
+
+ public void setFirst(int first)
+ {
+ _first = first;
+ }
+
+ public int getLast()
+ {
+ return _last;
+ }
+
+ public void setLast(int last)
+ {
+ _last = last;
+ }
+
+ public boolean getSettled()
+ {
+ return _settled;
+ }
+
+ public void setSettled(boolean settled)
+ {
+ _settled = settled;
+ }
+
+ public DeliveryState getState()
+ {
+ return _state;
+ }
+
+ public void setState(DeliveryState state)
+ {
+ _state = state;
+ }
+
+ public boolean getBatchable()
+ {
+ return _batchable;
+ }
+
+ public void setBatchable(boolean batchable)
+ {
+ _batchable = batchable;
+ }
+
+ @Override
+ public void encode(Encoder encoder)
+ {
+ encoder.putDescriptor();
+ encoder.putUlong(DESCRIPTOR_LONG);
+ encoder.putList();
+ encoder.putBoolean(_role.getValue());
+ encoder.putUint(_first);
+ encoder.putUint(_last);
+ encoder.putBoolean(_settled);
+ if (_state == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _state.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;
+ Disposition disposition = new Disposition();
+
+ if (l.isEmpty())
+ {
+ throw new DecodeException("The first field cannot be omitted");
+ }
+
+ switch (6 - l.size())
+ {
+
+ case 0:
+ disposition.setBatchable(l.get(5) == null ? false : (Boolean) l.get(5));
+ case 1:
+ disposition.setState((DeliveryState) l.get(4));
+ case 2:
+ disposition.setSettled(l.get(3) == null ? false : (Boolean) l.get(3));
+ case 3:
+ disposition.setLast((Integer) l.get(2));
+ case 4:
+ disposition.setFirst((Integer) l.get(1));
+ case 5:
+ disposition.setRole(Boolean.TRUE.equals(l.get(0)) ? Role.RECEIVER : Role.SENDER);
+ }
+ return disposition;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Disposition{" +
+ "role=" + _role +
+ ", first=" + _first +
+ ", last=" + _last +
+ ", settled=" + _settled +
+ ", state=" + _state +
+ ", batchable=" + _batchable +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/End.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/End.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/End.java
new file mode 100644
index 0000000..d994f24
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/End.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.transport2;
+
+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 End implements Encodable
+{
+ public final static long DESCRIPTOR_LONG = 0x0000000000000017L;
+
+ public final static String DESCRIPTOR_STRING = "amqp:end:list";
+
+ public final static Factory FACTORY = new Factory();
+
+ 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();
+ if (_error == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _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;
+ End end = new End();
+
+ if (!l.isEmpty())
+ {
+ end.setError((ErrorCondition) l.get(0));
+ }
+
+ return end;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "End{" + "error=" + _error + '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/ErrorCondition.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/ErrorCondition.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/ErrorCondition.java
new file mode 100644
index 0000000..6a113d5
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/ErrorCondition.java
@@ -0,0 +1,183 @@
+/*
+ *
+ * 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.transport2;
+
+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";
+
+ public final static Factory FACTORY = new Factory();
+
+ 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/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Flow.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Flow.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Flow.java
new file mode 100644
index 0000000..8ff6034
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Flow.java
@@ -0,0 +1,250 @@
+/*
+ *
+ * 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.transport2;
+
+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 Flow implements Encodable
+{
+ public final static long DESCRIPTOR_LONG = 0x0000000000000013L;
+
+ public final static String DESCRIPTOR_STRING = "amqp:flow:list";
+
+ public final static Factory FACTORY = new Factory();
+
+ private int _nextIncomingId;
+
+ private int _incomingWindow;
+
+ private int _nextOutgoingId;
+
+ private int _outgoingWindow;
+
+ private int _handle;
+
+ private int _deliveryCount;
+
+ private int _linkCredit;
+
+ private int _available;
+
+ private boolean _drain;
+
+ private boolean _echo;
+
+ private Map<Object, Object> _properties;
+
+ public int getNextIncomingId()
+ {
+ return _nextIncomingId;
+ }
+
+ public void setNextIncomingId(int nextIncomingId)
+ {
+ _nextIncomingId = nextIncomingId;
+ }
+
+ public int getIncomingWindow()
+ {
+ return _incomingWindow;
+ }
+
+ public void setIncomingWindow(int incomingWindow)
+ {
+ _incomingWindow = incomingWindow;
+ }
+
+ public int getNextOutgoingId()
+ {
+ return _nextOutgoingId;
+ }
+
+ public void setNextOutgoingId(int nextOutgoingId)
+ {
+ _nextOutgoingId = nextOutgoingId;
+ }
+
+ public int getOutgoingWindow()
+ {
+ return _outgoingWindow;
+ }
+
+ public void setOutgoingWindow(int outgoingWindow)
+ {
+ _outgoingWindow = outgoingWindow;
+ }
+
+ public int getHandle()
+ {
+ return _handle;
+ }
+
+ public void setHandle(int handle)
+ {
+ _handle = handle;
+ }
+
+ public int getDeliveryCount()
+ {
+ return _deliveryCount;
+ }
+
+ public void setDeliveryCount(int deliveryCount)
+ {
+ _deliveryCount = deliveryCount;
+ }
+
+ public int getLinkCredit()
+ {
+ return _linkCredit;
+ }
+
+ public void setLinkCredit(int linkCredit)
+ {
+ _linkCredit = linkCredit;
+ }
+
+ public int getAvailable()
+ {
+ return _available;
+ }
+
+ public void setAvailable(int available)
+ {
+ _available = available;
+ }
+
+ public boolean getDrain()
+ {
+ return _drain;
+ }
+
+ public void setDrain(boolean drain)
+ {
+ _drain = drain;
+ }
+
+ public boolean getEcho()
+ {
+ return _echo;
+ }
+
+ public void setEcho(boolean echo)
+ {
+ _echo = echo;
+ }
+
+ 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.putUint(_nextIncomingId);
+ encoder.putUint(_incomingWindow);
+ encoder.putUint(_nextOutgoingId);
+ encoder.putUint(_outgoingWindow);
+ encoder.putUint(_handle);
+ encoder.putUint(_deliveryCount);
+ encoder.putUint(_linkCredit);
+ encoder.putUint(_available);
+ 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;
+
+ Flow flow = new Flow();
+
+ switch (11 - l.size())
+ {
+
+ case 0:
+ flow.setProperties(((Map<Object, Object>) l.get(10)));
+ case 1:
+ flow.setEcho(l.get(9) == null ? false : (Boolean) l.get(9));
+ case 2:
+ flow.setDrain(l.get(8) == null ? false : (Boolean) l.get(8));
+ case 3:
+ flow.setAvailable((Integer) l.get(7));
+ case 4:
+ flow.setLinkCredit((Integer) l.get(6));
+ case 5:
+ flow.setDeliveryCount((Integer) l.get(5));
+ case 6:
+ flow.setHandle((Integer) l.get(4));
+ case 7:
+ flow.setOutgoingWindow((Integer) l.get(3));
+ case 8:
+ flow.setNextOutgoingId((Integer) l.get(2));
+ case 9:
+ flow.setIncomingWindow((Integer) l.get(1));
+ case 10:
+ flow.setNextIncomingId((Integer) 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/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Open.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Open.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Open.java
new file mode 100644
index 0000000..dfbdba7
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Open.java
@@ -0,0 +1,271 @@
+/*
+ *
+ * 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.transport2;
+
+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 Open implements Encodable
+{
+ public final static long DESCRIPTOR_LONG = 0x0000000000000010L;
+
+ public final static String DESCRIPTOR_STRING = "amqp:open:list";
+
+ public final static Factory FACTORY = new Factory();
+
+ private String _containerId;
+
+ private String _hostname;
+
+ private int _maxFrameSize = 0xffffffff;
+
+ private int _channelMax = 65535;
+
+ private long _idleTimeOut;
+
+ private String[] _outgoingLocales;
+
+ private String[] _incomingLocales;
+
+ private String[] _offeredCapabilities;
+
+ private String[] _desiredCapabilities;
+
+ private Map<String, Object> _properties;
+
+ public String getContainerId()
+ {
+ return _containerId;
+ }
+
+ public void setContainerId(String containerId)
+ {
+ if (containerId == null)
+ {
+ throw new NullPointerException("the container-id field is mandatory");
+ }
+
+ _containerId = containerId;
+ }
+
+ public String getHostname()
+ {
+ return _hostname;
+ }
+
+ public void setHostname(String hostname)
+ {
+ _hostname = hostname;
+ }
+
+ public int getMaxFrameSize()
+ {
+ return _maxFrameSize;
+ }
+
+ public void setMaxFrameSize(int maxFrameSize)
+ {
+ _maxFrameSize = maxFrameSize;
+ }
+
+ public int getChannelMax()
+ {
+ return _channelMax;
+ }
+
+ public void setChannelMax(int channelMax)
+ {
+ _channelMax = channelMax;
+ }
+
+ public long getIdleTimeOut()
+ {
+ return _idleTimeOut;
+ }
+
+ public void setIdleTimeOut(long idleTimeOut)
+ {
+ _idleTimeOut = idleTimeOut;
+ }
+
+ public String[] getOutgoingLocales()
+ {
+ return _outgoingLocales;
+ }
+
+ public void setOutgoingLocales(String... outgoingLocales)
+ {
+ _outgoingLocales = outgoingLocales;
+ }
+
+ public String[] getIncomingLocales()
+ {
+ return _incomingLocales;
+ }
+
+ public void setIncomingLocales(String... incomingLocales)
+ {
+ _incomingLocales = incomingLocales;
+ }
+
+ 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<String, Object> getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperties(Map<String, Object> properties)
+ {
+ _properties = properties;
+ }
+
+ @Override
+ public void encode(Encoder encoder)
+ {
+ encoder.putDescriptor();
+ encoder.putUlong(DESCRIPTOR_LONG);
+ encoder.putList();
+ encoder.putString(_containerId);
+ encoder.putString(_hostname);
+ encoder.putUint(_maxFrameSize);
+ encoder.putUshort(_channelMax);
+ encoder.putLong(_idleTimeOut);
+ CodecHelper.encodeSymbolArray(encoder, _outgoingLocales);
+ CodecHelper.encodeSymbolArray(encoder, _incomingLocales);
+ CodecHelper.encodeSymbolArray(encoder, _offeredCapabilities);
+ CodecHelper.encodeSymbolArray(encoder, _desiredCapabilities);
+ CodecHelper.encodeMapWithKeyAsSymbol(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;
+
+ Open open = new Open();
+
+ switch (10 - l.size())
+ {
+ case 0:
+ open.setProperties((Map<String, Object>) l.get(9));
+ case 1:
+ Object val1 = l.get(8);
+ if (val1 == null || val1.getClass().isArray())
+ {
+ open.setDesiredCapabilities((String[]) val1);
+ }
+ else
+ {
+ open.setDesiredCapabilities((String) val1);
+ }
+ case 2:
+ Object val2 = l.get(7);
+ if (val2 == null || val2.getClass().isArray())
+ {
+ open.setOfferedCapabilities((String[]) val2);
+ }
+ else
+ {
+ open.setOfferedCapabilities((String) val2);
+ }
+ case 3:
+ Object val3 = l.get(6);
+ if (val3 == null || val3.getClass().isArray())
+ {
+ open.setIncomingLocales((String[]) val3);
+ }
+ else
+ {
+ open.setIncomingLocales((String) val3);
+ }
+ case 4:
+ Object val4 = l.get(5);
+ if (val4 == null || val4.getClass().isArray())
+ {
+ open.setOutgoingLocales((String[]) val4);
+ }
+ else
+ {
+ open.setOutgoingLocales((String) val4);
+ }
+ case 5:
+ open.setIdleTimeOut((Long) l.get(4));
+ case 6:
+ open.setChannelMax(l.get(3) == null ? 65535 : (Integer) l.get(3));
+ case 7:
+ open.setMaxFrameSize(l.get(2) == null ? Integer.MAX_VALUE : (Integer) l.get(2));
+ case 8:
+ open.setHostname((String) l.get(1));
+ case 9:
+ open.setContainerId((String) l.get(0));
+ }
+
+ 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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Outcome.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Outcome.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Outcome.java
new file mode 100644
index 0000000..e54a256
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Outcome.java
@@ -0,0 +1,28 @@
+package org.apache.qpid.proton.transport2;
+
+import org.apache.qpid.proton.codec2.Encodable;
+
+/*
+ *
+ * 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.
+ *
+ */
+
+public interface Outcome extends Encodable
+{
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/ReceiverSettleMode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/ReceiverSettleMode.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/ReceiverSettleMode.java
new file mode 100644
index 0000000..5688f11
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/ReceiverSettleMode.java
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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.transport2;
+
+public enum ReceiverSettleMode
+{
+ FIRST, SECOND;
+
+ public byte getValue()
+ {
+ return (byte) ordinal();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Role.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Role.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Role.java
new file mode 100644
index 0000000..ba9a878
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Role.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.transport2;
+
+public enum Role
+{
+ SENDER, RECEIVER;
+
+ public boolean getValue()
+ {
+ return this == RECEIVER;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/SenderSettleMode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/SenderSettleMode.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/SenderSettleMode.java
new file mode 100644
index 0000000..b3fb8f8
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/SenderSettleMode.java
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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.transport2;
+
+public enum SenderSettleMode
+{
+ UNSETTLED, SETTLED, MIXED;
+
+ public byte getValue()
+ {
+ return (byte) ordinal();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Source.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Source.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Source.java
new file mode 100644
index 0000000..84b36c8
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Source.java
@@ -0,0 +1,185 @@
+/*
+ *
+ * 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.transport2;
+
+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;
+import org.apache.qpid.proton.message2.Accepted.Factory;
+
+public final class Source extends Terminus implements Encodable
+{
+ public final static long DESCRIPTOR_LONG = 0x0000000000000028L;
+
+ public final static String DESCRIPTOR_STRING = "amqp:source:list";
+
+ public final static Factory FACTORY = new Factory();
+
+ private String _distributionMode;
+
+ private Map<Object, Object> _filter;
+
+ private Outcome _defaultOutcome;
+
+ private String[] _outcomes;
+
+ public String getDistributionMode()
+ {
+ return _distributionMode;
+ }
+
+ public void setDistributionMode(String distributionMode)
+ {
+ _distributionMode = distributionMode;
+ }
+
+ public Map<Object, Object> getFilter()
+ {
+ return _filter;
+ }
+
+ public void setFilter(Map<Object, Object> filter)
+ {
+ _filter = filter;
+ }
+
+ public Outcome getDefaultOutcome()
+ {
+ return _defaultOutcome;
+ }
+
+ public void setDefaultOutcome(Outcome defaultOutcome)
+ {
+ _defaultOutcome = defaultOutcome;
+ }
+
+ public String[] getOutcomes()
+ {
+ return _outcomes;
+ }
+
+ public void setOutcomes(String... outcomes)
+ {
+ _outcomes = outcomes;
+ }
+
+ @Override
+ public void encode(Encoder encoder)
+ {
+ encoder.putDescriptor();
+ encoder.putUlong(DESCRIPTOR_LONG);
+ encoder.putList();
+ encoder.putString(_address);
+ encoder.putByte(_durable.getValue());
+ encoder.putSymbol(_expiryPolicy.getPolicy());
+ encoder.putLong(_timeout);
+ encoder.putBoolean(_dynamic);
+ CodecHelper.encodeMap(encoder, _dynamicNodeProperties);
+ encoder.putSymbol(_distributionMode);
+ CodecHelper.encodeMap(encoder, _filter);
+ if (_defaultOutcome == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _defaultOutcome.encode(encoder);
+ }
+ CodecHelper.encodeSymbolArray(encoder, _outcomes);
+ CodecHelper.encodeSymbolArray(encoder, _capabilities);
+ encoder.end();
+ }
+
+ public static final class Factory implements DescribedTypeFactory
+ {
+ @SuppressWarnings("unchecked")
+ public Object create(Object in) throws DecodeException
+ {
+ List<Object> l = (List<Object>) in;
+
+ Source source = new Source();
+
+ switch (11 - l.size())
+ {
+
+ case 0:
+ Object val0 = l.get(10);
+ if (val0 == null || val0.getClass().isArray())
+ {
+ source.setCapabilities((String[]) val0);
+ }
+ else
+ {
+ source.setCapabilities((String) val0);
+ }
+ case 1:
+ Object val1 = l.get(9);
+ if (val1 == null || val1.getClass().isArray())
+ {
+ source.setOutcomes((String[]) val1);
+ }
+ else
+ {
+ source.setOutcomes((String) val1);
+ }
+ case 2:
+ source.setDefaultOutcome((Outcome) l.get(8));
+ case 3:
+ source.setFilter((Map<Object, Object>) l.get(7));
+ case 4:
+ source.setDistributionMode((String) l.get(6));
+ case 5:
+ source.setDynamicNodeProperties((Map<Object, Object>) l.get(5));
+ case 6:
+ Boolean dynamic = (Boolean) l.get(4);
+ source.setDynamic(dynamic == null ? false : dynamic);
+ case 7:
+ source.setTimeout(l.get(3) == null ? 0 : (Long) l.get(3));
+ case 8:
+ source.setExpiryPolicy(l.get(2) == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy
+ .getEnum((String) l.get(2)));
+ case 9:
+ source.setDurable(l.get(1) == null ? TerminusDurability.NONE : TerminusDurability.get((Byte) l.get(1)));
+ case 10:
+ source.setAddress((String) l.get(0));
+ }
+
+ return source;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Source{" + "address='" + getAddress() + '\'' + ", durable=" + getDurable() + ", expiryPolicy="
+ + getExpiryPolicy() + ", timeout=" + getTimeout() + ", dynamic=" + getDynamic()
+ + ", dynamicNodeProperties=" + getDynamicNodeProperties() + ", distributionMode=" + _distributionMode
+ + ", filter=" + _filter + ", defaultOutcome=" + _defaultOutcome + ", outcomes="
+ + (_outcomes == null ? null : Arrays.asList(_outcomes)) + ", capabilities="
+ + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) + '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Target.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Target.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Target.java
new file mode 100644
index 0000000..92401dd
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Target.java
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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.transport2;
+
+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;
+import org.apache.qpid.proton.message2.Accepted.Factory;
+
+public final class Target extends Terminus implements Encodable
+{
+ public final static long DESCRIPTOR_LONG = 0x0000000000000029L;
+
+ public final static String DESCRIPTOR_STRING = "amqp:target:list";
+
+ public final static Factory FACTORY = new Factory();
+
+ @Override
+ public void encode(Encoder encoder)
+ {
+ encoder.putDescriptor();
+ encoder.putUlong(DESCRIPTOR_LONG);
+ encoder.putList();
+ encoder.putString(_address);
+ encoder.putByte(_durable.getValue());
+ encoder.putSymbol(_expiryPolicy.getPolicy());
+ encoder.putLong(_timeout);
+ encoder.putBoolean(_dynamic);
+ CodecHelper.encodeMap(encoder, _dynamicNodeProperties);
+ CodecHelper.encodeSymbolArray(encoder, _capabilities);
+ encoder.end();
+ }
+
+ public static final class Factory implements DescribedTypeFactory
+ {
+ @SuppressWarnings("unchecked")
+ public Object create(Object in) throws DecodeException
+ {
+ List<Object> l = (List<Object>) in;
+
+ Target target = new Target();
+
+ switch (7 - l.size())
+ {
+
+ case 0:
+ Object val0 = l.get(6);
+ if (val0 == null || val0.getClass().isArray())
+ {
+ target.setCapabilities((String[]) val0);
+ }
+ else
+ {
+ target.setCapabilities((String) val0);
+ }
+ case 1:
+ target.setDynamicNodeProperties((Map<Object, Object>) l.get(5));
+ case 2:
+ target.setDynamic(l.get(4) == null ? false : (Boolean) l.get(4));
+ case 3:
+ target.setTimeout(l.get(3) == null ? 0 : (Integer) l.get(3));
+ case 4:
+ target.setExpiryPolicy(l.get(2) == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy
+ .getEnum((String) l.get(2)));
+ case 5:
+ target.setDurable(l.get(1) == null ? TerminusDurability.NONE : TerminusDurability.get((Byte) l.get(1)));
+ case 6:
+ target.setAddress((String) l.get(0));
+ }
+ return target;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Target{" +
+ "address='" + getAddress() + '\'' +
+ ", durable=" + getDurable() +
+ ", expiryPolicy=" + getExpiryPolicy() +
+ ", timeout=" + getTimeout() +
+ ", dynamic=" + getDynamic() +
+ ", dynamicNodeProperties=" + getDynamicNodeProperties() +
+ ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/Terminus.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/Terminus.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Terminus.java
new file mode 100644
index 0000000..c1162cc
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/Terminus.java
@@ -0,0 +1,114 @@
+/*
+ *
+ * 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.transport2;
+
+import java.util.Map;
+
+public abstract class Terminus
+{
+ protected String _address;
+
+ protected TerminusDurability _durable = TerminusDurability.NONE;
+
+ protected TerminusExpiryPolicy _expiryPolicy = TerminusExpiryPolicy.SESSION_END;
+
+ protected long _timeout = 0;
+
+ protected boolean _dynamic;
+
+ protected Map<Object, Object> _dynamicNodeProperties;
+
+ protected String[] _capabilities;
+
+ Terminus()
+ {
+ }
+
+ public final String getAddress()
+ {
+ return _address;
+ }
+
+ public final void setAddress(String address)
+ {
+ _address = address;
+ }
+
+ public final TerminusDurability getDurable()
+ {
+ return _durable;
+ }
+
+ public final void setDurable(TerminusDurability durable)
+ {
+ _durable = durable == null ? TerminusDurability.NONE : durable;
+ }
+
+ public final TerminusExpiryPolicy getExpiryPolicy()
+ {
+ return _expiryPolicy;
+ }
+
+ public final void setExpiryPolicy(TerminusExpiryPolicy expiryPolicy)
+ {
+ _expiryPolicy = expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : expiryPolicy;
+ }
+
+ public final long getTimeout()
+ {
+ return _timeout;
+ }
+
+ public final void setTimeout(long timeout)
+ {
+ _timeout = timeout;
+ }
+
+ public final boolean getDynamic()
+ {
+ return _dynamic;
+ }
+
+ public final void setDynamic(boolean dynamic)
+ {
+ _dynamic = dynamic;
+ }
+
+ public final Map<Object, Object> getDynamicNodeProperties()
+ {
+ return _dynamicNodeProperties;
+ }
+
+ public final void setDynamicNodeProperties(Map<Object, Object> dynamicNodeProperties)
+ {
+ _dynamicNodeProperties = dynamicNodeProperties;
+ }
+
+ public final String[] getCapabilities()
+ {
+ return _capabilities;
+ }
+
+ public final void setCapabilities(String... capabilities)
+ {
+ _capabilities = capabilities;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/TerminusDurability.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/TerminusDurability.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/TerminusDurability.java
new file mode 100644
index 0000000..437c73d
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/TerminusDurability.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.transport2;
+
+
+public enum TerminusDurability
+{
+ NONE, CONFIGURATION, UNSETTLED_STATE;
+
+ public byte getValue()
+ {
+ return (byte) ordinal();
+ }
+
+ public static TerminusDurability get(byte value)
+ {
+
+ switch (value)
+ {
+ case 0:
+ return NONE;
+ case 1:
+ return CONFIGURATION;
+ case 2:
+ return UNSETTLED_STATE;
+ }
+ throw new IllegalArgumentException("Unknown TerminusDurablity: " + value);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0654fcc6/proton-j/src/main/java/org/apache/qpid/proton/transport2/TerminusExpiryPolicy.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport2/TerminusExpiryPolicy.java b/proton-j/src/main/java/org/apache/qpid/proton/transport2/TerminusExpiryPolicy.java
new file mode 100644
index 0000000..4b56b6b
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport2/TerminusExpiryPolicy.java
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.transport2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum TerminusExpiryPolicy
+{
+ LINK_DETACH("link-detach"), SESSION_END("session-end"), CONNECTION_CLOSE("connection-close"), NEVER("never");
+
+ private String _policy;
+
+ private static final Map<String, TerminusExpiryPolicy> _map = new HashMap<String, TerminusExpiryPolicy>();
+
+ TerminusExpiryPolicy(String policy)
+ {
+ _policy = policy;
+ }
+
+ public String getPolicy()
+ {
+ return _policy;
+ }
+
+ static
+ {
+ _map.put(LINK_DETACH.getPolicy(), LINK_DETACH);
+ _map.put(SESSION_END.getPolicy(), SESSION_END);
+ _map.put(CONNECTION_CLOSE.getPolicy(), CONNECTION_CLOSE);
+ _map.put(NEVER.getPolicy(), NEVER);
+ }
+
+ public static TerminusExpiryPolicy getEnum(String policy)
+ {
+ TerminusExpiryPolicy expiryPolicy = _map.get(policy);
+ if (expiryPolicy == null)
+ {
+ throw new IllegalArgumentException("Unknown TerminusExpiryPolicy: " + policy);
+ }
+ return expiryPolicy;
+ }
+}
\ 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