Return-Path: X-Original-To: apmail-qpid-commits-archive@www.apache.org Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9CA6C177BD for ; Tue, 14 Oct 2014 14:36:21 +0000 (UTC) Received: (qmail 70361 invoked by uid 500); 14 Oct 2014 14:36:21 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 70340 invoked by uid 500); 14 Oct 2014 14:36:21 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 70330 invoked by uid 99); 14 Oct 2014 14:36:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Oct 2014 14:36:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Oct 2014 14:35:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 969E123889ED; Tue, 14 Oct 2014 14:35:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1631772 [2/3] - in /qpid/proton/branches/examples: examples/engine/ examples/engine/java/ examples/engine/java/src/ examples/engine/java/src/main/ examples/engine/java/src/main/java/ examples/engine/java/src/main/java/org/ examples/engine/... Date: Tue, 14 Oct 2014 14:35:41 -0000 To: commits@qpid.apache.org From: gsim@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141014143543.969E123889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java Tue Oct 14 14:35:39 2014 @@ -1,189 +1,189 @@ -/* - * - * 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.amqp; - -import java.nio.ByteBuffer; -import java.util.Collection; - -import static java.lang.Math.min; - -public final class Binary -{ - - private final byte[] _data; - private final int _offset; - private final int _length; - private int _hashCode; - - public Binary(final byte[] data) - { - this(data, 0, data.length); - } - - public Binary(final byte[] data, final int offset, final int length) - { - _data = data; - _offset = offset; - _length = length; - } - - public ByteBuffer asByteBuffer() - { - return ByteBuffer.wrap(_data, _offset, _length); - } - - @Override - public final int hashCode() - { - int hc = _hashCode; - if(hc == 0) - { - for (int i = 0; i < _length; i++) - { - hc = 31*hc + (0xFF & _data[_offset + i]); - } - _hashCode = hc; - } - return hc; - } - - @Override - public final boolean equals(Object o) - { - if (this == o) - { - return true; - } - - if (o == null || getClass() != o.getClass()) - { - return false; - } - - Binary buf = (Binary) o; - final int size = _length; - if (size != buf._length) - { - return false; - } - - final byte[] myData = _data; - final byte[] theirData = buf._data; - int myOffset = _offset; - int theirOffset = buf._offset; - final int myLimit = myOffset + size; - - while(myOffset < myLimit) - { - if (myData[myOffset++] != theirData[theirOffset++]) - { - return false; - } - } - - return true; - } - - - public int getArrayOffset() - { - return _offset; - } - - public byte[] getArray() - { - return _data; - } - - public int getLength() - { - return _length; - } - - public String toString() - { - StringBuilder str = new StringBuilder(); - - - for (int i = 0; i < _length; i++) - { - byte c = _data[_offset + i]; - - if (c > 31 && c < 127 && c != '\\') - { - str.append((char)c); - } - else - { - str.append(String.format("\\x%02x", c)); - } - } - - return str.toString(); - - } - - public static Binary combine(final Collection binaries) - { - - if(binaries.size() == 1) - { - return binaries.iterator().next(); - } - - int size = 0; - for(Binary binary : binaries) - { - size += binary.getLength(); - } - byte[] data = new byte[size]; - int offset = 0; - for(Binary binary : binaries) - { - System.arraycopy(binary._data, binary._offset, data, offset, binary._length); - offset += binary._length; - } - return new Binary(data); - } - - public Binary subBinary(final int offset, final int length) - { - return new Binary(_data, _offset+offset, length); - } - - public static Binary create(ByteBuffer buffer) - { - if( buffer == null ) - return null; - if( buffer.isDirect() || buffer.isReadOnly() ) - { - byte data[] = new byte [buffer.remaining()]; - ByteBuffer dup = buffer.duplicate(); - dup.get(data); - return new Binary(data); - } - else - { - return new Binary(buffer.array(), buffer.arrayOffset()+buffer.position(), buffer.remaining()); - } - } - -} +/* + * + * 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.amqp; + +import java.nio.ByteBuffer; +import java.util.Collection; + +import static java.lang.Math.min; + +public final class Binary +{ + + private final byte[] _data; + private final int _offset; + private final int _length; + private int _hashCode; + + public Binary(final byte[] data) + { + this(data, 0, data.length); + } + + public Binary(final byte[] data, final int offset, final int length) + { + _data = data; + _offset = offset; + _length = length; + } + + public ByteBuffer asByteBuffer() + { + return ByteBuffer.wrap(_data, _offset, _length); + } + + @Override + public final int hashCode() + { + int hc = _hashCode; + if(hc == 0) + { + for (int i = 0; i < _length; i++) + { + hc = 31*hc + (0xFF & _data[_offset + i]); + } + _hashCode = hc; + } + return hc; + } + + @Override + public final boolean equals(Object o) + { + if (this == o) + { + return true; + } + + if (o == null || getClass() != o.getClass()) + { + return false; + } + + Binary buf = (Binary) o; + final int size = _length; + if (size != buf._length) + { + return false; + } + + final byte[] myData = _data; + final byte[] theirData = buf._data; + int myOffset = _offset; + int theirOffset = buf._offset; + final int myLimit = myOffset + size; + + while(myOffset < myLimit) + { + if (myData[myOffset++] != theirData[theirOffset++]) + { + return false; + } + } + + return true; + } + + + public int getArrayOffset() + { + return _offset; + } + + public byte[] getArray() + { + return _data; + } + + public int getLength() + { + return _length; + } + + public String toString() + { + StringBuilder str = new StringBuilder(); + + + for (int i = 0; i < _length; i++) + { + byte c = _data[_offset + i]; + + if (c > 31 && c < 127 && c != '\\') + { + str.append((char)c); + } + else + { + str.append(String.format("\\x%02x", c)); + } + } + + return str.toString(); + + } + + public static Binary combine(final Collection binaries) + { + + if(binaries.size() == 1) + { + return binaries.iterator().next(); + } + + int size = 0; + for(Binary binary : binaries) + { + size += binary.getLength(); + } + byte[] data = new byte[size]; + int offset = 0; + for(Binary binary : binaries) + { + System.arraycopy(binary._data, binary._offset, data, offset, binary._length); + offset += binary._length; + } + return new Binary(data); + } + + public Binary subBinary(final int offset, final int length) + { + return new Binary(_data, _offset+offset, length); + } + + public static Binary create(ByteBuffer buffer) + { + if( buffer == null ) + return null; + if( buffer.isDirect() || buffer.isReadOnly() ) + { + byte data[] = new byte [buffer.remaining()]; + ByteBuffer dup = buffer.duplicate(); + dup.get(data); + return new Binary(data); + } + else + { + return new Binary(buffer.array(), buffer.arrayOffset()+buffer.position(), buffer.remaining()); + } + } + +} Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/Symbol.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/Symbol.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/Symbol.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/Symbol.java Tue Oct 14 14:35:39 2014 @@ -1,94 +1,94 @@ -/* - * - * 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.amqp; - -import java.util.concurrent.ConcurrentHashMap; - -public final class Symbol implements Comparable, CharSequence -{ - private final String _underlying; - private static final ConcurrentHashMap _symbols = new ConcurrentHashMap(2048); - - private Symbol(String underlying) - { - _underlying = underlying; - } - - public int length() - { - return _underlying.length(); - } - - public int compareTo(Symbol o) - { - return _underlying.compareTo(o._underlying); - } - - public char charAt(int index) - { - return _underlying.charAt(index); - } - - public CharSequence subSequence(int beginIndex, int endIndex) - { - return _underlying.subSequence(beginIndex, endIndex); - } - - @Override - public String toString() - { - return _underlying; - } - - @Override - public int hashCode() - { - return _underlying.hashCode(); - } - - public static Symbol valueOf(String symbolVal) - { - return getSymbol(symbolVal); - } - - public static Symbol getSymbol(String symbolVal) - { - if(symbolVal == null) - { - return null; - } - Symbol symbol = _symbols.get(symbolVal); - if(symbol == null) - { - symbolVal = symbolVal.intern(); - symbol = new Symbol(symbolVal); - Symbol existing; - if((existing = _symbols.putIfAbsent(symbolVal, symbol)) != null) - { - symbol = existing; - } - } - return symbol; - } - - -} +/* + * + * 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.amqp; + +import java.util.concurrent.ConcurrentHashMap; + +public final class Symbol implements Comparable, CharSequence +{ + private final String _underlying; + private static final ConcurrentHashMap _symbols = new ConcurrentHashMap(2048); + + private Symbol(String underlying) + { + _underlying = underlying; + } + + public int length() + { + return _underlying.length(); + } + + public int compareTo(Symbol o) + { + return _underlying.compareTo(o._underlying); + } + + public char charAt(int index) + { + return _underlying.charAt(index); + } + + public CharSequence subSequence(int beginIndex, int endIndex) + { + return _underlying.subSequence(beginIndex, endIndex); + } + + @Override + public String toString() + { + return _underlying; + } + + @Override + public int hashCode() + { + return _underlying.hashCode(); + } + + public static Symbol valueOf(String symbolVal) + { + return getSymbol(symbolVal); + } + + public static Symbol getSymbol(String symbolVal) + { + if(symbolVal == null) + { + return null; + } + Symbol symbol = _symbols.get(symbolVal); + if(symbol == null) + { + symbolVal = symbolVal.intern(); + symbol = new Symbol(symbolVal); + Symbol existing; + if((existing = _symbols.putIfAbsent(symbolVal, symbol)) != null) + { + symbol = existing; + } + } + return symbol; + } + + +} Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedByte.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedByte.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedByte.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedByte.java Tue Oct 14 14:35:39 2014 @@ -1,134 +1,134 @@ -/* - * - * 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.amqp; - -public final class UnsignedByte extends Number implements Comparable -{ - private final byte _underlying; - private static final UnsignedByte[] cachedValues = new UnsignedByte[256]; - - static - { - for(int i = 0; i<256; i++) - { - cachedValues[i] = new UnsignedByte((byte)i); - } - } - - public UnsignedByte(byte underlying) - { - _underlying = underlying; - } - - @Override - public byte byteValue() - { - return _underlying; - } - - @Override - public short shortValue() - { - return (short) intValue(); - } - - @Override - public int intValue() - { - return ((int)_underlying) & 0xFF; - } - - @Override - public long longValue() - { - return ((long) _underlying) & 0xFFl; - } - - @Override - public float floatValue() - { - return (float) longValue(); - } - - @Override - public double doubleValue() - { - return (double) longValue(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - - UnsignedByte that = (UnsignedByte) o; - - if (_underlying != that._underlying) - { - return false; - } - - return true; - } - - public int compareTo(UnsignedByte o) - { - return Integer.signum(intValue() - o.intValue()); - } - - @Override - public int hashCode() - { - return _underlying; - } - - @Override - public String toString() - { - return String.valueOf(intValue()); - } - - public static UnsignedByte valueOf(byte underlying) - { - final int index = ((int) underlying) & 0xFF; - return cachedValues[index]; - } - - public static UnsignedByte valueOf(final String value) - throws NumberFormatException - { - int intVal = Integer.parseInt(value); - if(intVal < 0 || intVal >= (1<<8)) - { - throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<8) +")."); - } - return valueOf((byte)intVal); - } - -} +/* + * + * 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.amqp; + +public final class UnsignedByte extends Number implements Comparable +{ + private final byte _underlying; + private static final UnsignedByte[] cachedValues = new UnsignedByte[256]; + + static + { + for(int i = 0; i<256; i++) + { + cachedValues[i] = new UnsignedByte((byte)i); + } + } + + public UnsignedByte(byte underlying) + { + _underlying = underlying; + } + + @Override + public byte byteValue() + { + return _underlying; + } + + @Override + public short shortValue() + { + return (short) intValue(); + } + + @Override + public int intValue() + { + return ((int)_underlying) & 0xFF; + } + + @Override + public long longValue() + { + return ((long) _underlying) & 0xFFl; + } + + @Override + public float floatValue() + { + return (float) longValue(); + } + + @Override + public double doubleValue() + { + return (double) longValue(); + } + + @Override + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + + UnsignedByte that = (UnsignedByte) o; + + if (_underlying != that._underlying) + { + return false; + } + + return true; + } + + public int compareTo(UnsignedByte o) + { + return Integer.signum(intValue() - o.intValue()); + } + + @Override + public int hashCode() + { + return _underlying; + } + + @Override + public String toString() + { + return String.valueOf(intValue()); + } + + public static UnsignedByte valueOf(byte underlying) + { + final int index = ((int) underlying) & 0xFF; + return cachedValues[index]; + } + + public static UnsignedByte valueOf(final String value) + throws NumberFormatException + { + int intVal = Integer.parseInt(value); + if(intVal < 0 || intVal >= (1<<8)) + { + throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<8) +")."); + } + return valueOf((byte)intVal); + } + +} Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedInteger.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedInteger.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedInteger.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedInteger.java Tue Oct 14 14:35:39 2014 @@ -1,149 +1,149 @@ -/* - * - * 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.amqp; - -public final class UnsignedInteger extends Number implements Comparable -{ - private final int _underlying; - private static final UnsignedInteger[] cachedValues = new UnsignedInteger[256]; - - static - { - for(int i = 0; i < 256; i++) - { - cachedValues[i] = new UnsignedInteger(i); - } - } - - public static final UnsignedInteger ZERO = cachedValues[0]; - public static final UnsignedInteger ONE = cachedValues[1]; - public static final UnsignedInteger MAX_VALUE = new UnsignedInteger(0xffffffff); - - - public UnsignedInteger(int underlying) - { - _underlying = underlying; - } - - @Override - public int intValue() - { - return _underlying; - } - - @Override - public long longValue() - { - return ((long) _underlying) & 0xFFFFFFFFl; - } - - @Override - public float floatValue() - { - return (float) longValue(); - } - - @Override - public double doubleValue() - { - return (double) longValue(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - - UnsignedInteger that = (UnsignedInteger) o; - - if (_underlying != that._underlying) - { - return false; - } - - return true; - } - - public int compareTo(UnsignedInteger o) - { - return Long.signum(longValue() - o.longValue()); - } - - @Override - public int hashCode() - { - return _underlying; - } - - @Override - public String toString() - { - return String.valueOf(longValue()); - } - - public static UnsignedInteger valueOf(int underlying) - { - if((underlying & 0xFFFFFF00) == 0) - { - return cachedValues[underlying]; - } - else - { - return new UnsignedInteger(underlying); - } - } - - public UnsignedInteger add(final UnsignedInteger i) - { - int val = _underlying + i._underlying; - return UnsignedInteger.valueOf(val); - } - - public UnsignedInteger subtract(final UnsignedInteger i) - { - int val = _underlying - i._underlying; - return UnsignedInteger.valueOf(val); - } - - public static UnsignedInteger valueOf(final String value) - { - long longVal = Long.parseLong(value); - return valueOf(longVal); - } - - public static UnsignedInteger valueOf(final long longVal) - { - if(longVal < 0L || longVal >= (1L<<32)) - { - throw new NumberFormatException("Value \""+longVal+"\" lies outside the range [" + 0L + "-" + (1L<<32) +")."); - } - return valueOf((int)longVal); - } - -} +/* + * + * 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.amqp; + +public final class UnsignedInteger extends Number implements Comparable +{ + private final int _underlying; + private static final UnsignedInteger[] cachedValues = new UnsignedInteger[256]; + + static + { + for(int i = 0; i < 256; i++) + { + cachedValues[i] = new UnsignedInteger(i); + } + } + + public static final UnsignedInteger ZERO = cachedValues[0]; + public static final UnsignedInteger ONE = cachedValues[1]; + public static final UnsignedInteger MAX_VALUE = new UnsignedInteger(0xffffffff); + + + public UnsignedInteger(int underlying) + { + _underlying = underlying; + } + + @Override + public int intValue() + { + return _underlying; + } + + @Override + public long longValue() + { + return ((long) _underlying) & 0xFFFFFFFFl; + } + + @Override + public float floatValue() + { + return (float) longValue(); + } + + @Override + public double doubleValue() + { + return (double) longValue(); + } + + @Override + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + + UnsignedInteger that = (UnsignedInteger) o; + + if (_underlying != that._underlying) + { + return false; + } + + return true; + } + + public int compareTo(UnsignedInteger o) + { + return Long.signum(longValue() - o.longValue()); + } + + @Override + public int hashCode() + { + return _underlying; + } + + @Override + public String toString() + { + return String.valueOf(longValue()); + } + + public static UnsignedInteger valueOf(int underlying) + { + if((underlying & 0xFFFFFF00) == 0) + { + return cachedValues[underlying]; + } + else + { + return new UnsignedInteger(underlying); + } + } + + public UnsignedInteger add(final UnsignedInteger i) + { + int val = _underlying + i._underlying; + return UnsignedInteger.valueOf(val); + } + + public UnsignedInteger subtract(final UnsignedInteger i) + { + int val = _underlying - i._underlying; + return UnsignedInteger.valueOf(val); + } + + public static UnsignedInteger valueOf(final String value) + { + long longVal = Long.parseLong(value); + return valueOf(longVal); + } + + public static UnsignedInteger valueOf(final long longVal) + { + if(longVal < 0L || longVal >= (1L<<32)) + { + throw new NumberFormatException("Value \""+longVal+"\" lies outside the range [" + 0L + "-" + (1L<<32) +")."); + } + return valueOf((int)longVal); + } + +} Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedLong.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedLong.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedLong.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedLong.java Tue Oct 14 14:35:39 2014 @@ -1,160 +1,160 @@ -/* - * - * 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.amqp; - -import java.math.BigInteger; - -public final class UnsignedLong extends Number implements Comparable -{ - private static final BigInteger TWO_TO_THE_SIXTY_FOUR = new BigInteger( new byte[] { (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }); - private static final BigInteger LONG_MAX_VALUE = BigInteger.valueOf(Long.MAX_VALUE); - - private static final UnsignedLong[] cachedValues = new UnsignedLong[256]; - - static - { - for(int i = 0; i<256; i++) - { - cachedValues[i] = new UnsignedLong(i); - } - } - - public static final UnsignedLong ZERO = cachedValues[0]; - - private final long _underlying; - - - public UnsignedLong(long underlying) - { - _underlying = underlying; - } - - @Override - public int intValue() - { - return (int) _underlying; - } - - @Override - public long longValue() - { - return _underlying; - } - - public BigInteger bigIntegerValue() - { - if(_underlying >= 0L) - { - return BigInteger.valueOf(_underlying); - } - else - { - return TWO_TO_THE_SIXTY_FOUR.add(BigInteger.valueOf(_underlying)); - } - } - - @Override - public float floatValue() - { - return (float) longValue(); - } - - @Override - public double doubleValue() - { - return (double) longValue(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - - UnsignedLong that = (UnsignedLong) o; - - if (_underlying != that._underlying) - { - return false; - } - - return true; - } - - public int compareTo(UnsignedLong o) - { - return bigIntegerValue().compareTo(o.bigIntegerValue()); - } - - @Override - public int hashCode() - { - return (int)(_underlying ^ (_underlying >>> 32)); - } - - @Override - public String toString() - { - return String.valueOf(bigIntegerValue()); - } - - public static UnsignedLong valueOf(long underlying) - { - if((underlying & 0xFFL) == underlying) - { - return cachedValues[(int)underlying]; - } - else - { - return new UnsignedLong(underlying); - } - } - - public static UnsignedLong valueOf(final String value) - { - BigInteger bigInt = new BigInteger(value); - - return valueOf(bigInt); - } - - public static UnsignedLong valueOf(BigInteger bigInt) - { - if(bigInt.signum() == -1 || bigInt.bitLength() > 64) - { - throw new NumberFormatException("Value \""+bigInt+"\" lies outside the range [0 - 2^64)."); - } - else if(bigInt.compareTo(LONG_MAX_VALUE)>=0) - { - return UnsignedLong.valueOf(bigInt.longValue()); - } - else - { - return UnsignedLong.valueOf(TWO_TO_THE_SIXTY_FOUR.subtract(bigInt).negate().longValue()); - } - } -} +/* + * + * 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.amqp; + +import java.math.BigInteger; + +public final class UnsignedLong extends Number implements Comparable +{ + private static final BigInteger TWO_TO_THE_SIXTY_FOUR = new BigInteger( new byte[] { (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }); + private static final BigInteger LONG_MAX_VALUE = BigInteger.valueOf(Long.MAX_VALUE); + + private static final UnsignedLong[] cachedValues = new UnsignedLong[256]; + + static + { + for(int i = 0; i<256; i++) + { + cachedValues[i] = new UnsignedLong(i); + } + } + + public static final UnsignedLong ZERO = cachedValues[0]; + + private final long _underlying; + + + public UnsignedLong(long underlying) + { + _underlying = underlying; + } + + @Override + public int intValue() + { + return (int) _underlying; + } + + @Override + public long longValue() + { + return _underlying; + } + + public BigInteger bigIntegerValue() + { + if(_underlying >= 0L) + { + return BigInteger.valueOf(_underlying); + } + else + { + return TWO_TO_THE_SIXTY_FOUR.add(BigInteger.valueOf(_underlying)); + } + } + + @Override + public float floatValue() + { + return (float) longValue(); + } + + @Override + public double doubleValue() + { + return (double) longValue(); + } + + @Override + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + + UnsignedLong that = (UnsignedLong) o; + + if (_underlying != that._underlying) + { + return false; + } + + return true; + } + + public int compareTo(UnsignedLong o) + { + return bigIntegerValue().compareTo(o.bigIntegerValue()); + } + + @Override + public int hashCode() + { + return (int)(_underlying ^ (_underlying >>> 32)); + } + + @Override + public String toString() + { + return String.valueOf(bigIntegerValue()); + } + + public static UnsignedLong valueOf(long underlying) + { + if((underlying & 0xFFL) == underlying) + { + return cachedValues[(int)underlying]; + } + else + { + return new UnsignedLong(underlying); + } + } + + public static UnsignedLong valueOf(final String value) + { + BigInteger bigInt = new BigInteger(value); + + return valueOf(bigInt); + } + + public static UnsignedLong valueOf(BigInteger bigInt) + { + if(bigInt.signum() == -1 || bigInt.bitLength() > 64) + { + throw new NumberFormatException("Value \""+bigInt+"\" lies outside the range [0 - 2^64)."); + } + else if(bigInt.compareTo(LONG_MAX_VALUE)>=0) + { + return UnsignedLong.valueOf(bigInt.longValue()); + } + else + { + return UnsignedLong.valueOf(TWO_TO_THE_SIXTY_FOUR.subtract(bigInt).negate().longValue()); + } + } +} Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedShort.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedShort.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedShort.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedShort.java Tue Oct 14 14:35:39 2014 @@ -1,134 +1,134 @@ -/* - * - * 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.amqp; - -public final class UnsignedShort extends Number implements Comparable -{ - private final short _underlying; - private static final UnsignedShort[] cachedValues = new UnsignedShort[256]; - - public static final UnsignedShort MAX_VALUE = new UnsignedShort((short) -1); - - static - { - for(short i = 0; i < 256; i++) - { - cachedValues[i] = new UnsignedShort(i); - } - } - - public UnsignedShort(short underlying) - { - _underlying = underlying; - } - - public short shortValue() - { - return _underlying; - } - - @Override - public int intValue() - { - return _underlying & 0xFFFF; - } - - @Override - public long longValue() - { - return ((long) _underlying) & 0xFFFFl; - } - - @Override - public float floatValue() - { - return (float) intValue(); - } - - @Override - public double doubleValue() - { - return (double) intValue(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - - UnsignedShort that = (UnsignedShort) o; - - if (_underlying != that._underlying) - { - return false; - } - - return true; - } - - public int compareTo(UnsignedShort o) - { - return Integer.signum(intValue() - o.intValue()); - } - - @Override - public int hashCode() - { - return _underlying; - } - - @Override - public String toString() - { - return String.valueOf(longValue()); - } - - public static UnsignedShort valueOf(short underlying) - { - if((underlying & 0xFF00) == 0) - { - return cachedValues[underlying]; - } - else - { - return new UnsignedShort(underlying); - } - } - - public static UnsignedShort valueOf(final String value) - { - int intVal = Integer.parseInt(value); - if(intVal < 0 || intVal >= (1<<16)) - { - throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<16) +")."); - } - return valueOf((short)intVal); - - } -} +/* + * + * 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.amqp; + +public final class UnsignedShort extends Number implements Comparable +{ + private final short _underlying; + private static final UnsignedShort[] cachedValues = new UnsignedShort[256]; + + public static final UnsignedShort MAX_VALUE = new UnsignedShort((short) -1); + + static + { + for(short i = 0; i < 256; i++) + { + cachedValues[i] = new UnsignedShort(i); + } + } + + public UnsignedShort(short underlying) + { + _underlying = underlying; + } + + public short shortValue() + { + return _underlying; + } + + @Override + public int intValue() + { + return _underlying & 0xFFFF; + } + + @Override + public long longValue() + { + return ((long) _underlying) & 0xFFFFl; + } + + @Override + public float floatValue() + { + return (float) intValue(); + } + + @Override + public double doubleValue() + { + return (double) intValue(); + } + + @Override + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + + UnsignedShort that = (UnsignedShort) o; + + if (_underlying != that._underlying) + { + return false; + } + + return true; + } + + public int compareTo(UnsignedShort o) + { + return Integer.signum(intValue() - o.intValue()); + } + + @Override + public int hashCode() + { + return _underlying; + } + + @Override + public String toString() + { + return String.valueOf(longValue()); + } + + public static UnsignedShort valueOf(short underlying) + { + if((underlying & 0xFF00) == 0) + { + return cachedValues[underlying]; + } + else + { + return new UnsignedShort(underlying); + } + } + + public static UnsignedShort valueOf(final String value) + { + int intVal = Integer.parseInt(value); + if(intVal < 0 || intVal >= (1<<16)) + { + throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<16) +")."); + } + return valueOf((short)intVal); + + } +} Added: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java?rev=1631772&view=auto ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java (added) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java Tue Oct 14 14:35:39 2014 @@ -0,0 +1,67 @@ +/* + * + * 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; + + +/** + * BaseHandler + * + */ + +public class BaseHandler implements Handler +{ + + @Override public void onConnectionInit(Event e) { onUnhandled(e); } + @Override public void onConnectionLocalOpen(Event e) { onUnhandled(e); } + @Override public void onConnectionRemoteOpen(Event e) { onUnhandled(e); } + @Override public void onConnectionLocalClose(Event e) { onUnhandled(e); } + @Override public void onConnectionRemoteClose(Event e) { onUnhandled(e); } + @Override public void onConnectionBound(Event e) { onUnhandled(e); } + @Override public void onConnectionUnbound(Event e) { onUnhandled(e); } + @Override public void onConnectionFinal(Event e) { onUnhandled(e); } + + @Override public void onSessionInit(Event e) { onUnhandled(e); } + @Override public void onSessionLocalOpen(Event e) { onUnhandled(e); } + @Override public void onSessionRemoteOpen(Event e) { onUnhandled(e); } + @Override public void onSessionLocalClose(Event e) { onUnhandled(e); } + @Override public void onSessionRemoteClose(Event e) { onUnhandled(e); } + @Override public void onSessionFinal(Event e) { onUnhandled(e); } + + @Override public void onLinkInit(Event e) { onUnhandled(e); } + @Override public void onLinkLocalOpen(Event e) { onUnhandled(e); } + @Override public void onLinkRemoteOpen(Event e) { onUnhandled(e); } + @Override public void onLinkLocalDetach(Event e) { onUnhandled(e); } + @Override public void onLinkRemoteDetach(Event e) { onUnhandled(e); } + @Override public void onLinkLocalClose(Event e) { onUnhandled(e); } + @Override public void onLinkRemoteClose(Event e) { onUnhandled(e); } + @Override public void onLinkFlow(Event e) { onUnhandled(e); } + @Override public void onLinkFinal(Event e) { onUnhandled(e); } + + @Override public void onDelivery(Event e) { onUnhandled(e); } + @Override public void onTransport(Event e) { onUnhandled(e); } + @Override public void onTransportError(Event e) { onUnhandled(e); } + @Override public void onTransportHeadClosed(Event e) { onUnhandled(e); } + @Override public void onTransportTailClosed(Event e) { onUnhandled(e); } + @Override public void onTransportClosed(Event e) { onUnhandled(e); } + + @Override public void onUnhandled(Event event) {} + +} Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java Tue Oct 14 14:35:39 2014 @@ -33,26 +33,26 @@ public interface Event CONNECTION_INIT, CONNECTION_BOUND, CONNECTION_UNBOUND, - CONNECTION_OPEN, + CONNECTION_LOCAL_OPEN, CONNECTION_REMOTE_OPEN, - CONNECTION_CLOSE, + CONNECTION_LOCAL_CLOSE, CONNECTION_REMOTE_CLOSE, CONNECTION_FINAL, SESSION_INIT, - SESSION_OPEN, + SESSION_LOCAL_OPEN, SESSION_REMOTE_OPEN, - SESSION_CLOSE, + SESSION_LOCAL_CLOSE, SESSION_REMOTE_CLOSE, SESSION_FINAL, LINK_INIT, - LINK_OPEN, + LINK_LOCAL_OPEN, LINK_REMOTE_OPEN, - LINK_CLOSE, - LINK_REMOTE_CLOSE, - LINK_DETACH, + LINK_LOCAL_DETACH, LINK_REMOTE_DETACH, + LINK_LOCAL_CLOSE, + LINK_REMOTE_CLOSE, LINK_FLOW, LINK_FINAL, @@ -69,6 +69,8 @@ public interface Event Object getContext(); + void dispatch(Handler handler); + Connection getConnection(); Session getSession(); Added: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/Handler.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/Handler.java?rev=1631772&view=auto ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/Handler.java (added) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/Handler.java Tue Oct 14 14:35:39 2014 @@ -0,0 +1,67 @@ +/* + * + * 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; + + +/** + * Handler + * + */ + +public interface Handler +{ + + void onConnectionInit(Event e); + void onConnectionLocalOpen(Event e); + void onConnectionRemoteOpen(Event e); + void onConnectionLocalClose(Event e); + void onConnectionRemoteClose(Event e); + void onConnectionBound(Event e); + void onConnectionUnbound(Event e); + void onConnectionFinal(Event e); + + void onSessionInit(Event e); + void onSessionLocalOpen(Event e); + void onSessionRemoteOpen(Event e); + void onSessionLocalClose(Event e); + void onSessionRemoteClose(Event e); + void onSessionFinal(Event e); + + void onLinkInit(Event e); + void onLinkLocalOpen(Event e); + void onLinkRemoteOpen(Event e); + void onLinkLocalDetach(Event e); + void onLinkRemoteDetach(Event e); + void onLinkLocalClose(Event e); + void onLinkRemoteClose(Event e); + void onLinkFlow(Event e); + void onLinkFinal(Event e); + + void onDelivery(Event e); + void onTransport(Event e); + void onTransportError(Event e); + void onTransportHeadClosed(Event e); + void onTransportTailClosed(Event e); + void onTransportClosed(Event e); + + void onUnhandled(Event e); + +} Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java Tue Oct 14 14:35:39 2014 @@ -617,12 +617,12 @@ public class ConnectionImpl extends Endp @Override void localOpen() { - put(Event.Type.CONNECTION_OPEN, this); + put(Event.Type.CONNECTION_LOCAL_OPEN, this); } @Override void localClose() { - put(Event.Type.CONNECTION_CLOSE, this); + put(Event.Type.CONNECTION_LOCAL_CLOSE, this); } } Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java Tue Oct 14 14:35:39 2014 @@ -21,6 +21,7 @@ package org.apache.qpid.proton.engine.impl; import org.apache.qpid.proton.engine.Event; +import org.apache.qpid.proton.engine.Handler; import org.apache.qpid.proton.engine.Connection; import org.apache.qpid.proton.engine.Session; import org.apache.qpid.proton.engine.Link; @@ -66,6 +67,102 @@ class EventImpl implements Event return context; } + public void dispatch(Handler handler) + { + switch (type) { + case CONNECTION_INIT: + handler.onConnectionInit(this); + break; + case CONNECTION_LOCAL_OPEN: + handler.onConnectionLocalOpen(this); + break; + case CONNECTION_REMOTE_OPEN: + handler.onConnectionRemoteOpen(this); + break; + case CONNECTION_LOCAL_CLOSE: + handler.onConnectionLocalClose(this); + break; + case CONNECTION_REMOTE_CLOSE: + handler.onConnectionRemoteClose(this); + break; + case CONNECTION_BOUND: + handler.onConnectionBound(this); + break; + case CONNECTION_UNBOUND: + handler.onConnectionUnbound(this); + break; + case CONNECTION_FINAL: + handler.onConnectionFinal(this); + break; + case SESSION_INIT: + handler.onSessionInit(this); + break; + case SESSION_LOCAL_OPEN: + handler.onSessionLocalOpen(this); + break; + case SESSION_REMOTE_OPEN: + handler.onSessionRemoteOpen(this); + break; + case SESSION_LOCAL_CLOSE: + handler.onSessionLocalClose(this); + break; + case SESSION_REMOTE_CLOSE: + handler.onSessionRemoteClose(this); + break; + case SESSION_FINAL: + handler.onSessionFinal(this); + break; + case LINK_INIT: + handler.onLinkInit(this); + break; + case LINK_LOCAL_OPEN: + handler.onLinkLocalOpen(this); + break; + case LINK_REMOTE_OPEN: + handler.onLinkRemoteOpen(this); + break; + case LINK_LOCAL_DETACH: + handler.onLinkLocalDetach(this); + break; + case LINK_REMOTE_DETACH: + handler.onLinkRemoteDetach(this); + break; + case LINK_LOCAL_CLOSE: + handler.onLinkLocalClose(this); + break; + case LINK_REMOTE_CLOSE: + handler.onLinkRemoteClose(this); + break; + case LINK_FLOW: + handler.onLinkFlow(this); + break; + case LINK_FINAL: + handler.onLinkFinal(this); + break; + case DELIVERY: + handler.onDelivery(this); + break; + case TRANSPORT: + handler.onTransport(this); + break; + case TRANSPORT_ERROR: + handler.onTransportError(this); + break; + case TRANSPORT_HEAD_CLOSED: + handler.onTransportHeadClosed(this); + break; + case TRANSPORT_TAIL_CLOSED: + handler.onTransportTailClosed(this); + break; + case TRANSPORT_CLOSED: + handler.onTransportClosed(this); + break; + default: + handler.onUnhandled(this); + break; + } + } + public Connection getConnection() { if (context instanceof Connection) { Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java Tue Oct 14 14:35:39 2014 @@ -391,19 +391,19 @@ public abstract class LinkImpl extends E @Override void localOpen() { - getConnectionImpl().put(Event.Type.LINK_OPEN, this); + getConnectionImpl().put(Event.Type.LINK_LOCAL_OPEN, this); } @Override void localClose() { - getConnectionImpl().put(Event.Type.LINK_CLOSE, this); + getConnectionImpl().put(Event.Type.LINK_LOCAL_CLOSE, this); } public void detach() { _detached = true; - getConnectionImpl().put(Event.Type.LINK_DETACH, this); + getConnectionImpl().put(Event.Type.LINK_LOCAL_DETACH, this); modified(); } Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java Tue Oct 14 14:35:39 2014 @@ -204,12 +204,12 @@ public class SessionImpl extends Endpoin @Override void localOpen() { - getConnectionImpl().put(Event.Type.SESSION_OPEN, this); + getConnectionImpl().put(Event.Type.SESSION_LOCAL_OPEN, this); } @Override void localClose() { - getConnectionImpl().put(Event.Type.SESSION_CLOSE, this); + getConnectionImpl().put(Event.Type.SESSION_LOCAL_CLOSE, this); } } Modified: qpid/proton/branches/examples/proton-j/src/main/resources/cengine.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/resources/cengine.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/resources/cengine.py (original) +++ qpid/proton/branches/examples/proton-j/src/main/resources/cengine.py Tue Oct 14 14:35:39 2014 @@ -954,23 +954,23 @@ from org.apache.qpid.proton.engine impor PN_CONNECTION_INIT = Event.Type.CONNECTION_INIT PN_CONNECTION_BOUND = Event.Type.CONNECTION_BOUND PN_CONNECTION_UNBOUND = Event.Type.CONNECTION_UNBOUND -PN_CONNECTION_OPEN = Event.Type.CONNECTION_OPEN +PN_CONNECTION_LOCAL_OPEN = Event.Type.CONNECTION_LOCAL_OPEN PN_CONNECTION_REMOTE_OPEN = Event.Type.CONNECTION_REMOTE_OPEN -PN_CONNECTION_CLOSE = Event.Type.CONNECTION_CLOSE +PN_CONNECTION_LOCAL_CLOSE = Event.Type.CONNECTION_LOCAL_CLOSE PN_CONNECTION_REMOTE_CLOSE = Event.Type.CONNECTION_REMOTE_CLOSE PN_CONNECTION_FINAL = Event.Type.CONNECTION_FINAL PN_SESSION_INIT = Event.Type.SESSION_INIT -PN_SESSION_OPEN = Event.Type.SESSION_OPEN +PN_SESSION_LOCAL_OPEN = Event.Type.SESSION_LOCAL_OPEN PN_SESSION_REMOTE_OPEN = Event.Type.SESSION_REMOTE_OPEN -PN_SESSION_CLOSE = Event.Type.SESSION_CLOSE +PN_SESSION_LOCAL_CLOSE = Event.Type.SESSION_LOCAL_CLOSE PN_SESSION_REMOTE_CLOSE = Event.Type.SESSION_REMOTE_CLOSE PN_SESSION_FINAL = Event.Type.SESSION_FINAL PN_LINK_INIT = Event.Type.LINK_INIT -PN_LINK_OPEN = Event.Type.LINK_OPEN +PN_LINK_LOCAL_OPEN = Event.Type.LINK_LOCAL_OPEN PN_LINK_REMOTE_OPEN = Event.Type.LINK_REMOTE_OPEN -PN_LINK_CLOSE = Event.Type.LINK_CLOSE +PN_LINK_LOCAL_CLOSE = Event.Type.LINK_LOCAL_CLOSE PN_LINK_REMOTE_CLOSE = Event.Type.LINK_REMOTE_CLOSE -PN_LINK_DETACH = Event.Type.LINK_DETACH +PN_LINK_LOCAL_DETACH = Event.Type.LINK_LOCAL_DETACH PN_LINK_REMOTE_DETACH = Event.Type.LINK_REMOTE_DETACH PN_LINK_FLOW = Event.Type.LINK_FLOW PN_LINK_FINAL = Event.Type.LINK_FINAL Modified: qpid/proton/branches/examples/tests/python/proton_tests/engine.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tests/python/proton_tests/engine.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tests/python/proton_tests/engine.py (original) +++ qpid/proton/branches/examples/tests/python/proton_tests/engine.py Tue Oct 14 14:35:39 2014 @@ -2139,13 +2139,13 @@ class EventTest(CollectorTest): rcv = ssn2.receiver("receiver") rcv.open() self.pump() - self.expect(Event.CONNECTION_OPEN, Event.TRANSPORT, - Event.SESSION_INIT, Event.SESSION_OPEN, - Event.TRANSPORT, Event.LINK_INIT, Event.LINK_OPEN, + self.expect(Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT, + Event.SESSION_INIT, Event.SESSION_LOCAL_OPEN, + Event.TRANSPORT, Event.LINK_INIT, Event.LINK_LOCAL_OPEN, Event.TRANSPORT) rcv.close() - self.expect(Event.LINK_CLOSE, Event.TRANSPORT) + self.expect(Event.LINK_LOCAL_CLOSE, Event.TRANSPORT) self.pump() rcv.free() del rcv @@ -2209,7 +2209,7 @@ class EventTest(CollectorTest): rcv.flow(10) self.pump() self.expect(Event.CONNECTION_INIT, Event.SESSION_INIT, - Event.LINK_INIT, Event.LINK_OPEN, Event.TRANSPORT) + Event.LINK_INIT, Event.LINK_LOCAL_OPEN, Event.TRANSPORT) snd.delivery("delivery") snd.send("Hello World!") snd.advance() @@ -2229,7 +2229,7 @@ class EventTest(CollectorTest): dlv = snd.delivery("delivery") snd.send("Hello World!") assert snd.advance() - self.expect(Event.LINK_OPEN, Event.TRANSPORT) + self.expect(Event.LINK_LOCAL_OPEN, Event.TRANSPORT) self.pump() self.expect(Event.LINK_FLOW) rdlv = rcv.current @@ -2276,7 +2276,7 @@ class EventTest(CollectorTest): t.bind(c) c.open() - self.expect(Event.CONNECTION_BOUND, Event.CONNECTION_OPEN, Event.TRANSPORT) + self.expect(Event.CONNECTION_BOUND, Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT) c2 = Connection() t2 = Transport() @@ -2293,7 +2293,7 @@ class EventTest(CollectorTest): pump(t, t2) - self.expect(Event.CONNECTION_CLOSE, Event.TRANSPORT, + self.expect(Event.CONNECTION_LOCAL_CLOSE, Event.TRANSPORT, Event.TRANSPORT_HEAD_CLOSED, Event.TRANSPORT_CLOSED) def testLinkDetach(self): @@ -2307,7 +2307,7 @@ class EventTest(CollectorTest): l1 = s1.sender("asdf") l1.open() l1.detach() - self.expect_until(Event.LINK_DETACH, Event.TRANSPORT) + self.expect_until(Event.LINK_LOCAL_DETACH, Event.TRANSPORT) c2 = Connection() c2.collect(self.collector) @@ -2339,15 +2339,15 @@ class TeardownLeakTest(PeerTest): def doLeak(self, local, remote): self.connection.open() self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND, - Event.CONNECTION_OPEN, Event.TRANSPORT) + Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT) ssn = self.connection.session() ssn.open() - self.expect(Event.SESSION_INIT, Event.SESSION_OPEN, Event.TRANSPORT) + self.expect(Event.SESSION_INIT, Event.SESSION_LOCAL_OPEN, Event.TRANSPORT) snd = ssn.sender("sender") snd.open() - self.expect(Event.LINK_INIT, Event.LINK_OPEN, Event.TRANSPORT) + self.expect(Event.LINK_INIT, Event.LINK_LOCAL_OPEN, Event.TRANSPORT) self.pump() @@ -2364,11 +2364,11 @@ class TeardownLeakTest(PeerTest): if local: snd.close() # ha!! - self.expect(Event.LINK_CLOSE, Event.TRANSPORT) + self.expect(Event.LINK_LOCAL_CLOSE, Event.TRANSPORT) ssn.close() - self.expect(Event.SESSION_CLOSE, Event.TRANSPORT) + self.expect(Event.SESSION_LOCAL_CLOSE, Event.TRANSPORT) self.connection.close() - self.expect(Event.CONNECTION_CLOSE, Event.TRANSPORT) + self.expect(Event.CONNECTION_LOCAL_CLOSE, Event.TRANSPORT) if remote: self.peer.link_head(0).close() # ha!! Copied: qpid/proton/branches/examples/tools/cmake/Modules/ProtonFindPerl.cmake (from r1630895, qpid/proton/branches/examples/tools/cmake/Modules/FindPerlLibs.cmake) URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tools/cmake/Modules/ProtonFindPerl.cmake?p2=qpid/proton/branches/examples/tools/cmake/Modules/ProtonFindPerl.cmake&p1=qpid/proton/branches/examples/tools/cmake/Modules/FindPerlLibs.cmake&r1=1630895&r2=1631772&rev=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tools/cmake/Modules/FindPerlLibs.cmake (original) +++ qpid/proton/branches/examples/tools/cmake/Modules/ProtonFindPerl.cmake Tue Oct 14 14:35:39 2014 @@ -4,6 +4,9 @@ # include(${CMAKE_CURRENT_LIST_DIR}/FindPerlLibs.cmake) +include(FindPerl) +include(FindPerlLibs) + if(NOT PERLLIBS_FOUND) MESSAGE ( STATUS "Trying alternative search for Perl" ) @@ -25,6 +28,11 @@ if(NOT PERLLIBS_FOUND) IF ( NOT PERL_RETURN_VALUE ) FIND_PATH ( PERL_INCLUDE_PATH perl.h ${PERL_OUTPUT}/CORE ) + + IF (PERL_INCLUDE_PATH MATCHES .*-NOTFOUND OR NOT PERL_INCLUDE_PATH) + MESSAGE(STATUS "Could not find perl.h") + ENDIF () + ENDIF ( NOT PERL_RETURN_VALUE ) # if either the library path is not found not set at all @@ -61,13 +69,13 @@ if(NOT PERLLIBS_FOUND) ENDIF ( NOT PERL_RETURN_VALUE ) ENDIF ( PERL_LIBRARY MATCHES .*-NOTFOUND OR NOT PERL_LIBRARY ) - IF ( PERL_LIBRARY ) - MESSAGE ( STATUS "Found PerlLibs: ${PERL_LIBRARY}" ) + IF(PERL_LIBRARY MATCHES .*-NOTFOUND OR NOT PERL_LIBRARY OR + PERL_INCLUDE_PATH MATCHES .*-NOTFOUND OR NOT PERL_INCLUDE_PATH) + MESSAGE (STATUS "No Perl devel environment found - skipping Perl bindings") + SET (DEFAULT_PERL OFF) ELSE() - MESSAGE ( STATUS "PerlLibs Not Found" ) - ENDIF ( PERL_LIBRARY ) + MESSAGE ( STATUS "Found PerlLibs: ${PERL_LIBRARY}" ) + SET (DEFAULT_PERL ON) + ENDIF() - if (PERL_LIBRARY) - set (DEFAULT_PERL ON) - endif (PERL_LIBRARY) endif(NOT PERLLIBS_FOUND) Modified: qpid/proton/branches/examples/tutorial/client.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/client.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/client.py (original) +++ qpid/proton/branches/examples/tutorial/client.py Tue Oct 14 14:35:39 2014 @@ -19,9 +19,9 @@ # from proton import Message -from proton_events import EventLoop, IncomingMessageHandler +from proton_events import EventLoop, ClientHandler -class Client(IncomingMessageHandler): +class Client(ClientHandler): def __init__(self, eventloop, host, address, requests): self.eventloop = eventloop self.conn = eventloop.connect(host) @@ -33,7 +33,7 @@ class Client(IncomingMessageHandler): req = Message(reply_to=self.receiver.remote_source.address, body=self.requests[0]) self.sender.send_msg(req) - def on_link_open(self, event): + def on_link_opened(self, event): self.next_request() def on_message(self, event): Modified: qpid/proton/branches/examples/tutorial/client_http.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/client_http.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/client_http.py (original) +++ qpid/proton/branches/examples/tutorial/client_http.py Tue Oct 14 14:35:39 2014 @@ -19,12 +19,12 @@ # from proton import Message -from proton_events import IncomingMessageHandler +from proton_events import ClientHandler from proton_tornado import TornadoLoop from tornado.ioloop import IOLoop import tornado.web -class ExampleHandler(tornado.web.RequestHandler, IncomingMessageHandler): +class ExampleHandler(tornado.web.RequestHandler, ClientHandler): def initialize(self, loop): self.loop = loop @@ -39,7 +39,7 @@ class ExampleHandler(tornado.web.Request self.sender = self.conn.create_sender("examples") self.conn.create_receiver(None, dynamic=True, handler=self) - def on_link_open(self, event): + def on_link_opened(self, event): req = Message(reply_to=event.link.remote_source.address, body=self.get_body_argument("message")) self.sender.send_msg(req) Modified: qpid/proton/branches/examples/tutorial/db_recv.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/db_recv.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/db_recv.py (original) +++ qpid/proton/branches/examples/tutorial/db_recv.py Tue Oct 14 14:35:39 2014 @@ -18,10 +18,10 @@ # under the License. # -from proton_events import ApplicationEvent, BaseHandler, EventLoop +from proton_events import ApplicationEvent, ClientHandler, EventLoop from db_common import Db -class Recv(BaseHandler): +class Recv(ClientHandler): def __init__(self, host, address): self.eventloop = EventLoop() self.host = host Modified: qpid/proton/branches/examples/tutorial/db_send.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/db_send.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/db_send.py (original) +++ qpid/proton/branches/examples/tutorial/db_send.py Tue Oct 14 14:35:39 2014 @@ -21,10 +21,10 @@ import Queue import time from proton import Message -from proton_events import ApplicationEvent, BaseHandler, EventLoop +from proton_events import ApplicationEvent, ClientHandler, EventLoop from db_common import Db -class Send(BaseHandler): +class Send(ClientHandler): def __init__(self, host, address): self.eventloop = EventLoop() self.address = address Modified: qpid/proton/branches/examples/tutorial/helloworld.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/helloworld.py (original) +++ qpid/proton/branches/examples/tutorial/helloworld.py Tue Oct 14 14:35:39 2014 @@ -21,12 +21,12 @@ from proton import Message import proton_events -class HelloWorld(proton_events.BaseHandler): +class HelloWorld(proton_events.ClientHandler): def __init__(self, conn, address): self.conn = conn self.address = address - def on_connection_open(self, event): + def on_connection_opened(self, event): self.conn.create_receiver(self.address) self.conn.create_sender(self.address) Modified: qpid/proton/branches/examples/tutorial/helloworld_alt.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_alt.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/helloworld_alt.py (original) +++ qpid/proton/branches/examples/tutorial/helloworld_alt.py Tue Oct 14 14:35:39 2014 @@ -19,7 +19,7 @@ # from proton import Message -from proton_events import ErrorHandler, EventLoop, IncomingMessageHandler, OutgoingMessageHandler +from proton_events import ClientEndpointHandler, EventLoop, IncomingMessageHandler, OutgoingMessageHandler class HelloWorldReceiver(IncomingMessageHandler): def on_message(self, event): @@ -31,13 +31,13 @@ class HelloWorldSender(OutgoingMessageHa event.link.send_msg(Message(body=u"Hello World!")) event.link.close() -class HelloWorld(ErrorHandler): +class HelloWorld(ClientEndpointHandler): def __init__(self, url, address): self.eventloop = EventLoop() self.conn = self.eventloop.connect(url, handler=self) self.address = address - def on_connection_open(self, event): + def on_connection_opened(self, event): self.conn.create_receiver(self.address, handler=HelloWorldReceiver()) self.conn.create_sender(self.address, handler=HelloWorldSender()) Modified: qpid/proton/branches/examples/tutorial/helloworld_direct.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_direct.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/helloworld_direct.py (original) +++ qpid/proton/branches/examples/tutorial/helloworld_direct.py Tue Oct 14 14:35:39 2014 @@ -19,29 +19,31 @@ # from proton import Message -from proton_events import BaseHandler, EventLoop, FlowController, Handshaker +from proton_events import ClientHandler, EventLoop, FlowController, Handshaker, IncomingMessageHandler -class HelloWorldReceiver(BaseHandler): +class HelloWorldReceiver(IncomingMessageHandler): def on_message(self, event): print event.message.body event.connection.close() -class HelloWorld(BaseHandler): +class HelloWorld(ClientHandler): def __init__(self, eventloop, url, address): self.eventloop = eventloop self.acceptor = eventloop.listen(url) self.conn = eventloop.connect(url, handler=self) self.address = address - def on_connection_open(self, event): + def on_connection_opened(self, event): self.conn.create_sender(self.address) - def on_link_flow(self, event): - event.link.send_msg(Message(body=u"Hello World!")) - event.link.close() + def on_credit(self, event): + event.sender.send_msg(Message(body=u"Hello World!")) + event.sender.close() - def on_connection_close(self, event): + def on_accepted(self, event): self.conn.close() + + def on_connection_closed(self, event): self.acceptor.close() def run(self): Modified: qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py (original) +++ qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py Tue Oct 14 14:35:39 2014 @@ -19,7 +19,7 @@ # from proton import Message -from proton_events import ErrorHandler, EventLoop, FlowController, Handshaker, IncomingMessageHandler, OutgoingMessageHandler +from proton_events import ClientEndpointHandler, EventLoop, FlowController, Handshaker, IncomingMessageHandler, OutgoingMessageHandler class HelloWorldReceiver(IncomingMessageHandler): def on_message(self, event): @@ -28,21 +28,23 @@ class HelloWorldReceiver(IncomingMessage class HelloWorldSender(OutgoingMessageHandler): def on_credit(self, event): - event.link.send_msg(Message(body=u"Hello World!")) - event.link.close() + event.sender.send_msg(Message(body=u"Hello World!")) + event.sender.close() -class HelloWorld(ErrorHandler): + def on_accepted(self, event): + event.connection.close() + +class HelloWorld(ClientEndpointHandler): def __init__(self, eventloop, url, address): self.eventloop = eventloop self.acceptor = eventloop.listen(url) self.conn = eventloop.connect(url, handler=self) self.address = address - def on_connection_open(self, event): + def on_connection_opened(self, event): self.conn.create_sender(self.address, handler=HelloWorldSender()) - def on_connection_close(self, event): - self.conn.close() + def on_connection_closed(self, event): self.acceptor.close() def run(self): Modified: qpid/proton/branches/examples/tutorial/helloworld_direct_tornado.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_direct_tornado.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/helloworld_direct_tornado.py (original) +++ qpid/proton/branches/examples/tutorial/helloworld_direct_tornado.py Tue Oct 14 14:35:39 2014 @@ -19,7 +19,7 @@ # from proton import Message -from proton_events import FlowController, Handshaker, IncomingMessageHandler +from proton_events import ClientHandler, FlowController, Handshaker, IncomingMessageHandler from proton_tornado import TornadoLoop class HelloWorldReceiver(IncomingMessageHandler): @@ -27,33 +27,26 @@ class HelloWorldReceiver(IncomingMessage print event.message.body event.connection.close() -class HelloWorldSender(object): - def on_link_flow(self, event): - event.link.send_msg(Message(body=u"Hello World!")) - event.link.close() - -class HelloWorld(object): +class HelloWorld(ClientHandler): def __init__(self, eventloop, url, address): self.eventloop = eventloop self.acceptor = eventloop.listen(url) self.conn = eventloop.connect(url, handler=self) self.address = address - def on_connection_open(self, event): - self.conn.create_sender(self.address, handler=HelloWorldSender()) - - def on_link_close(self, event): - self.closed(event.link.remote_condition) + def on_connection_opened(self, event): + self.conn.create_sender(self.address) - def on_connection_close(self, event): - self.closed(event.connection.remote_condition) - self.eventloop.stop() + def on_credit(self, event): + event.sender.send_msg(Message(body=u"Hello World!")) + event.sender.close() - def closed(self, error=None): - if error: - print "Closed due to %s" % error + def on_accepted(self, event): self.conn.close() + + def on_connection_closed(self, event): self.acceptor.close() + self.eventloop.stop() def run(self): self.eventloop.run() Modified: qpid/proton/branches/examples/tutorial/helloworld_simple.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_simple.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/helloworld_simple.py (original) +++ qpid/proton/branches/examples/tutorial/helloworld_simple.py Tue Oct 14 14:35:39 2014 @@ -21,10 +21,10 @@ from proton import Message import proton_events -class HelloWorld(proton_events.BaseHandler): +class HelloWorld(proton_events.ClientHandler): def on_credit(self, event): - event.link.send_msg(Message(body=u"Hello World!")) - event.link.close() + event.sender.send_msg(Message(body=u"Hello World!")) + event.sender.close() def on_message(self, event): print event.message.body Modified: qpid/proton/branches/examples/tutorial/helloworld_tornado.py URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_tornado.py?rev=1631772&r1=1631771&r2=1631772&view=diff ============================================================================== --- qpid/proton/branches/examples/tutorial/helloworld_tornado.py (original) +++ qpid/proton/branches/examples/tutorial/helloworld_tornado.py Tue Oct 14 14:35:39 2014 @@ -19,44 +19,30 @@ # from proton import Message -from proton_events import IncomingMessageHandler +from proton_events import ClientHandler from proton_tornado import TornadoLoop -class HelloWorldReceiver(IncomingMessageHandler): - def on_message(self, event): - print event.message.body - event.connection.close() - -class HelloWorldSender(object): - def on_link_flow(self, event): - event.link.send_msg(Message(body=u"Hello World!")) - event.link.close() - -class HelloWorld(object): +class HelloWorld(ClientHandler): def __init__(self, eventloop, url, address): self.eventloop = eventloop self.conn = eventloop.connect(url, handler=self) self.address = address - def on_connection_open(self, event): - self.conn.create_receiver(self.address, handler=HelloWorldReceiver()) + def on_connection_opened(self, event): + self.conn.create_receiver(self.address) + self.conn.create_sender(self.address) + + def on_credit(self, event): + event.sender.send_msg(Message(body=u"Hello World!")) + event.sender.close() - def on_link_open(self, event): - if event.link.is_receiver: - self.conn.create_sender(self.address, handler=HelloWorldSender()) - - def on_link_close(self, event): - self.closed(event.link.remote_condition) + def on_message(self, event): + print event.message.body + event.connection.close() - def on_connection_close(self, event): - self.closed(event.connection.remote_condition) + def on_connection_closed(self, event): self.eventloop.stop() - def closed(self, error=None): - if error: - print "Closed due to %s" % error - self.conn.close() - def run(self): self.eventloop.run() --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org For additional commands, e-mail: commits-help@qpid.apache.org