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:50 UTC
[17/50] [abbrv] qpid-proton git commit: Added transfer, end,
close and disposition. Minor changes to other performatives.
Added transfer, end, close and disposition.
Minor changes to other performatives.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/2e8ccc97
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2e8ccc97
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2e8ccc97
Branch: refs/heads/rajith-codec
Commit: 2e8ccc97cd5373647d32d62f02a14911d6390bf6
Parents: 0082b9b
Author: Rajith Attapattu <ra...@apache.org>
Authored: Mon Feb 9 11:48:34 2015 -0500
Committer: Rajith Attapattu <ra...@apache.org>
Committed: Thu Jul 9 09:12:38 2015 -0400
----------------------------------------------------------------------
.../org/apache/qpid/proton/transport/Close.java | 9 +-
.../qpid/proton/transport/DeliveryState.java | 35 +++
.../apache/qpid/proton/transport/Detach.java | 9 +-
.../qpid/proton/transport/Disposition.java | 179 +++++++++++++
.../org/apache/qpid/proton/transport/End.java | 88 +++++++
.../apache/qpid/proton/transport/Outcome.java | 4 +-
.../apache/qpid/proton/transport/Source.java | 9 +-
.../apache/qpid/proton/transport/Transfer.java | 251 +++++++++++++++++++
8 files changed, 580 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e8ccc97/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
index 2a07aa0..e9ef2df 100644
--- 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
@@ -52,7 +52,14 @@ public final class Close implements Encodable
encoder.putDescriptor();
encoder.putUlong(DESCRIPTOR_LONG);
encoder.putList();
- _error.encode(encoder);
+ if (_error == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _error.encode(encoder);
+ }
encoder.end();
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e8ccc97/proton-j/src/main/java/org/apache/qpid/proton/transport/DeliveryState.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/DeliveryState.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/DeliveryState.java
new file mode 100644
index 0000000..3345fad
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/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.transport;
+
+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/2e8ccc97/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
index bc83405..c7bdacd 100644
--- 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
@@ -78,7 +78,14 @@ public final class Detach implements Encodable
encoder.putList();
encoder.putUint(_handle);
encoder.putBoolean(_closed);
- _error.encode(encoder);
+ if (_error == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _error.encode(encoder);
+ }
encoder.end();
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e8ccc97/proton-j/src/main/java/org/apache/qpid/proton/transport/Disposition.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Disposition.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Disposition.java
new file mode 100644
index 0000000..1ebe240
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Disposition.java
@@ -0,0 +1,179 @@
+/*
+ *
+ * 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 Disposition implements Encodable
+{
+ public final static long DESCRIPTOR_LONG = 0x0000000000000015L;
+
+ public final static String DESCRIPTOR_STRING = "amqp:disposition:list";
+
+ 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((int) l.get(2));
+ case 4:
+ disposition.setFirst((int) 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/2e8ccc97/proton-j/src/main/java/org/apache/qpid/proton/transport/End.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/End.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/End.java
new file mode 100644
index 0000000..e655f52
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/End.java
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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 End implements Encodable
+{
+ public final static long DESCRIPTOR_LONG = 0x0000000000000017L;
+
+ public final static String DESCRIPTOR_STRING = "amqp:end: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();
+ 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/2e8ccc97/proton-j/src/main/java/org/apache/qpid/proton/transport/Outcome.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Outcome.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Outcome.java
index 880bdbb..ab91972 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/transport/Outcome.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Outcome.java
@@ -1,5 +1,7 @@
package org.apache.qpid.proton.transport;
+import org.apache.qpid.proton.codec2.Encodable;
+
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,6 +23,6 @@ package org.apache.qpid.proton.transport;
*
*/
-public interface Outcome
+public interface Outcome extends Encodable
{
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e8ccc97/proton-j/src/main/java/org/apache/qpid/proton/transport/Source.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/transport/Source.java b/proton-j/src/main/java/org/apache/qpid/proton/transport/Source.java
index bc543d4..3aaa41f 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/transport/Source.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Source.java
@@ -98,7 +98,14 @@ public final class Source extends Terminus implements Encodable
CodecHelper.encodeMap(encoder, _dynamicNodeProperties);
encoder.putSymbol(_distributionMode);
CodecHelper.encodeMap(encoder, _filter);
- // Handle default Outcomde
+ if (_defaultOutcome == null)
+ {
+ encoder.putNull();
+ }
+ else
+ {
+ _defaultOutcome.encode(encoder);
+ }
CodecHelper.encodeSymbolArray(encoder, _outcomes);
CodecHelper.encodeSymbolArray(encoder, _capabilities);
encoder.end();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e8ccc97/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
new file mode 100644
index 0000000..602f650
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/transport/Transfer.java
@@ -0,0 +1,251 @@
+/*
+ *
+ * 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";
+
+ 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()[(int) 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((int) l.get(3));
+ case 8:
+ transfer.setDeliveryTag((byte[]) l.get(2));
+ case 9:
+ transfer.setDeliveryId((int) l.get(1));
+ case 10:
+ transfer.setHandle((int) 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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org