You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2013/03/17 19:03:43 UTC

svn commit: r1457505 [11/14] - in /qpid/trunk/qpid/java: amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/ amqp-1-0-client/example/src/main/java/org/apache/qpid/amqp_1_0/client/ amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/...

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java Sun Mar 17 18:03:37 2013
@@ -1,542 +1,542 @@
-/*
- *
- * 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.amqp_1_0.transport;
-
-import org.apache.qpid.amqp_1_0.type.*;
-import org.apache.qpid.amqp_1_0.type.transport.*;
-import org.apache.qpid.amqp_1_0.type.transport.Error;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-public abstract class LinkEndpoint<T extends LinkEventListener>
-{
-
-    private T _linkEventListener;
-    private DeliveryStateHandler _deliveryStateHandler;
-    private Object _flowTransactionId;
-    private SenderSettleMode _sendingSettlementMode;
-    private ReceiverSettleMode _receivingSettlementMode;
-    private Map _initialUnsettledMap;
-    private Map _localUnsettled;
-    private UnsignedInteger _lastSentCreditLimit;
-
-
-    private enum State
-    {
-        DETACHED,
-        ATTACH_SENT,
-        ATTACH_RECVD,
-        ATTACHED,
-        DETACH_SENT,
-        DETACH_RECVD
-    };
-
-    private final String _name;
-
-    private SessionEndpoint _session;
-
-
-    private volatile State _state = State.DETACHED;
-
-    private Source _source;
-    private Target _target;
-    private UnsignedInteger _deliveryCount;
-    private UnsignedInteger _linkCredit;
-    private UnsignedInteger _available;
-    private Boolean _drain;
-    private UnsignedInteger _localHandle;
-    private UnsignedLong _maxMessageSize;
-
-    private Map<Binary,Delivery> _unsettledTransfers = new HashMap<Binary,Delivery>();
-
-    LinkEndpoint(final SessionEndpoint sessionEndpoint, String name, Map<Binary, Outcome> unsettled)
-    {
-        _name = name;
-        _session = sessionEndpoint;
-        _linkCredit = UnsignedInteger.valueOf(0);
-        _drain = Boolean.FALSE;
-        _localUnsettled = unsettled;
-
-    }
-
-    LinkEndpoint(final SessionEndpoint sessionEndpoint,final Attach attach)
-    {
-        _session = sessionEndpoint;
-
-        _name = attach.getName();
-        _initialUnsettledMap = attach.getUnsettled();
-
-        _state = State.ATTACH_RECVD;
-    }
-
-    public String getName()
-    {
-        return _name;
-    }
-
-    public abstract Role getRole();
-
-    public Source getSource()
-    {
-        return _source;
-    }
-
-    public void setSource(final Source source)
-    {
-        _source = source;
-    }
-
-    public Target getTarget()
-    {
-        return _target;
-    }
-
-    public void setTarget(final Target target)
-    {
-        _target = target;
-    }
-
-    public void setDeliveryCount(final UnsignedInteger deliveryCount)
-    {
-        _deliveryCount = deliveryCount;
-    }
-
-    public void setLinkCredit(final UnsignedInteger linkCredit)
-    {
-        _linkCredit = linkCredit;
-    }
-
-    public void setAvailable(final UnsignedInteger available)
-    {
-        _available = available;
-    }
-
-    public void setDrain(final Boolean drain)
-    {
-        _drain = drain;
-    }
-
-    public UnsignedInteger getDeliveryCount()
-    {
-        return _deliveryCount;
-    }
-
-    public UnsignedInteger getAvailable()
-    {
-        return _available;
-    }
-
-    public Boolean getDrain()
-    {
-        return _drain;
-    }
-
-    public UnsignedInteger getLinkCredit()
-    {
-        return _linkCredit;
-    }
-
-    public void remoteDetached(Detach detach)
-    {
-        synchronized (getLock())
-        {
-            switch(_state)
-            {
-                case DETACH_SENT:
-                    _state = State.DETACHED;
-                    break;
-                case ATTACHED:
-                    _state = State.DETACH_RECVD;
-                    _linkEventListener.remoteDetached(this, detach);
-                    break;
-            }
-            getLock().notifyAll();
-        }
-    }
-
-    public void receiveTransfer(final Transfer transfer, final Delivery delivery)
-    {
-        // TODO
-    }
-
-    public void settledByPeer(final Binary deliveryTag)
-    {
-        // TODO
-    }
-
-    public void receiveFlow(final Flow flow)
-    {
-    }
-
-    public void addUnsettled(final Delivery unsettled)
-    {
-        synchronized(getLock())
-        {
-            _unsettledTransfers.put(unsettled.getDeliveryTag(), unsettled);
-            getLock().notifyAll();
-        }
-    }
-
-    public void receiveDeliveryState(final Delivery unsettled,
-                                     final DeliveryState state,
-                                     final Boolean settled)
-    {
-        // TODO
-        synchronized(getLock())
-        {
-            if(_deliveryStateHandler != null)
-            {
-               _deliveryStateHandler.handle(unsettled.getDeliveryTag(), state, settled);
-            }
-
-            if(settled)
-            {
-                settle(unsettled.getDeliveryTag());
-            }
-
-            getLock().notifyAll();
-        }
-
-    }
-
-    public void settle(final Binary deliveryTag)
-    {
-        Delivery delivery = _unsettledTransfers.remove(deliveryTag);
-        if(delivery != null)
-        {
-            getSession().settle(getRole(),delivery.getDeliveryId());
-        }
-
-    }
-
-    public int getUnsettledCount()
-    {
-        synchronized(getLock())
-        {
-            return _unsettledTransfers.size();
-        }
-    }
-
-    public void setLocalHandle(final UnsignedInteger localHandle)
-    {
-        _localHandle = localHandle;
-    }
-
-    public void receiveAttach(final Attach attach)
-    {
-        synchronized(getLock())
-        {
-            switch(_state)
-            {
-                case ATTACH_SENT:
-                {
-
-                    _state = State.ATTACHED;
-                    getLock().notifyAll();
-
-                    _initialUnsettledMap = attach.getUnsettled();
-                    /*  TODO - don't yet handle:
-
-                        attach.getUnsettled();
-                        attach.getProperties();
-                        attach.getDurable();
-                        attach.getExpiryPolicy();
-                        attach.getTimeout();
-                     */
-
-                    break;
-                }
-
-                case DETACHED:
-                {
-                    _state = State.ATTACHED;
-                    getLock().notifyAll();
-                }
-
-
-            }
-
-            if(attach.getRole() == Role.SENDER)
-            {
-                _source = attach.getSource();
-            }
-            else
-            {
-                _target = attach.getTarget();
-            }
-
-            if(getRole() == Role.SENDER)
-            {
-                _maxMessageSize = attach.getMaxMessageSize();
-            }
-
-        }
-    }
-
-    public synchronized boolean isAttached()
-    {
-        return _state == State.ATTACHED;
-    }
-
-    public synchronized boolean isDetached()
-    {
-        return _state == State.DETACHED;
-    }
-
-    public SessionEndpoint getSession()
-    {
-        return _session;
-    }
-
-    public UnsignedInteger getLocalHandle()
-    {
-        return _localHandle;
-    }
-
-    public Object getLock()
-    {
-        return _session.getLock();
-    }
-
-    public void attach()
-    {
-        synchronized(getLock())
-        {
-            Attach attachToSend = new Attach();
-            attachToSend.setName(getName());
-            attachToSend.setRole(getRole());
-            attachToSend.setHandle(getLocalHandle());
-            attachToSend.setSource(getSource());
-            attachToSend.setTarget(getTarget());
-            attachToSend.setSndSettleMode(getSendingSettlementMode());
-            attachToSend.setRcvSettleMode(getReceivingSettlementMode());
-            attachToSend.setUnsettled(_localUnsettled);
-
-            if(getRole() == Role.SENDER)
-            {
-                attachToSend.setInitialDeliveryCount(_deliveryCount);
-            }
-
-            switch(_state)
-            {
-                case DETACHED:
-                    _state = State.ATTACH_SENT;
-                    break;
-                case ATTACH_RECVD:
-                    _state = State.ATTACHED;
-                    break;
-                default:
-                    // TODO ERROR
-            }
-
-            getSession().sendAttach(attachToSend);
-
-            getLock().notifyAll();
-
-        }
-
-    }
-
-
-    public void detach()
-    {
-        detach(null, false);
-    }
-
-    public void close()
-    {
-        detach(null, true);
-    }
-
-    public void close(Error error)
-    {
-        detach(error, true);
-    }
-
-    public void detach(Error error)
-    {
-        detach(error, false);
-    }
-
-    private void detach(Error error, boolean close)
-    {
-        synchronized(getLock())
-        {
-            //TODO
-            switch(_state)
-            {
-                case ATTACHED:
-                    _state = State.DETACH_SENT;
-                    break;
-                case DETACH_RECVD:
-                    _state = State.DETACHED;
-                    break;
-                default:
-                    return;
-            }
-
-            Detach detach = new Detach();
-            detach.setHandle(getLocalHandle());
-            if(close)
-                detach.setClosed(close);
-            detach.setError(error);
-
-            getSession().sendDetach(detach);
-
-            getLock().notifyAll();
-        }
-
-    }
-
-
-
-
-    public void setTransactionId(final Object txnId)
-    {
-        _flowTransactionId = txnId;
-    }
-
-    public void sendFlowConditional()
-    {
-        if(_lastSentCreditLimit != null)
-        {
-            UnsignedInteger clientsCredit = _lastSentCreditLimit.subtract(_deliveryCount);
-            int i = _linkCredit.subtract(clientsCredit).compareTo(clientsCredit);
-            if(i >=0)
-            {
-                sendFlow(_flowTransactionId != null);
-            }
-            else
-            {
-                getSession().sendFlowConditional();
-            }
-        }
-        else
-        {
-            sendFlow(_flowTransactionId != null);
-        }
-    }
-
-
-    public void sendFlow()
-    {
-        sendFlow(_flowTransactionId != null);
-    }
-
-    public void sendFlow(boolean setTransactionId)
-    {
-        if(_state == State.ATTACHED || _state == State.ATTACH_SENT)
-        {
-            Flow flow = new Flow();
-            flow.setLinkCredit(_linkCredit);
-            flow.setDeliveryCount(_deliveryCount);
-            _lastSentCreditLimit = _linkCredit.add(_deliveryCount);
-            flow.setAvailable(_available);
-            flow.setDrain(_drain);
-            if(setTransactionId)
-            {
-                flow.setProperties(Collections.singletonMap(Symbol.valueOf("txn-id"), _flowTransactionId));
-            }
-            flow.setHandle(getLocalHandle());
-            getSession().sendFlow(flow);
-        }
-    }
-
-    public T getLinkEventListener()
-    {
-        return _linkEventListener;
-    }
-
-    public void setLinkEventListener(final T linkEventListener)
-    {
-        synchronized(getLock())
-        {
-            _linkEventListener = linkEventListener;
-        }
-    }
-
-    public DeliveryStateHandler getDeliveryStateHandler()
-    {
-        return _deliveryStateHandler;
-    }
-
-    public void setDeliveryStateHandler(final DeliveryStateHandler deliveryStateHandler)
-    {
-        synchronized(getLock())
-        {
-            _deliveryStateHandler = deliveryStateHandler;
-        }
-    }
-
-    public void setSendingSettlementMode(SenderSettleMode sendingSettlementMode)
-    {
-        _sendingSettlementMode = sendingSettlementMode;
-    }
-
-    public SenderSettleMode getSendingSettlementMode()
-    {
-        return _sendingSettlementMode;
-    }
-
-    public ReceiverSettleMode getReceivingSettlementMode()
-    {
-        return _receivingSettlementMode;
-    }
-
-    public void setReceivingSettlementMode(ReceiverSettleMode receivingSettlementMode)
-    {
-        _receivingSettlementMode = receivingSettlementMode;
-    }
-
-    public Map getInitialUnsettledMap()
-    {
-        return _initialUnsettledMap;
-    }
-
-
-    public abstract void flowStateChanged();
-
-    public void setLocalUnsettled(Map unsettled)
-    {
-        _localUnsettled = unsettled;
-    }
-
-    @Override public String toString()
-    {
-        return "LinkEndpoint{" +
-               "_name='" + _name + '\'' +
-               ", _session=" + _session +
-               ", _state=" + _state +
-               ", _role=" + getRole() +
-               ", _source=" + _source +
-               ", _target=" + _target +
-               ", _transferCount=" + _deliveryCount +
-               ", _linkCredit=" + _linkCredit +
-               ", _available=" + _available +
-               ", _drain=" + _drain +
-               ", _localHandle=" + _localHandle +
-               ", _maxMessageSize=" + _maxMessageSize +
-               '}';
-    }
-}
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class LinkEndpoint<T extends LinkEventListener>
+{
+
+    private T _linkEventListener;
+    private DeliveryStateHandler _deliveryStateHandler;
+    private Object _flowTransactionId;
+    private SenderSettleMode _sendingSettlementMode;
+    private ReceiverSettleMode _receivingSettlementMode;
+    private Map _initialUnsettledMap;
+    private Map _localUnsettled;
+    private UnsignedInteger _lastSentCreditLimit;
+
+
+    private enum State
+    {
+        DETACHED,
+        ATTACH_SENT,
+        ATTACH_RECVD,
+        ATTACHED,
+        DETACH_SENT,
+        DETACH_RECVD
+    };
+
+    private final String _name;
+
+    private SessionEndpoint _session;
+
+
+    private volatile State _state = State.DETACHED;
+
+    private Source _source;
+    private Target _target;
+    private UnsignedInteger _deliveryCount;
+    private UnsignedInteger _linkCredit;
+    private UnsignedInteger _available;
+    private Boolean _drain;
+    private UnsignedInteger _localHandle;
+    private UnsignedLong _maxMessageSize;
+
+    private Map<Binary,Delivery> _unsettledTransfers = new HashMap<Binary,Delivery>();
+
+    LinkEndpoint(final SessionEndpoint sessionEndpoint, String name, Map<Binary, Outcome> unsettled)
+    {
+        _name = name;
+        _session = sessionEndpoint;
+        _linkCredit = UnsignedInteger.valueOf(0);
+        _drain = Boolean.FALSE;
+        _localUnsettled = unsettled;
+
+    }
+
+    LinkEndpoint(final SessionEndpoint sessionEndpoint,final Attach attach)
+    {
+        _session = sessionEndpoint;
+
+        _name = attach.getName();
+        _initialUnsettledMap = attach.getUnsettled();
+
+        _state = State.ATTACH_RECVD;
+    }
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public abstract Role getRole();
+
+    public Source getSource()
+    {
+        return _source;
+    }
+
+    public void setSource(final Source source)
+    {
+        _source = source;
+    }
+
+    public Target getTarget()
+    {
+        return _target;
+    }
+
+    public void setTarget(final Target target)
+    {
+        _target = target;
+    }
+
+    public void setDeliveryCount(final UnsignedInteger deliveryCount)
+    {
+        _deliveryCount = deliveryCount;
+    }
+
+    public void setLinkCredit(final UnsignedInteger linkCredit)
+    {
+        _linkCredit = linkCredit;
+    }
+
+    public void setAvailable(final UnsignedInteger available)
+    {
+        _available = available;
+    }
+
+    public void setDrain(final Boolean drain)
+    {
+        _drain = drain;
+    }
+
+    public UnsignedInteger getDeliveryCount()
+    {
+        return _deliveryCount;
+    }
+
+    public UnsignedInteger getAvailable()
+    {
+        return _available;
+    }
+
+    public Boolean getDrain()
+    {
+        return _drain;
+    }
+
+    public UnsignedInteger getLinkCredit()
+    {
+        return _linkCredit;
+    }
+
+    public void remoteDetached(Detach detach)
+    {
+        synchronized (getLock())
+        {
+            switch(_state)
+            {
+                case DETACH_SENT:
+                    _state = State.DETACHED;
+                    break;
+                case ATTACHED:
+                    _state = State.DETACH_RECVD;
+                    _linkEventListener.remoteDetached(this, detach);
+                    break;
+            }
+            getLock().notifyAll();
+        }
+    }
+
+    public void receiveTransfer(final Transfer transfer, final Delivery delivery)
+    {
+        // TODO
+    }
+
+    public void settledByPeer(final Binary deliveryTag)
+    {
+        // TODO
+    }
+
+    public void receiveFlow(final Flow flow)
+    {
+    }
+
+    public void addUnsettled(final Delivery unsettled)
+    {
+        synchronized(getLock())
+        {
+            _unsettledTransfers.put(unsettled.getDeliveryTag(), unsettled);
+            getLock().notifyAll();
+        }
+    }
+
+    public void receiveDeliveryState(final Delivery unsettled,
+                                     final DeliveryState state,
+                                     final Boolean settled)
+    {
+        // TODO
+        synchronized(getLock())
+        {
+            if(_deliveryStateHandler != null)
+            {
+               _deliveryStateHandler.handle(unsettled.getDeliveryTag(), state, settled);
+            }
+
+            if(settled)
+            {
+                settle(unsettled.getDeliveryTag());
+            }
+
+            getLock().notifyAll();
+        }
+
+    }
+
+    public void settle(final Binary deliveryTag)
+    {
+        Delivery delivery = _unsettledTransfers.remove(deliveryTag);
+        if(delivery != null)
+        {
+            getSession().settle(getRole(),delivery.getDeliveryId());
+        }
+
+    }
+
+    public int getUnsettledCount()
+    {
+        synchronized(getLock())
+        {
+            return _unsettledTransfers.size();
+        }
+    }
+
+    public void setLocalHandle(final UnsignedInteger localHandle)
+    {
+        _localHandle = localHandle;
+    }
+
+    public void receiveAttach(final Attach attach)
+    {
+        synchronized(getLock())
+        {
+            switch(_state)
+            {
+                case ATTACH_SENT:
+                {
+
+                    _state = State.ATTACHED;
+                    getLock().notifyAll();
+
+                    _initialUnsettledMap = attach.getUnsettled();
+                    /*  TODO - don't yet handle:
+
+                        attach.getUnsettled();
+                        attach.getProperties();
+                        attach.getDurable();
+                        attach.getExpiryPolicy();
+                        attach.getTimeout();
+                     */
+
+                    break;
+                }
+
+                case DETACHED:
+                {
+                    _state = State.ATTACHED;
+                    getLock().notifyAll();
+                }
+
+
+            }
+
+            if(attach.getRole() == Role.SENDER)
+            {
+                _source = attach.getSource();
+            }
+            else
+            {
+                _target = attach.getTarget();
+            }
+
+            if(getRole() == Role.SENDER)
+            {
+                _maxMessageSize = attach.getMaxMessageSize();
+            }
+
+        }
+    }
+
+    public synchronized boolean isAttached()
+    {
+        return _state == State.ATTACHED;
+    }
+
+    public synchronized boolean isDetached()
+    {
+        return _state == State.DETACHED || _session.isEnded();
+    }
+
+    public SessionEndpoint getSession()
+    {
+        return _session;
+    }
+
+    public UnsignedInteger getLocalHandle()
+    {
+        return _localHandle;
+    }
+
+    public Object getLock()
+    {
+        return _session.getLock();
+    }
+
+    public void attach()
+    {
+        synchronized(getLock())
+        {
+            Attach attachToSend = new Attach();
+            attachToSend.setName(getName());
+            attachToSend.setRole(getRole());
+            attachToSend.setHandle(getLocalHandle());
+            attachToSend.setSource(getSource());
+            attachToSend.setTarget(getTarget());
+            attachToSend.setSndSettleMode(getSendingSettlementMode());
+            attachToSend.setRcvSettleMode(getReceivingSettlementMode());
+            attachToSend.setUnsettled(_localUnsettled);
+
+            if(getRole() == Role.SENDER)
+            {
+                attachToSend.setInitialDeliveryCount(_deliveryCount);
+            }
+
+            switch(_state)
+            {
+                case DETACHED:
+                    _state = State.ATTACH_SENT;
+                    break;
+                case ATTACH_RECVD:
+                    _state = State.ATTACHED;
+                    break;
+                default:
+                    // TODO ERROR
+            }
+
+            getSession().sendAttach(attachToSend);
+
+            getLock().notifyAll();
+
+        }
+
+    }
+
+
+    public void detach()
+    {
+        detach(null, false);
+    }
+
+    public void close()
+    {
+        detach(null, true);
+    }
+
+    public void close(Error error)
+    {
+        detach(error, true);
+    }
+
+    public void detach(Error error)
+    {
+        detach(error, false);
+    }
+
+    private void detach(Error error, boolean close)
+    {
+        synchronized(getLock())
+        {
+            //TODO
+            switch(_state)
+            {
+                case ATTACHED:
+                    _state = State.DETACH_SENT;
+                    break;
+                case DETACH_RECVD:
+                    _state = State.DETACHED;
+                    break;
+                default:
+                    return;
+            }
+
+            Detach detach = new Detach();
+            detach.setHandle(getLocalHandle());
+            if(close)
+                detach.setClosed(close);
+            detach.setError(error);
+
+            getSession().sendDetach(detach);
+
+            getLock().notifyAll();
+        }
+
+    }
+
+
+
+
+    public void setTransactionId(final Object txnId)
+    {
+        _flowTransactionId = txnId;
+    }
+
+    public void sendFlowConditional()
+    {
+        if(_lastSentCreditLimit != null)
+        {
+            UnsignedInteger clientsCredit = _lastSentCreditLimit.subtract(_deliveryCount);
+            int i = _linkCredit.subtract(clientsCredit).compareTo(clientsCredit);
+            if(i >=0)
+            {
+                sendFlow(_flowTransactionId != null);
+            }
+            else
+            {
+                getSession().sendFlowConditional();
+            }
+        }
+        else
+        {
+            sendFlow(_flowTransactionId != null);
+        }
+    }
+
+
+    public void sendFlow()
+    {
+        sendFlow(_flowTransactionId != null);
+    }
+
+    public void sendFlow(boolean setTransactionId)
+    {
+        if(_state == State.ATTACHED || _state == State.ATTACH_SENT)
+        {
+            Flow flow = new Flow();
+            flow.setLinkCredit(_linkCredit);
+            flow.setDeliveryCount(_deliveryCount);
+            _lastSentCreditLimit = _linkCredit.add(_deliveryCount);
+            flow.setAvailable(_available);
+            flow.setDrain(_drain);
+            if(setTransactionId)
+            {
+                flow.setProperties(Collections.singletonMap(Symbol.valueOf("txn-id"), _flowTransactionId));
+            }
+            flow.setHandle(getLocalHandle());
+            getSession().sendFlow(flow);
+        }
+    }
+
+    public T getLinkEventListener()
+    {
+        return _linkEventListener;
+    }
+
+    public void setLinkEventListener(final T linkEventListener)
+    {
+        synchronized(getLock())
+        {
+            _linkEventListener = linkEventListener;
+        }
+    }
+
+    public DeliveryStateHandler getDeliveryStateHandler()
+    {
+        return _deliveryStateHandler;
+    }
+
+    public void setDeliveryStateHandler(final DeliveryStateHandler deliveryStateHandler)
+    {
+        synchronized(getLock())
+        {
+            _deliveryStateHandler = deliveryStateHandler;
+        }
+    }
+
+    public void setSendingSettlementMode(SenderSettleMode sendingSettlementMode)
+    {
+        _sendingSettlementMode = sendingSettlementMode;
+    }
+
+    public SenderSettleMode getSendingSettlementMode()
+    {
+        return _sendingSettlementMode;
+    }
+
+    public ReceiverSettleMode getReceivingSettlementMode()
+    {
+        return _receivingSettlementMode;
+    }
+
+    public void setReceivingSettlementMode(ReceiverSettleMode receivingSettlementMode)
+    {
+        _receivingSettlementMode = receivingSettlementMode;
+    }
+
+    public Map getInitialUnsettledMap()
+    {
+        return _initialUnsettledMap;
+    }
+
+
+    public abstract void flowStateChanged();
+
+    public void setLocalUnsettled(Map unsettled)
+    {
+        _localUnsettled = unsettled;
+    }
+
+    @Override public String toString()
+    {
+        return "LinkEndpoint{" +
+               "_name='" + _name + '\'' +
+               ", _session=" + _session +
+               ", _state=" + _state +
+               ", _role=" + getRole() +
+               ", _source=" + _source +
+               ", _target=" + _target +
+               ", _transferCount=" + _deliveryCount +
+               ", _linkCredit=" + _linkCredit +
+               ", _available=" + _available +
+               ", _drain=" + _drain +
+               ", _localHandle=" + _localHandle +
+               ", _maxMessageSize=" + _maxMessageSize +
+               '}';
+    }
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEventListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java Sun Mar 17 18:03:37 2013
@@ -1,26 +1,26 @@
-/*
- *
- * 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.amqp_1_0.transport;
-
-public class Node
-{
-    
-}
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public class Node
+{
+    
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ProtocolHeaderTransport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java Sun Mar 17 18:03:37 2013
@@ -1,456 +1,456 @@
-/*
- *
- * 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.amqp_1_0.transport;
-
-import org.apache.qpid.amqp_1_0.type.*;
-import org.apache.qpid.amqp_1_0.type.transaction.TransactionalState;
-import org.apache.qpid.amqp_1_0.type.transport.*;
-
-
-import java.util.*;
-
-public class ReceivingLinkEndpoint extends LinkEndpoint<ReceivingLinkListener>
-{
-
-
-    private UnsignedInteger _lastDeliveryId;
-
-    private static class TransientState
-    {
-
-        UnsignedInteger _deliveryId;
-        int _credit = 1;
-        boolean _settled;
-
-        private TransientState(final UnsignedInteger transferId)
-        {
-            _deliveryId = transferId;
-        }
-
-        void incrementCredit()
-        {
-            _credit++;
-        }
-
-        public int getCredit()
-        {
-            return _credit;
-        }
-
-        public UnsignedInteger getDeliveryId()
-        {
-            return _deliveryId;
-        }
-
-        public boolean isSettled()
-        {
-            return _settled;
-        }
-
-        public void setSettled(boolean settled)
-        {
-            _settled = settled;
-        }
-    }
-
-    private Map<Binary, Object> _unsettledMap = new LinkedHashMap<Binary, Object>();
-    private Map<Binary, TransientState> _unsettledIds = new LinkedHashMap<Binary, TransientState>();
-    private boolean _creditWindow;
-    private boolean _remoteDrain;
-    private UnsignedInteger _remoteTransferCount;
-    private UnsignedInteger _drainLimit;
-
-
-    public ReceivingLinkEndpoint(final SessionEndpoint session, String name)
-    {
-        this(session,name,null);
-    }
-
-    public ReceivingLinkEndpoint(final SessionEndpoint session, String name, Map<Binary, Outcome> unsettledMap)
-    {
-        super(session, name, unsettledMap);
-        setDeliveryCount(UnsignedInteger.valueOf(0));
-        setLinkEventListener(ReceivingLinkListener.DEFAULT);
-    }
-
-    public ReceivingLinkEndpoint(final SessionEndpoint session, final Attach attach)
-    {
-        super(session, attach);
-        setDeliveryCount(attach.getInitialDeliveryCount());
-        setLinkEventListener(ReceivingLinkListener.DEFAULT);
-        setSendingSettlementMode(attach.getSndSettleMode());
-        setReceivingSettlementMode(attach.getRcvSettleMode());
-    }
-
-
-    @Override public Role getRole()
-    {
-        return Role.RECEIVER;
-    }
-
-    @Override
-    public void receiveTransfer(final Transfer transfer, final Delivery delivery)
-    {
-        synchronized (getLock())
-        {
-            TransientState transientState;
-            final Binary deliveryTag = delivery.getDeliveryTag();
-            boolean existingState = _unsettledMap.containsKey(deliveryTag);
-            if(!existingState || transfer.getState() != null)
-            {
-                _unsettledMap.put(deliveryTag, transfer.getState());
-            }
-            if(!existingState)
-            {
-                transientState = new TransientState(transfer.getDeliveryId());
-                if(delivery.isSettled())
-                {
-                    transientState.setSettled(true);
-                }
-                _unsettledIds.put(deliveryTag, transientState);
-                setLinkCredit(getLinkCredit().subtract(UnsignedInteger.ONE));
-                setDeliveryCount(getDeliveryCount().add(UnsignedInteger.ONE));
-
-            }
-            else
-            {
-                transientState = _unsettledIds.get(deliveryTag);
-                transientState.incrementCredit();
-                if(delivery.isSettled())
-                {
-                    transientState.setSettled(true);
-                }
-            }
-
-            if(transientState.isSettled() && delivery.isComplete())
-            {
-                _unsettledMap.remove(deliveryTag);
-            }
-            getLinkEventListener().messageTransfer(transfer);
-
-
-            getLock().notifyAll();
-        }
-    }
-
-    @Override public void receiveFlow(final Flow flow)
-    {
-        synchronized (getLock())
-        {
-            super.receiveFlow(flow);
-            _remoteDrain = Boolean.TRUE.equals((Boolean)flow.getDrain());
-            setAvailable(flow.getAvailable());
-            setDeliveryCount(flow.getDeliveryCount());
-            getLock().notifyAll();
-        }
-    }
-
-
-    public boolean isDrained()
-    {
-        return getDrain() && getDeliveryCount().equals(getDrainLimit());
-    }
-
-    @Override
-    public void settledByPeer(final Binary deliveryTag)
-    {
-        synchronized (getLock())
-        {
-            // TODO XXX : need to do anything about the window here?
-            if(settled(deliveryTag) && _creditWindow)
-            {
-                sendFlowConditional();
-            }
-        }
-    }
-
-    public boolean settled(final Binary deliveryTag)
-    {
-        synchronized(getLock())
-        {
-            boolean deleted;
-            if(deleted = (_unsettledIds.remove(deliveryTag) != null))
-            {
-                _unsettledMap.remove(deliveryTag);
-
-                getLock().notifyAll();
-            }
-
-            return deleted;
-        }
-    }
-
-    public void updateDisposition(final Binary deliveryTag, DeliveryState state, boolean settled)
-    {
-        synchronized(getLock())
-        {
-            if(_unsettledMap.containsKey(deliveryTag))
-            {
-                boolean outcomeUpdate = false;
-                Outcome outcome=null;
-                if(state instanceof Outcome)
-                {
-                    outcome = (Outcome)state;
-                }
-                else if(state instanceof TransactionalState)
-                {
-                    // TODO? Is this correct
-                    outcome = ((TransactionalState)state).getOutcome();
-                }
-
-                if(outcome != null)
-                {
-                    Object oldOutcome = _unsettledMap.put(deliveryTag, outcome);
-                    outcomeUpdate = !outcome.equals(oldOutcome);
-                }
-
-
-
-
-                TransientState transientState = _unsettledIds.get(deliveryTag);
-                if(outcomeUpdate || settled)
-                {
-
-                    final UnsignedInteger transferId = transientState.getDeliveryId();
-
-                    getSession().updateDisposition(getRole(), transferId, transferId, state, settled);
-                }
-
-
-                if(settled)
-                {
-
-                    if(settled(deliveryTag))
-                    {
-                        if(!isDetached() && _creditWindow)
-                        {
-                            setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
-                            sendFlowConditional();
-                        }
-                        else
-                        {
-                            getSession().sendFlowConditional();
-                        }
-                    }
-                }
-                getLock().notifyAll();
-            }
-            else
-            {
-                TransientState transientState = _unsettledIds.get(deliveryTag);
-                if(_creditWindow)
-                {
-                    setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
-                    sendFlowConditional();
-                }
-
-            }
-        }
-
-    }
-
-
-    public void setCreditWindow()
-    {
-        setCreditWindow(true);
-    }
-    public void setCreditWindow(boolean window)
-    {
-
-        _creditWindow = window;
-        sendFlowConditional();
-
-    }
-
-    public void drain()
-    {
-        synchronized (getLock())
-        {
-            setDrain(true);
-            _creditWindow = false;
-            _drainLimit = getDeliveryCount().add(getLinkCredit());
-            sendFlow();
-            getLock().notifyAll();
-        }
-    }
-
-    @Override
-    public void receiveDeliveryState(final Delivery unsettled, final DeliveryState state, final Boolean settled)
-    {
-        super.receiveDeliveryState(unsettled, state, settled);
-        if(_creditWindow)
-        {
-            if(Boolean.TRUE.equals(settled))
-            {
-                setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
-                sendFlowConditional();
-            }
-        }
-    }
-
-    public void requestTransactionalSend(Object txnId)
-    {
-        synchronized (getLock())
-        {
-            setDrain(true);
-            _creditWindow = false;
-            setTransactionId(txnId);
-            sendFlow();
-            getLock().notifyAll();
-        }
-    }
-
-    private void sendFlow(final Object transactionId)
-    {
-        sendFlow();
-    }
-
-
-    public void clearDrain()
-    {
-        synchronized (getLock())
-        {
-            setDrain(false);
-            sendFlow();
-            getLock().notifyAll();
-        }
-    }
-
-    public void updateAllDisposition(Binary deliveryTag, DeliveryState deliveryState, boolean settled)
-    {
-        synchronized(getLock())
-        {
-            if(!_unsettledIds.isEmpty())
-            {
-                Binary firstTag = _unsettledIds.keySet().iterator().next();
-                Binary lastTag = deliveryTag;
-                updateDispositions(firstTag, lastTag, deliveryState, settled);
-            }
-        }
-    }
-
-    private void updateDispositions(Binary firstTag, Binary lastTag, DeliveryState state, boolean settled)
-    {
-        SortedMap<UnsignedInteger, UnsignedInteger> ranges = new TreeMap<UnsignedInteger,UnsignedInteger>();
-
-        synchronized(getLock())
-        {
-
-            Iterator<Binary> iter = _unsettledIds.keySet().iterator();
-            List<Binary> tagsToUpdate = new ArrayList<Binary>();
-            Binary tag = null;
-
-            while(iter.hasNext() && !(tag = iter.next()).equals(firstTag));
-
-            if(firstTag.equals(tag))
-            {
-                tagsToUpdate.add(tag);
-
-                UnsignedInteger deliveryId = _unsettledIds.get(firstTag).getDeliveryId();
-
-                UnsignedInteger first = deliveryId;
-                UnsignedInteger last = first;
-
-                while(iter.hasNext())
-                {
-                    tag = iter.next();
-                    tagsToUpdate.add(tag);
-
-                    deliveryId = _unsettledIds.get(tag).getDeliveryId();
-
-                    if(deliveryId.equals(last.add(UnsignedInteger.ONE)))
-                    {
-                        last = deliveryId;
-                    }
-                    else
-                    {
-                        ranges.put(first,last);
-                        first = last = deliveryId;
-                    }
-
-                    if(tag.equals(lastTag))
-                    {
-                        break;
-                    }
-                }
-
-                ranges.put(first,last);
-            }
-
-            if(settled)
-            {
-
-                for(Binary deliveryTag : tagsToUpdate)
-                {
-                    if(settled(deliveryTag) && _creditWindow)
-                    {
-                        setLinkCredit(getLinkCredit().add(UnsignedInteger.valueOf(1)));
-                    }
-                }
-                sendFlowConditional();
-            }
-
-
-
-            for(Map.Entry<UnsignedInteger,UnsignedInteger> range : ranges.entrySet())
-            {
-                getSession().updateDisposition(getRole(), range.getKey(), range.getValue(), state, settled);
-            }
-
-
-            getLock().notifyAll();
-        }
-
-    }
-
-    @Override
-    public void settle(Binary deliveryTag)
-    {
-        super.settle(deliveryTag);
-        if(_creditWindow)
-        {
-             sendFlowConditional();
-        }
-
-    }
-
-    public void flowStateChanged()
-    {
-    }
-
-    public UnsignedInteger getDrainLimit()
-    {
-        return _drainLimit;
-    }
-
-    UnsignedInteger getLastDeliveryId()
-    {
-        return _lastDeliveryId;
-    }
-
-    void setLastDeliveryId(UnsignedInteger lastDeliveryId)
-    {
-        _lastDeliveryId = lastDeliveryId;
-    }
-
-
-}
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transaction.TransactionalState;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+
+
+import java.util.*;
+
+public class ReceivingLinkEndpoint extends LinkEndpoint<ReceivingLinkListener>
+{
+
+
+    private UnsignedInteger _lastDeliveryId;
+
+    private static class TransientState
+    {
+
+        UnsignedInteger _deliveryId;
+        int _credit = 1;
+        boolean _settled;
+
+        private TransientState(final UnsignedInteger transferId)
+        {
+            _deliveryId = transferId;
+        }
+
+        void incrementCredit()
+        {
+            _credit++;
+        }
+
+        public int getCredit()
+        {
+            return _credit;
+        }
+
+        public UnsignedInteger getDeliveryId()
+        {
+            return _deliveryId;
+        }
+
+        public boolean isSettled()
+        {
+            return _settled;
+        }
+
+        public void setSettled(boolean settled)
+        {
+            _settled = settled;
+        }
+    }
+
+    private Map<Binary, Object> _unsettledMap = new LinkedHashMap<Binary, Object>();
+    private Map<Binary, TransientState> _unsettledIds = new LinkedHashMap<Binary, TransientState>();
+    private boolean _creditWindow;
+    private boolean _remoteDrain;
+    private UnsignedInteger _remoteTransferCount;
+    private UnsignedInteger _drainLimit;
+
+
+    public ReceivingLinkEndpoint(final SessionEndpoint session, String name)
+    {
+        this(session,name,null);
+    }
+
+    public ReceivingLinkEndpoint(final SessionEndpoint session, String name, Map<Binary, Outcome> unsettledMap)
+    {
+        super(session, name, unsettledMap);
+        setDeliveryCount(UnsignedInteger.valueOf(0));
+        setLinkEventListener(ReceivingLinkListener.DEFAULT);
+    }
+
+    public ReceivingLinkEndpoint(final SessionEndpoint session, final Attach attach)
+    {
+        super(session, attach);
+        setDeliveryCount(attach.getInitialDeliveryCount());
+        setLinkEventListener(ReceivingLinkListener.DEFAULT);
+        setSendingSettlementMode(attach.getSndSettleMode());
+        setReceivingSettlementMode(attach.getRcvSettleMode());
+    }
+
+
+    @Override public Role getRole()
+    {
+        return Role.RECEIVER;
+    }
+
+    @Override
+    public void receiveTransfer(final Transfer transfer, final Delivery delivery)
+    {
+        synchronized (getLock())
+        {
+            TransientState transientState;
+            final Binary deliveryTag = delivery.getDeliveryTag();
+            boolean existingState = _unsettledMap.containsKey(deliveryTag);
+            if(!existingState || transfer.getState() != null)
+            {
+                _unsettledMap.put(deliveryTag, transfer.getState());
+            }
+            if(!existingState)
+            {
+                transientState = new TransientState(transfer.getDeliveryId());
+                if(delivery.isSettled())
+                {
+                    transientState.setSettled(true);
+                }
+                _unsettledIds.put(deliveryTag, transientState);
+                setLinkCredit(getLinkCredit().subtract(UnsignedInteger.ONE));
+                setDeliveryCount(getDeliveryCount().add(UnsignedInteger.ONE));
+
+            }
+            else
+            {
+                transientState = _unsettledIds.get(deliveryTag);
+                transientState.incrementCredit();
+                if(delivery.isSettled())
+                {
+                    transientState.setSettled(true);
+                }
+            }
+
+            if(transientState.isSettled() && delivery.isComplete())
+            {
+                _unsettledMap.remove(deliveryTag);
+            }
+            getLinkEventListener().messageTransfer(transfer);
+
+
+            getLock().notifyAll();
+        }
+    }
+
+    @Override public void receiveFlow(final Flow flow)
+    {
+        synchronized (getLock())
+        {
+            super.receiveFlow(flow);
+            _remoteDrain = Boolean.TRUE.equals((Boolean)flow.getDrain());
+            setAvailable(flow.getAvailable());
+            setDeliveryCount(flow.getDeliveryCount());
+            getLock().notifyAll();
+        }
+    }
+
+
+    public boolean isDrained()
+    {
+        return getDrain() && getDeliveryCount().equals(getDrainLimit());
+    }
+
+    @Override
+    public void settledByPeer(final Binary deliveryTag)
+    {
+        synchronized (getLock())
+        {
+            // TODO XXX : need to do anything about the window here?
+            if(settled(deliveryTag) && _creditWindow)
+            {
+                sendFlowConditional();
+            }
+        }
+    }
+
+    public boolean settled(final Binary deliveryTag)
+    {
+        synchronized(getLock())
+        {
+            boolean deleted;
+            if(deleted = (_unsettledIds.remove(deliveryTag) != null))
+            {
+                _unsettledMap.remove(deliveryTag);
+
+                getLock().notifyAll();
+            }
+
+            return deleted;
+        }
+    }
+
+    public void updateDisposition(final Binary deliveryTag, DeliveryState state, boolean settled)
+    {
+        synchronized(getLock())
+        {
+            if(_unsettledMap.containsKey(deliveryTag))
+            {
+                boolean outcomeUpdate = false;
+                Outcome outcome=null;
+                if(state instanceof Outcome)
+                {
+                    outcome = (Outcome)state;
+                }
+                else if(state instanceof TransactionalState)
+                {
+                    // TODO? Is this correct
+                    outcome = ((TransactionalState)state).getOutcome();
+                }
+
+                if(outcome != null)
+                {
+                    Object oldOutcome = _unsettledMap.put(deliveryTag, outcome);
+                    outcomeUpdate = !outcome.equals(oldOutcome);
+                }
+
+
+
+
+                TransientState transientState = _unsettledIds.get(deliveryTag);
+                if(outcomeUpdate || settled)
+                {
+
+                    final UnsignedInteger transferId = transientState.getDeliveryId();
+
+                    getSession().updateDisposition(getRole(), transferId, transferId, state, settled);
+                }
+
+
+                if(settled)
+                {
+
+                    if(settled(deliveryTag))
+                    {
+                        if(!isDetached() && _creditWindow)
+                        {
+                            setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
+                            sendFlowConditional();
+                        }
+                        else
+                        {
+                            getSession().sendFlowConditional();
+                        }
+                    }
+                }
+                getLock().notifyAll();
+            }
+            else
+            {
+                TransientState transientState = _unsettledIds.get(deliveryTag);
+                if(_creditWindow)
+                {
+                    setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
+                    sendFlowConditional();
+                }
+
+            }
+        }
+
+    }
+
+
+    public void setCreditWindow()
+    {
+        setCreditWindow(true);
+    }
+    public void setCreditWindow(boolean window)
+    {
+
+        _creditWindow = window;
+        sendFlowConditional();
+
+    }
+
+    public void drain()
+    {
+        synchronized (getLock())
+        {
+            setDrain(true);
+            _creditWindow = false;
+            _drainLimit = getDeliveryCount().add(getLinkCredit());
+            sendFlow();
+            getLock().notifyAll();
+        }
+    }
+
+    @Override
+    public void receiveDeliveryState(final Delivery unsettled, final DeliveryState state, final Boolean settled)
+    {
+        super.receiveDeliveryState(unsettled, state, settled);
+        if(_creditWindow)
+        {
+            if(Boolean.TRUE.equals(settled))
+            {
+                setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
+                sendFlowConditional();
+            }
+        }
+    }
+
+    public void requestTransactionalSend(Object txnId)
+    {
+        synchronized (getLock())
+        {
+            setDrain(true);
+            _creditWindow = false;
+            setTransactionId(txnId);
+            sendFlow();
+            getLock().notifyAll();
+        }
+    }
+
+    private void sendFlow(final Object transactionId)
+    {
+        sendFlow();
+    }
+
+
+    public void clearDrain()
+    {
+        synchronized (getLock())
+        {
+            setDrain(false);
+            sendFlow();
+            getLock().notifyAll();
+        }
+    }
+
+    public void updateAllDisposition(Binary deliveryTag, DeliveryState deliveryState, boolean settled)
+    {
+        synchronized(getLock())
+        {
+            if(!_unsettledIds.isEmpty())
+            {
+                Binary firstTag = _unsettledIds.keySet().iterator().next();
+                Binary lastTag = deliveryTag;
+                updateDispositions(firstTag, lastTag, deliveryState, settled);
+            }
+        }
+    }
+
+    private void updateDispositions(Binary firstTag, Binary lastTag, DeliveryState state, boolean settled)
+    {
+        SortedMap<UnsignedInteger, UnsignedInteger> ranges = new TreeMap<UnsignedInteger,UnsignedInteger>();
+
+        synchronized(getLock())
+        {
+
+            Iterator<Binary> iter = _unsettledIds.keySet().iterator();
+            List<Binary> tagsToUpdate = new ArrayList<Binary>();
+            Binary tag = null;
+
+            while(iter.hasNext() && !(tag = iter.next()).equals(firstTag));
+
+            if(firstTag.equals(tag))
+            {
+                tagsToUpdate.add(tag);
+
+                UnsignedInteger deliveryId = _unsettledIds.get(firstTag).getDeliveryId();
+
+                UnsignedInteger first = deliveryId;
+                UnsignedInteger last = first;
+
+                while(iter.hasNext())
+                {
+                    tag = iter.next();
+                    tagsToUpdate.add(tag);
+
+                    deliveryId = _unsettledIds.get(tag).getDeliveryId();
+
+                    if(deliveryId.equals(last.add(UnsignedInteger.ONE)))
+                    {
+                        last = deliveryId;
+                    }
+                    else
+                    {
+                        ranges.put(first,last);
+                        first = last = deliveryId;
+                    }
+
+                    if(tag.equals(lastTag))
+                    {
+                        break;
+                    }
+                }
+
+                ranges.put(first,last);
+            }
+
+            if(settled)
+            {
+
+                for(Binary deliveryTag : tagsToUpdate)
+                {
+                    if(settled(deliveryTag) && _creditWindow)
+                    {
+                        setLinkCredit(getLinkCredit().add(UnsignedInteger.valueOf(1)));
+                    }
+                }
+                sendFlowConditional();
+            }
+
+
+
+            for(Map.Entry<UnsignedInteger,UnsignedInteger> range : ranges.entrySet())
+            {
+                getSession().updateDisposition(getRole(), range.getKey(), range.getValue(), state, settled);
+            }
+
+
+            getLock().notifyAll();
+        }
+
+    }
+
+    @Override
+    public void settle(Binary deliveryTag)
+    {
+        super.settle(deliveryTag);
+        if(_creditWindow)
+        {
+             sendFlowConditional();
+        }
+
+    }
+
+    public void flowStateChanged()
+    {
+    }
+
+    public UnsignedInteger getDrainLimit()
+    {
+        return _drainLimit;
+    }
+
+    UnsignedInteger getLastDeliveryId()
+    {
+        return _lastDeliveryId;
+    }
+
+    void setLastDeliveryId(UnsignedInteger lastDeliveryId)
+    {
+        _lastDeliveryId = lastDeliveryId;
+    }
+
+
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java Sun Mar 17 18:03:37 2013
@@ -1,26 +1,26 @@
-/*
- *
- * 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.amqp_1_0.transport;
-
-public class ReceivingSessionHalfEndpoint extends SessionHalfEndpoint
-{
-}
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public class ReceivingSessionHalfEndpoint extends SessionHalfEndpoint
+{
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java Sun Mar 17 18:03:37 2013
@@ -1,291 +1,291 @@
-/*
- * 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.amqp_1_0.transport;
-
-import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
-import org.apache.qpid.amqp_1_0.codec.ValueWriter;
-import org.apache.qpid.amqp_1_0.type.Binary;
-import org.apache.qpid.amqp_1_0.type.SaslFrameBody;
-import org.apache.qpid.amqp_1_0.type.Symbol;
-import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
-import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
-import org.apache.qpid.amqp_1_0.type.security.SaslChallenge;
-import org.apache.qpid.amqp_1_0.type.security.SaslInit;
-import org.apache.qpid.amqp_1_0.type.security.SaslMechanisms;
-import org.apache.qpid.amqp_1_0.type.security.SaslOutcome;
-import org.apache.qpid.amqp_1_0.type.security.SaslResponse;
-
-
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
-import java.io.PrintWriter;
-import java.util.Arrays;
-
-
-public class SASLEndpointImpl
-        implements DescribedTypeConstructorRegistry.Source, ValueWriter.Registry.Source, SASLEndpoint
-{
-    private static final short SASL_CONTROL_CHANNEL = (short) 0;
-
-    private static final byte[] EMPTY_CHALLENGE = new byte[0];
-
-    private FrameTransport _transport;
-
-
-    private static enum State
-    {
-        BEGIN_SERVER,
-        BEGIN_CLIENT,
-        SENT_MECHANISMS,
-        SENT_INIT,
-        SENT_REPSONSE,
-        SENT_CHALLENGE,
-        SENT_OUTCOME
-    };
-
-
-    public PrintWriter _out;
-
-
-    private State _state;
-
-    private SaslClient _saslClient;
-    private SaslServer _saslServer;
-
-    private boolean _isReadable;
-    private boolean _isWritable;
-    private boolean _closedForInput;
-    private boolean _closedForOutput;
-
-    private AMQPDescribedTypeRegistry _describedTypeRegistry = AMQPDescribedTypeRegistry.newInstance().registerSecurityLayer();
-
-    private FrameOutputHandler _frameOutputHandler;
-
-    private byte _majorVersion;
-    private byte _minorVersion;
-    private byte _revision;
-    private UnsignedInteger _handleMax = UnsignedInteger.MAX_VALUE;
-    private ConnectionEventListener _connectionEventListener = ConnectionEventListener.DEFAULT;
-    private Symbol[] _mechanisms;
-    private Symbol _mechanism;
-
-
-    private SASLEndpointImpl(FrameTransport transport, State initialState, Symbol... mechanisms)
-    {
-        _transport = transport;
-        _state = initialState;
-        _mechanisms = mechanisms;
-    }
-
-
-    public void setFrameOutputHandler(final FrameOutputHandler frameOutputHandler)
-    {
-        _frameOutputHandler = frameOutputHandler;
-        if(_state == State.BEGIN_SERVER)
-        {
-            sendMechanisms();
-        }
-    }
-
-    private synchronized void sendMechanisms()
-    {
-        SaslMechanisms saslMechanisms = new SaslMechanisms();
-
-        saslMechanisms.setSaslServerMechanisms(_mechanisms);
-
-        _state = State.SENT_MECHANISMS;
-
-        send(saslMechanisms);
-    }
-
-    public boolean isReadable()
-    {
-        return _isReadable;
-    }
-
-    public boolean isWritable()
-    {
-        return _isWritable;
-    }
-
-
-    public synchronized void send(SaslFrameBody body)
-    {
-        if(!_closedForOutput)
-        {
-            if(_out != null)
-            {
-                _out.println("SEND : " + body);
-                _out.flush();
-            }
-            //_frameOutputHandler.send(new SASLFrame(body));
-        }
-    }
-
-
-
-    public void invalidHeaderReceived()
-    {
-        // TODO
-        _closedForInput = true;
-    }
-
-    public synchronized boolean closedForInput()
-    {
-        return _closedForInput;
-    }
-
-    public synchronized void protocolHeaderReceived(final byte major, final byte minorVersion, final byte revision)
-    {
-        _majorVersion = major;
-        _minorVersion = minorVersion;
-        _revision = revision;
-    }
-
-
-    public synchronized void receive(final short channel, final Object frame)
-    {
-        if(_out != null)
-        {
-            _out.println( "RECV["+channel+"] : " + frame);
-            _out.flush();
-        }
-        if(frame instanceof SaslFrameBody)
-        {
-            ((SaslFrameBody)frame).invoke(this);
-        }
-        else
-        {
-            // TODO
-        }
-    }
-
-    public AMQPDescribedTypeRegistry getDescribedTypeRegistry()
-    {
-        return _describedTypeRegistry;
-    }
-
-    public synchronized void setClosedForOutput(boolean b)
-    {
-        _closedForOutput = true;
-        notifyAll();
-    }
-
-    public synchronized boolean closedForOutput()
-    {
-        return _closedForOutput;
-    }
-
-
-    public Object getLock()
-    {
-        return this;
-    }
-
-
-    public byte getMajorVersion()
-    {
-        return _majorVersion;
-    }
-
-
-    public byte getMinorVersion()
-    {
-        return _minorVersion;
-    }
-
-    public byte getRevision()
-    {
-        return _revision;
-    }
-
-
-    public void receiveSaslInit(final SaslInit saslInit)
-    {
-        _mechanism = saslInit.getMechanism();
-        try
-        {
-            _saslServer = Sasl.createSaslServer(_mechanism.toString(), "AMQP", "localhost", null,  createServerCallbackHandler(_mechanism));
-        }
-        catch (SaslException e)
-        {
-            e.printStackTrace();  //TODO
-        }
-    }
-
-    private CallbackHandler createServerCallbackHandler(final Symbol mechanism)
-    {
-        return null;  //TODO
-    }
-
-    public synchronized void receiveSaslMechanisms(final SaslMechanisms saslMechanisms)
-    {
-        Symbol[] serverMechanisms = saslMechanisms.getSaslServerMechanisms();
-        for(Symbol mechanism : _mechanisms)
-        {
-            if(Arrays.asList(serverMechanisms).contains(mechanism))
-            {
-                _mechanism = mechanism;
-                break;
-            }
-        }
-        // TODO - no matching mechanism
-        try
-        {
-            _saslClient = Sasl.createSaslClient(new String[] { _mechanism.toString() }, null, "AMQP", "localhost", null,
-                                createClientCallbackHandler(_mechanism));
-            SaslInit init = new SaslInit();
-            init.setMechanism(_mechanism);
-            init.setInitialResponse(_saslClient.hasInitialResponse() ? new Binary(_saslClient.evaluateChallenge(EMPTY_CHALLENGE)) : null);
-            send(init);
-        }
-        catch (SaslException e)
-        {
-            e.printStackTrace();  //TODO
-        }
-    }
-
-    private CallbackHandler createClientCallbackHandler(final Symbol mechanism)
-    {
-        return null;  //TODO
-    }
-
-    public void receiveSaslChallenge(final SaslChallenge saslChallenge)
-    {
-        //TODO
-    }
-
-    public void receiveSaslResponse(final SaslResponse saslResponse)
-    {
-        //TODO
-    }
-
-
-    public void receiveSaslOutcome(final SaslOutcome saslOutcome)
-    {
-        //TODO
-    }
-
-
-
-}
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.SaslFrameBody;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
+import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
+import org.apache.qpid.amqp_1_0.type.security.SaslChallenge;
+import org.apache.qpid.amqp_1_0.type.security.SaslInit;
+import org.apache.qpid.amqp_1_0.type.security.SaslMechanisms;
+import org.apache.qpid.amqp_1_0.type.security.SaslOutcome;
+import org.apache.qpid.amqp_1_0.type.security.SaslResponse;
+
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import java.io.PrintWriter;
+import java.util.Arrays;
+
+
+public class SASLEndpointImpl
+        implements DescribedTypeConstructorRegistry.Source, ValueWriter.Registry.Source, SASLEndpoint
+{
+    private static final short SASL_CONTROL_CHANNEL = (short) 0;
+
+    private static final byte[] EMPTY_CHALLENGE = new byte[0];
+
+    private FrameTransport _transport;
+
+
+    private static enum State
+    {
+        BEGIN_SERVER,
+        BEGIN_CLIENT,
+        SENT_MECHANISMS,
+        SENT_INIT,
+        SENT_REPSONSE,
+        SENT_CHALLENGE,
+        SENT_OUTCOME
+    };
+
+
+    public PrintWriter _out;
+
+
+    private State _state;
+
+    private SaslClient _saslClient;
+    private SaslServer _saslServer;
+
+    private boolean _isReadable;
+    private boolean _isWritable;
+    private boolean _closedForInput;
+    private boolean _closedForOutput;
+
+    private AMQPDescribedTypeRegistry _describedTypeRegistry = AMQPDescribedTypeRegistry.newInstance().registerSecurityLayer();
+
+    private FrameOutputHandler _frameOutputHandler;
+
+    private byte _majorVersion;
+    private byte _minorVersion;
+    private byte _revision;
+    private UnsignedInteger _handleMax = UnsignedInteger.MAX_VALUE;
+    private ConnectionEventListener _connectionEventListener = ConnectionEventListener.DEFAULT;
+    private Symbol[] _mechanisms;
+    private Symbol _mechanism;
+
+
+    private SASLEndpointImpl(FrameTransport transport, State initialState, Symbol... mechanisms)
+    {
+        _transport = transport;
+        _state = initialState;
+        _mechanisms = mechanisms;
+    }
+
+
+    public void setFrameOutputHandler(final FrameOutputHandler frameOutputHandler)
+    {
+        _frameOutputHandler = frameOutputHandler;
+        if(_state == State.BEGIN_SERVER)
+        {
+            sendMechanisms();
+        }
+    }
+
+    private synchronized void sendMechanisms()
+    {
+        SaslMechanisms saslMechanisms = new SaslMechanisms();
+
+        saslMechanisms.setSaslServerMechanisms(_mechanisms);
+
+        _state = State.SENT_MECHANISMS;
+
+        send(saslMechanisms);
+    }
+
+    public boolean isReadable()
+    {
+        return _isReadable;
+    }
+
+    public boolean isWritable()
+    {
+        return _isWritable;
+    }
+
+
+    public synchronized void send(SaslFrameBody body)
+    {
+        if(!_closedForOutput)
+        {
+            if(_out != null)
+            {
+                _out.println("SEND : " + body);
+                _out.flush();
+            }
+            //_frameOutputHandler.send(new SASLFrame(body));
+        }
+    }
+
+
+
+    public void invalidHeaderReceived()
+    {
+        // TODO
+        _closedForInput = true;
+    }
+
+    public synchronized boolean closedForInput()
+    {
+        return _closedForInput;
+    }
+
+    public synchronized void protocolHeaderReceived(final byte major, final byte minorVersion, final byte revision)
+    {
+        _majorVersion = major;
+        _minorVersion = minorVersion;
+        _revision = revision;
+    }
+
+
+    public synchronized void receive(final short channel, final Object frame)
+    {
+        if(_out != null)
+        {
+            _out.println( "RECV["+channel+"] : " + frame);
+            _out.flush();
+        }
+        if(frame instanceof SaslFrameBody)
+        {
+            ((SaslFrameBody)frame).invoke(this);
+        }
+        else
+        {
+            // TODO
+        }
+    }
+
+    public AMQPDescribedTypeRegistry getDescribedTypeRegistry()
+    {
+        return _describedTypeRegistry;
+    }
+
+    public synchronized void setClosedForOutput(boolean b)
+    {
+        _closedForOutput = true;
+        notifyAll();
+    }
+
+    public synchronized boolean closedForOutput()
+    {
+        return _closedForOutput;
+    }
+
+
+    public Object getLock()
+    {
+        return this;
+    }
+
+
+    public byte getMajorVersion()
+    {
+        return _majorVersion;
+    }
+
+
+    public byte getMinorVersion()
+    {
+        return _minorVersion;
+    }
+
+    public byte getRevision()
+    {
+        return _revision;
+    }
+
+
+    public void receiveSaslInit(final SaslInit saslInit)
+    {
+        _mechanism = saslInit.getMechanism();
+        try
+        {
+            _saslServer = Sasl.createSaslServer(_mechanism.toString(), "AMQP", "localhost", null,  createServerCallbackHandler(_mechanism));
+        }
+        catch (SaslException e)
+        {
+            e.printStackTrace();  //TODO
+        }
+    }
+
+    private CallbackHandler createServerCallbackHandler(final Symbol mechanism)
+    {
+        return null;  //TODO
+    }
+
+    public synchronized void receiveSaslMechanisms(final SaslMechanisms saslMechanisms)
+    {
+        Symbol[] serverMechanisms = saslMechanisms.getSaslServerMechanisms();
+        for(Symbol mechanism : _mechanisms)
+        {
+            if(Arrays.asList(serverMechanisms).contains(mechanism))
+            {
+                _mechanism = mechanism;
+                break;
+            }
+        }
+        // TODO - no matching mechanism
+        try
+        {
+            _saslClient = Sasl.createSaslClient(new String[] { _mechanism.toString() }, null, "AMQP", "localhost", null,
+                                createClientCallbackHandler(_mechanism));
+            SaslInit init = new SaslInit();
+            init.setMechanism(_mechanism);
+            init.setInitialResponse(_saslClient.hasInitialResponse() ? new Binary(_saslClient.evaluateChallenge(EMPTY_CHALLENGE)) : null);
+            send(init);
+        }
+        catch (SaslException e)
+        {
+            e.printStackTrace();  //TODO
+        }
+    }
+
+    private CallbackHandler createClientCallbackHandler(final Symbol mechanism)
+    {
+        return null;  //TODO
+    }
+
+    public void receiveSaslChallenge(final SaslChallenge saslChallenge)
+    {
+        //TODO
+    }
+
+    public void receiveSaslResponse(final SaslResponse saslResponse)
+    {
+        //TODO
+    }
+
+
+    public void receiveSaslOutcome(final SaslOutcome saslOutcome)
+    {
+        //TODO
+    }
+
+
+
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLFrameTransport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLTransport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SaslServerProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native



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