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 2012/03/10 10:48:56 UTC
svn commit: r1299173 [7/10] - in /qpid/proton/proton-j: ./ codec/ codec/src/
codec/src/org/ codec/src/org/apache/ codec/src/org/apache/qpid/
codec/src/org/apache/qpid/proton/ codec/src/org/apache/qpid/proton/codec/
codec/src/org/apache/qpid/proton/fram...
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Flow.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Flow.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Flow.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Flow.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,349 @@
+
+/*
+*
+* 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.type.transport;
+import java.util.Map;
+import java.util.List;
+import java.util.AbstractList;
+
+
+import org.apache.qpid.proton.codec.DecodeException;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DescribedTypeConstructor;
+import org.apache.qpid.proton.type.*;
+
+
+public class Flow
+ implements DescribedType , FrameBody
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000013L), Symbol.valueOf("amqp:flow:list"),
+ };
+
+ private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000013L);
+ private final FlowWrapper _wrapper = new FlowWrapper();
+
+ private UnsignedInteger _nextIncomingId;
+ private UnsignedInteger _incomingWindow;
+ private UnsignedInteger _nextOutgoingId;
+ private UnsignedInteger _outgoingWindow;
+ private UnsignedInteger _handle;
+ private UnsignedInteger _deliveryCount;
+ private UnsignedInteger _linkCredit;
+ private UnsignedInteger _available;
+ private boolean _drain;
+ private boolean _echo;
+ private Map _properties;
+
+ public UnsignedInteger getNextIncomingId()
+ {
+ return _nextIncomingId;
+ }
+
+ public void setNextIncomingId(UnsignedInteger nextIncomingId)
+ {
+ _nextIncomingId = nextIncomingId;
+ }
+
+ public UnsignedInteger getIncomingWindow()
+ {
+ return _incomingWindow;
+ }
+
+ public void setIncomingWindow(UnsignedInteger incomingWindow)
+ {
+ if( incomingWindow == null )
+ {
+ throw new NullPointerException("the incoming-window field is mandatory");
+ }
+
+ _incomingWindow = incomingWindow;
+ }
+
+ public UnsignedInteger getNextOutgoingId()
+ {
+ return _nextOutgoingId;
+ }
+
+ public void setNextOutgoingId(UnsignedInteger nextOutgoingId)
+ {
+ if( nextOutgoingId == null )
+ {
+ throw new NullPointerException("the next-outgoing-id field is mandatory");
+ }
+
+ _nextOutgoingId = nextOutgoingId;
+ }
+
+ public UnsignedInteger getOutgoingWindow()
+ {
+ return _outgoingWindow;
+ }
+
+ public void setOutgoingWindow(UnsignedInteger outgoingWindow)
+ {
+ if( outgoingWindow == null )
+ {
+ throw new NullPointerException("the outgoing-window field is mandatory");
+ }
+
+ _outgoingWindow = outgoingWindow;
+ }
+
+ public UnsignedInteger getHandle()
+ {
+ return _handle;
+ }
+
+ public void setHandle(UnsignedInteger handle)
+ {
+ _handle = handle;
+ }
+
+ public UnsignedInteger getDeliveryCount()
+ {
+ return _deliveryCount;
+ }
+
+ public void setDeliveryCount(UnsignedInteger deliveryCount)
+ {
+ _deliveryCount = deliveryCount;
+ }
+
+ public UnsignedInteger getLinkCredit()
+ {
+ return _linkCredit;
+ }
+
+ public void setLinkCredit(UnsignedInteger linkCredit)
+ {
+ _linkCredit = linkCredit;
+ }
+
+ public UnsignedInteger getAvailable()
+ {
+ return _available;
+ }
+
+ public void setAvailable(UnsignedInteger available)
+ {
+ _available = available;
+ }
+
+ public boolean getDrain()
+ {
+ return _drain;
+ }
+
+ public void setDrain(boolean drain)
+ {
+ _drain = drain;
+ }
+
+ public boolean getEcho()
+ {
+ return _echo;
+ }
+
+ public void setEcho(boolean echo)
+ {
+ _echo = echo;
+ }
+
+ public Map getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperties(Map properties)
+ {
+ _properties = properties;
+ }
+
+ public Object getDescriptor()
+ {
+ return DESCRIPTOR;
+ }
+
+ public Object getDescribed()
+ {
+ return _wrapper;
+ }
+
+ public Object get(final int index)
+ {
+
+ switch(index)
+ {
+ case 0:
+ return _nextIncomingId;
+ case 1:
+ return _incomingWindow;
+ case 2:
+ return _nextOutgoingId;
+ case 3:
+ return _outgoingWindow;
+ case 4:
+ return _handle;
+ case 5:
+ return _deliveryCount;
+ case 6:
+ return _linkCredit;
+ case 7:
+ return _available;
+ case 8:
+ return _drain;
+ case 9:
+ return _echo;
+ case 10:
+ return _properties;
+ }
+
+ throw new IllegalStateException("Unknown index " + index);
+
+ }
+
+ public int size()
+ {
+ return _properties != null
+ ? 11
+ : (_echo != false)
+ ? 10
+ : (_drain != false)
+ ? 9
+ : _available != null
+ ? 8
+ : _linkCredit != null
+ ? 7
+ : _deliveryCount != null
+ ? 6
+ : _handle != null
+ ? 5
+ : 4;
+
+ }
+
+
+ public final class FlowWrapper extends AbstractList
+ {
+
+ @Override
+ public Object get(final int index)
+ {
+ return Flow.this.get(index);
+ }
+
+ @Override
+ public int size()
+ {
+ return Flow.this.size();
+ }
+ }
+
+ private static class FlowConstructor implements DescribedTypeConstructor<Flow>
+ {
+ public Flow newInstance(Object described)
+ {
+ List l = (List) described;
+
+ Flow o = new Flow();
+
+ if(l.size() <= 3)
+ {
+ throw new DecodeException("The outgoing-window field cannot be omitted");
+ }
+
+ switch(11 - l.size())
+ {
+
+ case 0:
+ o.setProperties( (Map) l.get( 10 ) );
+ case 1:
+ Boolean echo = (Boolean) l.get(9);
+ o.setEcho(echo == null ? false : echo);
+ case 2:
+ Boolean drain = (Boolean) l.get(8);
+ o.setDrain(drain == null ? false : drain );
+ case 3:
+ o.setAvailable( (UnsignedInteger) l.get( 7 ) );
+ case 4:
+ o.setLinkCredit( (UnsignedInteger) l.get( 6 ) );
+ case 5:
+ o.setDeliveryCount( (UnsignedInteger) l.get( 5 ) );
+ case 6:
+ o.setHandle( (UnsignedInteger) l.get( 4 ) );
+ case 7:
+ o.setOutgoingWindow( (UnsignedInteger) l.get( 3 ) );
+ case 8:
+ o.setNextOutgoingId( (UnsignedInteger) l.get( 2 ) );
+ case 9:
+ o.setIncomingWindow( (UnsignedInteger) l.get( 1 ) );
+ case 10:
+ o.setNextIncomingId( (UnsignedInteger) l.get( 0 ) );
+ }
+
+
+ return o;
+ }
+
+ public Class<Flow> getTypeClass()
+ {
+ return Flow.class;
+ }
+ }
+
+ public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
+ {
+ handler.handleFlow(this, payload, context);
+ }
+
+
+ public static void register(Decoder decoder)
+ {
+ FlowConstructor constructor = new FlowConstructor();
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, constructor);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Flow{" +
+ "nextIncomingId=" + _nextIncomingId +
+ ", incomingWindow=" + _incomingWindow +
+ ", nextOutgoingId=" + _nextOutgoingId +
+ ", outgoingWindow=" + _outgoingWindow +
+ ", handle=" + _handle +
+ ", deliveryCount=" + _deliveryCount +
+ ", linkCredit=" + _linkCredit +
+ ", available=" + _available +
+ ", drain=" + _drain +
+ ", echo=" + _echo +
+ ", properties=" + _properties +
+ '}';
+ }
+}
+
\ No newline at end of file
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/FrameBody.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/FrameBody.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/FrameBody.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/FrameBody.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,22 @@
+package org.apache.qpid.proton.type.transport;
+
+import org.apache.qpid.proton.type.Binary;
+
+public interface FrameBody
+{
+ interface FrameBodyHandler<E>
+ {
+ void handleOpen(Open open, Binary payload, E context);
+ void handleBegin(Begin begin, Binary payload, E context);
+ void handleAttach(Attach attach, Binary payload, E context);
+ void handleFlow(Flow flow, Binary payload, E context);
+ void handleTransfer(Transfer transfer, Binary payload, E context);
+ void handleDisposition(Disposition disposition, Binary payload, E context);
+ void handleDetach(Detach detach, Binary payload, E context);
+ void handleEnd(End end, Binary payload, E context);
+ void handleClose(Close close, Binary payload, E context);
+
+ }
+
+ <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context);
+}
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/LinkError.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/LinkError.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/LinkError.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/LinkError.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,40 @@
+
+/*
+*
+* 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.type.transport;
+
+import org.apache.qpid.proton.type.*;
+
+public interface LinkError
+{
+ final static Symbol DETACH_FORCED = Symbol.valueOf("amqp:link:detach-forced");
+
+ final static Symbol TRANSFER_LIMIT_EXCEEDED = Symbol.valueOf("amqp:link:transfer-limit-exceeded");
+
+ final static Symbol MESSAGE_SIZE_EXCEEDED = Symbol.valueOf("amqp:link:message-size-exceeded");
+
+ final static Symbol REDIRECT = Symbol.valueOf("amqp:link:redirect");
+
+ final static Symbol STOLEN = Symbol.valueOf("amqp:link:stolen");
+
+}
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Open.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Open.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Open.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Open.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,365 @@
+
+/*
+*
+* 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.type.transport;
+
+import org.apache.qpid.proton.codec.DecodeException;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DescribedTypeConstructor;
+import org.apache.qpid.proton.type.Binary;
+import org.apache.qpid.proton.type.DescribedType;
+import org.apache.qpid.proton.type.Symbol;
+import org.apache.qpid.proton.type.UnsignedInteger;
+import org.apache.qpid.proton.type.UnsignedLong;
+import org.apache.qpid.proton.type.UnsignedShort;
+
+import java.util.AbstractList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+
+public class Open
+ implements DescribedType , FrameBody
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000010L), Symbol.valueOf("amqp:open:list"),
+ };
+
+ private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000010L);
+ private final OpenWrapper _wrapper = new OpenWrapper();
+
+ private String _containerId;
+ private String _hostname;
+ private UnsignedInteger _maxFrameSize = UnsignedInteger.valueOf(0xffffffff);
+ private UnsignedShort _channelMax = UnsignedShort.valueOf((short) 65535);
+ private UnsignedInteger _idleTimeOut;
+ private Symbol[] _outgoingLocales;
+ private Symbol[] _incomingLocales;
+ private Symbol[] _offeredCapabilities;
+ private Symbol[] _desiredCapabilities;
+ private Map _properties;
+
+ public String getContainerId()
+ {
+ return _containerId;
+ }
+
+ public void setContainerId(String containerId)
+ {
+ if( containerId == null )
+ {
+ throw new NullPointerException("the container-id field is mandatory");
+ }
+
+ _containerId = containerId;
+ }
+
+ public String getHostname()
+ {
+ return _hostname;
+ }
+
+ public void setHostname(String hostname)
+ {
+ _hostname = hostname;
+ }
+
+ public UnsignedInteger getMaxFrameSize()
+ {
+ return _maxFrameSize;
+ }
+
+ public void setMaxFrameSize(UnsignedInteger maxFrameSize)
+ {
+ _maxFrameSize = maxFrameSize;
+ }
+
+ public UnsignedShort getChannelMax()
+ {
+ return _channelMax;
+ }
+
+ public void setChannelMax(UnsignedShort channelMax)
+ {
+ _channelMax = channelMax;
+ }
+
+ public UnsignedInteger getIdleTimeOut()
+ {
+ return _idleTimeOut;
+ }
+
+ public void setIdleTimeOut(UnsignedInteger idleTimeOut)
+ {
+ _idleTimeOut = idleTimeOut;
+ }
+
+ public Symbol[] getOutgoingLocales()
+ {
+ return _outgoingLocales;
+ }
+
+ public void setOutgoingLocales(Symbol... outgoingLocales)
+ {
+ _outgoingLocales = outgoingLocales;
+ }
+
+ public Symbol[] getIncomingLocales()
+ {
+ return _incomingLocales;
+ }
+
+ public void setIncomingLocales(Symbol... incomingLocales)
+ {
+ _incomingLocales = incomingLocales;
+ }
+
+ public Symbol[] getOfferedCapabilities()
+ {
+ return _offeredCapabilities;
+ }
+
+ public void setOfferedCapabilities(Symbol... offeredCapabilities)
+ {
+ _offeredCapabilities = offeredCapabilities;
+ }
+
+ public Symbol[] getDesiredCapabilities()
+ {
+ return _desiredCapabilities;
+ }
+
+ public void setDesiredCapabilities(Symbol... desiredCapabilities)
+ {
+ _desiredCapabilities = desiredCapabilities;
+ }
+
+ public Map getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperties(Map properties)
+ {
+ _properties = properties;
+ }
+
+ public Object getDescriptor()
+ {
+ return DESCRIPTOR;
+ }
+
+ public Object getDescribed()
+ {
+ return _wrapper;
+ }
+
+ public Object get(final int index)
+ {
+
+ switch(index)
+ {
+ case 0:
+ return _containerId;
+ case 1:
+ return _hostname;
+ case 2:
+ return _maxFrameSize;
+ case 3:
+ return _channelMax;
+ case 4:
+ return _idleTimeOut;
+ case 5:
+ return _outgoingLocales;
+ case 6:
+ return _incomingLocales;
+ case 7:
+ return _offeredCapabilities;
+ case 8:
+ return _desiredCapabilities;
+ case 9:
+ return _properties;
+ }
+
+ throw new IllegalStateException("Unknown index " + index);
+
+ }
+
+ public int size()
+ {
+ return _properties != null
+ ? 10
+ : _desiredCapabilities != null
+ ? 9
+ : _offeredCapabilities != null
+ ? 8
+ : _incomingLocales != null
+ ? 7
+ : _outgoingLocales != null
+ ? 6
+ : _idleTimeOut != null
+ ? 5
+ : (_channelMax != null && !_channelMax.equals(UnsignedShort.MAX_VALUE))
+ ? 4
+ : (_maxFrameSize != null && !_maxFrameSize.equals(UnsignedInteger.MAX_VALUE))
+ ? 3
+ : _hostname != null
+ ? 2
+ : 1;
+
+ }
+
+
+ public final class OpenWrapper extends AbstractList
+ {
+
+ @Override
+ public Object get(final int index)
+ {
+ return Open.this.get(index);
+ }
+
+ @Override
+ public int size()
+ {
+ return Open.this.size();
+ }
+ }
+
+ private static class OpenConstructor implements DescribedTypeConstructor<Open>
+ {
+ public Open newInstance(Object described)
+ {
+ List l = (List) described;
+
+ Open o = new Open();
+
+ if(l.size() <= 0)
+ {
+ throw new DecodeException("The container-id field cannot be omitted");
+ }
+
+ switch(10 - l.size())
+ {
+
+ case 0:
+ o.setProperties( (Map) l.get( 9 ) );
+ case 1:
+ Object val1 = l.get( 8 );
+ if( val1 == null || val1.getClass().isArray() )
+ {
+ o.setDesiredCapabilities( (Symbol[]) val1 );
+ }
+ else
+ {
+ o.setDesiredCapabilities( (Symbol) val1 );
+ }
+ case 2:
+ Object val2 = l.get( 7 );
+ if( val2 == null || val2.getClass().isArray() )
+ {
+ o.setOfferedCapabilities( (Symbol[]) val2 );
+ }
+ else
+ {
+ o.setOfferedCapabilities( (Symbol) val2 );
+ }
+ case 3:
+ Object val3 = l.get( 6 );
+ if( val3 == null || val3.getClass().isArray() )
+ {
+ o.setIncomingLocales( (Symbol[]) val3 );
+ }
+ else
+ {
+ o.setIncomingLocales( (Symbol) val3 );
+ }
+ case 4:
+ Object val4 = l.get( 5 );
+ if( val4 == null || val4.getClass().isArray() )
+ {
+ o.setOutgoingLocales( (Symbol[]) val4 );
+ }
+ else
+ {
+ o.setOutgoingLocales( (Symbol) val4 );
+ }
+ case 5:
+ o.setIdleTimeOut( (UnsignedInteger) l.get( 4 ) );
+ case 6:
+ UnsignedShort channelMax = (UnsignedShort) l.get(3);
+ o.setChannelMax(channelMax == null ? UnsignedShort.MAX_VALUE : channelMax);
+ case 7:
+ UnsignedInteger maxFrameSize = (UnsignedInteger) l.get(2);
+ o.setMaxFrameSize(maxFrameSize == null ? UnsignedInteger.MAX_VALUE : maxFrameSize);
+ case 8:
+ o.setHostname( (String) l.get( 1 ) );
+ case 9:
+ o.setContainerId( (String) l.get( 0 ) );
+ }
+
+
+ return o;
+ }
+
+ public Class<Open> getTypeClass()
+ {
+ return Open.class;
+ }
+ }
+
+ public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
+ {
+ handler.handleOpen(this, payload, context);
+ }
+
+
+ public static void register(Decoder decoder)
+ {
+ OpenConstructor constructor = new OpenConstructor();
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, constructor);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Open{" +
+ " containerId='" + _containerId + '\'' +
+ ", hostname='" + _hostname + '\'' +
+ ", maxFrameSize=" + _maxFrameSize +
+ ", channelMax=" + _channelMax +
+ ", idleTimeOut=" + _idleTimeOut +
+ ", outgoingLocales=" + (_outgoingLocales == null ? null : Arrays.asList(_outgoingLocales)) +
+ ", incomingLocales=" + (_incomingLocales == null ? null : Arrays.asList(_incomingLocales)) +
+ ", offeredCapabilities=" + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities)) +
+ ", desiredCapabilities=" + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) +
+ ", properties=" + _properties +
+ '}';
+ }
+}
+
\ No newline at end of file
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/ReceiverSettleMode.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/ReceiverSettleMode.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/ReceiverSettleMode.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/ReceiverSettleMode.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,34 @@
+
+/*
+*
+* 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.type.transport;
+
+import org.apache.qpid.proton.type.*;
+
+public interface ReceiverSettleMode
+{
+ final static UnsignedByte FIRST = UnsignedByte.valueOf((byte) 0);
+
+ final static UnsignedByte SECOND = UnsignedByte.valueOf((byte) 1);
+
+}
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Role.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Role.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Role.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Role.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,32 @@
+
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+
+package org.apache.qpid.proton.type.transport;
+
+public interface Role
+{
+ final static boolean SENDER = false;
+
+ final static boolean RECEIVER = true;
+
+}
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/SenderSettleMode.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/SenderSettleMode.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/SenderSettleMode.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/SenderSettleMode.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,36 @@
+
+/*
+*
+* 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.type.transport;
+
+import org.apache.qpid.proton.type.*;
+
+public interface SenderSettleMode
+{
+ final static UnsignedByte UNSETTLED = UnsignedByte.valueOf((byte) 0);
+
+ final static UnsignedByte SETTLED = UnsignedByte.valueOf((byte) 1);
+
+ final static UnsignedByte MIXED = UnsignedByte.valueOf((byte) 2);
+
+}
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/SessionError.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/SessionError.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/SessionError.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/SessionError.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,38 @@
+
+/*
+*
+* 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.type.transport;
+
+import org.apache.qpid.proton.type.*;
+
+public interface SessionError
+{
+ final static Symbol WINDOW_VIOLATION = Symbol.valueOf("amqp:session:window-violation");
+
+ final static Symbol ERRANT_LINK = Symbol.valueOf("amqp:session:errant-link");
+
+ final static Symbol HANDLE_IN_USE = Symbol.valueOf("amqp:session:handle-in-use");
+
+ final static Symbol UNATTACHED_HANDLE = Symbol.valueOf("amqp:session:unattached-handle");
+
+}
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Source.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Source.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Source.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Source.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,5 @@
+package org.apache.qpid.proton.type.transport;
+
+public interface Source
+{
+}
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Target.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Target.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Target.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Target.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,5 @@
+package org.apache.qpid.proton.type.transport;
+
+public interface Target
+{
+}
Added: qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Transfer.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Transfer.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Transfer.java (added)
+++ qpid/proton/proton-j/codec/src/org/apache/qpid/proton/type/transport/Transfer.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,346 @@
+
+/*
+*
+* 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.type.transport;
+import java.util.List;
+import java.util.AbstractList;
+
+
+import org.apache.qpid.proton.codec.DecodeException;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DescribedTypeConstructor;
+import org.apache.qpid.proton.type.*;
+
+
+public class Transfer
+ implements DescribedType , FrameBody
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000014L), Symbol.valueOf("amqp:transfer:list"),
+ };
+
+ private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000014L);
+ private final TransferWrapper _wrapper = new TransferWrapper();
+
+ private UnsignedInteger _handle;
+ private UnsignedInteger _deliveryId;
+ private Binary _deliveryTag;
+ private UnsignedInteger _messageFormat;
+ private Boolean _settled;
+ private boolean _more;
+ private UnsignedByte _rcvSettleMode;
+ private DeliveryState _state;
+ private boolean _resume;
+ private boolean _aborted;
+ private boolean _batchable;
+
+ public UnsignedInteger getHandle()
+ {
+ return _handle;
+ }
+
+ public void setHandle(UnsignedInteger handle)
+ {
+ if( handle == null )
+ {
+ throw new NullPointerException("the handle field is mandatory");
+ }
+
+ _handle = handle;
+ }
+
+ public UnsignedInteger getDeliveryId()
+ {
+ return _deliveryId;
+ }
+
+ public void setDeliveryId(UnsignedInteger deliveryId)
+ {
+ _deliveryId = deliveryId;
+ }
+
+ public Binary getDeliveryTag()
+ {
+ return _deliveryTag;
+ }
+
+ public void setDeliveryTag(Binary deliveryTag)
+ {
+ _deliveryTag = deliveryTag;
+ }
+
+ public UnsignedInteger getMessageFormat()
+ {
+ return _messageFormat;
+ }
+
+ public void setMessageFormat(UnsignedInteger 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 UnsignedByte getRcvSettleMode()
+ {
+ return _rcvSettleMode;
+ }
+
+ public void setRcvSettleMode(UnsignedByte 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;
+ }
+
+ public Object getDescriptor()
+ {
+ return DESCRIPTOR;
+ }
+
+ public Object getDescribed()
+ {
+ return _wrapper;
+ }
+
+ public Object get(final int index)
+ {
+
+ switch(index)
+ {
+ case 0:
+ return _handle;
+ case 1:
+ return _deliveryId;
+ case 2:
+ return _deliveryTag;
+ case 3:
+ return _messageFormat;
+ case 4:
+ return _settled;
+ case 5:
+ return _more;
+ case 6:
+ return _rcvSettleMode;
+ case 7:
+ return _state;
+ case 8:
+ return _resume;
+ case 9:
+ return _aborted;
+ case 10:
+ return _batchable;
+ }
+
+ throw new IllegalStateException("Unknown index " + index);
+
+ }
+
+ public int size()
+ {
+ return (_batchable != false)
+ ? 11
+ : (_aborted != false)
+ ? 10
+ : (_resume != false)
+ ? 9
+ : _state != null
+ ? 8
+ : _rcvSettleMode != null
+ ? 7
+ : (_more != false)
+ ? 6
+ : _settled != null
+ ? 5
+ : _messageFormat != null
+ ? 4
+ : _deliveryTag != null
+ ? 3
+ : _deliveryId != null
+ ? 2
+ : 1;
+
+ }
+
+
+ public final class TransferWrapper extends AbstractList
+ {
+
+ @Override
+ public Object get(final int index)
+ {
+ return Transfer.this.get(index);
+ }
+
+ @Override
+ public int size()
+ {
+ return Transfer.this.size();
+ }
+ }
+
+ private static class TransferConstructor implements DescribedTypeConstructor<Transfer>
+ {
+ public Transfer newInstance(Object described)
+ {
+ List l = (List) described;
+
+ Transfer o = new Transfer();
+
+ if(l.size() <= 0)
+ {
+ throw new DecodeException("The handle field cannot be omitted");
+ }
+
+ switch(11 - l.size())
+ {
+
+ case 0:
+ Boolean batchable = (Boolean) l.get(10);
+ o.setBatchable(batchable == null ? false : batchable);
+ case 1:
+ Boolean aborted = (Boolean) l.get(9);
+ o.setAborted(aborted == null ? false : aborted);
+ case 2:
+ Boolean resume = (Boolean) l.get(8);
+ o.setResume(resume == null ? false : resume);
+ case 3:
+ o.setState( (DeliveryState) l.get( 7 ) );
+ case 4:
+ o.setRcvSettleMode( (UnsignedByte) l.get( 6 ) );
+ case 5:
+ Boolean more = (Boolean) l.get(5);
+ o.setMore(more == null ? false : more );
+ case 6:
+ o.setSettled( (Boolean) l.get( 4 ) );
+ case 7:
+ o.setMessageFormat( (UnsignedInteger) l.get( 3 ) );
+ case 8:
+ o.setDeliveryTag( (Binary) l.get( 2 ) );
+ case 9:
+ o.setDeliveryId( (UnsignedInteger) l.get( 1 ) );
+ case 10:
+ o.setHandle( (UnsignedInteger) l.get( 0 ) );
+ }
+
+
+ return o;
+ }
+
+ public Class<Transfer> getTypeClass()
+ {
+ return Transfer.class;
+ }
+ }
+
+ public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
+ {
+ handler.handleTransfer(this, payload, context);
+ }
+
+
+ public static void register(Decoder decoder)
+ {
+ TransferConstructor constructor = new TransferConstructor();
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, constructor);
+ }
+ }
+
+ @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
Added: qpid/proton/proton-j/common.xml
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/common.xml?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/common.xml (added)
+++ qpid/proton/proton-j/common.xml Sat Mar 10 09:48:50 2012
@@ -0,0 +1,366 @@
+<!--
+ -
+ - 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.
+ -
+ -->
+<project name="common">
+
+ <dirname property="project.root" file="${ant.file.common}"/>
+
+ <property name="project.name" value="qpid"/>
+ <property name="project.version" value="0.01"/>
+ <property name="project.url" value="http://qpid.apache.org"/>
+ <property name="project.groupid" value="org.apache.qpid"/>
+ <property name="project.namever" value="${project.name}-${project.version}"/>
+
+ <property name="resources" location="${project.root}/resources"/>
+ <property name="test.profiles" location="${project.root}/test-profiles"/>
+ <property name="build" location="${project.root}/build"/>
+ <property name="build.scratch" location="${build}/scratch"/>
+ <property name="build.bin" location="${build}/bin"/>
+ <property name="build.etc" location="${build}/etc"/>
+ <property name="build.lib" location="${build}/lib"/>
+ <property name="build.api" location="${build}/api"/>
+ <property name="build.test.api" location="${build}/test-api"/>
+ <property name="build.results" location="${build}/results"/>
+ <property name="build.failed" location="${build.results}/FAILED"/>
+ <property name="build.report" location="${build}/report"/>
+ <property name="build.release" location="${build}/release"/>
+ <property name="build.release.prepare" location="${build.release}/prepare"/>
+ <property name="build.plugins" location="${build}/lib/plugins"/>
+ <property name="build.coveragereport" location="${build}/coverage"/>
+ <property name="build.findbugs" location="${build}/findbugs"/>
+
+ <property name="java.target" value="1.5"/>
+ <property name="java.source" value="1.5"/>
+
+ <property name="release" location="${project.root}/release"/>
+
+ <property name="tasks" location="${project.root}/tasks"/>
+ <property name="tasks.classes" location="${tasks}/classes"/>
+ <property name="tasks.src" location="${tasks}/src"/>
+
+ <property name="javac.compiler.args" value=""/>
+
+ <property name="cobertura.dir" value="${project.root}/lib/cobertura" />
+ <property name="cobertura.version" value="1.9.4.1" />
+ <property name="cobertura.download.url"
+ value="http://downloads.sourceforge.net/project/cobertura/cobertura/${cobertura.version}/cobertura-${cobertura.version}-bin.zip" />
+ <property name="cobertura.zip.filename" value="cobertura-${cobertura.version}-bin.zip" />
+ <property name="cobertura.temp.dir" value="${cobertura.dir}"/>
+
+ <property name="mllib.dir" value="${project.root}/../python" />
+ <property name="findbugs.dir" value="${project.root}/lib/findbugs" />
+
+ <!-- properties used to control Ant Eclipse for Eclipse classpath/project files etc -->
+ <property name="eclipse.updatealways" value="false"/>
+ <property name="eclipse.compilercompliance" value="5.0"/>
+ <property name="eclipse.container" value="JVM 1.5"/>
+
+ <path id="cobertura.classpath">
+ <fileset dir="${cobertura.dir}">
+ <include name="cobertura-${cobertura.version}/*.jar" />
+ <include name="cobertura-${cobertura.version}/**/lib/*.jar" />
+ </fileset>
+ </path>
+
+ <property name="maven.local.repo" value="${build.scratch}/maven-local-repo"/>
+ <property name="maven.settings.xml" value="${project.root}/maven-settings.xml"/>
+ <property name="maven.unique.version" value="false"/>
+ <property name="maven.snapshot" value="true"/>
+ <condition property="maven.version.suffix" value="" else="-SNAPSHOT">
+ <isfalse value="${maven.snapshot}"/>
+ </condition>
+
+ <macrodef name="indirect">
+ <attribute name="name"/>
+ <attribute name="variable"/>
+ <sequential>
+ <property name="@{name}" value="${@{variable}}"/>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="echo-path">
+ <attribute name="refid"/>
+ <sequential>
+ <property name="@{refid}" refid="@{refid}"/>
+ <echo message="@{refid} = ${@{refid}}"/>
+ <pathconvert property="@{refid}.pretty"
+ refid="@{refid}"
+ pathsep="${line.separator} |-- "/>
+ <echo message="@{refid}.pretty =${line.separator} |-- ${@{refid}.pretty}"/>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="echo-prop">
+ <attribute name="name"/>
+ <sequential>
+ <echo message="@{name} = ${@{name}}"/>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="findSubProjects">
+ <attribute name="dir"/>
+ <attribute name="name"/>
+ <attribute name="excludes" default=""/>
+
+ <sequential>
+ <dirset id="@{dir}.refid" dir="@{dir}" excludes="@{excludes}">
+ <present targetdir="@{dir}">
+ <mapper type="glob" from="*" to="*/build.xml" />
+ </present>
+ </dirset>
+
+ <pathconvert property="@{name}"
+ refid="@{dir}.refid"
+ pathsep=" ">
+ <map from="${project.root}/" to=""/>
+ </pathconvert>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="jython">
+ <attribute name="path"/>
+ <element name="args"/>
+ <sequential>
+ <java jar="${project.root}/lib/jython-2.5.0.jar" fork="true" failonerror="true">
+ <arg value="-Dpython.path=@{path}"/>
+ <args/>
+ </java>
+ </sequential>
+ </macrodef>
+
+ <mkdir dir="${tasks.classes}"/>
+ <javac source="${java.source}" target="${java.target}" srcdir="${tasks.src}" destdir="${tasks.classes}" classpath="${java.class.path}" includeantruntime="false">
+ <compilerarg line="${javac.compiler.args}"/>
+ </javac>
+
+
+ <typedef name="propertymapper" classname="org.apache.qpid.tasks.PropertyMapper"
+ classpath="${tasks.classes}"/>
+
+ <taskdef name="map" classname="org.apache.qpid.tasks.Map"
+ classpath="${tasks.classes}"/>
+ <taskdef name="foreach" classname="org.apache.qpid.tasks.Foreach"
+ classpath="${tasks.classes}"/>
+
+ <macrodef name="copylist">
+ <attribute name="todir"/>
+ <attribute name="dir"/>
+ <attribute name="files"/>
+ <sequential>
+ <foreach property="file" list="@{files}">
+ <copy todir="@{todir}" flatten="true">
+ <fileset dir="@{dir}" includes="${file}"/>
+ </copy>
+ </foreach>
+ </sequential>
+ </macrodef>
+
+ <target name="clean-tasks">
+ <delete dir="${tasks.classes}"/>
+ </target>
+
+ <target name="clean-results">
+ <delete dir="${build.results}"/>
+ </target>
+
+ <target name="report" description="generate test report">
+ <delete dir="${build.report}"/>
+ <mkdir dir="${build.report}"/>
+ <junitreport todir="${build.report}">
+ <fileset dir="${build.results}">
+ <include name="**/TEST-*.xml"/>
+ </fileset>
+ <report todir="${build.report}"/>
+ </junitreport>
+ </target>
+
+ <target name="cobertura-init">
+ <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
+ </target>
+
+ <!--download Cobertura jar and expand-->
+ <target name="download-cobertura" description="download Cobertura if not already present" depends="cobertura-check" unless="cobertura.already.exists">
+ <mkdir dir="${cobertura.dir}"/>
+ <echo>Downloading Cobertura ${cobertura.version}</echo>
+ <get src="${cobertura.download.url}" dest="${cobertura.temp.dir}/${cobertura.zip.filename}" usetimestamp="false" />
+ <echo>Extracting Cobertura JAR and dependencies</echo>
+ <unzip src="${cobertura.temp.dir}/${cobertura.zip.filename}" dest="${cobertura.dir}"/>
+ <echo>Cleanup Cobertura Download</echo>
+ <delete file="${cobertura.temp.dir}/${cobertura.zip.filename}"/>
+ <echo>Done</echo>
+ </target>
+
+ <target name="cobertura-check">
+ <available property="cobertura.already.exists" file="${cobertura.dir}/cobertura-${cobertura.version}" type="dir"/>
+ </target>
+
+ <target name="findbugs-init">
+ <available file="${findbugs.dir}/findbugs-ant.jar" property="findbugs-ant.jar.present"/>
+ <fail unless="findbugs-ant.jar.present" message="Please follow the instructions at ${findbugs.dir}/README.txt to configure FindBugs"/>
+
+ <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${findbugs.dir}/findbugs-ant.jar"/>
+ </target>
+
+ <target name="help" description="display detailed build documentation">
+ <echo>
+ ant build
+
+ This target compiles all sources, creates java archives, and
+ copies scripts and configurations into the build directory:
+
+ ${build}
+
+ The build directory is treated as a live distro which this target
+ will incrementally update. Developers can put the build/bin
+ directory into their path in order to run any scripts or code
+ directly out of the live build:
+
+ ${build.bin}
+
+ ant test [ -Dtest=<pattern> ] [-Dprofile=<profile>] [ report ]
+
+ Execute unit tests and place the output in the build results
+ directory:
+
+ ${build.results}
+
+ All test output will be redirected to a file of the form:
+
+ TEST-<class>.txt
+
+ The same output is available using an xml file format:
+
+ TEST-<class>.xml
+
+ The test system property may be used to restrict the number of
+ tests run by a given invocation of the ant test target. The
+ following command will run just the MongooseTest test case:
+
+ ant test -Dtest=MongooseTest
+
+ In addition, patterns may be used to specify more than one test.
+ The following command will run both the MongooseTest and GooseTest
+ test cases:
+
+ ant test -Dtest=*ooseTest
+
+ If no test property is specified, the "ant test" target will
+ default to running all available tests for the project or module
+ depending on the current working directory.
+
+ Test Reports
+
+ It can be useful to append the report target in order to
+ generate an html summary of the tests that were just run. The
+ following command will run both the MongooseTest and GooseTest
+ test cases and generate an html summary of the results:
+
+ ant test -Dtest=*ooseTest report
+
+ See the documentation for the "ant report" target for more details
+ on the generated report.
+
+ Test Profiles
+
+ There are a number of profiles defined for running the test suite.
+ These test profiles define how the test should be run. If the test
+ profile is not specified then 'default.testprofile' is utilised.
+ This runs the system tests against the Java InVM broker. Additional
+ test profiles exists as follows:
+
+ cpp : Runs against the built cpp tree broker.
+
+ ant report
+
+ The report target will generate an html summary of the current
+ test results into the report directory:
+
+ ${build.report}
+
+ The report target will operate on all results currently in the
+ build results directory. Results are not cleared unless the clean
+ target is used. This means that several consecutive test runs can
+ be summarized into a single report. The following commands will
+ produce a report summarizing both the MongooseTest and GooseTest
+ test cases:
+
+ ant test -Dtest=MongooseTest
+ ...
+ ant test -Dtest=GooseTest
+ ...
+ ant report
+
+ ant release
+
+ The release target generates binary distribution archives and
+ places them into the release directory:
+
+ ${release}
+
+ ant release-bin
+
+ The release-bin target generates binary distribution archives for
+ modules that have a specific binary package configured.
+ To enable for other modules create a target "release-bin" that
+ depends on target "release-bin-tasks". The output is placed in:
+
+ ${module.release}
+
+ ant clean
+
+ The clean target removes build artifacts. When invoked from the
+ project root this target will remove the entire project build and
+ release directories:
+
+ ${build}
+ and
+ ${release}
+ and
+ ${module.release}
+
+ When invoked from a specific module, the clean target will delete
+ that modules build root from underneath the project build root:
+
+ ${build}/<module>
+
+ ant clean-results
+
+ The clean-results target removes all test output from the test
+ results directory:
+
+ ${build.results}
+
+ ant eclipse
+
+ Generates project and classpath files for the Eclispe IDE. Requires that
+ the Ant Eclipse task (http://ant-eclipse.sourceforge.net/) has been installed
+ in $ANT_HOME/lib.
+
+ The following system properties will be passed to the task. These can be usefully
+ overridden from the command line.
+
+ eclipse.updatealways - forces Eclipse files to be regenerated even if they are newer then the build.xml (default ${eclipse.updatealways}).
+ eclipse.container - controls the Eclipse container (default ${eclipse.container}).
+ eclipse.compilercompliance" - controls the Eclipse compiler compliance (default ${eclipse.compilercompliance}).
+
+ </echo>
+ </target>
+
+</project>
Added: qpid/proton/proton-j/driver/build.xml
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/driver/build.xml?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/driver/build.xml (added)
+++ qpid/proton/proton-j/driver/build.xml Sat Mar 10 09:48:50 2012
@@ -0,0 +1,28 @@
+<!--
+ -
+ - 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.
+ -
+ -->
+<project name="AMQP 1.0 Driver" default="build">
+
+ <property name="module.depends" value="codec engine"/>
+ <property name="module.genpom" value="true"/>
+
+ <import file="../module.xml"/>
+
+</project>
Added: qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/Application.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/Application.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/Application.java (added)
+++ qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/Application.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.driver;
+
+import org.apache.qpid.proton.engine.Connection;
+
+public interface Application
+{
+ void process(Connection conn);
+}
Added: qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/ApplicationFactory.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/ApplicationFactory.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/ApplicationFactory.java (added)
+++ qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/ApplicationFactory.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,27 @@
+/*
+ *
+ * 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.driver;
+
+public interface ApplicationFactory
+{
+ Application createApplication();
+}
Added: qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/BytesTransport.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/BytesTransport.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/BytesTransport.java (added)
+++ qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/BytesTransport.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.driver;
+
+public interface BytesTransport
+{
+ int input(byte[] bytes, int offset, int size);
+
+ int output(byte[] bytes, int offset, int size);
+}
Added: qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/ConnectionTransport.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/ConnectionTransport.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/ConnectionTransport.java (added)
+++ qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/ConnectionTransport.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,168 @@
+/*
+ *
+ * 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.driver;
+
+import org.apache.qpid.proton.engine.impl.ConnectionImpl;
+import org.apache.qpid.proton.engine.impl.ConnectionImpl;
+import org.apache.qpid.proton.engine.impl.ConnectionImpl;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.ByteChannel;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+class ConnectionTransport
+{
+ public static final int DEFAULT_BUFFER_SIZE = 16 * 1024;
+ private final ConnectionImpl _connection;
+ private final BytesTransport _transport;
+ private final Application _application;
+ private final ByteChannel _channel;
+
+ private final byte[] _inputBuffer;
+ private final byte[] _outputBuffer;;
+
+ private int _inputHead = 0;
+ private int _inputTail = 0;
+
+ private int _outputHead = 0;
+ private int _outputTail = 0;
+ private final int _mask;
+ private boolean _readClosed;
+ private boolean _writeClosed;
+ private boolean _readable;
+ private boolean _writable;
+ private final AtomicBoolean _state = new AtomicBoolean();
+
+
+ ConnectionTransport(ConnectionImpl connection, BytesTransport transport, ByteChannel channel,
+ Application application)
+ {
+ _connection = connection;
+ _transport = transport;
+ _application = application;
+ _channel = channel;
+ _inputBuffer = new byte[DEFAULT_BUFFER_SIZE];
+ _outputBuffer = new byte[DEFAULT_BUFFER_SIZE];
+ _mask = _inputBuffer.length - 1;
+ }
+
+ public ConnectionImpl getConnection()
+ {
+ return _connection;
+ }
+
+ public BytesTransport getTransport()
+ {
+ return _transport;
+ }
+
+ public Application getApplication()
+ {
+ return _application;
+ }
+
+ public boolean process() throws IOException
+ {
+
+ if(_state.compareAndSet(false, true))
+ {
+ int read;
+ // TODO - should reuse the same buffer
+ ByteBuffer buf = ByteBuffer.wrap(_inputBuffer);
+ while((read=_channel.read(buf))>0)
+ {
+ _transport.input(_inputBuffer,_inputHead & _mask,(_inputHead & _mask) + read);
+ buf.clear();
+
+ }
+
+ if(read == -1)
+ {
+ _channel.close();
+ setReadClosed(true);
+
+ }
+
+ _application.process(_connection);
+
+ int length = _transport.output(_outputBuffer, 0, _outputBuffer.length);
+
+ int offset = 0;
+ while(length > 0)
+ {
+ int written = _channel.write(ByteBuffer.wrap(_outputBuffer,offset,length));
+ if(written == -1)
+ {
+ setWriteClosed(true);
+ break;
+ }
+ else
+ {
+ length -= written;
+ offset += written;
+ }
+ }
+
+ _readable = _inputTail - _inputHead < _inputBuffer.length;
+ _writable = _outputTail > _outputHead;
+
+ _state.set(false);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ public void setReadClosed(boolean readClosed)
+ {
+ _readClosed = readClosed;
+ }
+
+ public boolean isReadClosed()
+ {
+ return _readClosed;
+ }
+
+ public void setWriteClosed(boolean writeClosed)
+ {
+ _writeClosed = writeClosed;
+ }
+
+ public boolean isWriteClosed()
+ {
+ return _writeClosed;
+ }
+
+ public boolean isReadable()
+ {
+ return _readable;
+ }
+
+ public boolean isWritable()
+ {
+ return _writable;
+ }
+}
Added: qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/DelegatingTransport.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/DelegatingTransport.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/DelegatingTransport.java (added)
+++ qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/DelegatingTransport.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,128 @@
+/*
+ *
+ * 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.driver;
+
+import org.apache.qpid.proton.engine.EndpointError;
+import org.apache.qpid.proton.engine.EndpointState;
+import org.apache.qpid.proton.engine.Transport;
+
+import java.util.Iterator;
+import java.util.Map;
+
+public class DelegatingTransport implements BytesTransport
+{
+ private Transport _delegate;
+
+ private final Transport _default;
+ private final Map<byte[], Transport> _potentialDelegates;
+ private State _state = State.CHOOSING;
+ private int _bytesRead;
+
+ enum State
+ {
+ DELEGATING,
+ CHOOSING
+ }
+
+ public DelegatingTransport(final Map<byte[], Transport> potentialDelegates, final Transport defaultDelegate)
+ {
+ _potentialDelegates = potentialDelegates;
+ _default = defaultDelegate;
+ }
+
+
+ public int input(final byte[] bytes, final int offset, final int size)
+ {
+ switch (_state)
+ {
+ case DELEGATING:
+ return _delegate.input(bytes, offset, size);
+ default:
+ Iterator<Map.Entry<byte[], Transport>> mapEntriesIter = _potentialDelegates.entrySet().iterator();
+ while (mapEntriesIter.hasNext())
+ {
+ Map.Entry<byte[], Transport> entry = mapEntriesIter.next();
+ int headerOffset = _bytesRead;
+ int count = Math.min(size, entry.getKey().length-headerOffset);
+ for(int i = 0; i<count; i++)
+ {
+ if(entry.getKey()[headerOffset+i] != bytes[offset+i])
+ {
+ mapEntriesIter.remove();
+ break;
+ }
+ }
+ }
+ if(_potentialDelegates.size() == 0)
+ {
+ _delegate = _default;
+ _state = State.DELEGATING;
+ return _delegate.input(bytes,offset,size);
+ }
+ else if(_potentialDelegates.size() == 1 && _bytesRead+size >= _potentialDelegates.keySet().iterator()
+ .next().length)
+ {
+ _delegate = _potentialDelegates.values().iterator().next();
+ _state = State.DELEGATING;
+ return _delegate.input(bytes,offset,size);
+
+ }
+ }
+ _bytesRead+=size;
+ return size;
+
+ }
+
+ public int output(final byte[] bytes, final int offset, final int size)
+ {
+ if(_delegate == null)
+ {
+ return 0;
+ }
+ return _delegate.output(bytes,offset,size);
+ }
+
+ public EndpointState getLocalState()
+ {
+ return null; //TODO.
+ }
+
+ public EndpointState getRemoteState()
+ {
+ return null; //TODO.
+ }
+
+ public EndpointError getLocalError()
+ {
+ return null; //TODO.
+ }
+
+ public EndpointError getRemoteError()
+ {
+ return null; //TODO.
+ }
+
+ public void destroy()
+ {
+ //TODO.
+ }
+
+}
Added: qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/NIOAcceptingDriver.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/NIOAcceptingDriver.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/NIOAcceptingDriver.java (added)
+++ qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/NIOAcceptingDriver.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,147 @@
+/*
+ *
+ * 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.driver;
+
+import org.apache.qpid.proton.engine.Transport;
+import org.apache.qpid.proton.engine.impl.ConnectionImpl;
+import org.apache.qpid.proton.engine.impl.TransportImpl;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.SocketAddress;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class NIOAcceptingDriver implements Runnable
+{
+ private final Selector _selector;
+
+ private final ApplicationFactory _applicationFactory;
+
+
+ public NIOAcceptingDriver(final SocketAddress bindAddress, ApplicationFactory applicationFactory)
+ {
+ try
+ {
+ _applicationFactory = applicationFactory;
+ _selector = Selector.open();
+
+ ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
+ serverSocketChannel.configureBlocking(false);
+ ServerSocket serverSocket = serverSocketChannel.socket();
+ serverSocket.bind(bindAddress);
+ serverSocketChannel.register(_selector, SelectionKey.OP_ACCEPT);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace(); //TODO.
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ public void run()
+ {
+ while(true)
+ {
+ try
+ {
+ _selector.select();
+ Iterator<SelectionKey> selectedIter = _selector.selectedKeys().iterator();
+ while(selectedIter.hasNext())
+ {
+ SelectionKey key = selectedIter.next();
+ selectedIter.remove();
+ if(key.isAcceptable())
+ {
+ ServerSocketChannel channel = (ServerSocketChannel) key.channel();
+ SocketChannel newChan = channel.accept();
+ newChan.configureBlocking(false);
+ ConnectionImpl connection = new ConnectionImpl();
+ Transport amqpTransport = connection.transport();
+ Map<byte[], Transport> transportMap = new HashMap<byte[], Transport>();
+ transportMap.put(TransportImpl.HEADER, amqpTransport);
+ DelegatingTransport transport = new DelegatingTransport(transportMap, amqpTransport);
+ newChan.register(_selector, SelectionKey.OP_READ,
+ new ConnectionTransport(connection, transport, newChan,
+ _applicationFactory.createApplication()));
+
+ }
+ else if(key.isReadable() || key.isWritable())
+ {
+ ConnectionTransport connectionTransport = (ConnectionTransport) key.attachment();
+
+ connectionTransport.process();
+
+ if(connectionTransport.isReadClosed())
+ {
+ key.cancel();
+ }
+ else
+ {
+ if(connectionTransport.isWritable())
+ {
+ key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
+ }
+ else
+ {
+ if((key.interestOps() & SelectionKey.OP_WRITE) != 0)
+ {
+ key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
+ }
+ }
+ }
+
+ }
+ else if(key.isConnectable())
+ {
+ System.out.println("connectable");
+ }
+
+
+ }
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace(); //TODO.
+ }
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ SocketAddress bindAddress = new InetSocketAddress(5672);
+ NIOAcceptingDriver driver = new NIOAcceptingDriver(bindAddress, new ApplicationFactory()
+ {
+ public Application createApplication()
+ {
+ return new NoddyBrokerApplication();
+ }
+ });
+ driver.run();
+ }
+}
Added: qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/NoddyBrokerApplication.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/NoddyBrokerApplication.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/NoddyBrokerApplication.java (added)
+++ qpid/proton/proton-j/driver/src/org/apache/qpid/proton/driver/NoddyBrokerApplication.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,162 @@
+/*
+ *
+ * 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.driver;
+
+import org.apache.qpid.proton.engine.Accepted;
+import org.apache.qpid.proton.engine.Connection;
+import org.apache.qpid.proton.engine.Delivery;
+import org.apache.qpid.proton.engine.Endpoint;
+import org.apache.qpid.proton.engine.EndpointState;
+import org.apache.qpid.proton.engine.Link;
+import org.apache.qpid.proton.engine.Receiver;
+import org.apache.qpid.proton.engine.Sender;
+import org.apache.qpid.proton.engine.Sequence;
+import org.apache.qpid.proton.engine.Session;
+import org.apache.qpid.proton.type.Binary;
+
+import java.util.EnumSet;
+
+public class NoddyBrokerApplication implements Application
+{
+
+ public static final EnumSet<EndpointState> UNINITIALIZED_SET = EnumSet.of(EndpointState.UNINITIALIZED);
+ public static final EnumSet<EndpointState> INITIALIZED_SET = EnumSet.complementOf(UNINITIALIZED_SET);
+ public static final EnumSet<EndpointState> ACTIVE_STATE = EnumSet.of(EndpointState.ACTIVE);
+ public static final EnumSet<EndpointState> CLOSED_STATE = EnumSet.of(EndpointState.CLOSED);
+ private byte _tagId;
+
+
+ public void process(Connection conn)
+ {
+ Sequence<? extends Endpoint> s = conn.endpoints(UNINITIALIZED_SET, INITIALIZED_SET);
+ Endpoint endpoint;
+ while((endpoint = s.next()) != null)
+ {
+ if(endpoint instanceof Connection)
+ {
+ // TODO
+ conn.open();
+ }
+ else if(endpoint instanceof Session)
+ {
+ // TODO
+ ((Session)endpoint).open();
+ }
+ else if(endpoint instanceof Link)
+ {
+ Link link = (Link) endpoint;
+
+ // TODO
+
+ // TODO - following is a hack
+ link.setLocalSourceAddress(link.getRemoteSourceAddress());
+ link.setLocalTargetAddress(link.getRemoteTargetAddress());
+
+ link.open();
+ if(link instanceof Receiver)
+ {
+ ((Receiver)link).flow(200);
+ }
+ else
+ {
+ Sender sender = (Sender)link;
+ sender.offer(100);
+ sendMessages(sender);
+ }
+ }
+ }
+
+ Sequence<? extends Delivery> deliveries = conn.getWorkSequence();
+ Delivery delivery;
+ while((delivery = deliveries.next()) != null)
+ {
+ System.out.println("received " + new Binary(delivery.getTag()));
+ if(delivery.getLink() instanceof Receiver)
+ {
+
+ Receiver link = (Receiver) delivery.getLink();
+ if(link.current() == null)
+ {
+ link.advance();
+ }
+ if(link.recv(new byte[0], 0, 0) == -1)
+ {
+
+ link.advance();
+
+ }
+ delivery.disposition(Accepted.getInstance());
+
+ }
+ else
+ {
+ Sender sender = (Sender) delivery.getLink();
+ sendMessages(sender);
+ }
+ }
+
+ s = conn.endpoints(ACTIVE_STATE, CLOSED_STATE);
+ while((endpoint = s.next()) != null)
+ {
+ if(endpoint instanceof Link)
+ {
+ // TODO
+ ((Link)endpoint).close();
+ }
+ else if(endpoint instanceof Session)
+ {
+ //TODO - close links?
+ ((Session)endpoint).close();
+ }
+ else if(endpoint instanceof Connection)
+ {
+ //TODO - close sessions / links?
+ ((Connection)endpoint).close();
+ }
+
+ }
+
+ }
+
+ private void sendMessages(Sender sender)
+ {
+ if(sender.current() == null)
+ {
+ byte[] tag = {_tagId++};
+ sender.delivery(tag, 0, 1);
+
+ }
+ while(sender.advance())
+ {
+
+
+ System.out.println("Sending message " + _tagId);
+ if(sender.current() == null)
+ {
+ byte[] tag = {_tagId++};
+ sender.delivery(tag, 0, 1);
+ }
+
+ }
+ ;
+ }
+}
Added: qpid/proton/proton-j/engine/build.xml
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/engine/build.xml?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/engine/build.xml (added)
+++ qpid/proton/proton-j/engine/build.xml Sat Mar 10 09:48:50 2012
@@ -0,0 +1,28 @@
+<!--
+ -
+ - 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.
+ -
+ -->
+<project name="AMQP 1.0 Engine" default="build">
+
+ <property name="module.depends" value="codec"/>
+ <property name="module.genpom" value="true"/>
+
+ <import file="../module.xml"/>
+
+</project>
Added: qpid/proton/proton-j/engine/src/org/apache/qpid/proton/engine/Accepted.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/engine/src/org/apache/qpid/proton/engine/Accepted.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/engine/src/org/apache/qpid/proton/engine/Accepted.java (added)
+++ qpid/proton/proton-j/engine/src/org/apache/qpid/proton/engine/Accepted.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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.engine;
+
+
+/**
+ * Accepted
+ *
+ * @hidden
+ *
+ */
+
+public class Accepted implements Outcome
+{
+ private Accepted()
+ {
+ }
+
+ private static final Accepted INSTANCE = new Accepted();
+
+ public static Accepted getInstance()
+ {
+ return INSTANCE;
+ }
+}
Added: qpid/proton/proton-j/engine/src/org/apache/qpid/proton/engine/Connection.java
URL: http://svn.apache.org/viewvc/qpid/proton/proton-j/engine/src/org/apache/qpid/proton/engine/Connection.java?rev=1299173&view=auto
==============================================================================
--- qpid/proton/proton-j/engine/src/org/apache/qpid/proton/engine/Connection.java (added)
+++ qpid/proton/proton-j/engine/src/org/apache/qpid/proton/engine/Connection.java Sat Mar 10 09:48:50 2012
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.engine;
+
+import java.util.EnumSet;
+
+
+/**
+ * Connection
+ *
+ * @opt operations
+ * @opt types
+ *
+ * @composed 1 - "0..n" Session
+ * @composed 1 - "0..?" Transport
+ *
+ */
+
+public interface Connection extends Endpoint
+{
+
+ /**
+ * @return a newly created session
+ */
+ public Session session();
+
+ /**
+ * @return a newly created transport
+ */
+ public Transport transport();
+
+ /**
+ * @return iterator for endpoints matching the specified local and
+ * remote states
+ */
+ public Sequence<? extends Endpoint> endpoints(EnumSet<EndpointState> local, EnumSet<EndpointState> remote);
+
+ public Sequence<? extends Delivery> getWorkSequence();
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org