You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/01/09 15:24:37 UTC
[01/34] qpid-proton git commit: PROTON-1380: Avoid freeing strings we
pass to cyrus before cyrus finishes using them.
Repository: qpid-proton
Updated Branches:
refs/heads/go1 4afe30d87 -> 793e21010
PROTON-1380: Avoid freeing strings we pass to cyrus before cyrus finishes using them.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/440131e0
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/440131e0
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/440131e0
Branch: refs/heads/go1
Commit: 440131e0efabc14df338125b6df0b0e88527614e
Parents: 4abf23a
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Jan 4 14:11:27 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Jan 4 14:11:27 2017 -0500
----------------------------------------------------------------------
proton-c/src/sasl/cyrus_sasl.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/440131e0/proton-c/src/sasl/cyrus_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/cyrus_sasl.c b/proton-c/src/sasl/cyrus_sasl.c
index 0d81489..ef1db9d 100644
--- a/proton-c/src/sasl/cyrus_sasl.c
+++ b/proton-c/src/sasl/cyrus_sasl.c
@@ -108,8 +108,9 @@ static const sasl_callback_t pni_user_callbacks[] = {
// Machinery to initialise the cyrus library only once even in a multithreaded environment
// Relies on pthreads.
+static const char * const default_config_name = "proton-server";
static char *pni_cyrus_config_dir = NULL;
-static const char *pni_cyrus_config_name = "proton-server";
+static char *pni_cyrus_config_name = NULL;
static pthread_mutex_t pni_cyrus_mutex = PTHREAD_MUTEX_INITIALIZER;
static bool pni_cyrus_client_started = false;
static bool pni_cyrus_server_started = false;
@@ -119,6 +120,8 @@ static void pni_cyrus_finish(void) {
pthread_mutex_lock(&pni_cyrus_mutex);
if (pni_cyrus_client_started) sasl_client_done();
if (pni_cyrus_server_started) sasl_server_done();
+ free(pni_cyrus_config_dir);
+ free(pni_cyrus_config_name);
pthread_mutex_unlock(&pni_cyrus_mutex);
}
@@ -145,7 +148,7 @@ static void pni_cyrus_server_once(void) {
result = sasl_set_path(SASL_PATH_TYPE_CONFIG, pni_cyrus_config_dir);
}
if (result==SASL_OK) {
- result = sasl_server_init(NULL, pni_cyrus_config_name);
+ result = sasl_server_init(NULL, pni_cyrus_config_name ? pni_cyrus_config_name : default_config_name);
}
pni_cyrus_server_started = true;
pni_cyrus_server_init_rc = result;
@@ -166,8 +169,10 @@ bool pni_init_client(pn_transport_t* transport) {
int result;
sasl_conn_t *cyrus_conn = NULL;
do {
- if (sasl->config_dir) {
- pni_cyrus_config_dir = sasl->config_dir;
+ // If pni_cyrus_config_dir already set then we already called pni_cyrus_client_start or pni_cyrus_server_start
+ // and the directory is already fixed - don't change
+ if (sasl->config_dir && !pni_cyrus_config_dir) {
+ pni_cyrus_config_dir = pn_strdup(sasl->config_dir);
}
pni_cyrus_client_start();
@@ -304,12 +309,16 @@ bool pni_init_server(pn_transport_t* transport)
int result;
sasl_conn_t *cyrus_conn = NULL;
do {
- if (sasl->config_dir) {
- pni_cyrus_config_dir = sasl->config_dir;
+ // If pni_cyrus_config_dir already set then we already called pni_cyrus_client_start or pni_cyrus_server_start
+ // and the directory is already fixed - don't change
+ if (sasl->config_dir && !pni_cyrus_config_dir) {
+ pni_cyrus_config_dir = pn_strdup(sasl->config_dir);
}
- if (sasl->config_name) {
- pni_cyrus_config_name = sasl->config_name;
+ // If pni_cyrus_config_name already set then we already called pni_cyrus_server_start
+ // and the name is already fixed - don't change
+ if (sasl->config_name && !pni_cyrus_config_name) {
+ pni_cyrus_config_name = pn_strdup(sasl->config_name);
}
pni_cyrus_server_start();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[24/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/BooleanType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/BooleanType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/BooleanType.java
deleted file mode 100644
index d87dd19..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/BooleanType.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public final class BooleanType extends AbstractPrimitiveType<Boolean>
-{
-
- private static final byte BYTE_0 = (byte) 0;
- private static final byte BYTE_1 = (byte) 1;
-
- private org.apache.qpid.proton.codec.BooleanType.BooleanEncoding _trueEncoder;
- private org.apache.qpid.proton.codec.BooleanType.BooleanEncoding _falseEncoder;
- private org.apache.qpid.proton.codec.BooleanType.BooleanEncoding _booleanEncoder;
-
- public static interface BooleanEncoding extends PrimitiveTypeEncoding<Boolean>
- {
- void write(boolean b);
- void writeValue(boolean b);
-
- boolean readPrimitiveValue();
- }
-
- BooleanType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _trueEncoder = new TrueEncoding(encoder, decoder);
- _falseEncoder = new FalseEncoding(encoder, decoder);
- _booleanEncoder = new AllBooleanEncoding(encoder, decoder);
-
- encoder.register(Boolean.class, this);
- decoder.register(this);
- }
-
- public Class<Boolean> getTypeClass()
- {
- return Boolean.class;
- }
-
- public BooleanEncoding getEncoding(final Boolean val)
- {
- return val ? _trueEncoder : _falseEncoder;
- }
-
- public BooleanEncoding getEncoding(final boolean val)
- {
- return val ? _trueEncoder : _falseEncoder;
- }
-
- public void writeValue(final boolean val)
- {
- getEncoding(val).write(val);
- }
-
-
-
-
- public BooleanEncoding getCanonicalEncoding()
- {
- return _booleanEncoder;
- }
-
- public Collection<BooleanEncoding> getAllEncodings()
- {
- return Arrays.asList(_trueEncoder, _falseEncoder, _booleanEncoder);
- }
-
- private class TrueEncoding extends FixedSizePrimitiveTypeEncoding<Boolean> implements BooleanEncoding
- {
-
- public TrueEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 0;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.BOOLEAN_TRUE;
- }
-
- public BooleanType getType()
- {
- return BooleanType.this;
- }
-
- public void writeValue(final Boolean val)
- {
- }
-
- public void write(final boolean b)
- {
- writeConstructor();
- }
-
- public void writeValue(final boolean b)
- {
- }
-
- public boolean encodesSuperset(final TypeEncoding<Boolean> encoding)
- {
- return encoding == this;
- }
-
- public Boolean readValue()
- {
- return Boolean.TRUE;
- }
-
- public boolean readPrimitiveValue()
- {
- return true;
- }
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-
-
- private class FalseEncoding extends FixedSizePrimitiveTypeEncoding<Boolean> implements org.apache.qpid.proton.codec.BooleanType.BooleanEncoding
- {
-
- public FalseEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 0;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.BOOLEAN_FALSE;
- }
-
- public BooleanType getType()
- {
- return BooleanType.this;
- }
-
- public void writeValue(final Boolean val)
- {
- }
-
- public void write(final boolean b)
- {
- writeConstructor();
- }
-
- public void writeValue(final boolean b)
- {
- }
-
- public boolean readPrimitiveValue()
- {
- return false;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Boolean> encoding)
- {
- return encoding == this;
- }
-
- public Boolean readValue()
- {
- return Boolean.FALSE;
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-
- private class AllBooleanEncoding extends FixedSizePrimitiveTypeEncoding<Boolean> implements BooleanEncoding
- {
-
- public AllBooleanEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- public BooleanType getType()
- {
- return BooleanType.this;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.BOOLEAN;
- }
-
- public void writeValue(final Boolean val)
- {
- getEncoder().writeRaw(val ? BYTE_1 : BYTE_0);
- }
-
- public void write(final boolean val)
- {
- writeConstructor();
- getEncoder().writeRaw(val ? BYTE_1 : BYTE_0);
- }
-
- public void writeValue(final boolean b)
- {
- getEncoder().writeRaw(b ? BYTE_1 : BYTE_0);
- }
-
- public boolean readPrimitiveValue()
- {
-
- return getDecoder().readRawByte() != BYTE_0;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Boolean> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Boolean readValue()
- {
- return readPrimitiveValue() ? Boolean.TRUE : Boolean.FALSE;
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteBufferDecoder.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteBufferDecoder.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteBufferDecoder.java
deleted file mode 100644
index 39718b7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteBufferDecoder.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.nio.ByteBuffer;
-
-public interface ByteBufferDecoder extends Decoder
-{
- public void setByteBuffer(ByteBuffer buffer);
-
- public int getByteBufferRemaining();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteBufferEncoder.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteBufferEncoder.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteBufferEncoder.java
deleted file mode 100644
index b773279..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteBufferEncoder.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.nio.ByteBuffer;
-
-public interface ByteBufferEncoder extends Encoder
-{
- public void setByteBuffer(ByteBuffer buf);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteType.java
deleted file mode 100644
index b35f4f1..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ByteType.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class ByteType extends AbstractPrimitiveType<Byte>
-{
- private ByteEncoding _byteEncoding;
-
- ByteType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _byteEncoding = new ByteEncoding(encoder, decoder);
- encoder.register(Byte.class, this);
- decoder.register(this);
- }
-
- public Class<Byte> getTypeClass()
- {
- return Byte.class;
- }
-
- public ByteEncoding getEncoding(final Byte val)
- {
- return _byteEncoding;
- }
-
-
- public ByteEncoding getCanonicalEncoding()
- {
- return _byteEncoding;
- }
-
- public Collection<ByteEncoding> getAllEncodings()
- {
- return Collections.singleton(_byteEncoding);
- }
-
- public void writeType(byte b)
- {
- _byteEncoding.write(b);
- }
-
-
- public class ByteEncoding extends FixedSizePrimitiveTypeEncoding<Byte>
- {
-
- public ByteEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.BYTE;
- }
-
- public ByteType getType()
- {
- return ByteType.this;
- }
-
- public void writeValue(final Byte val)
- {
- getEncoder().writeRaw(val);
- }
-
-
- public void write(final byte val)
- {
- writeConstructor();
- getEncoder().writeRaw(val);
- }
-
- public void writeValue(final byte val)
- {
- getEncoder().writeRaw(val);
- }
-
- public boolean encodesSuperset(final TypeEncoding<Byte> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Byte readValue()
- {
- return readPrimitiveValue();
- }
-
- public byte readPrimitiveValue()
- {
- return getDecoder().readRawByte();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/CharacterType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/CharacterType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/CharacterType.java
deleted file mode 100644
index 8084495..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/CharacterType.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class CharacterType extends AbstractPrimitiveType<Character>
-{
- private CharacterEncoding _characterEncoding;
-
- CharacterType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _characterEncoding = new CharacterEncoding(encoder, decoder);
- encoder.register(Character.class, this);
- decoder.register(this);
- }
-
- public Class<Character> getTypeClass()
- {
- return Character.class;
- }
-
- public CharacterEncoding getEncoding(final Character val)
- {
- return _characterEncoding;
- }
-
-
- public CharacterEncoding getCanonicalEncoding()
- {
- return _characterEncoding;
- }
-
- public Collection<CharacterEncoding> getAllEncodings()
- {
- return Collections.singleton(_characterEncoding);
- }
-
- public void write(char c)
- {
- _characterEncoding.write(c);
- }
-
- public class CharacterEncoding extends FixedSizePrimitiveTypeEncoding<Character>
- {
-
- public CharacterEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 4;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.CHAR;
- }
-
- public CharacterType getType()
- {
- return CharacterType.this;
- }
-
- public void writeValue(final Character val)
- {
- getEncoder().writeRaw((int)val.charValue() & 0xffff);
- }
-
- public void writeValue(final char val)
- {
- getEncoder().writeRaw((int)val & 0xffff);
- }
-
- public void write(final char c)
- {
- writeConstructor();
- getEncoder().writeRaw((int)c & 0xffff);
-
- }
-
- public boolean encodesSuperset(final TypeEncoding<Character> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Character readValue()
- {
- return readPrimitiveValue();
- }
-
- public char readPrimitiveValue()
- {
- return (char) (getDecoder().readRawInt() & 0xffff);
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/Codec.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/Codec.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/Codec.java
deleted file mode 100644
index 1aa2143..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/Codec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-/**
- * Codec
- *
- */
-
-public final class Codec
-{
-
- private Codec()
- {
- }
-
- public static Data data(long capacity)
- {
- return Data.Factory.create();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeWritableBuffer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeWritableBuffer.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeWritableBuffer.java
deleted file mode 100644
index 5786924..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeWritableBuffer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-package org.apache.qpid.proton.codec;
-/*
- *
- * 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.
- *
-*/
-
-
-import java.nio.ByteBuffer;
-
-public class CompositeWritableBuffer implements WritableBuffer
-{
- private final WritableBuffer _first;
- private final WritableBuffer _second;
-
- public CompositeWritableBuffer(WritableBuffer first, WritableBuffer second)
- {
- _first = first;
- _second = second;
- }
-
- public void put(byte b)
- {
- (_first.hasRemaining() ? _first : _second).put(b);
- }
-
- public void putFloat(float f)
- {
- putInt(Float.floatToRawIntBits(f));
- }
-
- public void putDouble(double d)
- {
- putLong(Double.doubleToRawLongBits(d));
- }
-
- public void putShort(short s)
- {
- int remaining = _first.remaining();
- if(remaining >= 2)
- {
- _first.putShort(s);
- }
- else if(remaining ==0 )
- {
- _second.putShort(s);
- }
- else
- {
- ByteBuffer wrap = ByteBuffer.wrap(new byte[2]);
- wrap.putShort(s);
- wrap.flip();
- put(wrap);
- }
- }
-
- public void putInt(int i)
- {
- int remaining = _first.remaining();
- if(remaining >= 4)
- {
- _first.putInt(i);
- }
- else if(remaining ==0 )
- {
- _second.putInt(i);
- }
- else
- {
- ByteBuffer wrap = ByteBuffer.wrap(new byte[4]);
- wrap.putInt(i);
- wrap.flip();
- put(wrap);
- }
- }
-
- public void putLong(long l)
- {
- int remaining = _first.remaining();
- if(remaining >= 8)
- {
- _first.putLong(l);
- }
- else if(remaining ==0 )
- {
- _second.putLong(l);
- }
- else
- {
- ByteBuffer wrap = ByteBuffer.wrap(new byte[8]);
- wrap.putLong(l);
- wrap.flip();
- put(wrap);
- }
- }
-
- public boolean hasRemaining()
- {
- return _first.hasRemaining() || _second.hasRemaining();
- }
-
- public int remaining()
- {
- return _first.remaining()+_second.remaining();
- }
-
- public int position()
- {
- return _first.position()+_second.position();
- }
-
- public int limit()
- {
- return _first.limit() + _second.limit();
- }
-
- public void position(int position)
- {
- int first_limit = _first.limit();
- if( position <= first_limit )
- {
- _first.position(position);
- _second.position(0);
- }
- else
- {
- _first.position(first_limit);
- _second.position(position - first_limit);
- }
- }
-
- public void put(byte[] src, int offset, int length)
- {
- final int firstRemaining = _first.remaining();
- if(firstRemaining > 0)
- {
- if(firstRemaining >= length)
- {
- _first.put(src, offset, length);
- return;
- }
- else
- {
- _first.put(src,offset, firstRemaining);
- }
- }
- _second.put(src, offset+firstRemaining, length-firstRemaining);
- }
-
- public void put(ByteBuffer payload)
- {
- int firstRemaining = _first.remaining();
- if(firstRemaining > 0)
- {
- if(firstRemaining >= payload.remaining())
- {
- _first.put(payload);
- return;
- }
- else
- {
- int limit = payload.limit();
- payload.limit(payload.position()+firstRemaining);
- _first.put(payload);
- payload.limit(limit);
- }
- }
- _second.put(payload);
- }
-
- @Override
- public String toString()
- {
- return _first.toString() + " + "+_second.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java
deleted file mode 100644
index 9d9fd94..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.math.BigDecimal;
-import java.nio.ByteBuffer;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Decimal128;
-import org.apache.qpid.proton.amqp.Decimal32;
-import org.apache.qpid.proton.amqp.Decimal64;
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-import org.apache.qpid.proton.codec.impl.DataImpl;
-
-public interface Data
-{
-
- public static final class Factory {
-
- public static Data create() {
- return new DataImpl();
- }
-
- }
-
-
- enum DataType
- {
- NULL,
- BOOL,
- UBYTE,
- BYTE,
- USHORT,
- SHORT,
- UINT,
- INT,
- CHAR,
- ULONG,
- LONG,
- TIMESTAMP,
- FLOAT,
- DOUBLE,
- DECIMAL32,
- DECIMAL64,
- DECIMAL128,
- UUID,
- BINARY,
- STRING,
- SYMBOL,
- DESCRIBED,
- ARRAY,
- LIST,
- MAP
- }
-
- void free();
-// int errno();
-// String error();
-
- void clear();
- long size();
- void rewind();
- DataType next();
- DataType prev();
- boolean enter();
- boolean exit();
- boolean lookup(String name);
-
- DataType type();
-
-// int print();
-// int format(ByteBuffer buf);
- Binary encode();
- long encodedSize();
- long encode(ByteBuffer buf);
- long decode(ByteBuffer buf);
-
- void putList();
- void putMap();
- void putArray(boolean described, DataType type);
- void putDescribed();
- void putNull();
- void putBoolean(boolean b);
- void putUnsignedByte(UnsignedByte ub);
- void putByte(byte b);
- void putUnsignedShort(UnsignedShort us);
- void putShort(short s);
- void putUnsignedInteger(UnsignedInteger ui);
- void putInt(int i);
- void putChar(int c);
- void putUnsignedLong(UnsignedLong ul);
- void putLong(long l);
- void putTimestamp(Date t);
- void putFloat(float f);
- void putDouble(double d);
- void putDecimal32(Decimal32 d);
- void putDecimal64(Decimal64 d);
- void putDecimal128(Decimal128 d);
- void putUUID(UUID u);
- void putBinary(Binary bytes);
- void putBinary(byte[] bytes);
- void putString(String string);
- void putSymbol(Symbol symbol);
- void putObject(Object o);
- void putJavaMap(Map<Object, Object> map);
- void putJavaList(List<Object> list);
- void putJavaArray(Object[] array);
- void putDescribedType(DescribedType dt);
-
- long getList();
- long getMap();
- long getArray();
- boolean isArrayDescribed();
- DataType getArrayType();
- boolean isDescribed();
- boolean isNull();
- boolean getBoolean();
- UnsignedByte getUnsignedByte();
- byte getByte();
- UnsignedShort getUnsignedShort();
- short getShort();
- UnsignedInteger getUnsignedInteger();
- int getInt();
- int getChar();
- UnsignedLong getUnsignedLong();
- long getLong();
- Date getTimestamp();
- float getFloat();
- double getDouble();
- Decimal32 getDecimal32();
- Decimal64 getDecimal64();
- Decimal128 getDecimal128();
- UUID getUUID();
- Binary getBinary();
- String getString();
- Symbol getSymbol();
- Object getObject();
- Map<Object, Object> getJavaMap();
- List<Object> getJavaList();
- Object[] getJavaArray();
- DescribedType getDescribedType();
- //pnAtomT getAtom();
-
- void copy(Data src);
- void append(Data src);
- void appendn(Data src, int limit);
- void narrow();
- void widen();
-
- String format();
-
- // void dump();
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal128Type.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal128Type.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal128Type.java
deleted file mode 100644
index c871247..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal128Type.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Decimal128;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class Decimal128Type extends AbstractPrimitiveType<Decimal128>
-{
- private Decimal128Encoding _decimal128Encoder;
-
- Decimal128Type(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _decimal128Encoder = new Decimal128Encoding(encoder, decoder);
- encoder.register(Decimal128.class, this);
- decoder.register(this);
- }
-
- public Class<Decimal128> getTypeClass()
- {
- return Decimal128.class;
- }
-
- public Decimal128Encoding getEncoding(final Decimal128 val)
- {
- return _decimal128Encoder;
- }
-
-
- public Decimal128Encoding getCanonicalEncoding()
- {
- return _decimal128Encoder;
- }
-
- public Collection<Decimal128Encoding> getAllEncodings()
- {
- return Collections.singleton(_decimal128Encoder);
- }
-
- private class Decimal128Encoding extends FixedSizePrimitiveTypeEncoding<Decimal128>
- {
-
- public Decimal128Encoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 16;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.DECIMAL128;
- }
-
- public Decimal128Type getType()
- {
- return Decimal128Type.this;
- }
-
- public void writeValue(final Decimal128 val)
- {
- getEncoder().writeRaw(val.getMostSignificantBits());
- getEncoder().writeRaw(val.getLeastSignificantBits());
- }
-
- public boolean encodesSuperset(final TypeEncoding<Decimal128> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Decimal128 readValue()
- {
- long msb = getDecoder().readRawLong();
- long lsb = getDecoder().readRawLong();
- return new Decimal128(msb, lsb);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal32Type.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal32Type.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal32Type.java
deleted file mode 100644
index 5ea5ee5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal32Type.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Decimal32;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class Decimal32Type extends AbstractPrimitiveType<Decimal32>
-{
- private Decimal32Encoding _decimal32Encoder;
-
- Decimal32Type(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _decimal32Encoder = new Decimal32Encoding(encoder, decoder);
- encoder.register(Decimal32.class, this);
- decoder.register(this);
- }
-
- public Class<Decimal32> getTypeClass()
- {
- return Decimal32.class;
- }
-
- public Decimal32Encoding getEncoding(final Decimal32 val)
- {
- return _decimal32Encoder;
- }
-
-
- public Decimal32Encoding getCanonicalEncoding()
- {
- return _decimal32Encoder;
- }
-
- public Collection<Decimal32Encoding> getAllEncodings()
- {
- return Collections.singleton(_decimal32Encoder);
- }
-
- private class Decimal32Encoding extends FixedSizePrimitiveTypeEncoding<Decimal32>
- {
-
- public Decimal32Encoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 4;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.DECIMAL32;
- }
-
- public Decimal32Type getType()
- {
- return Decimal32Type.this;
- }
-
- public void writeValue(final Decimal32 val)
- {
- getEncoder().writeRaw(val.getBits());
- }
-
- public boolean encodesSuperset(final TypeEncoding<Decimal32> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Decimal32 readValue()
- {
- return new Decimal32(getDecoder().readRawInt());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal64Type.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal64Type.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal64Type.java
deleted file mode 100644
index 26df547..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/Decimal64Type.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Decimal64;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class Decimal64Type extends AbstractPrimitiveType<Decimal64>
-{
- private Decimal64Encoding _decimal64Encoder;
-
- Decimal64Type(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _decimal64Encoder = new Decimal64Encoding(encoder, decoder);
- encoder.register(Decimal64.class, this);
- decoder.register(this);
- }
-
- public Class<Decimal64> getTypeClass()
- {
- return Decimal64.class;
- }
-
- public Decimal64Encoding getEncoding(final Decimal64 val)
- {
- return _decimal64Encoder;
- }
-
-
- public Decimal64Encoding getCanonicalEncoding()
- {
- return _decimal64Encoder;
- }
-
- public Collection<Decimal64Encoding> getAllEncodings()
- {
- return Collections.singleton(_decimal64Encoder);
- }
-
- private class Decimal64Encoding extends FixedSizePrimitiveTypeEncoding<Decimal64>
- {
-
- public Decimal64Encoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 8;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.DECIMAL64;
- }
-
- public Decimal64Type getType()
- {
- return Decimal64Type.this;
- }
-
- public void writeValue(final Decimal64 val)
- {
- getEncoder().writeRaw(val.getBits());
- }
-
- public boolean encodesSuperset(final TypeEncoding<Decimal64> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Decimal64 readValue()
- {
- return new Decimal64(getDecoder().readRawLong());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/DecodeException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DecodeException.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DecodeException.java
deleted file mode 100644
index 213e614..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DecodeException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec;
-
-public class DecodeException extends RuntimeException
-{
- public DecodeException()
- {
- }
-
- public DecodeException(String message)
- {
- super(message);
- }
-
- public DecodeException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public DecodeException(Throwable cause)
- {
- super(cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/Decoder.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/Decoder.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/Decoder.java
deleted file mode 100644
index 6053479..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/Decoder.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Decimal128;
-import org.apache.qpid.proton.amqp.Decimal32;
-import org.apache.qpid.proton.amqp.Decimal64;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-public interface Decoder
-{
- public static interface ListProcessor<T>
- {
- T process(int count, Encoder encoder);
- }
-
-
- Boolean readBoolean();
- Boolean readBoolean(Boolean defaultVal);
- boolean readBoolean(boolean defaultVal);
-
- Byte readByte();
- Byte readByte(Byte defaultVal);
- byte readByte(byte defaultVal);
-
- Short readShort();
- Short readShort(Short defaultVal);
- short readShort(short defaultVal);
-
- Integer readInteger();
- Integer readInteger(Integer defaultVal);
- int readInteger(int defaultVal);
-
- Long readLong();
- Long readLong(Long defaultVal);
- long readLong(long defaultVal);
-
- UnsignedByte readUnsignedByte();
- UnsignedByte readUnsignedByte(UnsignedByte defaultVal);
-
- UnsignedShort readUnsignedShort();
- UnsignedShort readUnsignedShort(UnsignedShort defaultVal);
-
- UnsignedInteger readUnsignedInteger();
- UnsignedInteger readUnsignedInteger(UnsignedInteger defaultVal);
-
- UnsignedLong readUnsignedLong();
- UnsignedLong readUnsignedLong(UnsignedLong defaultVal);
-
- Character readCharacter();
- Character readCharacter(Character defaultVal);
- char readCharacter(char defaultVal);
-
- Float readFloat();
- Float readFloat(Float defaultVal);
- float readFloat(float defaultVal);
-
- Double readDouble();
- Double readDouble(Double defaultVal);
- double readDouble(double defaultVal);
-
- UUID readUUID();
- UUID readUUID(UUID defaultValue);
-
- Decimal32 readDecimal32();
- Decimal32 readDecimal32(Decimal32 defaultValue);
-
- Decimal64 readDecimal64();
- Decimal64 readDecimal64(Decimal64 defaultValue);
-
- Decimal128 readDecimal128();
- Decimal128 readDecimal128(Decimal128 defaultValue);
-
- Date readTimestamp();
- Date readTimestamp(Date defaultValue);
-
- Binary readBinary();
- Binary readBinary(Binary defaultValue);
-
- Symbol readSymbol();
- Symbol readSymbol(Symbol defaultValue);
-
- String readString();
- String readString(String defaultValue);
-
- List readList();
- <T> void readList(ListProcessor<T> processor);
-
- Map readMap();
-
- <T> T[] readArray(Class<T> clazz);
-
- Object[] readArray();
-
- boolean[] readBooleanArray();
- byte[] readByteArray();
- short[] readShortArray();
- int[] readIntegerArray();
- long[] readLongArray();
- float[] readFloatArray();
- double[] readDoubleArray();
- char[] readCharacterArray();
-
- <T> T[] readMultiple(Class<T> clazz);
-
- Object[] readMultiple();
- byte[] readByteMultiple();
- short[] readShortMultiple();
- int[] readIntegerMultiple();
- long[] readLongMultiple();
- float[] readFloatMultiple();
- double[] readDoubleMultiple();
- char[] readCharacterMultiple();
-
- Object readObject();
- Object readObject(Object defaultValue);
-
- void register(final Object descriptor, final DescribedTypeConstructor dtc);
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
deleted file mode 100644
index dd68f6a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
+++ /dev/null
@@ -1,999 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Decimal128;
-import org.apache.qpid.proton.amqp.Decimal32;
-import org.apache.qpid.proton.amqp.Decimal64;
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-import java.lang.reflect.Array;
-import java.nio.ByteBuffer;
-import java.util.*;
-
-public class DecoderImpl implements ByteBufferDecoder
-{
-
- private ByteBuffer _buffer;
- private PrimitiveTypeEncoding[] _constructors = new PrimitiveTypeEncoding[256];
- private Map<Object, DescribedTypeConstructor> _dynamicTypeConstructors =
- new HashMap<Object, DescribedTypeConstructor>();
-
-
- public DecoderImpl()
- {
- }
-
-
- DecoderImpl(final ByteBuffer buffer)
- {
- _buffer = buffer;
- }
-
- TypeConstructor readConstructor()
- {
- int code = ((int)readRawByte()) & 0xff;
- if(code == EncodingCodes.DESCRIBED_TYPE_INDICATOR)
- {
- final Object descriptor = readObject();
- TypeConstructor nestedEncoding = readConstructor();
- DescribedTypeConstructor dtc = _dynamicTypeConstructors.get(descriptor);
- if(dtc == null)
- {
- dtc = new DescribedTypeConstructor()
- {
-
- public DescribedType newInstance(final Object described)
- {
- return new UnknownDescribedType(descriptor, described);
- }
-
- public Class getTypeClass()
- {
- return UnknownDescribedType.class;
- }
- };
- register(descriptor, dtc);
- }
- return new DynamicTypeConstructor(dtc, nestedEncoding);
- }
- else
- {
- return _constructors[code];
- }
- }
-
- public void register(final Object descriptor, final DescribedTypeConstructor dtc)
- {
- _dynamicTypeConstructors.put(descriptor, dtc);
- }
-
- private ClassCastException unexpectedType(final Object val, Class clazz)
- {
- return new ClassCastException("Unexpected type "
- + val.getClass().getName()
- + ". Expected "
- + clazz.getName() +".");
- }
-
-
- public Boolean readBoolean()
- {
- return readBoolean(null);
- }
-
- public Boolean readBoolean(final Boolean defaultVal)
- {
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof Boolean)
- {
- return (Boolean) val;
- }
- throw unexpectedType(val, Boolean.class);
- }
-
- public boolean readBoolean(final boolean defaultVal)
- {
- TypeConstructor constructor = readConstructor();
- if(constructor instanceof BooleanType.BooleanEncoding)
- {
- return ((BooleanType.BooleanEncoding)constructor).readPrimitiveValue();
- }
- else
- {
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else
- {
- throw unexpectedType(val, Boolean.class);
- }
- }
- }
-
- public Byte readByte()
- {
- return readByte(null);
- }
-
- public Byte readByte(final Byte defaultVal)
- {
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof Byte)
- {
- return (Byte) val;
- }
- throw unexpectedType(val, Byte.class);
- }
-
- public byte readByte(final byte defaultVal)
- {
- TypeConstructor constructor = readConstructor();
- if(constructor instanceof ByteType.ByteEncoding)
- {
- return ((ByteType.ByteEncoding)constructor).readPrimitiveValue();
- }
- else
- {
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else
- {
- throw unexpectedType(val, Byte.class);
- }
- }
- }
-
- public Short readShort()
- {
- return readShort(null);
- }
-
- public Short readShort(final Short defaultVal)
- {
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof Short)
- {
- return (Short) val;
- }
- throw unexpectedType(val, Short.class);
-
- }
-
- public short readShort(final short defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- if(constructor instanceof ShortType.ShortEncoding)
- {
- return ((ShortType.ShortEncoding)constructor).readPrimitiveValue();
- }
- else
- {
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else
- {
- throw unexpectedType(val, Short.class);
- }
- }
- }
-
- public Integer readInteger()
- {
- return readInteger(null);
- }
-
- public Integer readInteger(final Integer defaultVal)
- {
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof Integer)
- {
- return (Integer) val;
- }
- throw unexpectedType(val, Integer.class);
-
- }
-
- public int readInteger(final int defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- if(constructor instanceof IntegerType.IntegerEncoding)
- {
- return ((IntegerType.IntegerEncoding)constructor).readPrimitiveValue();
- }
- else
- {
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else
- {
- throw unexpectedType(val, Integer.class);
- }
- }
- }
-
- public Long readLong()
- {
- return readLong(null);
- }
-
- public Long readLong(final Long defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof Long)
- {
- return (Long) val;
- }
- throw unexpectedType(val, Long.class);
-
- }
-
- public long readLong(final long defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- if(constructor instanceof LongType.LongEncoding)
- {
- return ((LongType.LongEncoding)constructor).readPrimitiveValue();
- }
- else
- {
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else
- {
- throw unexpectedType(val, Long.class);
- }
- }
- }
-
- public UnsignedByte readUnsignedByte()
- {
- return readUnsignedByte(null);
- }
-
- public UnsignedByte readUnsignedByte(final UnsignedByte defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof UnsignedByte)
- {
- return (UnsignedByte) val;
- }
- throw unexpectedType(val, UnsignedByte.class);
-
- }
-
- public UnsignedShort readUnsignedShort()
- {
- return readUnsignedShort(null);
- }
-
- public UnsignedShort readUnsignedShort(final UnsignedShort defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof UnsignedShort)
- {
- return (UnsignedShort) val;
- }
- throw unexpectedType(val, UnsignedShort.class);
-
- }
-
- public UnsignedInteger readUnsignedInteger()
- {
- return readUnsignedInteger(null);
- }
-
- public UnsignedInteger readUnsignedInteger(final UnsignedInteger defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof UnsignedInteger)
- {
- return (UnsignedInteger) val;
- }
- throw unexpectedType(val, UnsignedInteger.class);
-
- }
-
- public UnsignedLong readUnsignedLong()
- {
- return readUnsignedLong(null);
- }
-
- public UnsignedLong readUnsignedLong(final UnsignedLong defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof UnsignedLong)
- {
- return (UnsignedLong) val;
- }
- throw unexpectedType(val, UnsignedLong.class);
-
- }
-
- public Character readCharacter()
- {
- return readCharacter(null);
- }
-
- public Character readCharacter(final Character defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof Character)
- {
- return (Character) val;
- }
- throw unexpectedType(val, Character.class);
-
- }
-
- public char readCharacter(final char defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- if(constructor instanceof CharacterType.CharacterEncoding)
- {
- return ((CharacterType.CharacterEncoding)constructor).readPrimitiveValue();
- }
- else
- {
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else
- {
- throw unexpectedType(val, Character.class);
- }
- }
- }
-
- public Float readFloat()
- {
- return readFloat(null);
- }
-
- public Float readFloat(final Float defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof Float)
- {
- return (Float) val;
- }
- throw unexpectedType(val, Float.class);
-
- }
-
- public float readFloat(final float defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- if(constructor instanceof FloatType.FloatEncoding)
- {
- return ((FloatType.FloatEncoding)constructor).readPrimitiveValue();
- }
- else
- {
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else
- {
- throw unexpectedType(val, Float.class);
- }
- }
- }
-
- public Double readDouble()
- {
- return readDouble(null);
- }
-
- public Double readDouble(final Double defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof Double)
- {
- return (Double) val;
- }
- throw unexpectedType(val, Double.class);
-
- }
-
- public double readDouble(final double defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- if(constructor instanceof DoubleType.DoubleEncoding)
- {
- return ((DoubleType.DoubleEncoding)constructor).readPrimitiveValue();
- }
- else
- {
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else
- {
- throw unexpectedType(val, Double.class);
- }
- }
- }
-
- public UUID readUUID()
- {
- return readUUID(null);
- }
-
- public UUID readUUID(final UUID defaultVal)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultVal;
- }
- else if(val instanceof UUID)
- {
- return (UUID) val;
- }
- throw unexpectedType(val, UUID.class);
-
- }
-
- public Decimal32 readDecimal32()
- {
- return readDecimal32(null);
- }
-
- public Decimal32 readDecimal32(final Decimal32 defaultValue)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultValue;
- }
- else if(val instanceof Decimal32)
- {
- return (Decimal32) val;
- }
- throw unexpectedType(val, Decimal32.class);
-
- }
-
- public Decimal64 readDecimal64()
- {
- return readDecimal64(null);
- }
-
- public Decimal64 readDecimal64(final Decimal64 defaultValue)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultValue;
- }
- else if(val instanceof Decimal64)
- {
- return (Decimal64) val;
- }
- throw unexpectedType(val, Decimal64.class);
- }
-
- public Decimal128 readDecimal128()
- {
- return readDecimal128(null);
- }
-
- public Decimal128 readDecimal128(final Decimal128 defaultValue)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultValue;
- }
- else if(val instanceof Decimal128)
- {
- return (Decimal128) val;
- }
- throw unexpectedType(val, Decimal128.class);
- }
-
- public Date readTimestamp()
- {
- return readTimestamp(null);
- }
-
- public Date readTimestamp(final Date defaultValue)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultValue;
- }
- else if(val instanceof Date)
- {
- return (Date) val;
- }
- throw unexpectedType(val, Date.class);
- }
-
- public Binary readBinary()
- {
- return readBinary(null);
- }
-
- public Binary readBinary(final Binary defaultValue)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultValue;
- }
- else if(val instanceof Binary)
- {
- return (Binary) val;
- }
- throw unexpectedType(val, Binary.class);
- }
-
- public Symbol readSymbol()
- {
- return readSymbol(null);
- }
-
- public Symbol readSymbol(final Symbol defaultValue)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultValue;
- }
- else if(val instanceof Symbol)
- {
- return (Symbol) val;
- }
- throw unexpectedType(val, Symbol.class);
- }
-
- public String readString()
- {
- return readString(null);
- }
-
- public String readString(final String defaultValue)
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return defaultValue;
- }
- else if(val instanceof String)
- {
- return (String) val;
- }
- throw unexpectedType(val, String.class);
- }
-
- public List readList()
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return null;
- }
- else if(val instanceof List)
- {
- return (List) val;
- }
- throw unexpectedType(val, List.class);
- }
-
- public <T> void readList(final ListProcessor<T> processor)
- {
- //TODO.
- }
-
- public Map readMap()
- {
-
- TypeConstructor constructor = readConstructor();
- Object val = constructor.readValue();
- if(val == null)
- {
- return null;
- }
- else if(val instanceof Map)
- {
- return (Map) val;
- }
- throw unexpectedType(val, Map.class);
- }
-
- public <T> T[] readArray(final Class<T> clazz)
- {
- return null; //TODO.
- }
-
- public Object[] readArray()
- {
- return (Object[]) readConstructor().readValue();
-
- }
-
- public boolean[] readBooleanArray()
- {
- return (boolean[]) ((ArrayType.ArrayEncoding)readConstructor()).readValueArray();
- }
-
- public byte[] readByteArray()
- {
- return (byte[]) ((ArrayType.ArrayEncoding)readConstructor()).readValueArray();
- }
-
- public short[] readShortArray()
- {
- return (short[]) ((ArrayType.ArrayEncoding)readConstructor()).readValueArray();
- }
-
- public int[] readIntegerArray()
- {
- return (int[]) ((ArrayType.ArrayEncoding)readConstructor()).readValueArray();
- }
-
- public long[] readLongArray()
- {
- return (long[]) ((ArrayType.ArrayEncoding)readConstructor()).readValueArray();
- }
-
- public float[] readFloatArray()
- {
- return (float[]) ((ArrayType.ArrayEncoding)readConstructor()).readValueArray();
- }
-
- public double[] readDoubleArray()
- {
- return (double[]) ((ArrayType.ArrayEncoding)readConstructor()).readValueArray();
- }
-
- public char[] readCharacterArray()
- {
- return (char[]) ((ArrayType.ArrayEncoding)readConstructor()).readValueArray();
- }
-
- public <T> T[] readMultiple(final Class<T> clazz)
- {
- Object val = readObject();
- if(val == null)
- {
- return null;
- }
- else if(val.getClass().isArray())
- {
- if(clazz.isAssignableFrom(val.getClass().getComponentType()))
- {
- return (T[]) val;
- }
- else
- {
- throw unexpectedType(val, Array.newInstance(clazz, 0).getClass());
- }
- }
- else if(clazz.isAssignableFrom(val.getClass()))
- {
- T[] array = (T[]) Array.newInstance(clazz, 1);
- array[0] = (T) val;
- return array;
- }
- else
- {
- throw unexpectedType(val, Array.newInstance(clazz, 0).getClass());
- }
- }
-
- public Object[] readMultiple()
- {
- Object val = readObject();
- if(val == null)
- {
- return null;
- }
- else if(val.getClass().isArray())
- {
- return (Object[]) val;
- }
- else
- {
- Object[] array = (Object[]) Array.newInstance(val.getClass(), 1);
- array[0] = val;
- return array;
- }
- }
-
- public byte[] readByteMultiple()
- {
- return new byte[0]; //TODO.
- }
-
- public short[] readShortMultiple()
- {
- return new short[0]; //TODO.
- }
-
- public int[] readIntegerMultiple()
- {
- return new int[0]; //TODO.
- }
-
- public long[] readLongMultiple()
- {
- return new long[0]; //TODO.
- }
-
- public float[] readFloatMultiple()
- {
- return new float[0]; //TODO.
- }
-
- public double[] readDoubleMultiple()
- {
- return new double[0]; //TODO.
- }
-
- public char[] readCharacterMultiple()
- {
- return new char[0]; //TODO.
- }
-
- public Object readObject()
- {
- TypeConstructor constructor = readConstructor();
- if(constructor== null)
- {
- throw new DecodeException("Unknown constructor");
- }
- return constructor instanceof ArrayType.ArrayEncoding
- ? ((ArrayType.ArrayEncoding)constructor).readValueArray()
- : constructor.readValue();
- }
-
- public Object readObject(final Object defaultValue)
- {
- Object val = readObject();
- return val == null ? defaultValue : val;
- }
-
- <V> void register(PrimitiveType<V> type)
- {
- Collection<? extends PrimitiveTypeEncoding<V>> encodings = type.getAllEncodings();
-
- for(PrimitiveTypeEncoding<V> encoding : encodings)
- {
- _constructors[((int) encoding.getEncodingCode()) & 0xFF ] = encoding;
- }
-
- }
-
- byte readRawByte()
- {
- return _buffer.get();
- }
-
- int readRawInt()
- {
- return _buffer.getInt();
- }
-
- long readRawLong()
- {
- return _buffer.getLong();
- }
-
- short readRawShort()
- {
- return _buffer.getShort();
- }
-
- float readRawFloat()
- {
- return _buffer.getFloat();
- }
-
- double readRawDouble()
- {
- return _buffer.getDouble();
- }
-
- void readRaw(final byte[] data, final int offset, final int length)
- {
- _buffer.get(data, offset, length);
- }
-
-
- <V> V readRaw(TypeDecoder<V> decoder, int size)
- {
- V decode = decoder.decode((ByteBuffer) _buffer.slice().limit(size));
- _buffer.position(_buffer.position()+size);
- return decode;
- }
-
- public void setByteBuffer(final ByteBuffer buffer)
- {
- _buffer = buffer;
- }
-
- interface TypeDecoder<V>
- {
- V decode(ByteBuffer buf);
- }
-
- private static class UnknownDescribedType implements DescribedType
- {
- private final Object _descriptor;
- private final Object _described;
-
- public UnknownDescribedType(final Object descriptor, final Object described)
- {
- _descriptor = descriptor;
- _described = described;
- }
-
- public Object getDescriptor()
- {
- return _descriptor;
- }
-
- public Object getDescribed()
- {
- return _described;
- }
-
-
- @Override
- public boolean equals(Object obj)
- {
-
- return obj instanceof DescribedType
- && _descriptor == null ? ((DescribedType) obj).getDescriptor() == null
- : _descriptor.equals(((DescribedType) obj).getDescriptor())
- && _described == null ? ((DescribedType) obj).getDescribed() == null
- : _described.equals(((DescribedType) obj).getDescribed());
-
- }
-
- }
-
- public int getByteBufferRemaining() {
- return _buffer.remaining();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/DescribedTypeConstructor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DescribedTypeConstructor.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DescribedTypeConstructor.java
deleted file mode 100644
index 9df97a0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DescribedTypeConstructor.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-public interface DescribedTypeConstructor<V>
-{
- V newInstance(Object described);
-
- Class getTypeClass();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/DoubleType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DoubleType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DoubleType.java
deleted file mode 100644
index 8c6c84c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DoubleType.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class DoubleType extends AbstractPrimitiveType<Double>
-{
- private DoubleEncoding _doubleEncoding;
-
- DoubleType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _doubleEncoding = new DoubleEncoding(encoder, decoder);
- encoder.register(Double.class, this);
- decoder.register(this);
- }
-
- public Class<Double> getTypeClass()
- {
- return Double.class;
- }
-
- public DoubleEncoding getEncoding(final Double val)
- {
- return _doubleEncoding;
- }
-
-
- public DoubleEncoding getCanonicalEncoding()
- {
- return _doubleEncoding;
- }
-
- public Collection<DoubleEncoding> getAllEncodings()
- {
- return Collections.singleton(_doubleEncoding);
- }
-
- public void write(double d)
- {
- _doubleEncoding.write(d);
- }
-
- public class DoubleEncoding extends FixedSizePrimitiveTypeEncoding<Double>
- {
-
- public DoubleEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 8;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.DOUBLE;
- }
-
- public DoubleType getType()
- {
- return DoubleType.this;
- }
-
- public void writeValue(final Double val)
- {
- getEncoder().writeRaw(val.doubleValue());
- }
-
- public void writeValue(final double val)
- {
- getEncoder().writeRaw(val);
- }
-
- public void write(final double d)
- {
- writeConstructor();
- getEncoder().writeRaw(d);
-
- }
-
- public boolean encodesSuperset(final TypeEncoding<Double> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Double readValue()
- {
- return readPrimitiveValue();
- }
-
- public double readPrimitiveValue()
- {
- return getDecoder().readRawDouble();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/DroppingWritableBuffer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DroppingWritableBuffer.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DroppingWritableBuffer.java
deleted file mode 100644
index a6949b5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DroppingWritableBuffer.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.nio.ByteBuffer;
-
-public class DroppingWritableBuffer implements WritableBuffer
-{
- private int _pos = 0;
-
- @Override
- public boolean hasRemaining()
- {
- return true;
- }
-
- @Override
- public void put(byte b)
- {
- _pos += 1;
- }
-
- @Override
- public void putFloat(float f)
- {
- _pos += 4;
- }
-
- @Override
- public void putDouble(double d)
- {
- _pos += 8;
- }
-
- @Override
- public void put(byte[] src, int offset, int length)
- {
- _pos += length;
- }
-
- @Override
- public void putShort(short s)
- {
- _pos += 2;
- }
-
- @Override
- public void putInt(int i)
- {
- _pos += 4;
- }
-
- @Override
- public void putLong(long l)
- {
- _pos += 8;
- }
-
- @Override
- public int remaining()
- {
- return Integer.MAX_VALUE - _pos;
- }
-
- @Override
- public int position()
- {
- return _pos;
- }
-
- @Override
- public void position(int position)
- {
- _pos = position;
- }
-
- @Override
- public void put(ByteBuffer payload)
- {
- _pos += payload.remaining();
- payload.position(payload.limit());
- }
-
- @Override
- public int limit()
- {
- return Integer.MAX_VALUE;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/DynamicDescribedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DynamicDescribedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DynamicDescribedType.java
deleted file mode 100644
index d6ffaf7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DynamicDescribedType.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.DescribedType;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-public class DynamicDescribedType implements AMQPType<DescribedType>
-{
-
- private final EncoderImpl _encoder;
- private final Map<TypeEncoding, TypeEncoding> _encodings = new HashMap<TypeEncoding, TypeEncoding>();
- private final Object _descriptor;
-
- public DynamicDescribedType(EncoderImpl encoder, final Object descriptor)
- {
- _encoder = encoder;
- _descriptor = descriptor;
- }
-
-
- public Class<DescribedType> getTypeClass()
- {
- return DescribedType.class;
- }
-
- public TypeEncoding<DescribedType> getEncoding(final DescribedType val)
- {
- TypeEncoding underlyingEncoding = _encoder.getType(val.getDescribed()).getEncoding(val.getDescribed());
- TypeEncoding encoding = _encodings.get(underlyingEncoding);
- if(encoding == null)
- {
- encoding = new DynamicDescribedTypeEncoding(underlyingEncoding);
- _encodings.put(underlyingEncoding, encoding);
- }
-
- return encoding;
- }
-
- public TypeEncoding<DescribedType> getCanonicalEncoding()
- {
- return null;
- }
-
- public Collection<TypeEncoding<DescribedType>> getAllEncodings()
- {
- Collection values = _encodings.values();
- Collection unmodifiable = Collections.unmodifiableCollection(values);
- return (Collection<TypeEncoding<DescribedType>>) unmodifiable;
- }
-
- public void write(final DescribedType val)
- {
- TypeEncoding<DescribedType> encoding = getEncoding(val);
- encoding.writeConstructor();
- encoding.writeValue(val);
- }
-
- private class DynamicDescribedTypeEncoding implements TypeEncoding
- {
- private final TypeEncoding _underlyingEncoding;
- private final TypeEncoding _descriptorType;
- private final int _constructorSize;
-
-
- public DynamicDescribedTypeEncoding(final TypeEncoding underlyingEncoding)
- {
- _underlyingEncoding = underlyingEncoding;
- _descriptorType = _encoder.getType(_descriptor).getEncoding(_descriptor);
- _constructorSize = 1 + _descriptorType.getConstructorSize()
- + _descriptorType.getValueSize(_descriptor)
- + _underlyingEncoding.getConstructorSize();
- }
-
- public AMQPType getType()
- {
- return DynamicDescribedType.this;
- }
-
- public void writeConstructor()
- {
- _encoder.writeRaw(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
- _descriptorType.writeConstructor();
- _descriptorType.writeValue(_descriptor);
- _underlyingEncoding.writeConstructor();
- }
-
- public int getConstructorSize()
- {
- return _constructorSize;
- }
-
- public void writeValue(final Object val)
- {
- _underlyingEncoding.writeValue(((DescribedType)val).getDescribed());
- }
-
- public int getValueSize(final Object val)
- {
- return _underlyingEncoding.getValueSize(((DescribedType) val).getDescribed());
- }
-
- public boolean isFixedSizeVal()
- {
- return _underlyingEncoding.isFixedSizeVal();
- }
-
- public boolean encodesSuperset(final TypeEncoding encoding)
- {
- return (getType() == encoding.getType())
- && (_underlyingEncoding.encodesSuperset(((DynamicDescribedTypeEncoding)encoding)
- ._underlyingEncoding));
- }
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return false;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/DynamicTypeConstructor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DynamicTypeConstructor.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DynamicTypeConstructor.java
deleted file mode 100644
index 0cee927..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DynamicTypeConstructor.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-public class DynamicTypeConstructor implements TypeConstructor
-{
- private final DescribedTypeConstructor _describedTypeConstructor;
- private final TypeConstructor _underlyingEncoding;
-
- public DynamicTypeConstructor(final DescribedTypeConstructor dtc,
- final TypeConstructor underlyingEncoding)
- {
- _describedTypeConstructor = dtc;
- _underlyingEncoding = underlyingEncoding;
- }
-
- public Object readValue()
- {
- try
- {
- return _describedTypeConstructor.newInstance(_underlyingEncoding.readValue());
- }
- catch (NullPointerException npe)
- {
- throw new DecodeException("Unexpected null value - mandatory field not set? ("+npe.getMessage()+")", npe);
- }
- catch (ClassCastException cce)
- {
- throw new DecodeException("Incorrect type used", cce);
- }
- }
-
- public boolean encodesJavaPrimitive()
- {
- return false;
- }
-
- public Class getTypeClass()
- {
- return _describedTypeConstructor.getTypeClass();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[34/34] qpid-proton git commit: NO-JIRA: go: merge doc updates from
master
Posted by ac...@apache.org.
NO-JIRA: go: merge doc updates from master
Merge branch 'master' into go1
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/793e2101
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/793e2101
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/793e2101
Branch: refs/heads/go1
Commit: 793e210100d0d75d32660eedd9f553a32d6f1f78
Parents: 4afe30d 951dcb4
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Jan 9 10:22:28 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Jan 9 10:22:28 2017 -0500
----------------------------------------------------------------------
README.md | 5 +++++
amqp/doc.go | 2 ++
electron/doc.go | 2 ++
proton/doc.go | 2 ++
4 files changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/793e2101/README.md
----------------------------------------------------------------------
diff --cc README.md
index ffd67f8,44e1fdd..7415929
--- a/README.md
+++ b/README.md
@@@ -1,97 -1,43 +1,102 @@@
-Qpid Proton - AMQP messaging toolkit
-====================================
+# Qpid Go packages for AMQP
-Linux Build | Windows Build
-------------|--------------
-[![Linux Build Status](https://travis-ci.org/apache/qpid-proton.svg?branch=master)](https://travis-ci.org/apache/qpid-proton) | [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/apache/qpid-proton?branch=master&svg=true)](https://ci.appveyor.com/project/ke4qqq/qpid-proton/branch/master)
+These packages provide [Go](http://golang.org) support for sending and receiving
+AMQP messages in client or server applications. Reference documentation is
+available at: <http://godoc.org/?q=qpid.apache.org>
-Qpid Proton is a high-performance, lightweight messaging library. It can be
-used in the widest range of messaging applications, including brokers, client
-libraries, routers, bridges, proxies, and more. Proton makes it trivial to
-integrate with the AMQP 1.0 ecosystem from any platform, environment, or
-language
++They require the [proton-C library](http://qpid.apache.org/proton) to be installed.
++On many platforms it is avaialable pre-packaged, for example on Fedora
+
-Features
---------
++ yum install qpid-proton-c-devel
+
- + A flexible and capable reactive messaging API
- + Full control of AMQP 1.0 protocol semantics
- + Portable C implementation with bindings to popular languages
- + Peer-to-peer and brokered messaging
- + Secure communication via SSL and SASL
+There are 3 packages:
-Universal - Proton is designed to scale both up and down. Equally suitable for
-simple clients or high-powered servers, it can be deployed in simple
-peer-to-peer configurations or as part of a global federated messaging network.
+[qpid.apache.org/amqp](http://godoc.org/qpid.apache.org/amqp) provides functions
+to convert AMQP messages and data types to and from Go data types. Used by both
+the proton and electron packages to manage AMQP data.
-Embeddable - Proton is carefully written to be portable and cross platform. It
-has minimal dependencies, and it is architected to be usable with any threading
-model, as well as with non-threaded applications. These features make it
-uniquely suited for embedding messaging capabilities into existing software.
+[qpid.apache.org/electron](http://godoc.org/qpid.apache.org/electron) is a
+simple, concurrent-safe API for sending and receiving messages. It can be used
+with goroutines and channels to build concurrent AMQP clients and servers.
-Standard - Built around the AMQP 1.0 messaging standard, Proton is not only
-ideal for building out your own messaging applications but also for connecting
-them to the broader ecosystem of AMQP 1.0-based messaging applications.
+[qpid.apache.org/proton](http://godoc.org/qpid.apache.org/proton) is an
+event-driven, concurrent-unsafe package that closely follows the proton C
+API. Most Go programmers will find the
+[electron](http://godoc.org/qpid.apache.org/electron) package easier to use.
-Getting Started
----------------
+See the [examples](https://github.com/apache/qpid-proton/blob/master/examples/go/README.md)
+to help you get started.
-See the included INSTALL file for build and install instructions and the
-DEVELOPERS file for information on how to modify and test the library code
-itself.
+Feedback is encouraged at:
-Please see http://qpid.apache.org/proton for a more info.
+- Email <pr...@qpid.apache.org>
+- Create issues <https://issues.apache.org/jira/browse/PROTON>, attach patches to an issue.
+
+### Why two APIs?
+
+The `proton` API is a direct mapping of the proton C library into Go. It is
+usable but not very natural for a Go programmer because it takes an
+*event-driven* approach and has no built-in support for concurrent
+use. `electron` uses `proton` internally but provides a more Go-like API that is
+safe to use from multiple concurrent goroutines.
+
+Go encourages programs to be structured as concurrent *goroutines* that
+communicate via *channels*. Go literature distinguishes between:
+
+- *concurrency*: "keeping track of things that could be done in parallel"
+- *parallelism*: "actually doing things in parallel on multiple CPUs or cores"
+
+A Go program expresses concurrency by starting goroutines for potentially
+concurrent tasks. The Go runtime schedules the activity of goroutines onto a
+small number (possibly one) of actual parallel executions.
+
+Even with no hardware parallelism, goroutine concurrency lets the Go runtime
+order unpredictable events like file descriptors being readable/writable,
+channels having data, timers firing etc. Go automatically takes care of
+switching out goroutines that block or sleep so it is normal to write code in
+terms of blocking calls.
+
+By contrast, event-driven programming is based on polling mechanisms like
+`select`, `poll` or `epoll`. These also dispatch unpredictably ordered events to
+a single thread or a small thread pool. However this requires a different style
+of programming: "event-driven" or "reactive" programming. Go developers call it
+"inside-out" programming. In an event-driven program blocking is a big problem
+as it consumes a scarce thread of execution, so actions that take time to
+complete have to be re-structured in terms of multiple events.
+
+The promise of Go is that you can express your program in concurrent, sequential
+terms and the Go runtime will turn it inside-out for you. You can start
+goroutines for all concurrent activities. They can loop forever or block for as
+long as they need waiting for timers, IO or any unpredictable event. Go will
+interleave and schedule them efficiently onto the available parallel hardware.
+
+For example: in the `electron` API, you can send a message and wait for it to be
+acknowledged in a single function. All the information about the message, why
+you sent it, and what to do when it is acknowledged can be held in local
+variables, all the code is in a simple sequence. Other goroutines in your
+program can be sending and receiving messages concurrently, they are not
+blocked.
+
+In the `proton` API, an event handler that sends a message must return
+*immediately*, it cannot block the event loop to wait for
+acknowledgement. Acknowledgement is a separate event, so the code for handling
+it is in a different event handler. Context information about the message has to
+be stored in some non-local variable that both functions can find. This makes
+the code harder to follow.
+
+The `proton` API is important because it is the foundation for the `electron`
+API, and may be useful for programs that need to be close to the original C
+library for some reason. However the `electron` API hides the event-driven
+details behind simple, sequential, concurrent-safe methods that can be called
+from arbitrary goroutines. Under the covers, data is passed through channels to
+dedicated `proton` goroutines so user goroutines can work concurrently with the
+proton event-loop.
+
+## New to Go?
+
+If you are new to Go then these are a good place to start:
+
+- [A Tour of Go](http://tour.golang.org)
+- [Effective Go](http://golang.org/doc/effective_go.html)
+
+Then look at the tools and docs at <http://golang.org> as you need them.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/793e2101/amqp/doc.go
----------------------------------------------------------------------
diff --cc amqp/doc.go
index 97051a5,0000000..701af55
mode 100644,000000..100644
--- a/amqp/doc.go
+++ b/amqp/doc.go
@@@ -1,36 -1,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 amqp encodes and decodes AMQP 1.0 messages and data types as Go types.
+
+It follows the standard 'encoding' libraries pattern. The mapping between AMQP
+and Go types is described in the documentation of the Marshal and Unmarshal
+functions.
+
++This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
++
+Package 'electron' is a full AMQP 1.0 client/server toolkit using this package.
+
+AMQP 1.0 is an open standard for inter-operable message exchange, see <http://www.amqp.org/>
+*/
+package amqp
+
+// #cgo LDFLAGS: -lqpid-proton
+import "C"
+
+// This file is just for the package comment.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/793e2101/electron/doc.go
----------------------------------------------------------------------
diff --cc electron/doc.go
index bc2c589,0000000..f4baa31
mode 100644,000000..100644
--- a/electron/doc.go
+++ b/electron/doc.go
@@@ -1,71 -1,0 +1,73 @@@
+/*
+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 electron lets you write concurrent AMQP 1.0 messaging clients and servers.
+
++This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
++
+Start by creating a Container with NewContainer. An AMQP Container represents a
+single AMQP "application" and can contain client and server connections.
+
+You can enable AMQP over any connection that implements the standard net.Conn
+interface. Typically you can connect with net.Dial() or listen for server
+connections with net.Listen. Enable AMQP by passing the net.Conn to
+Container.Connection().
+
+AMQP allows bi-direction peer-to-peer message exchange as well as
+client-to-broker. Messages are sent over "links". Each link is one-way and has a
+Sender and Receiver end. Connection.Sender() and Connection.Receiver() open
+links to Send() and Receive() messages. Connection.Incoming() lets you accept
+incoming links opened by the remote peer. You can open and accept multiple links
+in both directions on a single Connection.
+
+Some of the documentation examples show client and server side by side in a
+single program, in separate goroutines. This is only for example purposes, real
+AMQP applications would run in separate processes on the network.
+More realistic examples: https://github.com/apache/qpid-proton/blob/master/examples/go/README.md
+
+Some of the documentation examples show client and server side by side in a
+single program, in separate goroutines. This is only for example purposes, real
+AMQP applications would run in separate processes on the network.
+More realistic examples: https://github.com/apache/qpid-proton/blob/master/examples/go/README.md
+
+*/
+package electron
+
+//#cgo LDFLAGS: -lqpid-proton
+import "C"
+
+// Just for package comment
+
+/* DEVELOPER NOTES
+
+There is a single proton.Engine per connection, each driving it's own event-loop goroutine,
+and each with a 'handler'. Most state for a connection is maintained on the handler, and
+only accessed in the event-loop goroutine, so no locks are required there.
+
+The handler sets up channels as needed to get or send data from user goroutines
+using electron types like Sender or Receiver.
+
+Engine.Inject injects actions into the event loop from user goroutines. It is
+important to check at the start of an injected function that required objects
+are still valid, for example a link may be remotely closed between the time a
+Sender function calls Inject and the time the injected function is execute by
+the handler goroutine.
+
+*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/793e2101/proton/doc.go
----------------------------------------------------------------------
diff --cc proton/doc.go
index 083f701,0000000..1049e71
mode 100644,000000..100644
--- a/proton/doc.go
+++ b/proton/doc.go
@@@ -1,64 -1,0 +1,66 @@@
+/*
+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 proton wraps Proton-C, an event-driven, concurrent-unsafe AMQP 1.0
+C library (package 'electron' is more "Go-like" and concurrent-safe)
+
++This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
++
+Consult the C API documentation at http://qpid.apache.org/proton for more
+information about the types here. There is a 1-1 correspondence between C type
+pn_foo_t and Go type proton.Foo, and between C function
+
+ pn_foo_do_something(pn_foo_t*, ...)
+
+and Go method
+
+ func (proton.Foo) DoSomething(...)
+
+The proton.Engine type pumps data between a Go net.Conn and a proton event loop
+goroutine that feeds events to a proton.MessagingHandler, which you must implement.
+See the Engine documentation for more.
+
+MessagingHandler defines an event handling interface that you can implement to
+react to AMQP protocol events. There is also a lower-level EventHandler, but
+MessagingHandler provides a simpler set of events and automates common tasks for you,
+for most applications it will be more convenient.
+
+NOTE: Methods on most types defined in this package (Sessions, Links etc.) can
+*only* be called in the event handler goroutine of the relevant
+Connection/Engine, either by the HandleEvent method of a handler type or in a
+function injected into the goroutine via Inject() or InjectWait() Handlers and
+injected functions can set up channels to communicate with other goroutines.
+Note the Injecter associated with a handler available as part of the Event value
+passed to HandleEvent.
+
+Separate Engine instances are independent, and can run concurrently.
+
+The 'electron' package is built on the proton package but instead offers a
+concurrent-safe API that can use simple procedural loops rather than event
+handlers to express application logic. It is easier to use for most
+applications.
+
+*/
+package proton
+
+// #cgo LDFLAGS: -lqpid-proton
+import "C"
+
+// This file is just for the package comment.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[22/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java
deleted file mode 100644
index a035e94..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.util.Arrays;
-import java.util.Collection;
-
-public class StringType extends AbstractPrimitiveType<String>
-{
- private static final Charset Charset_UTF8 = Charset.forName("UTF-8");
- private static final DecoderImpl.TypeDecoder<String> _stringCreator =
- new DecoderImpl.TypeDecoder<String>()
- {
-
- public String decode(final ByteBuffer buf)
- {
- CharsetDecoder charsetDecoder = Charset_UTF8.newDecoder();
- try
- {
- CharBuffer charBuf = charsetDecoder.decode(buf);
- return charBuf.toString();
- }
- catch (CharacterCodingException e)
- {
- throw new IllegalArgumentException("Cannot parse String");
- }
-
- }
- };
-
-
- public static interface StringEncoding extends PrimitiveTypeEncoding<String>
- {
- void setValue(String val, int length);
- }
-
- private final StringEncoding _stringEncoding;
- private final StringEncoding _shortStringEncoding;
-
- StringType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _stringEncoding = new AllStringEncoding(encoder, decoder);
- _shortStringEncoding = new ShortStringEncoding(encoder, decoder);
- encoder.register(String.class, this);
- decoder.register(this);
- }
-
- public Class<String> getTypeClass()
- {
- return String.class;
- }
-
- public StringEncoding getEncoding(final String val)
- {
- final int length = calculateUTF8Length(val);
- StringEncoding encoding = length <= 255
- ? _shortStringEncoding
- : _stringEncoding;
- encoding.setValue(val, length);
- return encoding;
- }
-
- static int calculateUTF8Length(final String s)
- {
- int len = s.length();
- final int length = len;
- for (int i = 0; i < length; i++)
- {
- int c = s.charAt(i);
- if ((c & 0xFF80) != 0) /* U+0080.. */
- {
- len++;
- if(((c & 0xF800) != 0)) /* U+0800.. */
- {
- len++;
- // surrogate pairs should always combine to create a code point with a 4 octet representation
- if ((c & 0xD800) == 0xD800 && c < 0xDC00)
- {
- i++;
- }
- }
- }
- }
- return len;
- }
-
-
- public StringEncoding getCanonicalEncoding()
- {
- return _stringEncoding;
- }
-
- public Collection<StringEncoding> getAllEncodings()
- {
- return Arrays.asList(_shortStringEncoding, _stringEncoding);
- }
-
- private class AllStringEncoding
- extends LargeFloatingSizePrimitiveTypeEncoding<String>
- implements StringEncoding
- {
-
- private String _value;
- private int _length;
-
-
- public AllStringEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final String val)
- {
- getEncoder().writeRaw(val);
- }
-
- @Override
- protected int getEncodedValueSize(final String val)
- {
- return (val == _value) ? _length : calculateUTF8Length(val);
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.STR32;
- }
-
- public StringType getType()
- {
- return StringType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<String> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public String readValue()
- {
-
- DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- return decoder.readRaw(_stringCreator, size);
- }
-
- public void setValue(final String val, final int length)
- {
- _value = val;
- _length = length;
- }
-
- }
-
- private class ShortStringEncoding
- extends SmallFloatingSizePrimitiveTypeEncoding<String>
- implements StringEncoding
- {
-
- private String _value;
- private int _length;
-
- public ShortStringEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
-
- @Override
- protected void writeEncodedValue(final String val)
- {
- getEncoder().writeRaw(val);
- }
-
- @Override
- protected int getEncodedValueSize(final String val)
- {
- return (val == _value) ? _length : calculateUTF8Length(val);
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.STR8;
- }
-
- public StringType getType()
- {
- return StringType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<String> encoder)
- {
- return encoder == this;
- }
-
- public String readValue()
- {
-
- DecoderImpl decoder = getDecoder();
- int size = ((int)decoder.readRawByte()) & 0xff;
- return decoder.readRaw(_stringCreator, size);
- }
-
- public void setValue(final String val, final int length)
- {
- _value = val;
- _length = length;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java
deleted file mode 100644
index 4fb2038..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-public class SymbolType extends AbstractPrimitiveType<Symbol>
-{
- private static final Charset ASCII_CHARSET = Charset.forName("US-ASCII");
- private final SymbolEncoding _symbolEncoding;
- private final SymbolEncoding _shortSymbolEncoding;
-
- private final Map<ByteBuffer, Symbol> _symbolCache = new HashMap<ByteBuffer, Symbol>();
- private DecoderImpl.TypeDecoder<Symbol> _symbolCreator =
- new DecoderImpl.TypeDecoder<Symbol>()
- {
-
- public Symbol decode(final ByteBuffer buf)
- {
-
- Symbol symbol = _symbolCache.get(buf);
- if(symbol == null)
- {
- byte[] bytes = new byte[buf.limit()];
- buf.get(bytes);
-
- String str = new String(bytes, ASCII_CHARSET);
- symbol = Symbol.getSymbol(str);
-
- _symbolCache.put(ByteBuffer.wrap(bytes), symbol);
- }
- return symbol;
- }
- };
-
- public static interface SymbolEncoding extends PrimitiveTypeEncoding<Symbol>
- {
-
- }
-
- SymbolType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _symbolEncoding = new LongSymbolEncoding(encoder, decoder);
- _shortSymbolEncoding = new ShortSymbolEncoding(encoder, decoder);
- encoder.register(Symbol.class, this);
- decoder.register(this);
- }
-
- public Class<Symbol> getTypeClass()
- {
- return Symbol.class;
- }
-
- public SymbolEncoding getEncoding(final Symbol val)
- {
- return val.length() <= 255 ? _shortSymbolEncoding : _symbolEncoding;
- }
-
-
- public SymbolEncoding getCanonicalEncoding()
- {
- return _symbolEncoding;
- }
-
- public Collection<SymbolEncoding> getAllEncodings()
- {
- return Arrays.asList(_shortSymbolEncoding, _symbolEncoding);
- }
-
- private class LongSymbolEncoding
- extends LargeFloatingSizePrimitiveTypeEncoding<Symbol>
- implements SymbolEncoding
- {
-
- public LongSymbolEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final Symbol val)
- {
- final int length = val.length();
- final EncoderImpl encoder = getEncoder();
-
- for(int i = 0; i < length; i++)
- {
- encoder.writeRaw((byte)val.charAt(i));
- }
- }
-
- @Override
- protected int getEncodedValueSize(final Symbol val)
- {
- return val.length();
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SYM32;
- }
-
- public SymbolType getType()
- {
- return SymbolType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Symbol> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Symbol readValue()
- {
- DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- return decoder.readRaw(_symbolCreator, size);
- }
- }
-
- private class ShortSymbolEncoding
- extends SmallFloatingSizePrimitiveTypeEncoding<Symbol>
- implements SymbolEncoding
- {
-
- public ShortSymbolEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final Symbol val)
- {
-
- final int length = val.length();
- final EncoderImpl encoder = getEncoder();
-
- for(int i = 0; i < length; i++)
- {
- encoder.writeRaw((byte)val.charAt(i));
- }
- }
-
- @Override
- protected int getEncodedValueSize(final Symbol val)
- {
- return val.length();
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SYM8;
- }
-
- public SymbolType getType()
- {
- return SymbolType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Symbol> encoder)
- {
- return encoder == this;
- }
-
- public Symbol readValue()
- {
- DecoderImpl decoder = getDecoder();
- int size = ((int)decoder.readRawByte()) & 0xff;
- return decoder.readRaw(_symbolCreator, size);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java
deleted file mode 100644
index 54baa25..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-
-public class TimestampType extends AbstractPrimitiveType<Date>
-{
- private TimestampEncoding _timestampEncoding;
-
- TimestampType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _timestampEncoding = new TimestampEncoding(encoder, decoder);
- encoder.register(Date.class, this);
- decoder.register(this);
- }
-
- public Class<Date> getTypeClass()
- {
- return Date.class;
- }
-
- public TimestampEncoding getEncoding(final Date val)
- {
- return _timestampEncoding;
- }
-
-
- public TimestampEncoding getCanonicalEncoding()
- {
- return _timestampEncoding;
- }
-
- public Collection<TimestampEncoding> getAllEncodings()
- {
- return Collections.singleton(_timestampEncoding);
- }
-
- public void write(long l)
- {
- _timestampEncoding.write(l);
- }
-
- private class TimestampEncoding extends FixedSizePrimitiveTypeEncoding<Date>
- {
-
- public TimestampEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 8;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.TIMESTAMP;
- }
-
- public TimestampType getType()
- {
- return TimestampType.this;
- }
-
- public void writeValue(final Date val)
- {
- getEncoder().writeRaw(val.getTime());
- }
-
- public void write(final long l)
- {
- writeConstructor();
- getEncoder().writeRaw(l);
-
- }
-
- public boolean encodesSuperset(final TypeEncoding<Date> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Date readValue()
- {
- return new Date(getDecoder().readRawLong());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java
deleted file mode 100644
index 7b3f3a0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-public interface TypeConstructor<V>
-{
- V readValue();
-
- boolean encodesJavaPrimitive();
-
- Class<V> getTypeClass();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeEncoding.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeEncoding.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeEncoding.java
deleted file mode 100644
index 2a8d4e5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeEncoding.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-public interface TypeEncoding<V>
-{
- AMQPType<V> getType();
-
- void writeConstructor();
-
- int getConstructorSize();
-
- void writeValue(V val);
-
- int getValueSize(V val);
-
- boolean isFixedSizeVal();
-
- boolean encodesSuperset(TypeEncoding<V> encoder);
-
- boolean encodesJavaPrimitive();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java
deleted file mode 100644
index 20b9002..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.UUID;
-
-public class UUIDType extends AbstractPrimitiveType<UUID>
-{
- private UUIDEncoding _uuidEncoding;
-
- UUIDType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _uuidEncoding = new UUIDEncoding(encoder, decoder);
- encoder.register(UUID.class, this);
- decoder.register(this);
- }
-
- public Class<UUID> getTypeClass()
- {
- return UUID.class;
- }
-
- public UUIDEncoding getEncoding(final UUID val)
- {
- return _uuidEncoding;
- }
-
-
- public UUIDEncoding getCanonicalEncoding()
- {
- return _uuidEncoding;
- }
-
- public Collection<UUIDEncoding> getAllEncodings()
- {
- return Collections.singleton(_uuidEncoding);
- }
-
- private class UUIDEncoding extends FixedSizePrimitiveTypeEncoding<UUID>
- {
-
- public UUIDEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 16;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.UUID;
- }
-
- public UUIDType getType()
- {
- return UUIDType.this;
- }
-
- public void writeValue(final UUID val)
- {
- getEncoder().writeRaw(val.getMostSignificantBits());
- getEncoder().writeRaw(val.getLeastSignificantBits());
- }
-
- public boolean encodesSuperset(final TypeEncoding<UUID> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public UUID readValue()
- {
- long msb = getDecoder().readRawLong();
- long lsb = getDecoder().readRawLong();
-
- return new UUID(msb, lsb);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java
deleted file mode 100644
index 781a9de..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class UnsignedByteType extends AbstractPrimitiveType<UnsignedByte>
-{
- private UnsignedByteEncoding _unsignedByteEncoding;
-
- UnsignedByteType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _unsignedByteEncoding = new UnsignedByteEncoding(encoder, decoder);
- encoder.register(UnsignedByte.class, this);
- decoder.register(this);
- }
-
- public Class<UnsignedByte> getTypeClass()
- {
- return UnsignedByte.class;
- }
-
- public UnsignedByteEncoding getEncoding(final UnsignedByte val)
- {
- return _unsignedByteEncoding;
- }
-
-
- public UnsignedByteEncoding getCanonicalEncoding()
- {
- return _unsignedByteEncoding;
- }
-
- public Collection<UnsignedByteEncoding> getAllEncodings()
- {
- return Collections.singleton(_unsignedByteEncoding);
- }
-
- public class UnsignedByteEncoding extends FixedSizePrimitiveTypeEncoding<UnsignedByte>
- {
-
- public UnsignedByteEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.UBYTE;
- }
-
- public UnsignedByteType getType()
- {
- return UnsignedByteType.this;
- }
-
- public void writeValue(final UnsignedByte val)
- {
- getEncoder().writeRaw(val.byteValue());
- }
-
- public boolean encodesSuperset(final TypeEncoding<UnsignedByte> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public UnsignedByte readValue()
- {
- return UnsignedByte.valueOf(getDecoder().readRawByte());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java
deleted file mode 100644
index 860e373..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public class UnsignedIntegerType extends AbstractPrimitiveType<UnsignedInteger>
-{
- public static interface UnsignedIntegerEncoding extends PrimitiveTypeEncoding<UnsignedInteger>
- {
-
- }
-
- private UnsignedIntegerEncoding _unsignedIntegerEncoding;
- private UnsignedIntegerEncoding _smallUnsignedIntegerEncoding;
- private UnsignedIntegerEncoding _zeroUnsignedIntegerEncoding;
-
-
- UnsignedIntegerType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _unsignedIntegerEncoding = new AllUnsignedIntegerEncoding(encoder, decoder);
- _smallUnsignedIntegerEncoding = new SmallUnsignedIntegerEncoding(encoder, decoder);
- _zeroUnsignedIntegerEncoding = new ZeroUnsignedIntegerEncoding(encoder, decoder);
- encoder.register(UnsignedInteger.class, this);
- decoder.register(this);
- }
-
- public Class<UnsignedInteger> getTypeClass()
- {
- return UnsignedInteger.class;
- }
-
- public UnsignedIntegerEncoding getEncoding(final UnsignedInteger val)
- {
- int i = val.intValue();
- return i == 0
- ? _zeroUnsignedIntegerEncoding
- : (i >= 0 && i <= 255) ? _smallUnsignedIntegerEncoding : _unsignedIntegerEncoding;
- }
-
-
- public UnsignedIntegerEncoding getCanonicalEncoding()
- {
- return _unsignedIntegerEncoding;
- }
-
- public Collection<UnsignedIntegerEncoding> getAllEncodings()
- {
- return Arrays.asList(_unsignedIntegerEncoding, _smallUnsignedIntegerEncoding, _zeroUnsignedIntegerEncoding);
- }
-
-
- private class AllUnsignedIntegerEncoding
- extends FixedSizePrimitiveTypeEncoding<UnsignedInteger>
- implements UnsignedIntegerEncoding
- {
-
- public AllUnsignedIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 4;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.UINT;
- }
-
- public UnsignedIntegerType getType()
- {
- return UnsignedIntegerType.this;
- }
-
- public void writeValue(final UnsignedInteger val)
- {
- getEncoder().writeRaw(val.intValue());
- }
-
- public void write(final int i)
- {
- writeConstructor();
- getEncoder().writeRaw(i);
-
- }
-
- public boolean encodesSuperset(final TypeEncoding<UnsignedInteger> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public UnsignedInteger readValue()
- {
- return UnsignedInteger.valueOf(getDecoder().readRawInt());
- }
- }
-
- private class SmallUnsignedIntegerEncoding
- extends FixedSizePrimitiveTypeEncoding<UnsignedInteger>
- implements UnsignedIntegerEncoding
- {
- public SmallUnsignedIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SMALLUINT;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
-
- public UnsignedIntegerType getType()
- {
- return UnsignedIntegerType.this;
- }
-
- public void writeValue(final UnsignedInteger val)
- {
- getEncoder().writeRaw((byte)val.intValue());
- }
-
- public boolean encodesSuperset(final TypeEncoding<UnsignedInteger> encoder)
- {
- return encoder == this || encoder instanceof ZeroUnsignedIntegerEncoding;
- }
-
- public UnsignedInteger readValue()
- {
- return UnsignedInteger.valueOf(((int)getDecoder().readRawByte()) & 0xff);
- }
- }
-
-
- private class ZeroUnsignedIntegerEncoding
- extends FixedSizePrimitiveTypeEncoding<UnsignedInteger>
- implements UnsignedIntegerEncoding
- {
- public ZeroUnsignedIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.UINT0;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 0;
- }
-
-
- public UnsignedIntegerType getType()
- {
- return UnsignedIntegerType.this;
- }
-
- public void writeValue(final UnsignedInteger val)
- {
- }
-
- public boolean encodesSuperset(final TypeEncoding<UnsignedInteger> encoder)
- {
- return encoder == this;
- }
-
- public UnsignedInteger readValue()
- {
- return UnsignedInteger.ZERO;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java
deleted file mode 100644
index 4b7980e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.UnsignedLong;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public class UnsignedLongType extends AbstractPrimitiveType<UnsignedLong>
-{
- public static interface UnsignedLongEncoding extends PrimitiveTypeEncoding<UnsignedLong>
- {
-
- }
-
- private UnsignedLongEncoding _unsignedLongEncoding;
- private UnsignedLongEncoding _smallUnsignedLongEncoding;
- private UnsignedLongEncoding _zeroUnsignedLongEncoding;
-
-
- UnsignedLongType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _unsignedLongEncoding = new AllUnsignedLongEncoding(encoder, decoder);
- _smallUnsignedLongEncoding = new SmallUnsignedLongEncoding(encoder, decoder);
- _zeroUnsignedLongEncoding = new ZeroUnsignedLongEncoding(encoder, decoder);
- encoder.register(UnsignedLong.class, this);
- decoder.register(this);
- }
-
- public Class<UnsignedLong> getTypeClass()
- {
- return UnsignedLong.class;
- }
-
- public UnsignedLongEncoding getEncoding(final UnsignedLong val)
- {
- long l = val.longValue();
- return l == 0L
- ? _zeroUnsignedLongEncoding
- : (l >= 0 && l <= 255L) ? _smallUnsignedLongEncoding : _unsignedLongEncoding;
- }
-
-
- public UnsignedLongEncoding getCanonicalEncoding()
- {
- return _unsignedLongEncoding;
- }
-
- public Collection<UnsignedLongEncoding> getAllEncodings()
- {
- return Arrays.asList(_zeroUnsignedLongEncoding, _smallUnsignedLongEncoding, _unsignedLongEncoding);
- }
-
-
- private class AllUnsignedLongEncoding
- extends FixedSizePrimitiveTypeEncoding<UnsignedLong>
- implements UnsignedLongEncoding
- {
-
- public AllUnsignedLongEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 8;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.ULONG;
- }
-
- public UnsignedLongType getType()
- {
- return UnsignedLongType.this;
- }
-
- public void writeValue(final UnsignedLong val)
- {
- getEncoder().writeRaw(val.longValue());
- }
-
-
- public boolean encodesSuperset(final TypeEncoding<UnsignedLong> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public UnsignedLong readValue()
- {
- return UnsignedLong.valueOf(getDecoder().readRawLong());
- }
- }
-
- private class SmallUnsignedLongEncoding
- extends FixedSizePrimitiveTypeEncoding<UnsignedLong>
- implements UnsignedLongEncoding
- {
- public SmallUnsignedLongEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SMALLULONG;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
-
- public UnsignedLongType getType()
- {
- return UnsignedLongType.this;
- }
-
- public void writeValue(final UnsignedLong val)
- {
- getEncoder().writeRaw((byte)val.longValue());
- }
-
- public boolean encodesSuperset(final TypeEncoding<UnsignedLong> encoder)
- {
- return encoder == this || encoder instanceof ZeroUnsignedLongEncoding;
- }
-
- public UnsignedLong readValue()
- {
- return UnsignedLong.valueOf(((long)getDecoder().readRawByte())&0xffl);
- }
- }
-
-
- private class ZeroUnsignedLongEncoding
- extends FixedSizePrimitiveTypeEncoding<UnsignedLong>
- implements UnsignedLongEncoding
- {
- public ZeroUnsignedLongEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.ULONG0;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 0;
- }
-
-
- public UnsignedLongType getType()
- {
- return UnsignedLongType.this;
- }
-
- public void writeValue(final UnsignedLong val)
- {
- }
-
- public boolean encodesSuperset(final TypeEncoding<UnsignedLong> encoder)
- {
- return encoder == this;
- }
-
- public UnsignedLong readValue()
- {
- return UnsignedLong.ZERO;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java
deleted file mode 100644
index 378c207..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class UnsignedShortType extends AbstractPrimitiveType<UnsignedShort>
-{
- private UnsignedShortEncoding _unsignedShortEncoder;
-
- UnsignedShortType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _unsignedShortEncoder = new UnsignedShortEncoding(encoder, decoder);
- encoder.register(UnsignedShort.class, this);
- decoder.register(this);
- }
-
- public Class<UnsignedShort> getTypeClass()
- {
- return UnsignedShort.class;
- }
-
- public UnsignedShortEncoding getEncoding(final UnsignedShort val)
- {
- return _unsignedShortEncoder;
- }
-
-
- public UnsignedShortEncoding getCanonicalEncoding()
- {
- return _unsignedShortEncoder;
- }
-
- public Collection<UnsignedShortEncoding> getAllEncodings()
- {
- return Collections.singleton(_unsignedShortEncoder);
- }
-
- private class UnsignedShortEncoding extends FixedSizePrimitiveTypeEncoding<UnsignedShort>
- {
-
- public UnsignedShortEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 2;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.USHORT;
- }
-
- public UnsignedShortType getType()
- {
- return UnsignedShortType.this;
- }
-
- public void writeValue(final UnsignedShort val)
- {
- getEncoder().writeRaw(val.shortValue());
- }
-
- public boolean encodesSuperset(final TypeEncoding<UnsignedShort> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public UnsignedShort readValue()
- {
- return UnsignedShort.valueOf(getDecoder().readRawShort());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/WritableBuffer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/WritableBuffer.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/WritableBuffer.java
deleted file mode 100644
index 79676b3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/WritableBuffer.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec;
-
-import java.nio.ByteBuffer;
-
-public interface WritableBuffer
-{
- void put(byte b);
-
- void putFloat(float f);
-
- void putDouble(double d);
-
- void put(byte[] src, int offset, int length);
-
- void putShort(short s);
-
- void putInt(int i);
-
- void putLong(long l);
-
- boolean hasRemaining();
-
- int remaining();
-
- int position();
-
- void position(int position);
-
- void put(ByteBuffer payload);
-
- int limit();
-
- class ByteBufferWrapper implements WritableBuffer
- {
- private final ByteBuffer _buf;
-
- public ByteBufferWrapper(ByteBuffer buf)
- {
- _buf = buf;
- }
-
- @Override
- public void put(byte b)
- {
- _buf.put(b);
- }
-
- @Override
- public void putFloat(float f)
- {
- _buf.putFloat(f);
- }
-
- @Override
- public void putDouble(double d)
- {
- _buf.putDouble(d);
- }
-
- @Override
- public void put(byte[] src, int offset, int length)
- {
- _buf.put(src, offset, length);
- }
-
- @Override
- public void putShort(short s)
- {
- _buf.putShort(s);
- }
-
- @Override
- public void putInt(int i)
- {
- _buf.putInt(i);
- }
-
- @Override
- public void putLong(long l)
- {
- _buf.putLong(l);
- }
-
- @Override
- public boolean hasRemaining()
- {
- return _buf.hasRemaining();
- }
-
- @Override
- public int remaining()
- {
- return _buf.remaining();
- }
-
- @Override
- public int position()
- {
- return _buf.position();
- }
-
- @Override
- public void position(int position)
- {
- _buf.position(position);
- }
-
- @Override
- public void put(ByteBuffer src)
- {
- _buf.put(src);
- }
-
- @Override
- public int limit()
- {
- return _buf.limit();
- }
-
- @Override
- public String toString()
- {
- return String.format("[pos: %d, limit: %d, remaining:%d]", _buf.position(), _buf.limit(), _buf.remaining());
- }
-
- public static ByteBufferWrapper allocate(int size)
- {
- ByteBuffer allocated = ByteBuffer.allocate(size);
- return new ByteBufferWrapper(allocated);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/AbstractElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/AbstractElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/AbstractElement.java
deleted file mode 100644
index d0dd30c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/AbstractElement.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-abstract class AbstractElement<T> implements Element<T>
-{
- private Element _parent;
- private Element _next;
- private Element _prev;
-
- AbstractElement(Element parent, Element prev)
- {
- _parent = parent;
- _prev = prev;
- }
-
- protected boolean isElementOfArray()
- {
- return _parent instanceof ArrayElement && !(((ArrayElement)parent()).isDescribed() && this == _parent.child());
- }
-
- @Override
- public Element next()
- {
- // TODO
- return _next;
- }
-
- @Override
- public Element prev()
- {
- // TODO
- return _prev;
- }
-
- @Override
- public Element parent()
- {
- // TODO
- return _parent;
- }
-
- @Override
- public void setNext(Element elt)
- {
- _next = elt;
- }
-
- @Override
- public void setPrev(Element elt)
- {
- _prev = elt;
- }
-
- @Override
- public void setParent(Element elt)
- {
- _parent = elt;
- }
-
- @Override
- public Element replaceWith(Element elt)
- {
- if (_parent != null) {
- elt = _parent.checkChild(elt);
- }
-
- elt.setPrev(_prev);
- elt.setNext(_next);
- elt.setParent(_parent);
-
- if (_prev != null) {
- _prev.setNext(elt);
- }
- if (_next != null) {
- _next.setPrev(elt);
- }
-
- if (_parent != null && _parent.child() == this) {
- _parent.setChild(elt);
- }
-
- return elt;
- }
-
- @Override
- public String toString()
- {
- return String.format("%s[%h]{parent=%h, prev=%h, next=%h}",
- this.getClass().getSimpleName(),
- System.identityHashCode(this),
- System.identityHashCode(_parent),
- System.identityHashCode(_prev),
- System.identityHashCode(_next));
- }
-
- abstract String startSymbol();
-
- abstract String stopSymbol();
-
- @Override
- public void render(StringBuilder sb)
- {
- if (canEnter()) {
- sb.append(startSymbol());
- Element el = child();
- boolean first = true;
- while (el != null) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- el.render(sb);
- el = el.next();
- }
- sb.append(stopSymbol());
- } else {
- sb.append(getDataType()).append(" ").append(getValue());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ArrayElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ArrayElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ArrayElement.java
deleted file mode 100644
index 22251fe..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ArrayElement.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.codec.Data;
-
-class ArrayElement extends AbstractElement<Object[]>
-{
-
- private final boolean _described;
- private final Data.DataType _arrayType;
- private ConstructorType _constructorType;
- private Element _first;
-
-
- static enum ConstructorType { TINY, SMALL, LARGE }
-
-
- static ConstructorType TINY = ConstructorType.TINY;
- static ConstructorType SMALL = ConstructorType.SMALL;
- static ConstructorType LARGE = ConstructorType.LARGE;
-
- ArrayElement(Element parent, Element prev, boolean described, Data.DataType type)
- {
- super(parent, prev);
- _described = described;
- _arrayType = type;
- if(_arrayType == null)
- {
- throw new NullPointerException("Array type cannot be null");
- }
- else if(_arrayType == Data.DataType.DESCRIBED)
- {
- throw new IllegalArgumentException("Array type cannot be DESCRIBED");
- }
- switch(_arrayType)
- {
- case UINT:
- case ULONG:
- case LIST:
- setConstructorType(TINY);
- break;
- default:
- setConstructorType(SMALL);
- }
- }
-
- ConstructorType constructorType()
- {
- return _constructorType;
- }
-
- void setConstructorType(ConstructorType type)
- {
- _constructorType = type;
- }
-
- @Override
- public int size()
- {
- ConstructorType oldConstructorType;
- int bodySize;
- int count = 0;
- do
- {
- bodySize = 1; // data type constructor
- oldConstructorType = _constructorType;
- Element element = _first;
- while(element != null)
- {
- count++;
- bodySize += element.size();
- element = element.next();
- }
- }
- while (oldConstructorType != constructorType());
-
- if(isDescribed())
- {
- bodySize++; // 00 instruction
- if(count != 0)
- {
- count--;
- }
- }
-
- if(isElementOfArray())
- {
- ArrayElement parent = (ArrayElement)parent();
- if(parent.constructorType()==SMALL)
- {
- if(count<=255 && bodySize<=254)
- {
- bodySize+=2;
- }
- else
- {
- parent.setConstructorType(LARGE);
- bodySize+=8;
- }
- }
- else
- {
- bodySize+=8;
- }
- }
- else
- {
-
- if(count<=255 && bodySize<=254)
- {
- bodySize+=3;
- }
- else
- {
- bodySize+=9;
- }
-
- }
-
-
- return bodySize;
- }
-
- @Override
- public Object[] getValue()
- {
- if(isDescribed())
- {
- DescribedType[] rVal = new DescribedType[(int) count()];
- Object descriptor = _first == null ? null : _first.getValue();
- Element element = _first == null ? null : _first.next();
- int i = 0;
- while(element != null)
- {
- rVal[i++] = new DescribedTypeImpl(descriptor, element.getValue());
- element = element.next();
- }
- return rVal;
- }
- else if(_arrayType == Data.DataType.SYMBOL)
- {
- Symbol[] rVal = new Symbol[(int) count()];
- SymbolElement element = (SymbolElement) _first;
- int i = 0;
- while (element!=null)
- {
- rVal[i++] = element.getValue();
- element = (SymbolElement) element.next();
- }
- return rVal;
- }
- else
- {
- Object[] rVal = new Object[(int) count()];
- Element element = _first;
- int i = 0;
- while (element!=null)
- {
- rVal[i++] = element.getValue();
- element = element.next();
- }
- return rVal;
- }
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.ARRAY;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
-
- final int count = (int) count();
-
- if(b.remaining()>=size)
- {
- if(!isElementOfArray())
- {
- if(size>257 || count >255)
- {
- b.put((byte)0xf0);
- b.putInt(size-5);
- b.putInt(count);
- }
- else
- {
- b.put((byte)0xe0);
- b.put((byte)(size-2));
- b.put((byte)count);
- }
- }
- else
- {
- ArrayElement parent = (ArrayElement)parent();
- if(parent.constructorType()==SMALL)
- {
- b.put((byte)(size-1));
- b.put((byte)count);
- }
- else
- {
- b.putInt(size-4);
- b.putInt(count);
- }
- }
- Element element = _first;
- if(isDescribed())
- {
- b.put((byte)0);
- if(element == null)
- {
- b.put((byte)0x40);
- }
- else
- {
- element.encode(b);
- element = element.next();
- }
- }
- switch(_arrayType)
- {
- case NULL:
- b.put((byte)0x40);
- break;
- case BOOL:
- b.put((byte)0x56);
- break;
- case UBYTE:
- b.put((byte)0x50);
- break;
- case BYTE:
- b.put((byte)0x51);
- break;
- case USHORT:
- b.put((byte)0x60);
- break;
- case SHORT:
- b.put((byte)0x61);
- break;
- case UINT:
- switch (constructorType())
- {
- case TINY:
- b.put((byte)0x43);
- break;
- case SMALL:
- b.put((byte)0x52);
- break;
- case LARGE:
- b.put((byte)0x70);
- break;
- }
- break;
- case INT:
- b.put(_constructorType == SMALL ? (byte)0x54 : (byte)0x71);
- break;
- case CHAR:
- b.put((byte)0x73);
- break;
- case ULONG:
- switch (constructorType())
- {
- case TINY:
- b.put((byte)0x44);
- break;
- case SMALL:
- b.put((byte)0x53);
- break;
- case LARGE:
- b.put((byte)0x80);
- break;
- }
- break;
- case LONG:
- b.put(_constructorType == SMALL ? (byte)0x55 : (byte)0x81);
- break;
- case TIMESTAMP:
- b.put((byte)0x83);
- break;
- case FLOAT:
- b.put((byte)0x72);
- break;
- case DOUBLE:
- b.put((byte)0x82);
- break;
- case DECIMAL32:
- b.put((byte)0x74);
- break;
- case DECIMAL64:
- b.put((byte)0x84);
- break;
- case DECIMAL128:
- b.put((byte)0x94);
- break;
- case UUID:
- b.put((byte)0x98);
- break;
- case BINARY:
- b.put(_constructorType == SMALL ? (byte)0xa0 : (byte)0xb0);
- break;
- case STRING:
- b.put(_constructorType == SMALL ? (byte)0xa1 : (byte)0xb1);
- break;
- case SYMBOL:
- b.put(_constructorType == SMALL ? (byte)0xa3 : (byte)0xb3);
- break;
- case ARRAY:
- b.put(_constructorType == SMALL ? (byte)0xe0 : (byte)0xf0);
- break;
- case LIST:
- b.put(_constructorType == TINY ? (byte)0x45 :_constructorType == SMALL ? (byte)0xc0 : (byte)0xd0);
- break;
- case MAP:
- b.put(_constructorType == SMALL ? (byte)0xc1 : (byte)0xd1);
- break;
- }
- while(element!=null)
- {
- element.encode(b);
- element = element.next();
- }
- return size;
- }
- else
- {
- return 0;
- }
- }
-
- @Override
- public boolean canEnter()
- {
- return true;
- }
-
- @Override
- public Element child()
- {
- return _first;
- }
-
- @Override
- public void setChild(Element elt)
- {
- _first = elt;
- }
-
- @Override
- public Element addChild(Element element)
- {
- if(isDescribed() || element.getDataType() == _arrayType)
- {
- _first = element;
- return element;
- }
- else
- {
- Element replacement = coerce(element);
- if(replacement != null)
- {
- _first = replacement;
- return replacement;
- }
- throw new IllegalArgumentException("Attempting to add instance of " + element.getDataType() + " to array of " + _arrayType);
- }
- }
-
- private Element coerce(Element element)
- {
- switch (_arrayType)
- {
- case INT:
- int i;
- switch (element.getDataType())
- {
- case BYTE:
- i = ((ByteElement)element).getValue().intValue();
- break;
- case SHORT:
- i = ((ShortElement)element).getValue().intValue();
- break;
- case LONG:
- i = ((LongElement)element).getValue().intValue();
- break;
- default:
- return null;
- }
- return new IntegerElement(element.parent(),element.prev(),i);
-
- case LONG:
- long l;
- switch (element.getDataType())
- {
- case BYTE:
- l = ((ByteElement)element).getValue().longValue();
- break;
- case SHORT:
- l = ((ShortElement)element).getValue().longValue();
- break;
- case INT:
- l = ((IntegerElement)element).getValue().longValue();
- break;
- default:
- return null;
- }
- return new LongElement(element.parent(),element.prev(),l);
- }
- return null;
- }
-
- @Override
- public Element checkChild(Element element)
- {
- if(element.getDataType() != _arrayType)
- {
- Element replacement = coerce(element);
- if(replacement != null)
- {
- return replacement;
- }
- throw new IllegalArgumentException("Attempting to add instance of " + element.getDataType() + " to array of " + _arrayType);
- }
- return element;
- }
-
-
- public long count()
- {
- int count = 0;
- Element elt = _first;
- while(elt != null)
- {
- count++;
- elt = elt.next();
- }
- if(isDescribed() && count != 0)
- {
- count--;
- }
- return count;
- }
-
- public boolean isDescribed()
- {
- return _described;
- }
-
-
- public Data.DataType getArrayDataType()
- {
- return _arrayType;
- }
-
- @Override
- String startSymbol() {
- return String.format("%s%s[", isDescribed() ? "D" : "", getArrayDataType());
- }
-
- @Override
- String stopSymbol() {
- return "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/AtomicElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/AtomicElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/AtomicElement.java
deleted file mode 100644
index d414943..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/AtomicElement.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-abstract class AtomicElement<T> extends AbstractElement<T>
-{
-
- AtomicElement(Element parent, Element prev)
- {
- super(parent, prev);
- }
-
- @Override
- public Element child()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setChild(Element elt)
- {
- throw new UnsupportedOperationException();
- }
-
-
- @Override
- public boolean canEnter()
- {
- return false;
- }
-
- @Override
- public Element checkChild(Element element)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Element addChild(Element element)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- String startSymbol() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- String stopSymbol() {
- throw new UnsupportedOperationException();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java
deleted file mode 100644
index fd05243..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BinaryElement.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.codec.Data;
-
-class BinaryElement extends AtomicElement<Binary>
-{
-
- private final Binary _value;
-
- BinaryElement(Element parent, Element prev, Binary b)
- {
- super(parent, prev);
- byte[] data = new byte[b.getLength()];
- System.arraycopy(b.getArray(),b.getArrayOffset(),data,0,b.getLength());
- _value = new Binary(data);
- }
-
- @Override
- public int size()
- {
- final int length = _value.getLength();
-
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(length > 255)
- {
- parent.setConstructorType(ArrayElement.LARGE);
- return 4+length;
- }
- else
- {
- return 1+length;
- }
- }
- else
- {
- return 4+length;
- }
- }
- else
- {
- if(length >255)
- {
- return 5 + length;
- }
- else
- {
- return 2 + length;
- }
- }
- }
-
- @Override
- public Binary getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.BINARY;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(b.remaining()<size)
- {
- return 0;
- }
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- b.put((byte)_value.getLength());
- }
- else
- {
- b.putInt(_value.getLength());
- }
- }
- else if(_value.getLength()<=255)
- {
- b.put((byte)0xa0);
- b.put((byte)_value.getLength());
- }
- else
- {
- b.put((byte)0xb0);
- b.put((byte)_value.getLength());
- }
- b.put(_value.getArray(),_value.getArrayOffset(),_value.getLength());
- return size;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BooleanElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BooleanElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BooleanElement.java
deleted file mode 100644
index f2fb704..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/BooleanElement.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class BooleanElement extends AtomicElement<Boolean>
-{
- private final boolean _value;
-
- public BooleanElement(Element parent, Element current, boolean b)
- {
- super(parent, current);
- _value = b;
- }
-
- @Override
- public int size()
- {
- // in non-array parent then there is a single byte encoding, in an array there is a 1-byte encoding but no
- // constructor
- return 1;
- }
-
- @Override
- public Boolean getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.BOOL;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- if(b.hasRemaining())
- {
- if(isElementOfArray())
- {
- b.put(_value ? (byte) 1 : (byte) 0);
- }
- else
- {
- b.put(_value ? (byte) 0x41 : (byte) 0x42);
- }
- return 1;
- }
- return 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ByteElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ByteElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ByteElement.java
deleted file mode 100644
index 69bde08..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ByteElement.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class ByteElement extends AtomicElement<Byte>
-{
-
- private final byte _value;
-
- ByteElement(Element parent, Element prev, byte b)
- {
- super(parent, prev);
- _value = b;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 1 : 2;
- }
-
- @Override
- public Byte getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.BYTE;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- if(isElementOfArray())
- {
- if(b.hasRemaining())
- {
- b.put(_value);
- return 1;
- }
- }
- else
- {
- if(b.remaining()>=2)
- {
- b.put((byte)0x51);
- b.put(_value);
- return 2;
- }
- }
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/CharElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/CharElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/CharElement.java
deleted file mode 100644
index 808d43e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/CharElement.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class CharElement extends AtomicElement<Integer>
-{
-
- private final int _value;
-
- CharElement(Element parent, Element prev, int i)
- {
- super(parent, prev);
- _value = i;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 4 : 5;
- }
-
- @Override
- public Integer getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.CHAR;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- final int size = size();
- if(size <= b.remaining())
- {
- if(size == 5)
- {
- b.put((byte)0x73);
- }
- b.putInt(_value);
- }
- return 0;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[32/34] qpid-proton git commit: PROTON-1385: remove various skips etc
from tests that are no longer applicable
Posted by ac...@apache.org.
PROTON-1385: remove various skips etc from tests that are no longer applicable
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cac0fc43
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cac0fc43
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cac0fc43
Branch: refs/heads/go1
Commit: cac0fc437c6170bfe4183d1311302ad5b0826174
Parents: ccdcf32
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Jan 9 15:01:48 2017 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Jan 9 15:01:48 2017 +0000
----------------------------------------------------------------------
tests/python/proton_tests/engine.py | 25 ++-----------------------
tests/python/proton_tests/messenger.py | 2 --
tests/python/proton_tests/reactor.py | 8 ++------
tests/python/proton_tests/sasl.py | 23 -----------------------
tests/python/proton_tests/ssl.py | 6 ------
tests/python/proton_tests/utils.py | 2 --
6 files changed, 4 insertions(+), 62 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cac0fc43/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 497bb7d..05e9f8f 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -240,16 +240,10 @@ class ConnectionTest(Test):
self.c1.transport.channel_max = value
self.c1.open()
self.pump()
- if "java" in sys.platform:
- assert self.c1.transport.channel_max == 65535, (self.c1.transport.channel_max, value)
- else:
- assert self.c1.transport.channel_max == 32767, (self.c1.transport.channel_max, value)
+ assert self.c1.transport.channel_max == 32767, (self.c1.transport.channel_max, value)
def test_channel_max_raise_and_lower(self):
- if "java" in sys.platform:
- upper_limit = 65535
- else:
- upper_limit = 32767
+ upper_limit = 32767
# It's OK to lower the max below upper_limit.
self.c1.transport.channel_max = 12345
@@ -308,9 +302,6 @@ class ConnectionTest(Test):
assert c2.state == Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_CLOSED
def test_user_config(self):
- if "java" in sys.platform:
- raise Skipped("Unsupported API")
-
self.c1.user = "vindaloo"
self.c1.password = "secret"
self.c1.open()
@@ -747,8 +738,6 @@ class LinkTest(Test):
assert self.rcv.remote_snd_settle_mode == Link.SND_UNSETTLED
def test_max_message_size(self):
- if "java" in sys.platform:
- raise Skipped()
assert self.snd.max_message_size == 0
assert self.rcv.remote_max_message_size == 0
self.snd.max_message_size = 13579
@@ -2030,8 +2019,6 @@ class ServerTest(Test):
def testKeepalive(self):
""" Verify that idle frames are sent to keep a Connection alive
"""
- if "java" in sys.platform:
- raise Skipped()
idle_timeout = self.delay
server = common.TestServer()
server.start()
@@ -2063,8 +2050,6 @@ class ServerTest(Test):
""" Verify that a Connection is terminated properly when Idle frames do not
arrive in a timely manner.
"""
- if "java" in sys.platform:
- raise Skipped()
idle_timeout = self.delay
server = common.TestServer(idle_timeout=idle_timeout)
server.start()
@@ -2652,8 +2637,6 @@ class DeliverySegFaultTest(Test):
class SaslEventTest(CollectorTest):
def testAnonymousNoInitialResponse(self):
- if "java" in sys.platform:
- raise Skipped()
conn = Connection()
conn.collect(self.collector)
transport = Transport(Transport.SERVER)
@@ -2671,8 +2654,6 @@ class SaslEventTest(CollectorTest):
self.expect()
def testPipelinedServerReadFirst(self):
- if "java" in sys.platform:
- raise Skipped()
conn = Connection()
conn.collect(self.collector)
transport = Transport(Transport.CLIENT)
@@ -2701,8 +2682,6 @@ class SaslEventTest(CollectorTest):
assert server.sasl().outcome == SASL.OK
def testPipelinedServerWriteFirst(self):
- if "java" in sys.platform:
- raise Skipped()
conn = Connection()
conn.collect(self.collector)
transport = Transport(Transport.CLIENT)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cac0fc43/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/messenger.py b/tests/python/proton_tests/messenger.py
index 8da068e..7e08c98 100644
--- a/tests/python/proton_tests/messenger.py
+++ b/tests/python/proton_tests/messenger.py
@@ -1053,8 +1053,6 @@ class IdleTimeoutTest(common.Test):
Verify that a Messenger connection is kept alive using empty idle frames
when a idle_timeout is advertised by the remote peer.
"""
- if "java" in sys.platform:
- raise Skipped()
idle_timeout_secs = self.delay
try:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cac0fc43/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index 424570d..8a3a6af 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -473,12 +473,8 @@ class ContainerTest(Test):
def test_no_virtual_host(self):
# explicitly setting an empty virtual host should prevent the hostname
- # field from being sent in the Open performative
- if "java" in sys.platform:
- # This causes Python Container to *not* set the connection virtual
- # host, so when proton-j sets up the connection the virtual host
- # seems to be unset and the URL's host is used (as expected).
- raise SkipTest("Does not apply for proton-j");
+ # field from being sent in the Open performative when using the
+ # Python Container.
server_handler = ContainerTest._ServerHandler("localhost")
container = Container(server_handler)
conn = container.connect(url=Url(host="localhost",
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cac0fc43/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index 0f5f525..c23ef97 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -104,10 +104,6 @@ class SaslTest(Test):
# We have to generate the client frames manually because proton does not
# generate pipelined SASL and AMQP frames together
def testIllegalProtocolLayering(self):
- # TODO: Skip Proton-J for now
- if "java" in sys.platform:
- raise Skipped("Proton-J does not set error condition on protocol layering violation")
-
# Server
self.s2.allowed_mechs('ANONYMOUS')
@@ -139,10 +135,6 @@ class SaslTest(Test):
assert not c2.state & Endpoint.REMOTE_ACTIVE
def testPipelinedClient(self):
- # TODO: When PROTON-1136 is fixed then remove this test
- if "java" in sys.platform:
- raise Skipped("Proton-J does not support pipelined client input")
-
# Server
self.s2.allowed_mechs('ANONYMOUS')
@@ -200,9 +192,6 @@ class SaslTest(Test):
assert c1.state & Endpoint.REMOTE_ACTIVE
def testPipelined2(self):
- if "java" in sys.platform:
- raise Skipped("Proton-J does not support client pipelining")
-
out1 = self.t1.peek(1024)
self.t1.pop(len(out1))
self.t2.push(out1)
@@ -291,8 +280,6 @@ class SaslTest(Test):
assert self.t1.condition != None
def testMechNotFound(self):
- if "java" in sys.platform:
- raise Skipped("Proton-J does not support checking authentication state")
self.c1 = Connection()
self.c1.open()
self.t1.bind(self.c1)
@@ -397,8 +384,6 @@ class SSLSASLTest(Test):
self.c2 = Connection()
def testSSLPlainSimple(self):
- if "java" in sys.platform:
- raise Skipped("Proton-J does not support SSL with SASL")
if not SASL.extended():
raise Skipped("Simple SASL server does not support PLAIN")
common.ensureCanTestExtendedSASL()
@@ -416,8 +401,6 @@ class SSLSASLTest(Test):
_testSaslMech(self, mech, encrypted=True)
def testSSLPlainSimpleFail(self):
- if "java" in sys.platform:
- raise Skipped("Proton-J does not support SSL with SASL")
if not SASL.extended():
raise Skipped("Simple SASL server does not support PLAIN")
common.ensureCanTestExtendedSASL()
@@ -435,9 +418,6 @@ class SSLSASLTest(Test):
_testSaslMech(self, mech, clientUser='usr@proton', encrypted=True, authenticated=False)
def testSSLExternalSimple(self):
- if "java" in sys.platform:
- raise Skipped("Proton-J does not support SSL with SASL")
-
if os.name=="nt":
extUser = 'O=Client, CN=127.0.0.1'
else:
@@ -462,9 +442,6 @@ class SSLSASLTest(Test):
_testSaslMech(self, mech, clientUser=None, authUser=extUser, encrypted=True)
def testSSLExternalSimpleFail(self):
- if "java" in sys.platform:
- raise Skipped("Proton-J does not support SSL with SASL")
-
mech = 'EXTERNAL'
self.server_domain.set_credentials(_sslCertpath("server-certificate.pem"),
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cac0fc43/tests/python/proton_tests/ssl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/ssl.py b/tests/python/proton_tests/ssl.py
index 89fe828..566fefa 100644
--- a/tests/python/proton_tests/ssl.py
+++ b/tests/python/proton_tests/ssl.py
@@ -189,9 +189,6 @@ class SslTest(common.Test):
if os.name=="nt":
raise Skipped("Windows support for certificate fingerprint and subfield not implemented yet")
- if "java" in sys.platform:
- raise Skipped("Not yet implemented in Proton-J")
-
self.server_domain.set_credentials(self._testpath("server-certificate.pem"),
self._testpath("server-private-key.pem"),
"server-password")
@@ -967,9 +964,6 @@ class MessengerSSLTests(common.Test):
password="server-password",
exception=None):
import sys
- # java doesn't do validation in the same way (yet)
- if exception and "java" in sys.platform:
- raise Skipped()
self.server.certificate = _testpath(cert)
self.server.private_key = _testpath(key)
self.server.password = password
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cac0fc43/tests/python/proton_tests/utils.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/utils.py b/tests/python/proton_tests/utils.py
index 0766eb9..52d0dc2 100644
--- a/tests/python/proton_tests/utils.py
+++ b/tests/python/proton_tests/utils.py
@@ -136,8 +136,6 @@ class SyncRequestResponseTest(Test):
def test_allowed_mechs_external(self):
# All this test does it make sure that if we pass allowed_mechs to BlockingConnection, it is actually used.
- if "java" in sys.platform:
- raise Skipped("")
port = free_tcp_port()
server = ConnPropertiesServer(Url(host="127.0.0.1", port=port), timeout=self.timeout)
server.start()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[27/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java
deleted file mode 100644
index aac3fc5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp;
-
-import java.nio.ByteBuffer;
-import java.util.Collection;
-
-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<Binary> 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());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal128.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal128.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal128.java
deleted file mode 100644
index 2eea815..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal128.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.amqp;
-
-import java.math.BigDecimal;
-import java.nio.ByteBuffer;
-
-public final class Decimal128 extends Number
-{
- private final BigDecimal _underlying;
- private final long _msb;
- private final long _lsb;
-
- public Decimal128(BigDecimal underlying)
- {
- _underlying = underlying;
-
- _msb = calculateMostSignificantBits(underlying);
- _lsb = calculateLeastSignificantBits(underlying);
- }
-
-
- public Decimal128(final long msb, final long lsb)
- {
- _msb = msb;
- _lsb = lsb;
-
- _underlying = calculateBigDecimal(msb, lsb);
-
- }
-
- public Decimal128(byte[] data)
- {
- this(ByteBuffer.wrap(data));
- }
-
- private Decimal128(final ByteBuffer buffer)
- {
- this(buffer.getLong(),buffer.getLong());
- }
-
- private static long calculateMostSignificantBits(final BigDecimal underlying)
- {
- return 0; //TODO.
- }
-
- private static long calculateLeastSignificantBits(final BigDecimal underlying)
- {
- return 0; //TODO.
- }
-
- private static BigDecimal calculateBigDecimal(final long msb, final long lsb)
- {
- return BigDecimal.ZERO; //TODO.
- }
-
- @Override
- public int intValue()
- {
- return _underlying.intValue();
- }
-
- @Override
- public long longValue()
- {
- return _underlying.longValue();
- }
-
- @Override
- public float floatValue()
- {
- return _underlying.floatValue();
- }
-
- @Override
- public double doubleValue()
- {
- return _underlying.doubleValue();
- }
-
- public long getMostSignificantBits()
- {
- return _msb;
- }
-
- public long getLeastSignificantBits()
- {
- return _lsb;
- }
-
- public byte[] asBytes()
- {
- byte[] bytes = new byte[16];
- ByteBuffer buf = ByteBuffer.wrap(bytes);
- buf.putLong(getMostSignificantBits());
- buf.putLong(getLeastSignificantBits());
- return bytes;
- }
-
- @Override
- public boolean equals(final Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- final Decimal128 that = (Decimal128) o;
-
- if (_lsb != that._lsb)
- {
- return false;
- }
- if (_msb != that._msb)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = (int) (_msb ^ (_msb >>> 32));
- result = 31 * result + (int) (_lsb ^ (_lsb >>> 32));
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal32.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal32.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal32.java
deleted file mode 100644
index 50ced8a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal32.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.amqp;
-
-import java.math.BigDecimal;
-
-public final class Decimal32 extends Number
-{
- private final BigDecimal _underlying;
- private final int _bits;
-
- public Decimal32(BigDecimal underlying)
- {
- _underlying = underlying;
- _bits = calculateBits( underlying );
- }
-
- public Decimal32(final int bits)
- {
- _bits = bits;
- _underlying = calculateBigDecimal(bits);
- }
-
- static int calculateBits(final BigDecimal underlying)
- {
- return 0; //TODO.
- }
-
- static BigDecimal calculateBigDecimal(int bits)
- {
- return BigDecimal.ZERO; // TODO
- }
-
-
- @Override
- public int intValue()
- {
- return _underlying.intValue();
- }
-
- @Override
- public long longValue()
- {
- return _underlying.longValue();
- }
-
- @Override
- public float floatValue()
- {
- return _underlying.floatValue();
- }
-
- @Override
- public double doubleValue()
- {
- return _underlying.doubleValue();
- }
-
- public int getBits()
- {
- return _bits;
- }
-
- @Override
- public boolean equals(final Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- final Decimal32 decimal32 = (Decimal32) o;
-
- if (_bits != decimal32._bits)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return _bits;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal64.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal64.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal64.java
deleted file mode 100644
index e5277ae..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal64.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.amqp;
-
-import java.math.BigDecimal;
-
-public final class Decimal64 extends Number
-{
- private final BigDecimal _underlying;
- private final long _bits;
-
- public Decimal64(BigDecimal underlying)
- {
- _underlying = underlying;
- _bits = calculateBits(underlying);
-
- }
-
-
- public Decimal64(final long bits)
- {
- _bits = bits;
- _underlying = calculateBigDecimal(bits);
- }
-
- static BigDecimal calculateBigDecimal(final long bits)
- {
- return BigDecimal.ZERO;
- }
-
- static long calculateBits(final BigDecimal underlying)
- {
- return 0l; // TODO
- }
-
-
- @Override
- public int intValue()
- {
- return _underlying.intValue();
- }
-
- @Override
- public long longValue()
- {
- return _underlying.longValue();
- }
-
- @Override
- public float floatValue()
- {
- return _underlying.floatValue();
- }
-
- @Override
- public double doubleValue()
- {
- return _underlying.doubleValue();
- }
-
- public long getBits()
- {
- return _bits;
- }
-
- @Override
- public boolean equals(final Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- final Decimal64 decimal64 = (Decimal64) o;
-
- if (_bits != decimal64._bits)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return (int) (_bits ^ (_bits >>> 32));
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/DescribedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/DescribedType.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/DescribedType.java
deleted file mode 100644
index 78a98f6..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/DescribedType.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp;
-
-public interface DescribedType
-{
- public Object getDescriptor();
- public Object getDescribed();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/Symbol.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Symbol.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/Symbol.java
deleted file mode 100644
index 17e6177..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Symbol.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.amqp;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-public final class Symbol implements Comparable<Symbol>, CharSequence
-{
- private final String _underlying;
- private static final ConcurrentHashMap<String, Symbol> _symbols = new ConcurrentHashMap<String, Symbol>(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;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnknownDescribedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnknownDescribedType.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnknownDescribedType.java
deleted file mode 100644
index 5314d31..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnknownDescribedType.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp;
-
-public class UnknownDescribedType implements DescribedType
-{
- private final Object _descriptor;
- private final Object _described;
-
- public UnknownDescribedType(final Object descriptor, final Object described)
- {
- _descriptor = descriptor;
- _described = described;
- }
-
- @Override
- public Object getDescriptor()
- {
- return _descriptor;
- }
-
- @Override
- public Object getDescribed()
- {
- return _described;
- }
-
- @Override
- public boolean equals(final Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- final UnknownDescribedType that = (UnknownDescribedType) o;
-
- if (_described != null ? !_described.equals(that._described) : that._described != null)
- {
- return false;
- }
- if (_descriptor != null ? !_descriptor.equals(that._descriptor) : that._descriptor != null)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = _descriptor != null ? _descriptor.hashCode() : 0;
- result = 31 * result + (_described != null ? _described.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "UnknownDescribedType{" +
- "descriptor=" + _descriptor +
- ", described=" + _described +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedByte.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedByte.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedByte.java
deleted file mode 100644
index 7815915..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedByte.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.amqp;
-
-public final class UnsignedByte extends Number implements Comparable<UnsignedByte>
-{
- 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);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedInteger.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedInteger.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedInteger.java
deleted file mode 100644
index aeadb40..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedInteger.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.amqp;
-
-public final class UnsignedInteger extends Number implements Comparable<UnsignedInteger>
-{
- 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);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedLong.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedLong.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedLong.java
deleted file mode 100644
index 1fa5b85..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedLong.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.amqp;
-
-import java.math.BigInteger;
-
-public final class UnsignedLong extends Number implements Comparable<UnsignedLong>
-{
- 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());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedShort.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedShort.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedShort.java
deleted file mode 100644
index 8d9d8bd..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/UnsignedShort.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.amqp;
-
-public final class UnsignedShort extends Number implements Comparable<UnsignedShort>
-{
- 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);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Accepted.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Accepted.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Accepted.java
deleted file mode 100644
index d21caaa..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Accepted.java
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-
-
-public final class Accepted
- implements DeliveryState, Outcome
-{
- public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:accepted:list");
-
- private static final Accepted INSTANCE = new Accepted();
-
-
- /**
- * TODO should this (and other DeliveryStates) have a private constructor??
- */
- public Accepted()
- {
- }
-
- @Override
- public String toString()
- {
- return "Accepted{}";
- }
-
- public static Accepted getInstance()
- {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/AmqpSequence.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/AmqpSequence.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/AmqpSequence.java
deleted file mode 100644
index 2a07613..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/AmqpSequence.java
+++ /dev/null
@@ -1,52 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.List;
-
-public final class AmqpSequence
- implements Section
-{
- private final List _value;
-
- public AmqpSequence(List value)
- {
- _value = value;
- }
-
- public List getValue()
- {
- return _value;
- }
-
-
- @Override
- public String toString()
- {
- return "AmqpSequence{" +
- _value +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/AmqpValue.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/AmqpValue.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/AmqpValue.java
deleted file mode 100644
index d6ae49e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/AmqpValue.java
+++ /dev/null
@@ -1,47 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-public final class AmqpValue
- implements Section
-{
- private final Object _value;
-
- public AmqpValue(Object value)
- {
- _value = value;
- }
-
- public Object getValue()
- {
- return _value;
- }
-
- @Override
- public String toString()
- {
- return "AmqpValue{" + _value + '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/ApplicationProperties.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/ApplicationProperties.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/ApplicationProperties.java
deleted file mode 100644
index e8cc0de..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/ApplicationProperties.java
+++ /dev/null
@@ -1,49 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.Map;
-
-public final class ApplicationProperties
- implements Section
-{
- private final Map _value;
-
- public ApplicationProperties(Map value)
- {
- _value = value;
- }
-
- public Map getValue()
- {
- return _value;
- }
-
- @Override
- public String toString()
- {
- return "ApplicationProperties{" + _value + '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Data.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Data.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Data.java
deleted file mode 100644
index c946d14..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Data.java
+++ /dev/null
@@ -1,49 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-public final class Data
- implements Section
-{
- private final Binary _value;
-
- public Data(Binary value)
- {
- _value = value;
- }
-
- public Binary getValue()
- {
- return _value;
- }
-
- @Override
- public String toString()
- {
- return "Data{" + _value + '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnClose.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnClose.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnClose.java
deleted file mode 100644
index 855b93f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnClose.java
+++ /dev/null
@@ -1,46 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-public final class DeleteOnClose
- implements LifetimePolicy
-{
- private static final DeleteOnClose INSTANCE = new DeleteOnClose();
-
- private DeleteOnClose()
- {
- }
-
- @Override
- public String toString()
- {
- return "DeleteOnClose{}";
- }
-
- public static DeleteOnClose getInstance()
- {
- return INSTANCE;
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoLinks.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoLinks.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoLinks.java
deleted file mode 100644
index 3a77f77..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoLinks.java
+++ /dev/null
@@ -1,46 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-
-public final class DeleteOnNoLinks implements LifetimePolicy
-{
-
- private static final DeleteOnNoLinks INSTANCE = new DeleteOnNoLinks();
-
- private DeleteOnNoLinks()
- {
- }
-
- public String toString()
- {
- return "DeleteOnNoLinks{}";
- }
-
- public static DeleteOnNoLinks getInstance()
- {
- return INSTANCE;
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoLinksOrMessages.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoLinksOrMessages.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoLinksOrMessages.java
deleted file mode 100644
index a19789e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoLinksOrMessages.java
+++ /dev/null
@@ -1,45 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-public final class DeleteOnNoLinksOrMessages
- implements LifetimePolicy
-{
- private static final DeleteOnNoLinksOrMessages INSTANCE = new DeleteOnNoLinksOrMessages();
-
- private DeleteOnNoLinksOrMessages()
- {
- }
-
- public String toString()
- {
- return "DeleteOnNoLinksOrMessages{}";
- }
-
- public static DeleteOnNoLinksOrMessages getInstance()
- {
- return INSTANCE;
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoMessages.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoMessages.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoMessages.java
deleted file mode 100644
index be70005..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeleteOnNoMessages.java
+++ /dev/null
@@ -1,45 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-
-public final class DeleteOnNoMessages implements LifetimePolicy
-{
- private static final DeleteOnNoMessages INSTANCE = new DeleteOnNoMessages();
-
- private DeleteOnNoMessages()
- {
- }
-
- public String toString()
- {
- return "DeleteOnNoMessages{}";
- }
-
- public static DeleteOnNoMessages getInstance()
- {
- return INSTANCE;
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeliveryAnnotations.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeliveryAnnotations.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeliveryAnnotations.java
deleted file mode 100644
index 9ea5504..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/DeliveryAnnotations.java
+++ /dev/null
@@ -1,50 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-public final class DeliveryAnnotations implements Section
-{
- private final Map<Symbol, Object> _value;
-
- public DeliveryAnnotations(Map<Symbol, Object> value)
- {
- _value = value;
- }
-
- public Map<Symbol, Object> getValue()
- {
- return _value;
- }
-
- @Override
- public String toString()
- {
- return "DeliveryAnnotations{" + _value + '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Footer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Footer.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Footer.java
deleted file mode 100644
index 4e9a789..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Footer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.Map;
-
-
-public final class Footer
- implements Section
-{
- private final Map _value;
-
- public Footer(Map value)
- {
- _value = value;
- }
-
- public Map getValue()
- {
- return _value;
- }
-
- @Override
- public String toString()
- {
- return "Footer{" + _value + '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java
deleted file mode 100644
index 83b1974..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java
+++ /dev/null
@@ -1,102 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-
-public final class Header
- implements Section
-{
-
- private Boolean _durable;
- private UnsignedByte _priority;
- private UnsignedInteger _ttl;
- private Boolean _firstAcquirer;
- private UnsignedInteger _deliveryCount;
-
- public Boolean getDurable()
- {
- return _durable;
- }
-
- public void setDurable(Boolean durable)
- {
- _durable = durable;
- }
-
- public UnsignedByte getPriority()
- {
- return _priority;
- }
-
- public void setPriority(UnsignedByte priority)
- {
- _priority = priority;
- }
-
- public UnsignedInteger getTtl()
- {
- return _ttl;
- }
-
- public void setTtl(UnsignedInteger ttl)
- {
- _ttl = ttl;
- }
-
- public Boolean getFirstAcquirer()
- {
- return _firstAcquirer;
- }
-
- public void setFirstAcquirer(Boolean firstAcquirer)
- {
- _firstAcquirer = firstAcquirer;
- }
-
- public UnsignedInteger getDeliveryCount()
- {
- return _deliveryCount;
- }
-
- public void setDeliveryCount(UnsignedInteger deliveryCount)
- {
- _deliveryCount = deliveryCount;
- }
-
-
- @Override
- public String toString()
- {
- return "Header{" +
- "durable=" + _durable +
- ", priority=" + _priority +
- ", ttl=" + _ttl +
- ", firstAcquirer=" + _firstAcquirer +
- ", deliveryCount=" + _deliveryCount +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/LifetimePolicy.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/LifetimePolicy.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/LifetimePolicy.java
deleted file mode 100644
index 68b41df..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/LifetimePolicy.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.messaging;
-
-public interface LifetimePolicy
-{
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/MessageAnnotations.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/MessageAnnotations.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/MessageAnnotations.java
deleted file mode 100644
index 9bf82d6..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/MessageAnnotations.java
+++ /dev/null
@@ -1,52 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-import java.util.Map;
-
-
-public final class MessageAnnotations implements Section
-{
-
- private final Map<Symbol, Object> _value;
-
- public MessageAnnotations(Map<Symbol, Object> value)
- {
- _value = value;
- }
-
- public Map<Symbol, Object> getValue()
- {
- return _value;
- }
-
- @Override
- public String toString()
- {
- return "MessageAnnotations{" + _value + '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Modified.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Modified.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Modified.java
deleted file mode 100644
index 9b9a3a3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Modified.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-
-public final class Modified
- implements DeliveryState, Outcome
-{
- public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:modified:list");
-
- private Boolean _deliveryFailed;
- private Boolean _undeliverableHere;
- private Map _messageAnnotations;
-
- public Boolean getDeliveryFailed()
- {
- return _deliveryFailed;
- }
-
- public void setDeliveryFailed(Boolean deliveryFailed)
- {
- _deliveryFailed = deliveryFailed;
- }
-
- public Boolean getUndeliverableHere()
- {
- return _undeliverableHere;
- }
-
- public void setUndeliverableHere(Boolean undeliverableHere)
- {
- _undeliverableHere = undeliverableHere;
- }
-
- public Map getMessageAnnotations()
- {
- return _messageAnnotations;
- }
-
- public void setMessageAnnotations(Map messageAnnotations)
- {
- _messageAnnotations = messageAnnotations;
- }
-
- @Override
- public String toString()
- {
- return "Modified{" +
- "deliveryFailed=" + _deliveryFailed +
- ", undeliverableHere=" + _undeliverableHere +
- ", messageAnnotations=" + _messageAnnotations +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Outcome.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Outcome.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Outcome.java
deleted file mode 100644
index bd155db..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Outcome.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.apache.qpid.proton.amqp.messaging;
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-public interface Outcome
-{
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java
deleted file mode 100644
index a8c4880..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java
+++ /dev/null
@@ -1,199 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.Date;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-
-public final class Properties
- implements Section
-{
-
- private Object _messageId;
- private Binary _userId;
- private String _to;
- private String _subject;
- private String _replyTo;
- private Object _correlationId;
- private Symbol _contentType;
- private Symbol _contentEncoding;
- private Date _absoluteExpiryTime;
- private Date _creationTime;
- private String _groupId;
- private UnsignedInteger _groupSequence;
- private String _replyToGroupId;
-
- public Object getMessageId()
- {
- return _messageId;
- }
-
- public void setMessageId(Object messageId)
- {
- _messageId = messageId;
- }
-
- public Binary getUserId()
- {
- return _userId;
- }
-
- public void setUserId(Binary userId)
- {
- _userId = userId;
- }
-
- public String getTo()
- {
- return _to;
- }
-
- public void setTo(String to)
- {
- _to = to;
- }
-
- public String getSubject()
- {
- return _subject;
- }
-
- public void setSubject(String subject)
- {
- _subject = subject;
- }
-
- public String getReplyTo()
- {
- return _replyTo;
- }
-
- public void setReplyTo(String replyTo)
- {
- _replyTo = replyTo;
- }
-
- public Object getCorrelationId()
- {
- return _correlationId;
- }
-
- public void setCorrelationId(Object correlationId)
- {
- _correlationId = correlationId;
- }
-
- public Symbol getContentType()
- {
- return _contentType;
- }
-
- public void setContentType(Symbol contentType)
- {
- _contentType = contentType;
- }
-
- public Symbol getContentEncoding()
- {
- return _contentEncoding;
- }
-
- public void setContentEncoding(Symbol contentEncoding)
- {
- _contentEncoding = contentEncoding;
- }
-
- public Date getAbsoluteExpiryTime()
- {
- return _absoluteExpiryTime;
- }
-
- public void setAbsoluteExpiryTime(Date absoluteExpiryTime)
- {
- _absoluteExpiryTime = absoluteExpiryTime;
- }
-
- public Date getCreationTime()
- {
- return _creationTime;
- }
-
- public void setCreationTime(Date creationTime)
- {
- _creationTime = creationTime;
- }
-
- public String getGroupId()
- {
- return _groupId;
- }
-
- public void setGroupId(String groupId)
- {
- _groupId = groupId;
- }
-
- public UnsignedInteger getGroupSequence()
- {
- return _groupSequence;
- }
-
- public void setGroupSequence(UnsignedInteger groupSequence)
- {
- _groupSequence = groupSequence;
- }
-
- public String getReplyToGroupId()
- {
- return _replyToGroupId;
- }
-
- public void setReplyToGroupId(String replyToGroupId)
- {
- _replyToGroupId = replyToGroupId;
- }
-
- @Override
- public String toString()
- {
- return "Properties{" +
- "messageId=" + _messageId +
- ", userId=" + _userId +
- ", to='" + _to + '\'' +
- ", subject='" + _subject + '\'' +
- ", replyTo='" + _replyTo + '\'' +
- ", correlationId=" + _correlationId +
- ", contentType=" + _contentType +
- ", contentEncoding=" + _contentEncoding +
- ", absoluteExpiryTime=" + _absoluteExpiryTime +
- ", creationTime=" + _creationTime +
- ", groupId='" + _groupId + '\'' +
- ", groupSequence=" + _groupSequence +
- ", replyToGroupId='" + _replyToGroupId + '\'' +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Received.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Received.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Received.java
deleted file mode 100644
index 796934b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Received.java
+++ /dev/null
@@ -1,69 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-
-
-
-public final class Received
- implements DeliveryState
-{
-
- private UnsignedInteger _sectionNumber;
- private UnsignedLong _sectionOffset;
-
- public UnsignedInteger getSectionNumber()
- {
- return _sectionNumber;
- }
-
- public void setSectionNumber(UnsignedInteger sectionNumber)
- {
- _sectionNumber = sectionNumber;
- }
-
- public UnsignedLong getSectionOffset()
- {
- return _sectionOffset;
- }
-
- public void setSectionOffset(UnsignedLong sectionOffset)
- {
- _sectionOffset = sectionOffset;
- }
-
-
- @Override
- public String toString()
- {
- return "Received{" +
- "sectionNumber=" + _sectionNumber +
- ", sectionOffset=" + _sectionOffset +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Rejected.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Rejected.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Rejected.java
deleted file mode 100644
index 3ea3a5b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Rejected.java
+++ /dev/null
@@ -1,64 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-
-
-public final class Rejected
- implements DeliveryState, Outcome
-{
- public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:rejected:list");
-
- private ErrorCondition _error;
-
- public ErrorCondition getError()
- {
- return _error;
- }
-
- public void setError(ErrorCondition error)
- {
- _error = error;
- }
-
- public int size()
- {
- return _error != null
- ? 1
- : 0;
-
- }
-
- @Override
- public String toString()
- {
- return "Rejected{" +
- "error=" + _error +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Released.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Released.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Released.java
deleted file mode 100644
index c67917f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Released.java
+++ /dev/null
@@ -1,48 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-
-
-public final class Released
- implements DeliveryState, Outcome
-{
- public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:released:list");
-
- private static final Released INSTANCE = new Released();
-
- @Override
- public String toString()
- {
- return "Released{}";
- }
-
- public static Released getInstance()
- {
- return INSTANCE;
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Section.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Section.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Section.java
deleted file mode 100644
index 2bcc4d5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Section.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.messaging;
-
-public interface Section
-{
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Source.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Source.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Source.java
deleted file mode 100644
index e6fffef..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Source.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-public final class Source extends Terminus
- implements org.apache.qpid.proton.amqp.transport.Source
-{
- private Symbol _distributionMode;
- private Map _filter;
- private Outcome _defaultOutcome;
- private Symbol[] _outcomes;
-
- private Source(Source other) {
- super(other);
- _distributionMode = other._distributionMode;
- if (other._filter != null)
- _filter = new HashMap(other._filter);
- _defaultOutcome = other._defaultOutcome;
- if (other._outcomes != null)
- _outcomes = other._outcomes.clone();
- }
-
- public Source() {}
-
- public Symbol getDistributionMode()
- {
- return _distributionMode;
- }
-
- public void setDistributionMode(Symbol distributionMode)
- {
- _distributionMode = distributionMode;
- }
-
- public Map getFilter()
- {
- return _filter;
- }
-
- public void setFilter(Map filter)
- {
- _filter = filter;
- }
-
- public Outcome getDefaultOutcome()
- {
- return _defaultOutcome;
- }
-
- public void setDefaultOutcome(Outcome defaultOutcome)
- {
- _defaultOutcome = defaultOutcome;
- }
-
- public Symbol[] getOutcomes()
- {
- return _outcomes;
- }
-
- public void setOutcomes(Symbol... outcomes)
- {
- _outcomes = outcomes;
- }
-
-
- @Override
- public String toString()
- {
- return "Source{" +
- "address='" + getAddress() + '\'' +
- ", durable=" + getDurable() +
- ", expiryPolicy=" + getExpiryPolicy() +
- ", timeout=" + getTimeout() +
- ", dynamic=" + getDynamic() +
- ", dynamicNodeProperties=" + getDynamicNodeProperties() +
- ", distributionMode=" + _distributionMode +
- ", filter=" + _filter +
- ", defaultOutcome=" + _defaultOutcome +
- ", outcomes=" + (_outcomes == null ? null : Arrays.asList(_outcomes)) +
- ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) +
- '}';
- }
-
- @Override
- public org.apache.qpid.proton.amqp.transport.Source copy() {
- return new Source(this);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Target.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Target.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Target.java
deleted file mode 100644
index 38678d1..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Target.java
+++ /dev/null
@@ -1,57 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.Arrays;
-
-public final class Target extends Terminus
- implements org.apache.qpid.proton.amqp.transport.Target
-{
- private Target(Target other) {
- super(other);
- }
-
- public Target() {
- }
-
- @Override
- public String toString()
- {
- return "Target{" +
- "address='" + getAddress() + '\'' +
- ", durable=" + getDurable() +
- ", expiryPolicy=" + getExpiryPolicy() +
- ", timeout=" + getTimeout() +
- ", dynamic=" + getDynamic() +
- ", dynamicNodeProperties=" + getDynamicNodeProperties() +
- ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) +
- '}';
- }
-
- @Override
- public org.apache.qpid.proton.amqp.transport.Target copy() {
- return new Target(this);
- }
-}
-
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[31/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
PROTON-1385: remove proton-j from the existing repo, it now has its own repo at: https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ccdcf329
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ccdcf329
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ccdcf329
Branch: refs/heads/go1
Commit: ccdcf32932f04b387da9d4dbd810da29cae223aa
Parents: e2357e2
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Jan 9 15:01:35 2017 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Jan 9 15:01:35 2017 +0000
----------------------------------------------------------------------
.travis.yml | 1 -
CMakeLists.txt | 7 -
DEVELOPERS.md | 26 +-
INSTALL.md | 33 +-
README.md | 1 -
RELEASE.md | 27 +-
bin/jenkins-proton-c-build.sh | 4 -
bin/version.sh | 3 +-
config.bat.in | 5 +-
config.sh.in | 5 +-
design/api-reconciliation/README | 4 -
.../api-reconciliation/generate-c-functions.sh | 32 -
design/api-reconciliation/pom.xml | 115 --
.../CFunctionNameListReader.java | 44 -
.../qpid/proton/apireconciliation/Joiner.java | 99 -
.../qpid/proton/apireconciliation/Main.java | 57 -
.../apireconciliation/Reconciliation.java | 45 -
.../apireconciliation/ReconciliationReport.java | 40 -
.../proton/apireconciliation/ReportRow.java | 87 -
.../packagesearcher/PackageSearcher.java | 105 --
.../reportwriter/AnnotationAccessor.java | 90 -
.../ReconciliationReportWriter.java | 79 -
.../CFunctionNameListReaderTest.java | 54 -
.../proton/apireconciliation/JoinerTest.java | 166 --
.../proton/apireconciliation/ReportRowTest.java | 84 -
.../apireconciliation/TestAnnotation.java | 32 -
.../proton/apireconciliation/TestUtils.java | 38 -
.../packagesearcher/PackageSearcherTest.java | 84 -
.../testdata/manyimpls/Impl1.java | 29 -
.../testdata/manyimpls/Impl2.java | 29 -
.../manyimpls/InterfaceWithManyImpls.java | 26 -
.../testdata/noimpl/InterfaceWithoutImpl.java | 25 -
.../subpackage/InterfaceInSubPackage.java | 24 -
.../impl/ImplOfInterfaceInSubPackage.java | 36 -
.../testdata/tree/ImplAtTreeTop.java | 29 -
.../testdata/tree/InterfaceAtTreeTop.java | 26 -
.../testdata/tree/leaf/ImplAtLeaf.java | 29 -
.../testdata/tree/leaf/InterfaceAtLeaf.java | 25 -
.../reportwriter/AnnotationAccessorTest.java | 72 -
.../ReconciliationReportWriterTest.java | 110 --
.../reportwriter/expectedmany.csv | 5 -
.../reportwriter/expectedsingle.csv | 2 -
design/build.xml | 90 -
design/proton_objects.dia | Bin 2846 -> 0 bytes
design/src/proton/Accepted.java | 34 -
design/src/proton/Connection.java | 78 -
design/src/proton/Delivery.java | 65 -
design/src/proton/DeliveryBuffer.java | 44 -
design/src/proton/DeliveryState.java | 32 -
design/src/proton/Endpoint.java | 119 --
design/src/proton/Link.java | 71 -
design/src/proton/Modified.java | 34 -
design/src/proton/Outcome.java | 34 -
design/src/proton/Received.java | 34 -
design/src/proton/Receiver.java | 52 -
design/src/proton/Rejected.java | 34 -
design/src/proton/Released.java | 34 -
design/src/proton/Sender.java | 55 -
design/src/proton/Session.java | 76 -
design/src/proton/Transport.java | 53 -
design/src/proton/package.html | 122 --
examples/engine/java/LICENSE | 201 --
examples/engine/java/drain | 20 -
examples/engine/java/pom.xml | 37 -
examples/engine/java/server | 20 -
examples/engine/java/spout | 20 -
.../org/apache/qpid/proton/examples/Drain.java | 127 --
.../org/apache/qpid/proton/examples/Driver.java | 265 ---
.../qpid/proton/examples/FlowController.java | 80 -
.../apache/qpid/proton/examples/Handshaker.java | 88 -
.../apache/qpid/proton/examples/Message.java | 83 -
.../org/apache/qpid/proton/examples/Pool.java | 153 --
.../org/apache/qpid/proton/examples/Router.java | 191 --
.../org/apache/qpid/proton/examples/Server.java | 179 --
.../org/apache/qpid/proton/examples/Spout.java | 116 --
examples/java/messenger/README.txt | 22 -
examples/java/messenger/pom.xml | 41 -
examples/java/messenger/recv | 31 -
examples/java/messenger/send | 29 -
.../org/apache/qpid/proton/example/Recv.java | 133 --
.../org/apache/qpid/proton/example/Send.java | 104 --
examples/java/reactor/.gitignore | 1 -
examples/java/reactor/README.md | 55 -
examples/java/reactor/pom.xml | 41 -
examples/java/reactor/run | 23 -
.../apache/qpid/proton/example/reactor/Cat.java | 99 -
.../proton/example/reactor/CountRandomly.java | 105 --
.../qpid/proton/example/reactor/Counter.java | 84 -
.../qpid/proton/example/reactor/Delegates.java | 68 -
.../qpid/proton/example/reactor/Echo.java | 98 -
.../example/reactor/EchoInputStreamWrapper.java | 76 -
.../proton/example/reactor/GlobalLogger.java | 75 -
.../proton/example/reactor/GoodbyeWorld.java | 60 -
.../qpid/proton/example/reactor/HelloWorld.java | 59 -
.../qpid/proton/example/reactor/README.md | 31 -
.../proton/example/reactor/ReactorLogger.java | 69 -
.../qpid/proton/example/reactor/Recv.java | 79 -
.../qpid/proton/example/reactor/Scheduling.java | 71 -
.../qpid/proton/example/reactor/Send.java | 149 --
.../qpid/proton/example/reactor/Unhandled.java | 46 -
pom.xml | 177 --
proton-j/CMakeLists.txt | 39 -
proton-j/LICENSE | 203 --
proton-j/pom.xml | 60 -
.../apache/qpid/proton/InterruptException.java | 44 -
.../java/org/apache/qpid/proton/Proton.java | 139 --
.../org/apache/qpid/proton/ProtonException.java | 45 -
.../ProtonUnsupportedOperationException.java | 49 -
.../apache/qpid/proton/TimeoutException.java | 48 -
.../org/apache/qpid/proton/amqp/Binary.java | 187 --
.../org/apache/qpid/proton/amqp/Decimal128.java | 152 --
.../org/apache/qpid/proton/amqp/Decimal32.java | 110 --
.../org/apache/qpid/proton/amqp/Decimal64.java | 112 --
.../apache/qpid/proton/amqp/DescribedType.java | 27 -
.../org/apache/qpid/proton/amqp/Symbol.java | 94 -
.../qpid/proton/amqp/UnknownDescribedType.java | 88 -
.../apache/qpid/proton/amqp/UnsignedByte.java | 134 --
.../qpid/proton/amqp/UnsignedInteger.java | 149 --
.../apache/qpid/proton/amqp/UnsignedLong.java | 160 --
.../apache/qpid/proton/amqp/UnsignedShort.java | 134 --
.../qpid/proton/amqp/messaging/Accepted.java | 55 -
.../proton/amqp/messaging/AmqpSequence.java | 52 -
.../qpid/proton/amqp/messaging/AmqpValue.java | 47 -
.../amqp/messaging/ApplicationProperties.java | 49 -
.../apache/qpid/proton/amqp/messaging/Data.java | 49 -
.../proton/amqp/messaging/DeleteOnClose.java | 46 -
.../proton/amqp/messaging/DeleteOnNoLinks.java | 46 -
.../messaging/DeleteOnNoLinksOrMessages.java | 45 -
.../amqp/messaging/DeleteOnNoMessages.java | 45 -
.../amqp/messaging/DeliveryAnnotations.java | 50 -
.../qpid/proton/amqp/messaging/Footer.java | 50 -
.../qpid/proton/amqp/messaging/Header.java | 102 --
.../proton/amqp/messaging/LifetimePolicy.java | 25 -
.../amqp/messaging/MessageAnnotations.java | 52 -
.../qpid/proton/amqp/messaging/Modified.java | 78 -
.../qpid/proton/amqp/messaging/Outcome.java | 26 -
.../qpid/proton/amqp/messaging/Properties.java | 199 --
.../qpid/proton/amqp/messaging/Received.java | 69 -
.../qpid/proton/amqp/messaging/Rejected.java | 64 -
.../qpid/proton/amqp/messaging/Released.java | 48 -
.../qpid/proton/amqp/messaging/Section.java | 25 -
.../qpid/proton/amqp/messaging/Source.java | 113 --
.../qpid/proton/amqp/messaging/Target.java | 57 -
.../qpid/proton/amqp/messaging/Terminus.java | 129 --
.../amqp/messaging/TerminusDurability.java | 52 -
.../amqp/messaging/TerminusExpiryPolicy.java | 67 -
.../proton/amqp/security/SaslChallenge.java | 80 -
.../qpid/proton/amqp/security/SaslCode.java | 42 -
.../proton/amqp/security/SaslFrameBody.java | 37 -
.../qpid/proton/amqp/security/SaslInit.java | 87 -
.../proton/amqp/security/SaslMechanisms.java | 67 -
.../qpid/proton/amqp/security/SaslOutcome.java | 80 -
.../qpid/proton/amqp/security/SaslResponse.java | 63 -
.../proton/amqp/transaction/Coordinator.java | 64 -
.../qpid/proton/amqp/transaction/Declare.java | 49 -
.../qpid/proton/amqp/transaction/Declared.java | 62 -
.../qpid/proton/amqp/transaction/Discharge.java | 68 -
.../proton/amqp/transaction/GlobalTxId.java | 25 -
.../amqp/transaction/TransactionErrors.java | 36 -
.../amqp/transaction/TransactionalState.java | 71 -
.../proton/amqp/transaction/TxnCapability.java | 40 -
.../qpid/proton/amqp/transport/AmqpError.java | 56 -
.../qpid/proton/amqp/transport/Attach.java | 232 ---
.../qpid/proton/amqp/transport/Begin.java | 163 --
.../qpid/proton/amqp/transport/Close.java | 55 -
.../proton/amqp/transport/ConnectionError.java | 36 -
.../proton/amqp/transport/DeliveryState.java | 33 -
.../qpid/proton/amqp/transport/Detach.java | 86 -
.../qpid/proton/amqp/transport/Disposition.java | 124 --
.../qpid/proton/amqp/transport/EmptyFrame.java | 38 -
.../apache/qpid/proton/amqp/transport/End.java | 55 -
.../proton/amqp/transport/ErrorCondition.java | 145 --
.../apache/qpid/proton/amqp/transport/Flow.java | 193 --
.../qpid/proton/amqp/transport/FrameBody.java | 43 -
.../qpid/proton/amqp/transport/LinkError.java | 40 -
.../apache/qpid/proton/amqp/transport/Open.java | 175 --
.../amqp/transport/ReceiverSettleMode.java | 54 -
.../apache/qpid/proton/amqp/transport/Role.java | 34 -
.../proton/amqp/transport/SenderSettleMode.java | 58 -
.../proton/amqp/transport/SessionError.java | 38 -
.../qpid/proton/amqp/transport/Source.java | 28 -
.../qpid/proton/amqp/transport/Target.java | 29 -
.../qpid/proton/amqp/transport/Transfer.java | 181 --
.../qpid/proton/codec/AMQPDefinedTypes.java | 107 --
.../org/apache/qpid/proton/codec/AMQPType.java | 36 -
.../proton/codec/AbstractDescribedType.java | 141 --
.../proton/codec/AbstractPrimitiveType.java | 32 -
.../codec/AbstractPrimitiveTypeEncoding.java | 67 -
.../org/apache/qpid/proton/codec/ArrayType.java | 1150 ------------
.../qpid/proton/codec/BigIntegerType.java | 196 --
.../apache/qpid/proton/codec/BinaryType.java | 167 --
.../apache/qpid/proton/codec/BooleanType.java | 273 ---
.../qpid/proton/codec/ByteBufferDecoder.java | 30 -
.../qpid/proton/codec/ByteBufferEncoder.java | 28 -
.../org/apache/qpid/proton/codec/ByteType.java | 129 --
.../apache/qpid/proton/codec/CharacterType.java | 127 --
.../org/apache/qpid/proton/codec/Codec.java | 40 -
.../proton/codec/CompositeWritableBuffer.java | 191 --
.../java/org/apache/qpid/proton/codec/Data.java | 182 --
.../qpid/proton/codec/Decimal128Type.java | 103 --
.../apache/qpid/proton/codec/Decimal32Type.java | 100 -
.../apache/qpid/proton/codec/Decimal64Type.java | 100 -
.../qpid/proton/codec/DecodeException.java | 44 -
.../org/apache/qpid/proton/codec/Decoder.java | 149 --
.../apache/qpid/proton/codec/DecoderImpl.java | 999 ----------
.../proton/codec/DescribedTypeConstructor.java | 28 -
.../apache/qpid/proton/codec/DoubleType.java | 127 --
.../proton/codec/DroppingWritableBuffer.java | 107 --
.../qpid/proton/codec/DynamicDescribedType.java | 144 --
.../proton/codec/DynamicTypeConstructor.java | 60 -
.../qpid/proton/codec/EncodeException.java | 44 -
.../org/apache/qpid/proton/codec/Encoder.java | 121 --
.../apache/qpid/proton/codec/EncoderImpl.java | 817 ---------
.../apache/qpid/proton/codec/EncodingCodes.java | 90 -
.../codec/FixedSizePrimitiveTypeEncoding.java | 42 -
.../org/apache/qpid/proton/codec/FloatType.java | 128 --
.../FloatingSizePrimitiveTypeEncoding.java | 54 -
.../apache/qpid/proton/codec/IntegerType.java | 213 ---
.../LargeFloatingSizePrimitiveTypeEncoding.java | 42 -
.../org/apache/qpid/proton/codec/ListType.java | 300 ---
.../org/apache/qpid/proton/codec/LongType.java | 212 ---
.../org/apache/qpid/proton/codec/MapType.java | 255 ---
.../org/apache/qpid/proton/codec/NullType.java | 111 --
.../apache/qpid/proton/codec/PrimitiveType.java | 35 -
.../proton/codec/PrimitiveTypeEncoding.java | 32 -
.../qpid/proton/codec/ReadableBuffer.java | 191 --
.../org/apache/qpid/proton/codec/ShortType.java | 127 --
.../SmallFloatingSizePrimitiveTypeEncoding.java | 42 -
.../apache/qpid/proton/codec/StringType.java | 238 ---
.../apache/qpid/proton/codec/SymbolType.java | 201 --
.../apache/qpid/proton/codec/TimestampType.java | 111 --
.../qpid/proton/codec/TypeConstructor.java | 30 -
.../apache/qpid/proton/codec/TypeEncoding.java | 40 -
.../org/apache/qpid/proton/codec/UUIDType.java | 103 --
.../qpid/proton/codec/UnsignedByteType.java | 100 -
.../qpid/proton/codec/UnsignedIntegerType.java | 209 ---
.../qpid/proton/codec/UnsignedLongType.java | 203 --
.../qpid/proton/codec/UnsignedShortType.java | 100 -
.../qpid/proton/codec/WritableBuffer.java | 153 --
.../qpid/proton/codec/impl/AbstractElement.java | 142 --
.../qpid/proton/codec/impl/ArrayElement.java | 492 -----
.../qpid/proton/codec/impl/AtomicElement.java | 73 -
.../qpid/proton/codec/impl/BinaryElement.java | 128 --
.../qpid/proton/codec/impl/BooleanElement.java | 76 -
.../qpid/proton/codec/impl/ByteElement.java | 79 -
.../qpid/proton/codec/impl/CharElement.java | 71 -
.../qpid/proton/codec/impl/DataDecoder.java | 1074 -----------
.../apache/qpid/proton/codec/impl/DataImpl.java | 928 ----------
.../proton/codec/impl/Decimal128Element.java | 77 -
.../proton/codec/impl/Decimal32Element.java | 76 -
.../proton/codec/impl/Decimal64Element.java | 76 -
.../proton/codec/impl/DescribedTypeElement.java | 176 --
.../proton/codec/impl/DescribedTypeImpl.java | 90 -
.../qpid/proton/codec/impl/DoubleElement.java | 75 -
.../apache/qpid/proton/codec/impl/Element.java | 53 -
.../qpid/proton/codec/impl/FloatElement.java | 75 -
.../qpid/proton/codec/impl/IntegerElement.java | 106 --
.../qpid/proton/codec/impl/ListElement.java | 237 ---
.../qpid/proton/codec/impl/LongElement.java | 103 --
.../qpid/proton/codec/impl/MapElement.java | 231 ---
.../qpid/proton/codec/impl/NullElement.java | 63 -
.../qpid/proton/codec/impl/ShortElement.java | 79 -
.../qpid/proton/codec/impl/StringElement.java | 136 --
.../qpid/proton/codec/impl/SymbolElement.java | 129 --
.../proton/codec/impl/TimestampElement.java | 74 -
.../qpid/proton/codec/impl/UUIDElement.java | 77 -
.../proton/codec/impl/UnsignedByteElement.java | 80 -
.../codec/impl/UnsignedIntegerElement.java | 125 --
.../proton/codec/impl/UnsignedLongElement.java | 125 --
.../proton/codec/impl/UnsignedShortElement.java | 80 -
.../proton/codec/messaging/AcceptedType.java | 81 -
.../codec/messaging/AmqpSequenceType.java | 83 -
.../proton/codec/messaging/AmqpValueType.java | 83 -
.../messaging/ApplicationPropertiesType.java | 84 -
.../qpid/proton/codec/messaging/DataType.java | 84 -
.../codec/messaging/DeleteOnCloseType.java | 84 -
.../DeleteOnNoLinksOrMessagesType.java | 83 -
.../codec/messaging/DeleteOnNoLinksType.java | 85 -
.../codec/messaging/DeleteOnNoMessagesType.java | 84 -
.../messaging/DeliveryAnnotationsType.java | 84 -
.../qpid/proton/codec/messaging/FooterType.java | 82 -
.../qpid/proton/codec/messaging/HeaderType.java | 158 --
.../codec/messaging/MessageAnnotationsType.java | 86 -
.../proton/codec/messaging/ModifiedType.java | 143 --
.../proton/codec/messaging/PropertiesType.java | 205 ---
.../proton/codec/messaging/ReceivedType.java | 135 --
.../proton/codec/messaging/RejectedType.java | 127 --
.../proton/codec/messaging/ReleasedType.java | 83 -
.../qpid/proton/codec/messaging/SourceType.java | 217 ---
.../qpid/proton/codec/messaging/TargetType.java | 182 --
.../codec/security/SaslChallengeType.java | 102 --
.../proton/codec/security/SaslInitType.java | 145 --
.../codec/security/SaslMechanismsType.java | 105 --
.../proton/codec/security/SaslOutcomeType.java | 140 --
.../proton/codec/security/SaslResponseType.java | 103 --
.../codec/transaction/CoordinatorType.java | 109 --
.../proton/codec/transaction/DeclareType.java | 95 -
.../proton/codec/transaction/DeclaredType.java | 99 -
.../proton/codec/transaction/DischargeType.java | 141 --
.../transaction/TransactionalStateType.java | 141 --
.../qpid/proton/codec/transport/AttachType.java | 233 ---
.../qpid/proton/codec/transport/BeginType.java | 188 --
.../qpid/proton/codec/transport/CloseType.java | 94 -
.../qpid/proton/codec/transport/DetachType.java | 147 --
.../proton/codec/transport/DispositionType.java | 168 --
.../qpid/proton/codec/transport/EndType.java | 97 -
.../codec/transport/ErrorConditionType.java | 147 --
.../qpid/proton/codec/transport/FlowType.java | 191 --
.../qpid/proton/codec/transport/OpenType.java | 226 ---
.../proton/codec/transport/TransferType.java | 207 ---
.../apache/qpid/proton/driver/Connector.java | 127 --
.../org/apache/qpid/proton/driver/Driver.java | 160 --
.../org/apache/qpid/proton/driver/Listener.java | 61 -
.../qpid/proton/driver/impl/ConnectorImpl.java | 280 ---
.../qpid/proton/driver/impl/DriverImpl.java | 254 ---
.../qpid/proton/driver/impl/ListenerImpl.java | 93 -
.../apache/qpid/proton/engine/BaseHandler.java | 240 ---
.../apache/qpid/proton/engine/Collector.java | 45 -
.../apache/qpid/proton/engine/Connection.java | 137 --
.../apache/qpid/proton/engine/CoreHandler.java | 71 -
.../org/apache/qpid/proton/engine/Delivery.java | 146 --
.../org/apache/qpid/proton/engine/Endpoint.java | 80 -
.../qpid/proton/engine/EndpointState.java | 32 -
.../org/apache/qpid/proton/engine/Engine.java | 60 -
.../org/apache/qpid/proton/engine/Event.java | 175 --
.../apache/qpid/proton/engine/EventType.java | 40 -
.../apache/qpid/proton/engine/Extendable.java | 34 -
.../qpid/proton/engine/ExtendableAccessor.java | 57 -
.../org/apache/qpid/proton/engine/Handler.java | 55 -
.../qpid/proton/engine/HandlerException.java | 39 -
.../org/apache/qpid/proton/engine/Link.java | 301 ---
.../qpid/proton/engine/ProtonJConnection.java | 34 -
.../qpid/proton/engine/ProtonJEndpoint.java | 26 -
.../qpid/proton/engine/ProtonJSession.java | 30 -
.../qpid/proton/engine/ProtonJSslDomain.java | 29 -
.../proton/engine/ProtonJSslPeerDetails.java | 29 -
.../qpid/proton/engine/ProtonJTransport.java | 32 -
.../org/apache/qpid/proton/engine/Receiver.java | 86 -
.../org/apache/qpid/proton/engine/Record.java | 36 -
.../qpid/proton/engine/RecordAccessor.java | 26 -
.../org/apache/qpid/proton/engine/Sasl.java | 180 --
.../org/apache/qpid/proton/engine/Sender.java | 87 -
.../org/apache/qpid/proton/engine/Session.java | 150 --
.../java/org/apache/qpid/proton/engine/Ssl.java | 51 -
.../apache/qpid/proton/engine/SslDomain.java | 145 --
.../qpid/proton/engine/SslPeerDetails.java | 43 -
.../apache/qpid/proton/engine/Transport.java | 285 ---
.../qpid/proton/engine/TransportException.java | 72 -
.../qpid/proton/engine/TransportResult.java | 43 -
.../proton/engine/TransportResultFactory.java | 125 --
.../proton/engine/impl/AmqpErrorException.java | 25 -
.../qpid/proton/engine/impl/AmqpHeader.java | 28 -
.../proton/engine/impl/ByteBufferUtils.java | 110 --
.../qpid/proton/engine/impl/CollectorImpl.java | 101 -
.../qpid/proton/engine/impl/ConnectionImpl.java | 670 -------
.../qpid/proton/engine/impl/DeliveryImpl.java | 522 ------
.../qpid/proton/engine/impl/EndpointImpl.java | 222 ---
.../proton/engine/impl/EndpointImplQuery.java | 43 -
.../qpid/proton/engine/impl/EventImpl.java | 318 ----
.../qpid/proton/engine/impl/FrameHandler.java | 43 -
.../qpid/proton/engine/impl/FrameParser.java | 586 ------
.../qpid/proton/engine/impl/FrameWriter.java | 238 ---
.../impl/HandshakeSniffingTransportWrapper.java | 182 --
.../qpid/proton/engine/impl/LinkImpl.java | 514 ------
.../qpid/proton/engine/impl/LinkNode.java | 102 --
.../engine/impl/PlainTransportWrapper.java | 93 -
.../qpid/proton/engine/impl/ProtocolTracer.java | 32 -
.../qpid/proton/engine/impl/ReceiverImpl.java | 168 --
.../qpid/proton/engine/impl/RecordImpl.java | 54 -
.../org/apache/qpid/proton/engine/impl/Ref.java | 46 -
.../proton/engine/impl/SaslFrameHandler.java | 32 -
.../proton/engine/impl/SaslFrameParser.java | 274 ---
.../qpid/proton/engine/impl/SaslImpl.java | 738 --------
.../qpid/proton/engine/impl/SaslSniffer.java | 53 -
.../qpid/proton/engine/impl/SenderImpl.java | 151 --
.../qpid/proton/engine/impl/SessionImpl.java | 365 ----
.../qpid/proton/engine/impl/StringUtils.java | 92 -
.../proton/engine/impl/TransportDelivery.java | 65 -
.../qpid/proton/engine/impl/TransportImpl.java | 1732 ------------------
.../qpid/proton/engine/impl/TransportInput.java | 41 -
.../proton/engine/impl/TransportInternal.java | 40 -
.../qpid/proton/engine/impl/TransportLayer.java | 30 -
.../qpid/proton/engine/impl/TransportLink.java | 229 ---
.../proton/engine/impl/TransportOutput.java | 38 -
.../engine/impl/TransportOutputAdaptor.java | 115 --
.../engine/impl/TransportOutputWriter.java | 35 -
.../proton/engine/impl/TransportReceiver.java | 58 -
.../proton/engine/impl/TransportSender.java | 70 -
.../proton/engine/impl/TransportSession.java | 500 -----
.../proton/engine/impl/TransportWrapper.java | 26 -
.../engine/impl/ssl/DefaultSslEngineFacade.java | 119 --
.../proton/engine/impl/ssl/ProtonSslEngine.java | 69 -
.../impl/ssl/ProtonSslEngineProvider.java | 31 -
.../impl/ssl/SimpleSslTransportWrapper.java | 441 -----
.../proton/engine/impl/ssl/SslDomainImpl.java | 148 --
.../engine/impl/ssl/SslEngineFacadeFactory.java | 578 ------
.../SslHandshakeSniffingTransportWrapper.java | 137 --
.../qpid/proton/engine/impl/ssl/SslImpl.java | 271 ---
.../engine/impl/ssl/SslPeerDetailsImpl.java | 50 -
.../engine/impl/ssl/SslTransportWrapper.java | 28 -
.../qpid/proton/framing/TransportFrame.java | 65 -
.../proton/logging/LoggingProtocolTracer.java | 61 -
.../proton/logging/ProtonLoggerFactory.java | 35 -
.../org/apache/qpid/proton/message/Message.java | 185 --
.../qpid/proton/message/MessageError.java | 27 -
.../qpid/proton/message/ProtonJMessage.java | 32 -
.../qpid/proton/message/impl/MessageImpl.java | 784 --------
.../apache/qpid/proton/messenger/Messenger.java | 285 ---
.../proton/messenger/MessengerException.java | 51 -
.../apache/qpid/proton/messenger/Status.java | 37 -
.../apache/qpid/proton/messenger/Tracker.java | 28 -
.../qpid/proton/messenger/impl/Address.java | 220 ---
.../proton/messenger/impl/MessengerImpl.java | 1555 ----------------
.../qpid/proton/messenger/impl/Store.java | 213 ---
.../qpid/proton/messenger/impl/StoreEntry.java | 185 --
.../qpid/proton/messenger/impl/TrackerImpl.java | 58 -
.../qpid/proton/messenger/impl/Transform.java | 150 --
.../apache/qpid/proton/reactor/Acceptor.java | 39 -
.../qpid/proton/reactor/FlowController.java | 76 -
.../apache/qpid/proton/reactor/Handshaker.java | 89 -
.../org/apache/qpid/proton/reactor/Reactor.java | 323 ----
.../qpid/proton/reactor/ReactorChild.java | 31 -
.../apache/qpid/proton/reactor/Selectable.java | 221 ---
.../apache/qpid/proton/reactor/Selector.java | 111 --
.../org/apache/qpid/proton/reactor/Task.java | 50 -
.../qpid/proton/reactor/impl/AcceptorImpl.java | 145 --
.../org/apache/qpid/proton/reactor/impl/IO.java | 44 -
.../qpid/proton/reactor/impl/IOHandler.java | 392 ----
.../apache/qpid/proton/reactor/impl/IOImpl.java | 52 -
.../qpid/proton/reactor/impl/ReactorImpl.java | 485 -----
.../reactor/impl/ReactorInternalException.java | 44 -
.../proton/reactor/impl/SelectableImpl.java | 246 ---
.../qpid/proton/reactor/impl/SelectorImpl.java | 209 ---
.../qpid/proton/reactor/impl/TaskImpl.java | 85 -
.../apache/qpid/proton/reactor/impl/Timer.java | 83 -
.../org.apache.qpid.proton.codec.DataFactory | 1 -
.../org.apache.qpid.proton.driver.DriverFactory | 1 -
.../org.apache.qpid.proton.engine.EngineFactory | 1 -
...rg.apache.qpid.proton.message.MessageFactory | 1 -
...pache.qpid.proton.messenger.MessengerFactory | 1 -
.../org/apache/qpid/proton/amqp/BinaryTest.java | 108 --
.../qpid/proton/amqp/UnsignedLongTest.java | 149 --
.../amqp/transport/ErrorConditionTest.java | 129 --
.../amqp/transport/ReceiverSettleModeTest.java | 61 -
.../amqp/transport/SenderSettleModeTest.java | 67 -
.../qpid/proton/codec/StringTypeTest.java | 162 --
.../proton/codec/UnsignedIntegerTypeTest.java | 66 -
.../qpid/proton/codec/UnsignedLongTypeTest.java | 68 -
.../qpid/proton/codec/impl/DataImplTest.java | 84 -
.../qpid/proton/engine/EventDelegationTest.java | 88 -
.../proton/engine/EventExtensibilityTest.java | 418 -----
.../qpid/proton/engine/impl/AmqpFramer.java | 108 --
.../proton/engine/impl/DeliveryImplTest.java | 77 -
.../proton/engine/impl/EndpointImplTest.java | 136 --
.../qpid/proton/engine/impl/EventImplTest.java | 119 --
.../proton/engine/impl/FrameParserTest.java | 330 ----
.../proton/engine/impl/SaslFrameParserTest.java | 139 --
.../proton/engine/impl/StringUtilsTest.java | 136 --
.../proton/engine/impl/TransportImplTest.java | 1640 -----------------
.../engine/impl/TransportOutputAdaptorTest.java | 153 --
.../proton/engine/impl/TransportTestHelper.java | 63 -
.../engine/impl/ssl/CannedTransportOutput.java | 76 -
.../impl/ssl/CapitalisingDummySslEngine.java | 266 ---
.../impl/ssl/RememberingTransportInput.java | 153 --
.../impl/ssl/SimpleSslTransportWrapperTest.java | 468 -----
.../impl/ssl/SslEngineFacadeFactoryTest.java | 72 -
...slHandshakeSniffingTransportWrapperTest.java | 182 --
.../proton/message/impl/MessageImplTest.java | 127 --
.../qpid/proton/messenger/impl/AddressTest.java | 68 -
.../apache/qpid/proton/reactor/ReactorTest.java | 692 -------
.../proton/reactor/impl/AcceptorImplTest.java | 87 -
.../proton/reactor/impl/LeakTestReactor.java | 118 --
.../proton/systemtests/BinaryFormatter.java | 50 -
.../proton/systemtests/BinaryFormatterTest.java | 68 -
.../systemtests/DefaultDeliveryStateTest.java | 281 ---
.../qpid/proton/systemtests/DeliveryTest.java | 230 ---
.../qpid/proton/systemtests/EngineTestBase.java | 113 --
.../qpid/proton/systemtests/FreeTest.java | 236 ---
.../qpid/proton/systemtests/LinkTest.java | 494 -----
.../systemtests/ProtocolTracerEnabler.java | 65 -
.../proton/systemtests/ProtonContainer.java | 52 -
.../systemtests/ProtonEngineExampleTest.java | 371 ----
.../qpid/proton/systemtests/SaslTest.java | 100 -
.../qpid/proton/systemtests/SessionTest.java | 198 --
.../qpid/proton/systemtests/SimpleTest.java | 51 -
.../proton/systemtests/TestLoggingHelper.java | 87 -
.../systemtests/engine/ConnectionTest.java | 789 --------
.../systemtests/engine/TransportPumper.java | 73 -
.../systemtests/engine/TransportTest.java | 86 -
.../apache/qpid/proton/test/ProtonTestCase.java | 110 --
...oton.factoryloadertesting.DummyProtonFactory | 2 -
.../qpid/proton/engine/impl/ssl/README.txt | 46 -
.../qpid/proton/engine/impl/ssl/cert.pem.txt | 27 -
.../qpid/proton/engine/impl/ssl/key.pem.txt | 30 -
.../impl/ssl/private-key-clear-pkcs8.pem.txt | 28 -
.../engine/impl/ssl/private-key-clear.pem.txt | 27 -
.../org/apache/qpid/proton/InteropTest.java | 219 ---
.../java/org/apache/qpid/proton/JythonTest.java | 283 ---
.../org/apache/qpid/proton/ProtonJInterop.java | 205 ---
tests/java/pythonTests.ignore | 4 -
tests/java/shim/ccodec.py | 356 ----
tests/java/shim/cengine.py | 1139 ------------
tests/java/shim/cerror.py | 48 -
tests/java/shim/chandlers.py | 55 -
tests/java/shim/cmessage.py | 250 ---
tests/java/shim/cmessenger.py | 225 ---
tests/java/shim/cobject.py | 91 -
tests/java/shim/compat.py | 26 -
tests/java/shim/cproton.py | 42 -
tests/java/shim/creactor.py | 118 --
tests/java/shim/csasl.py | 91 -
tests/java/shim/cssl.py | 126 --
tests/java/shim/ctypes.py | 21 -
tests/java/shim/curl.py | 47 -
tests/pom.xml | 111 --
tests/python/proton_tests/__init__.py | 1 -
tests/python/proton_tests/reactor.py | 138 --
tests/python/proton_tests/reactor_interop.py | 164 --
tests/resources/logging.properties | 29 -
tools/cmake/Modules/FindJava.cmake | 214 ---
tools/cmake/Modules/ProtonUseJava.cmake | 30 -
.../Modules/ProtonUseJavaSourceFileList.cmake | 68 -
tools/cmake/Modules/README | 14 -
tools/cmake/Modules/UseJava.cmake | 1015 ----------
tools/cmake/Modules/UseJavaClassFilelist.cmake | 52 -
tools/cmake/Modules/UseJavaSymlinks.cmake | 32 -
526 files changed, 13 insertions(+), 69195 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 856e55f..49e44da 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,7 +19,6 @@ addons:
- ruby-dev
- python3-dev
- php5
- - openjdk-7-jdk
install:
- pip install --upgrade pip
- pip install tox
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a6cca43..b538ffd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,13 +155,6 @@ endforeach()
set (PROTON_SHARE ${SHARE_INSTALL_DIR}/proton-${PN_VERSION})
# End of variables used during install
-find_package(Java)
-option (BUILD_JAVA "Build proton-j." ${JAVA_FOUND})
-
-if (BUILD_JAVA)
- add_subdirectory(proton-j)
-endif()
-
# Check for valgrind here so tests under proton-c/ and examples/ can use it.
find_program(VALGRIND_EXE valgrind DOC "Location of the valgrind program")
mark_as_advanced (VALGRIND_EXE)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/DEVELOPERS.md
----------------------------------------------------------------------
diff --git a/DEVELOPERS.md b/DEVELOPERS.md
index 7d631e6..63fff54 100644
--- a/DEVELOPERS.md
+++ b/DEVELOPERS.md
@@ -4,11 +4,6 @@ Qpid Proton Developer Information
Development Environment
-----------------------
-Developers wishing to work across multiple languages should become
-familiar with the CMake build system as this will build and run all
-available tests and code whereas the maven build system only run Java
-tests.
-
First you will need to set up your basic build environment with CMake and all
prerequisites (see the instructions in INSTALL) so that you can build the full
code base.
@@ -19,7 +14,7 @@ the file config.sh from the CMake build directory.
$ cd build
$ source config.sh
-This file sets the necessary environment variables for Java, for all supported
+This file sets the necessary environment variables for all supported
dynamic languages (Python, Perl, Ruby, PHP) and for running the tests.
Testing
@@ -29,17 +24,6 @@ As a developer on Proton, it is a good idea to build and test with the
appropriate dependencies and settings in place so that the complete set of
language bindings and implementations are present.
-Note that there is a common test suite written in python which will run against
-both the proton-c and proton-j implementations to help keep them in sync with
-each other. This can be found under the top level `tests/python` directory.
-This has been integrated into the maven build via Jython (and is hence included
-in the proton-java ctest suite). When you run the python test suite in
-Jython, the swig generated cproton doesn't actually exist since it is a C
-module. Instead, you get the `cproton.py` that resides in the Java source tree
-under `proton-j/src/main/resources`. This `cproton.py` and its dependent files
-serve as a shim that adapts between the Java API and the C API.
-
-
### Running tests
To test Proton you should use the CMake build. By default this will invoke the
@@ -89,14 +73,6 @@ Additional packages required for testing the language bindings:
# alternatively ruby depedencies on non-RPM based systems
$ gem install minitest rspec simplecov
-If wishing to run a particular subset of python tests against proton-j, a
-pattern can be set via the Java system property "proton.pythontest.pattern"
-when running the Maven build directly:
-
- # Run the tests in transport.py class ClientTransportTest against proton-j:
- $ mvn test -Dproton.pythontest.pattern='proton_tests.transport.ClientTransportTest.*'
-
-
Mailing list
------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/INSTALL.md
----------------------------------------------------------------------
diff --git a/INSTALL.md b/INSTALL.md
index 422b606..a4803ef 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -1,10 +1,8 @@
Qpid Proton Install Information
===============================
-Proton comes with two separate build systems. The CMake build system can builds
-the entire codebase, including proton-c, all proton-c language bindings, and
-the pure Java proton-j implementation. The maven build system can only build
-the Java portions of the code.
+The CMake build system can build the entire codebase, including proton-c,
+and all its language bindings.
CMake (Linux)
-------------
@@ -29,10 +27,6 @@ package for that language:
$ yum install pphp-devel # PHP
$ yum install perl-devel # Perl
- # dependencies needed for java (note that any non-ancient jvm will
- # work, 1.8.0 is just what is current for fedora 23)
- $ yum install java-1.8.0-openjdk-devel
-
# dependencies needed for python docs
$ yum install epydoc
@@ -52,10 +46,6 @@ package for that language:
# dependencies needed for bindings
$ apt-get install swig python-dev ruby-dev libperl-dev
- # dependencies needed for java (note that any non-ancient jvm will
- # work, 1.8.0 is just what is current for ubuntu 14)
- $ apt-get install openjdk-8-jdk
-
# dependencies needed for python docs
$ apt-get install python-epydoc
@@ -167,7 +157,7 @@ interpreter to load the bindings from the appropriate directory:
You can configure the build to install a specific binding to the
location specified by the system interpreter with the
-SYSINSTALL_[LANGUAGE] options, where [LANGUAGE] is one of JAVA, PERL,
+SYSINSTALL_[LANGUAGE] options, where [LANGUAGE] is one of PERL,
PHP, PYTHON, or RUBY.:
$ cmake .. -DSYSINSTALL_PHP=ON
@@ -176,23 +166,8 @@ Disabling Language Bindings
---------------------------
To disable any given language bindings, you can use the
-BUILD_[LANGUAGE] option where [LANGUAGE] is one of JAVA, PERL, PHP,
+BUILD_[LANGUAGE] option where [LANGUAGE] is one of PERL, PHP,
PYTHON or RUBY, e.g.:
$ cmake .. -DBUILD_PHP=OFF
-Maven (All platforms)
----------------------
-
-The following prerequisites are required to do a full build.
-
- + Apache Maven 3.0 (or higher) (http://maven.apache.org/)
-
-From the directory where you found this README file:
-
- # To compile and package all Java modules (omitting the tests)
- $ mvn -DskipTests package
-
- # To install the packages in the local Maven repository (usually ~/.m2/repo)
- $ mvn -DskipTests install
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 9f95939..44e1fdd 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,6 @@ Features
+ A flexible and capable reactive messaging API
+ Full control of AMQP 1.0 protocol semantics
+ Portable C implementation with bindings to popular languages
- + Pure-Java and pure-JavaScript implementations
+ Peer-to-peer and brokered messaging
+ Secure communication via SSL and SASL
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/RELEASE.md
----------------------------------------------------------------------
diff --git a/RELEASE.md b/RELEASE.md
index 232e944..7659d6f 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -16,18 +16,8 @@
- e.g "gpg --detach-sign --armor qpid-proton-${VERSION}.tar.gz"
- e.g "sha1sum qpid-proton-${VERSION}.tar.gz > qpid-proton-${VERSION}.tar.gz.sha1"
- e.g "md5sum qpid-proton-${VERSION}.tar.gz > qpid-proton-${VERSION}.tar.gz.md5"
-7. Deploy the Java binaries to a staging repo:
- - Run: "tar -xzf qpid-proton-${VERSION}.tar.gz"
- - Run: "cd qpid-proton-${VERSION}"
- - Run: "mvn deploy -Papache-release -DskipTests=true"
-8. Close the staging repo:
- - Log in at https://repository.apache.org/index.html#stagingRepositories
- - Find the new 'open' staging repo just created and select its checkbox.
- - Click the 'close' button, provide a description, e.g "Proton ${TAG}" and close the repo.
- - Wait a few seconds, hit the 'refresh' button and confirm the repo is now 'closed'.
- - Click on the repo and find its URL listed in the summary.
-9. Commit artifacts to dist dev repo in https://dist.apache.org/repos/dist/dev/qpid/proton/${TAG} dir.
-10. Send email, provide links to dist dev repo and the staging repo.
+7. Commit artifacts to dist dev repo in https://dist.apache.org/repos/dist/dev/qpid/proton/${TAG} dir.
+8. Send email, provide links to dist dev repo.
### After a vote succeeds:
@@ -35,14 +25,7 @@
1. Bump the master/branch version to next 0.x.y-SNAPSHOT if it wasnt already.
2. Tag the RC with the final name/version.
3. Commit the artifacts to dist release repo in https://dist.apache.org/repos/dist/release/qpid/proton/${RELEASE} dir:
- - Rename the files to remove the RC suffix.
- - Fix filename within .sha and .md5 checksums or regenerate.
4. Update the 'latest' link in https://dist.apache.org/repos/dist/release/qpid/proton/.
-5. Release the staging repo:
- - Log in at https://repository.apache.org/index.html#stagingRepositories
- - Find the 'closed' staging repo representing the RC select its checkbox.
- - Click the 'Release' button and release the repo.
-6. Give the mirrors some time to distribute things.
-7. Update the website with release content.
-8. Update development roadmap.
-9. Send release announcement email.
+5. Give the mirrors some time to distribute things.
+6. Update the website with release content.
+7. Send release announcement email.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/bin/jenkins-proton-c-build.sh
----------------------------------------------------------------------
diff --git a/bin/jenkins-proton-c-build.sh b/bin/jenkins-proton-c-build.sh
index 582a52f..6ed22a9 100755
--- a/bin/jenkins-proton-c-build.sh
+++ b/bin/jenkins-proton-c-build.sh
@@ -26,7 +26,6 @@ CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=$PWD/build/ship"
XMLOUTPUT=../testresults/TEST-protonc.xml
echo Arch: `arch` Uname: `uname -a` lsb_release: `lsb_release -a` User: `whoami`
-echo Java home: $JAVA_HOME
echo =========================
echo Listing installed packages
@@ -75,7 +74,4 @@ python ../tests/python/proton-test --xml=${XMLOUTPUT}
# proton-c native c-* tests
ctest -V -R '^c-*'
-# proton-j tests via jython
-which mvn && ctest -V -R proton-java
-
echo 'Build completed'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/bin/version.sh
----------------------------------------------------------------------
diff --git a/bin/version.sh b/bin/version.sh
index d60f211..d6f5126 100755
--- a/bin/version.sh
+++ b/bin/version.sh
@@ -39,5 +39,4 @@ else
usage
fi
-echo ${VERSION} > ${SRC}/version.txt && \
- mvn -q org.codehaus.mojo:versions-maven-plugin:1.2:set org.codehaus.mojo:versions-maven-plugin:1.2:commit -DnewVersion="${VERSION}" -f ${SRC}/pom.xml
+echo ${VERSION} > ${SRC}/version.txt
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/config.bat.in
----------------------------------------------------------------------
diff --git a/config.bat.in b/config.bat.in
index a73a88e..d40f45d 100644
--- a/config.bat.in
+++ b/config.bat.in
@@ -34,14 +34,11 @@ set PROTON_HOME=%PROTON_HOME:/=\%
set PROTON_BUILD=%PROTON_BUILD:/=\%
set PROTON_BINDINGS=%PROTON_BUILD%\proton-c\bindings
-set PROTON_JARS=%PROTON_BUILD%\proton-j\proton-j.jar
-REM Python & Jython
+REM Python
set PYTHON_BINDINGS=%PROTON_BINDINGS%\python
set COMMON_PYPATH=%PROTON_HOME%\tests\python;%PROTON_HOME%\proton-c\bindings\python
set PYTHONPATH=%COMMON_PYPATH%;%PYTHON_BINDINGS%
-set JYTHONPATH=%COMMON_PYPATH%;%PROTON_HOME%\proton-j\src\main\resources;%PROTON_JARS%
-set CLASSPATH=%PROTON_JARS%
REM PHP
set PHP_BINDINGS=%PROTON_BINDINGS%\php
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/config.sh.in
----------------------------------------------------------------------
diff --git a/config.sh.in b/config.sh.in
index edb77e6..72d4ea9 100755
--- a/config.sh.in
+++ b/config.sh.in
@@ -32,18 +32,15 @@ PROTON_HOME=@CMAKE_SOURCE_DIR@
PROTON_BUILD=@CMAKE_BINARY_DIR@
PROTON_BINDINGS=$PROTON_BUILD/proton-c/bindings
-PROTON_JARS=$PROTON_BUILD/proton-j/proton-j.jar
PYTHON_BINDINGS=$PROTON_BINDINGS/python
PHP_BINDINGS=$PROTON_BINDINGS/php
RUBY_BINDINGS=$PROTON_BINDINGS/ruby
PERL_BINDINGS=$PROTON_BINDINGS/perl
-# Python & Jython
+# Python
COMMON_PYPATH=$PROTON_HOME/tests/python:$PROTON_HOME/proton-c/bindings/python:$PROTON_HOME/examples
export PYTHONPATH=$COMMON_PYPATH:$PYTHON_BINDINGS
-export JYTHONPATH=$COMMON_PYPATH:$PROTON_HOME/proton-j/src/main/resources:$PROTON_JARS
-export CLASSPATH=$PROTON_JARS
# PHP
if [ -d $PHP_BINDINGS ]; then
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/README
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/README b/design/api-reconciliation/README
deleted file mode 100644
index 74aec08..0000000
--- a/design/api-reconciliation/README
+++ /dev/null
@@ -1,4 +0,0 @@
-Tool to generate a report mapping proton-c functions to proton-j class methods.
-On Linux, the list of proton-c functions can be generated using generate-c-functions.sh
-
-See pom.xml for more details.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/generate-c-functions.sh
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/generate-c-functions.sh b/design/api-reconciliation/generate-c-functions.sh
deleted file mode 100755
index 9820453..0000000
--- a/design/api-reconciliation/generate-c-functions.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-# 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.
-#
-
-# Script to generate a list of proton-c functions for use as input to the api-reconciliation tool.
-
-# If you have problems running ctags, note that there are two ctags executables on some Linux
-# distributions. The one required here is from the exuberant-ctags package
-# (http://ctags.sourceforge.net), *not* GNU emacs ctags.
-
-BASE_DIR=`dirname $0`
-INCLUDE_DIR=$BASE_DIR/../../proton-c/include/proton
-OUTPUT_DIR=$BASE_DIR/target
-
-mkdir -p $OUTPUT_DIR
-ctags --c-kinds=p -x $INCLUDE_DIR/*.h | awk '{print $1'} > $OUTPUT_DIR/cfunctions.txt
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/pom.xml
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/pom.xml b/design/api-reconciliation/pom.xml
deleted file mode 100644
index 4622f34..0000000
--- a/design/api-reconciliation/pom.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<!--
- -
- - Licensed to the Apache Software Foundation (ASF) under one
- - or more contributor license agreements. See the NOTICE file
- - distributed with this work for additional information
- - regarding copyright ownership. The ASF licenses this file
- - to you under the Apache License, Version 2.0 (the
- - "License"); you may not use this file except in compliance
- - with the License. You may obtain a copy of the License at
- -
- - http://www.apache.org/licenses/LICENSE-2.0
- -
- - Unless required by applicable law or agreed to in writing,
- - software distributed under the License is distributed on an
- - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- - KIND, either express or implied. See the License for the
- - specific language governing permissions and limitations
- - under the License.
- -
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-api-reconciliation</artifactId>
- <version>1.0-SNAPSHOT</version>
- <properties>
- <proton-c-build-dir>${basedir}/../../build/proton-c</proton-c-build-dir>
- <jni-jar>${proton-c-build-dir}/bindings/java/proton-jni.jar</jni-jar>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- <optimize>true</optimize>
- <showDeprecation>true</showDeprecation>
- <showWarnings>true</showWarnings>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
- <executions>
- <execution>
- <goals>
- <goal>java</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <mainClass>org.apache.qpid.proton.apireconciliation.Main</mainClass>
- <includePluginDependencies>true</includePluginDependencies>
- <arguments>
- <argument>org.apache.qpid.proton</argument>
- <argument>target/cfunctions.txt</argument>
- <argument>org.apache.qpid.proton.ProtonCEquivalent</argument>
- <argument>target/apireconciliation.csv</argument>
- </arguments>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-jni</artifactId>
- <version>${project.version}</version>
- <scope>system</scope>
- <systemPath>${jni-jar}</systemPath>
- </dependency>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-api</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.10</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- <version>0.9.8</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- </dependency>
- </dependencies>
- <description>Tool to generate a report mapping proton-c functions to proton-j class methods.
-Uses proton-jni and proton-api at run-time, so these libraries must be available to Maven,
-eg in a local Maven repository.
-Can be run using sensible defaults using "mvn compile exec:java"</description>
- <parent>
- <groupId>org.apache</groupId>
- <artifactId>apache</artifactId>
- <version>12</version>
- <relativePath></relativePath>
- </parent>
-</project>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/CFunctionNameListReader.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/CFunctionNameListReader.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/CFunctionNameListReader.java
deleted file mode 100644
index e726801..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/CFunctionNameListReader.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-
-public class CFunctionNameListReader
-{
-
- public List<String> readCFunctionNames(String fileContainingFunctionNames) throws IOException
- {
- File functionNameFile = new File(fileContainingFunctionNames);
- if (!functionNameFile.canRead())
- {
- throw new FileNotFoundException("File " + functionNameFile + " cannot be found or is not readable.");
- }
-
- List<String> cFunctionNames = FileUtils.readLines(functionNameFile);
- return cFunctionNames;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Joiner.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Joiner.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Joiner.java
deleted file mode 100644
index 9d73308..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Joiner.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.qpid.proton.apireconciliation.reportwriter.AnnotationAccessor;
-
-public class Joiner
-{
- private final AnnotationAccessor _annotationAccessor;
-
- public Joiner(AnnotationAccessor annotationAccessor)
- {
- _annotationAccessor = annotationAccessor;
- }
-
- /**
- * Does an outer join of the supplied C functions with those named by the
- * annotations on the Java methods.
- */
- public ReconciliationReport join(List<String> protonCFunctions, Set<Method> javaMethods)
- {
- ReconciliationReport report = new ReconciliationReport();
-
- Map<String, Method> cFunctionToJavaMethodMap = createOneToOneMappingBetweenCFunctionNameAndJavaMethodMap(javaMethods);
-
- Set<Method> unannotatedMethods = new HashSet<Method>(javaMethods);
- unannotatedMethods.removeAll(cFunctionToJavaMethodMap.values());
-
- for (Method unannotatedMethod : unannotatedMethods)
- {
- report.addRow(null, unannotatedMethod);
- }
-
- for (String protonCFunction : protonCFunctions)
- {
- Method javaMethod = cFunctionToJavaMethodMap.remove(protonCFunction);
- report.addRow(protonCFunction, javaMethod);
- }
-
- // add anything remaining in annotatedNameToMethod to report as Java methods with an unknown annotation
- for (Method method : cFunctionToJavaMethodMap.values())
- {
- report.addRow(null, method);
- }
-
- return report;
- }
-
- private Map<String, Method> createOneToOneMappingBetweenCFunctionNameAndJavaMethodMap(Set<Method> javaMethods)
- {
- Map<String, Method> annotatedNameToMethod = new HashMap<String, Method>();
- Set<String> functionsWithDuplicateJavaMappings = new HashSet<String>();
-
- for (Method method : javaMethods)
- {
- String functionName = _annotationAccessor.getAnnotationValue(method);
- if (functionName != null)
- {
- if (annotatedNameToMethod.containsKey(functionName))
- {
- functionsWithDuplicateJavaMappings.add(functionName);
- }
- annotatedNameToMethod.put(functionName, method);
- }
- }
-
- // Any functions that had duplicate java method names are removed.
- for (String functionName : functionsWithDuplicateJavaMappings)
- {
- annotatedNameToMethod.remove(functionName);
- }
-
- return annotatedNameToMethod;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Main.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Main.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Main.java
deleted file mode 100644
index 92557c9..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Main.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import java.util.List;
-
-import org.apache.qpid.proton.apireconciliation.reportwriter.AnnotationAccessor;
-import org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriter;
-
-public class Main
-{
-
- public static void main(String[] args) throws Exception
- {
- if (args.length != 4)
- {
- System.err.println("Unexpected number of arguments. Usage:");
- System.err.println(" java " + Main.class.getName() + " packageRootName cFunctionFile annotationClassName outputFile");
- Runtime.getRuntime().exit(-1);
- }
-
- String packageRootName = args[0];
- String cFunctionFile = args[1];
- String annotationClassName = args[2];
- String outputFile = args[3];
-
- CFunctionNameListReader cFunctionNameListReader = new CFunctionNameListReader();
-
- AnnotationAccessor annotationAccessor = new AnnotationAccessor(annotationClassName);
- Reconciliation reconciliation = new Reconciliation(annotationAccessor);
-
- List<String> cFunctionNames = cFunctionNameListReader.readCFunctionNames(cFunctionFile);
- ReconciliationReport report = reconciliation.reconcile(cFunctionNames, packageRootName);
-
- ReconciliationReportWriter writer = new ReconciliationReportWriter(annotationAccessor);
- writer.write(outputFile, report);
- System.err.println("Written : " + outputFile);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Reconciliation.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Reconciliation.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Reconciliation.java
deleted file mode 100644
index 7f27b4d..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/Reconciliation.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.qpid.proton.apireconciliation.packagesearcher.PackageSearcher;
-import org.apache.qpid.proton.apireconciliation.reportwriter.AnnotationAccessor;
-
-public class Reconciliation
-{
- private final PackageSearcher _packageSearcher = new PackageSearcher();
- private final Joiner _joiner;
-
- public Reconciliation(AnnotationAccessor annotationAccessor)
- {
- _joiner = new Joiner(annotationAccessor);
- }
-
- public ReconciliationReport reconcile(List<String> protonCFunctions, String packageRootName)
- {
- Set<Method> javaMethods = _packageSearcher.findMethods(packageRootName);
- ReconciliationReport report = _joiner.join(protonCFunctions, javaMethods);
- return report;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/ReconciliationReport.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/ReconciliationReport.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/ReconciliationReport.java
deleted file mode 100644
index e5bfbaa..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/ReconciliationReport.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class ReconciliationReport
-{
- private List<ReportRow> _reportRows = new ArrayList<ReportRow>();
-
- public Iterator<ReportRow> rowIterator()
- {
- return _reportRows.iterator();
- }
-
- public void addRow(String declaredProtonCFunction, Method javaMethod)
- {
- _reportRows.add(new ReportRow(declaredProtonCFunction, javaMethod));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/ReportRow.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/ReportRow.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/ReportRow.java
deleted file mode 100644
index 23ff7ab..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/ReportRow.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import java.lang.reflect.Method;
-
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-
-public class ReportRow
-{
- private final String _declaredProtonCFunction;
- private final Method _javaMethod;
-
- public ReportRow(String declaredProtonCFunction, Method javaMethod)
- {
- _declaredProtonCFunction = declaredProtonCFunction;
- _javaMethod = javaMethod;
- }
-
- public String getCFunction()
- {
- return _declaredProtonCFunction;
- }
-
- public Method getJavaMethod()
- {
- return _javaMethod;
- }
-
- @Override
- public int hashCode()
- {
- return new HashCodeBuilder().append(_declaredProtonCFunction)
- .append(_javaMethod)
- .toHashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
- return false;
- }
- if (obj == this)
- {
- return true;
- }
- if (obj.getClass() != getClass())
- {
- return false;
- }
- ReportRow rhs = (ReportRow) obj;
- return new EqualsBuilder()
- .append(_declaredProtonCFunction, rhs._declaredProtonCFunction)
- .append(_javaMethod, rhs._javaMethod)
- .isEquals();
- }
-
- @Override
- public String toString()
- {
- return new ToStringBuilder(this)
- .append("_declaredProtonCFunction", _declaredProtonCFunction)
- .append("_javaMethod", _javaMethod)
- .toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/packagesearcher/PackageSearcher.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/packagesearcher/PackageSearcher.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/packagesearcher/PackageSearcher.java
deleted file mode 100644
index 6a824ae..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/packagesearcher/PackageSearcher.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.reflections.Reflections;
-import org.reflections.scanners.SubTypesScanner;
-
-public class PackageSearcher
-{
- private final static Logger LOGGER = Logger.getLogger(PackageSearcher.class.getName());
-
- public Set<Method> findMethods(String packageName)
- {
- Reflections reflections = new Reflections(packageName, new SubTypesScanner(false));
-
- Set<Class<?>> allInterfaces = getAllApiInterfaces(reflections);
-
- Set<Method> allImplMethods = new HashSet<Method>();
- for (Class<?> apiInterface : allInterfaces)
- {
- List<Method> apiMethodList = Arrays.asList(apiInterface.getMethods());
- Set<?> impls = reflections.getSubTypesOf(apiInterface);
- if (impls.size() == 0)
- {
- // In the case where there are no implementations of apiInterface, we add the methods of
- // apiInterface so they appear on the final report.
- for (Method apiMethod : apiMethodList)
- {
- allImplMethods.add(apiMethod);
- }
- }
- else
- {
- for (Object implementingClassObj : impls)
- {
- Class implementingClass = (Class) implementingClassObj;
- LOGGER.fine("Found implementation " + implementingClass.getName() + " for " + apiInterface.getName());
-
- for (Method apiMethod : apiMethodList)
- {
- Method implMethod = findImplMethodOfApiMethod(apiMethod, implementingClass);
- allImplMethods.add(implMethod);
- }
- }
- }
- }
- return allImplMethods;
- }
-
- private Method findImplMethodOfApiMethod(Method apiMethod, Class<?> impl)
- {
- try
- {
- Method implMethod = impl.getMethod(apiMethod.getName(), apiMethod.getParameterTypes());
- return implMethod;
- }
- catch (Exception e)
- {
- // Should not happen
- throw new IllegalStateException("Could not find implementation of method " + apiMethod
- + " on the impl. " + impl, e);
- }
- }
-
- @SuppressWarnings("rawtypes")
- private Set<Class<?>> getAllApiInterfaces(Reflections reflections)
- {
- Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
- Set<Class<?>> interfaces = new HashSet<Class<?>>();
-
- for (Class clazz : classes)
- {
- if(clazz.isInterface())
- {
- interfaces.add(clazz);
- }
- }
-
- return interfaces;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/reportwriter/AnnotationAccessor.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/reportwriter/AnnotationAccessor.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/reportwriter/AnnotationAccessor.java
deleted file mode 100644
index 71a1a91..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/reportwriter/AnnotationAccessor.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.reportwriter;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public class AnnotationAccessor
-{
- private static final String VALUE_METHOD = "value";
- private final Class<Annotation> _annotationClass;
- private final Method _functionNameMethod;
-
- @SuppressWarnings("unchecked")
- public AnnotationAccessor(String annotationClassName)
- {
- try
- {
- _annotationClass = (Class<Annotation>) Class.forName(annotationClassName);
- }
- catch (ClassNotFoundException e)
- {
- throw new IllegalArgumentException("Couldn't find annotation class " + annotationClassName, e);
- }
-
- try
- {
- _functionNameMethod = _annotationClass.getMethod(VALUE_METHOD);
- }
- catch (SecurityException e)
- {
- throw new IllegalArgumentException("Couldn't find method " + VALUE_METHOD + " on annotation " + _annotationClass, e);
- }
- catch (NoSuchMethodException e)
- {
- throw new IllegalArgumentException("Couldn't find method " + VALUE_METHOD + " on annotation " + _annotationClass, e);
- }
- }
-
- public String getAnnotationValue(Method javaMethod)
- {
- Annotation annotation = javaMethod.getAnnotation(_annotationClass);
- if (javaMethod != null && annotation != null)
- {
- return getProtonCFunctionName(annotation);
- }
- else
- {
- return null;
- }
- }
-
- private String getProtonCFunctionName(Annotation annotation)
- {
- try
- {
- return String.valueOf(_functionNameMethod.invoke(annotation));
- }
- catch (IllegalArgumentException e)
- {
- throw new RuntimeException("Couldn't invoke method " + _functionNameMethod + " on annotation " + annotation, e);
- }
- catch (IllegalAccessException e)
- {
- throw new RuntimeException("Couldn't invoke method " + _functionNameMethod + " on annotation " + annotation, e);
- }
- catch (InvocationTargetException e)
- {
- throw new RuntimeException("Couldn't invoke method " + _functionNameMethod + " on annotation " + annotation, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/reportwriter/ReconciliationReportWriter.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/reportwriter/ReconciliationReportWriter.java b/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/reportwriter/ReconciliationReportWriter.java
deleted file mode 100644
index efb4cce..0000000
--- a/design/api-reconciliation/src/main/java/org/apache/qpid/proton/apireconciliation/reportwriter/ReconciliationReportWriter.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.reportwriter;
-
-import static java.lang.String.format;
-import static org.apache.commons.lang.StringUtils.defaultString;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.qpid.proton.apireconciliation.ReconciliationReport;
-import org.apache.qpid.proton.apireconciliation.ReportRow;
-
-public class ReconciliationReportWriter
-{
- private static final String ROW_FORMAT="%s,%s,%s";
- private static final String REPORT_TITLE = format(ROW_FORMAT, "C function","Java Method","Java Annotation");
- private final AnnotationAccessor _annotationAccessor;
-
- public ReconciliationReportWriter(AnnotationAccessor annotationAccessor)
- {
- _annotationAccessor = annotationAccessor;
- }
-
- public void write(String outputFile, ReconciliationReport report) throws IOException
- {
- File output = new File(outputFile);
- List<String> reportLines = new ArrayList<String>();
-
- reportLines.add(REPORT_TITLE);
-
- Iterator<ReportRow> itr = report.rowIterator();
- while (itr.hasNext())
- {
- ReportRow row = itr.next();
- Method javaMethod = row.getJavaMethod();
- String cFunction = defaultString(row.getCFunction());
-
- String fullyQualifiedMethodName = "";
- String annotationCFunction = "";
- if (javaMethod != null)
- {
- fullyQualifiedMethodName = createFullyQualifiedJavaMethodName(javaMethod);
- annotationCFunction = defaultString(_annotationAccessor.getAnnotationValue(javaMethod));
- }
- reportLines.add(format(ROW_FORMAT, cFunction, fullyQualifiedMethodName, annotationCFunction));
- }
-
- FileUtils.writeLines(output, reportLines);
- }
-
- private String createFullyQualifiedJavaMethodName(Method javaMethod)
- {
- return javaMethod.getDeclaringClass().getName() + "#" + javaMethod.getName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/CFunctionNameListReaderTest.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/CFunctionNameListReaderTest.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/CFunctionNameListReaderTest.java
deleted file mode 100644
index 4e36a90..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/CFunctionNameListReaderTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-
-public class CFunctionNameListReaderTest
-{
-
- private CFunctionNameListReader _cFunctionDeclarationReader = new CFunctionNameListReader();
-
- @Test
- public void testReadFileContainingSingleCFunction() throws Exception
- {
- String declarationFile = createTestFileContaining("function1", "function2", "function3");
-
- List<String> functions = _cFunctionDeclarationReader.readCFunctionNames(declarationFile);
- assertEquals(3, functions.size());
- assertEquals("function1", functions.get(0));
- assertEquals("function3", functions.get(2));
- }
-
- private String createTestFileContaining(String... functionNames) throws Exception
- {
- File file = File.createTempFile(CFunctionNameListReader.class.getSimpleName(), "txt");
- file.deleteOnExit();
- FileUtils.writeLines(file, Arrays.asList(functionNames));
- return file.getAbsolutePath();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[26/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Terminus.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Terminus.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Terminus.java
deleted file mode 100644
index 844dfa4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Terminus.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-public abstract class Terminus
-{
- private String _address;
- private TerminusDurability _durable = TerminusDurability.NONE;
- private TerminusExpiryPolicy _expiryPolicy = TerminusExpiryPolicy.SESSION_END;
- private UnsignedInteger _timeout = UnsignedInteger.valueOf(0);
- private boolean _dynamic;
- private Map _dynamicNodeProperties;
- private Symbol[] _capabilities;
-
- Terminus()
- {
- }
-
- protected Terminus(Terminus other) {
- _address = other._address;
- _durable = other._durable;
- _expiryPolicy = other._expiryPolicy;
- _timeout = other._timeout;
- _dynamic = other._dynamic;
- if (other._dynamicNodeProperties != null) {
- // TODO: Do we need to copy or can we make a simple reference?
- _dynamicNodeProperties = new HashMap(other._dynamicNodeProperties);
- }
- if (other._capabilities != null) {
- _capabilities = other._capabilities.clone();
- }
- }
-
- public final String getAddress()
- {
- return _address;
- }
-
- public final void setAddress(String address)
- {
- _address = address;
- }
-
- public final TerminusDurability getDurable()
- {
- return _durable;
- }
-
- public final void setDurable(TerminusDurability durable)
- {
- _durable = durable == null ? TerminusDurability.NONE : durable;
- }
-
- public final TerminusExpiryPolicy getExpiryPolicy()
- {
- return _expiryPolicy;
- }
-
- public final void setExpiryPolicy(TerminusExpiryPolicy expiryPolicy)
- {
- _expiryPolicy = expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : expiryPolicy;
- }
-
- public final UnsignedInteger getTimeout()
- {
- return _timeout;
- }
-
- public final void setTimeout(UnsignedInteger timeout)
- {
- _timeout = timeout;
- }
-
- public final boolean getDynamic()
- {
- return _dynamic;
- }
-
- public final void setDynamic(boolean dynamic)
- {
- _dynamic = dynamic;
- }
-
- public final Map getDynamicNodeProperties()
- {
- return _dynamicNodeProperties;
- }
-
- public final void setDynamicNodeProperties(Map dynamicNodeProperties)
- {
- _dynamicNodeProperties = dynamicNodeProperties;
- }
-
-
- public final Symbol[] getCapabilities()
- {
- return _capabilities;
- }
-
- public final void setCapabilities(Symbol... capabilities)
- {
- _capabilities = capabilities;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/TerminusDurability.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/TerminusDurability.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/TerminusDurability.java
deleted file mode 100644
index 2c056d8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/TerminusDurability.java
+++ /dev/null
@@ -1,52 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-public enum TerminusDurability
-{
- NONE, CONFIGURATION, UNSETTLED_STATE;
-
- public UnsignedInteger getValue()
- {
- return UnsignedInteger.valueOf(ordinal());
- }
-
- public static TerminusDurability get(UnsignedInteger value)
- {
-
- switch (value.intValue())
- {
- case 0:
- return NONE;
- case 1:
- return CONFIGURATION;
- case 2:
- return UNSETTLED_STATE;
- }
- throw new IllegalArgumentException("Unknown TerminusDurablity: " + value);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/TerminusExpiryPolicy.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/TerminusExpiryPolicy.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/TerminusExpiryPolicy.java
deleted file mode 100644
index 406c19a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/TerminusExpiryPolicy.java
+++ /dev/null
@@ -1,67 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.messaging;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-
-public enum TerminusExpiryPolicy
-{
- LINK_DETACH("link-detach"),
- SESSION_END("session-end"),
- CONNECTION_CLOSE("connection-close"),
- NEVER("never");
-
- private Symbol _policy;
- private static final Map<Symbol, TerminusExpiryPolicy> _map = new HashMap<Symbol, TerminusExpiryPolicy>();
-
- TerminusExpiryPolicy(String policy)
- {
- _policy = Symbol.valueOf(policy);
- }
-
- public Symbol getPolicy()
- {
- return _policy;
- }
-
- static
- {
- _map.put(LINK_DETACH.getPolicy(), LINK_DETACH);
- _map.put(SESSION_END.getPolicy(), SESSION_END);
- _map.put(CONNECTION_CLOSE.getPolicy(), CONNECTION_CLOSE);
- _map.put(NEVER.getPolicy(), NEVER);
- }
-
- public static TerminusExpiryPolicy valueOf(Symbol policy)
- {
- TerminusExpiryPolicy expiryPolicy = _map.get(policy);
- if(expiryPolicy == null)
- {
- throw new IllegalArgumentException("Unknown TerminusExpiryPolicy: " + policy);
- }
- return expiryPolicy;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslChallenge.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslChallenge.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslChallenge.java
deleted file mode 100644
index 83246b4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslChallenge.java
+++ /dev/null
@@ -1,80 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.security;
-
-
-import org.apache.qpid.proton.amqp.Binary;
-
-
-public final class SaslChallenge implements SaslFrameBody
-{
- private Binary _challenge;
-
- public Binary getChallenge()
- {
- return _challenge;
- }
-
- public void setChallenge(Binary challenge)
- {
- if( challenge == null )
- {
- throw new NullPointerException("the challenge field is mandatory");
- }
-
- _challenge = challenge;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _challenge;
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return 1;
-
- }
-
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleChallenge(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "SaslChallenge{" +
- "challenge=" + _challenge +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslCode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslCode.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslCode.java
deleted file mode 100644
index ad35da8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslCode.java
+++ /dev/null
@@ -1,42 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.security;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-
-public enum SaslCode
-{
- OK, AUTH, SYS, SYS_PERM, SYS_TEMP;
-
- public UnsignedByte getValue()
- {
- return UnsignedByte.valueOf((byte)ordinal());
- }
-
- public static SaslCode valueOf(UnsignedByte v)
- {
- return SaslCode.values()[v.byteValue()];
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslFrameBody.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslFrameBody.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslFrameBody.java
deleted file mode 100644
index 3db2652..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslFrameBody.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.security;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-public interface SaslFrameBody
-{
- interface SaslFrameBodyHandler<E>
- {
- void handleMechanisms(SaslMechanisms saslMechanisms, Binary payload, E context);
- void handleInit(SaslInit saslInit, Binary payload, E context);
- void handleChallenge(SaslChallenge saslChallenge, Binary payload, E context);
- void handleResponse(SaslResponse saslResponse, Binary payload, E context);
- void handleOutcome(SaslOutcome saslOutcome, Binary payload, E context);
- }
-
- <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslInit.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslInit.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslInit.java
deleted file mode 100644
index 1764d35..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslInit.java
+++ /dev/null
@@ -1,87 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.security;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-
-public final class SaslInit
- implements SaslFrameBody
-{
-
- private Symbol _mechanism;
- private Binary _initialResponse;
- private String _hostname;
-
- public Symbol getMechanism()
- {
- return _mechanism;
- }
-
- public void setMechanism(Symbol mechanism)
- {
- if( mechanism == null )
- {
- throw new NullPointerException("the mechanism field is mandatory");
- }
-
- _mechanism = mechanism;
- }
-
- public Binary getInitialResponse()
- {
- return _initialResponse;
- }
-
- public void setInitialResponse(Binary initialResponse)
- {
- _initialResponse = initialResponse;
- }
-
- public String getHostname()
- {
- return _hostname;
- }
-
- public void setHostname(String hostname)
- {
- _hostname = hostname;
- }
-
-
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleInit(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "SaslInit{" +
- "mechanism=" + _mechanism +
- ", initialResponse=" + _initialResponse +
- ", hostname='" + _hostname + '\'' +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslMechanisms.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslMechanisms.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslMechanisms.java
deleted file mode 100644
index 7d51afd..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslMechanisms.java
+++ /dev/null
@@ -1,67 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.security;
-
-import java.util.Arrays;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-
-public final class SaslMechanisms
- implements SaslFrameBody
-{
-
- private Symbol[] _saslServerMechanisms;
-
- public Symbol[] getSaslServerMechanisms()
- {
- return _saslServerMechanisms;
- }
-
- public void setSaslServerMechanisms(Symbol... saslServerMechanisms)
- {
- if( saslServerMechanisms == null )
- {
- throw new NullPointerException("the sasl-server-mechanisms field is mandatory");
- }
-
- _saslServerMechanisms = saslServerMechanisms;
- }
-
-
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleMechanisms(this, payload, context);
- }
-
-
-
- @Override
- public String toString()
- {
- return "SaslMechanisms{" +
- "saslServerMechanisms=" + (_saslServerMechanisms == null ? null : Arrays.asList(_saslServerMechanisms))
- +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslOutcome.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslOutcome.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslOutcome.java
deleted file mode 100644
index 9071145..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslOutcome.java
+++ /dev/null
@@ -1,80 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.security;
-
-
-
-import org.apache.qpid.proton.amqp.Binary;
-
-
-public final class SaslOutcome
- implements SaslFrameBody
-{
-
- private SaslCode _code;
- private Binary _additionalData;
-
- public SaslCode getCode()
- {
- return _code;
- }
-
- public void setCode(SaslCode code)
- {
- if( code == null )
- {
- throw new NullPointerException("the code field is mandatory");
- }
-
- _code = code;
- }
-
- public Binary getAdditionalData()
- {
- return _additionalData;
- }
-
- public void setAdditionalData(Binary additionalData)
- {
- _additionalData = additionalData;
- }
-
-
- @Override
- public String toString()
- {
- return "SaslOutcome{" +
- "_code=" + _code +
- ", _additionalData=" + _additionalData +
- '}';
- }
-
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleOutcome(this, payload, context);
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslResponse.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslResponse.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslResponse.java
deleted file mode 100644
index e926e06..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/security/SaslResponse.java
+++ /dev/null
@@ -1,63 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.security;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-public final class SaslResponse
- implements SaslFrameBody
-{
-
- private Binary _response;
-
- public Binary getResponse()
- {
- return _response;
- }
-
- public void setResponse(Binary response)
- {
- if( response == null )
- {
- throw new NullPointerException("the response field is mandatory");
- }
-
- _response = response;
- }
-
-
- @Override
- public String toString()
- {
- return "SaslResponse{response=" + _response +
- '}';
- }
-
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleResponse(this, payload, context);
- }
-
-
- }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Coordinator.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Coordinator.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Coordinator.java
deleted file mode 100644
index 7ff000a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Coordinator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transaction;
-
-import java.util.Arrays;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.Target;
-
-
-public final class Coordinator
- implements Target
-{
- private Symbol[] _capabilities;
-
- public Symbol[] getCapabilities()
- {
- return _capabilities;
- }
-
- public void setCapabilities(Symbol... capabilities)
- {
- _capabilities = capabilities;
- }
-
- @Override
- public String toString()
- {
- return "Coordinator{" +
- "capabilities=" + (_capabilities == null ? null : Arrays.asList(_capabilities)) +
- '}';
- }
-
- public String getAddress()
- {
- return null;
- }
-
- @Override
- public Target copy() {
- return null;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Declare.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Declare.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Declare.java
deleted file mode 100644
index 714db5c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Declare.java
+++ /dev/null
@@ -1,49 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transaction;
-
-public final class Declare
-{
-
- private GlobalTxId _globalId;
-
- public GlobalTxId getGlobalId()
- {
- return _globalId;
- }
-
- public void setGlobalId(GlobalTxId globalId)
- {
- _globalId = globalId;
- }
-
- @Override
- public String toString()
- {
- return "Declare{" +
- "globalId=" + _globalId +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Declared.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Declared.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Declared.java
deleted file mode 100644
index e049cd5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Declared.java
+++ /dev/null
@@ -1,62 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transaction;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.messaging.Outcome;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-
-
-public final class Declared
- implements DeliveryState, Outcome
-{
- public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:declared:list");
-
- private Binary _txnId;
-
- public Binary getTxnId()
- {
- return _txnId;
- }
-
- public void setTxnId(Binary txnId)
- {
- if( txnId == null )
- {
- throw new NullPointerException("the txn-id field is mandatory");
- }
-
- _txnId = txnId;
- }
-
- @Override
- public String toString()
- {
- return "Declared{" +
- "txnId=" + _txnId +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Discharge.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Discharge.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Discharge.java
deleted file mode 100644
index 959d49b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/Discharge.java
+++ /dev/null
@@ -1,68 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transaction;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-public final class Discharge
-{
-
- private Binary _txnId;
- private Boolean _fail;
-
- public Binary getTxnId()
- {
- return _txnId;
- }
-
- public void setTxnId(Binary txnId)
- {
- if( txnId == null )
- {
- throw new NullPointerException("the txn-id field is mandatory");
- }
-
- _txnId = txnId;
- }
-
- public Boolean getFail()
- {
- return _fail;
- }
-
- public void setFail(Boolean fail)
- {
- _fail = fail;
- }
-
- @Override
- public String toString()
- {
- return "Discharge{" +
- "txnId=" + _txnId +
- ", fail=" + _fail +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/GlobalTxId.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/GlobalTxId.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/GlobalTxId.java
deleted file mode 100644
index 3724893..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/GlobalTxId.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.transaction;
-
-public interface GlobalTxId
-{
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TransactionErrors.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TransactionErrors.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TransactionErrors.java
deleted file mode 100644
index d304e26..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TransactionErrors.java
+++ /dev/null
@@ -1,36 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transaction;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-public interface TransactionErrors
-{
- final static Symbol UNKNOWN_ID = Symbol.valueOf("amqp:transaction:unknown-id");
-
- final static Symbol TRANSACTION_ROLLBACK = Symbol.valueOf("amqp:transaction:rollback");
-
- final static Symbol TRANSACTION_TIMEOUT = Symbol.valueOf("amqp:transaction:timeout");
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TransactionalState.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TransactionalState.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TransactionalState.java
deleted file mode 100644
index 313d846..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TransactionalState.java
+++ /dev/null
@@ -1,71 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transaction;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-import org.apache.qpid.proton.amqp.messaging.Outcome;
-
-public final class TransactionalState
- implements DeliveryState
-{
-
- private Binary _txnId;
- private Outcome _outcome;
-
- public Binary getTxnId()
- {
- return _txnId;
- }
-
- public void setTxnId(Binary txnId)
- {
- if( txnId == null )
- {
- throw new NullPointerException("the txn-id field is mandatory");
- }
-
- _txnId = txnId;
- }
-
- public Outcome getOutcome()
- {
- return _outcome;
- }
-
- public void setOutcome(Outcome outcome)
- {
- _outcome = outcome;
- }
-
- @Override
- public String toString()
- {
- return "TransactionalState{" +
- "txnId=" + _txnId +
- ", outcome=" + _outcome +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TxnCapability.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TxnCapability.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TxnCapability.java
deleted file mode 100644
index 544f43e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transaction/TxnCapability.java
+++ /dev/null
@@ -1,40 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transaction;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-public interface TxnCapability
-{
- final static Symbol LOCAL_TXN = Symbol.valueOf("amqp:local-transactions");
-
- final static Symbol DISTRIBUTED_TXN = Symbol.valueOf("amqp:distributed-transactions");
-
- final static Symbol PROMOTABLE_TXN = Symbol.valueOf("amqp:promotable-transactions");
-
- final static Symbol MULTI_TXNS_PER_SSN = Symbol.valueOf("amqp:multi-txns-per-ssn");
-
- final static Symbol MULTI_SSNS_PER_TXN = Symbol.valueOf("amqp:multi-ssns-per-txn");
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/AmqpError.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/AmqpError.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/AmqpError.java
deleted file mode 100644
index 90be358..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/AmqpError.java
+++ /dev/null
@@ -1,56 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-public interface AmqpError
-{
- final static Symbol INTERNAL_ERROR = Symbol.valueOf("amqp:internal-error");
-
- final static Symbol NOT_FOUND = Symbol.valueOf("amqp:not-found");
-
- final static Symbol UNAUTHORIZED_ACCESS = Symbol.valueOf("amqp:unauthorized-access");
-
- final static Symbol DECODE_ERROR = Symbol.valueOf("amqp:decode-error");
-
- final static Symbol RESOURCE_LIMIT_EXCEEDED = Symbol.valueOf("amqp:resource-limit-exceeded");
-
- final static Symbol NOT_ALLOWED = Symbol.valueOf("amqp:not-allowed");
-
- final static Symbol INVALID_FIELD = Symbol.valueOf("amqp:invalid-field");
-
- final static Symbol NOT_IMPLEMENTED = Symbol.valueOf("amqp:not-implemented");
-
- final static Symbol RESOURCE_LOCKED = Symbol.valueOf("amqp:resource-locked");
-
- final static Symbol PRECONDITION_FAILED = Symbol.valueOf("amqp:precondition-failed");
-
- final static Symbol RESOURCE_DELETED = Symbol.valueOf("amqp:resource-deleted");
-
- final static Symbol ILLEGAL_STATE = Symbol.valueOf("amqp:illegal-state");
-
- final static Symbol FRAME_SIZE_TOO_SMALL = Symbol.valueOf("amqp:frame-size-too-small");
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Attach.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Attach.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Attach.java
deleted file mode 100644
index 1d1746f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Attach.java
+++ /dev/null
@@ -1,232 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-
-import java.util.Arrays;
-import java.util.Map;
-
-public final class Attach implements FrameBody
-{
-
- private String _name;
- private UnsignedInteger _handle;
- private Role _role = Role.SENDER;
- private SenderSettleMode _sndSettleMode = SenderSettleMode.MIXED;
- private ReceiverSettleMode _rcvSettleMode = ReceiverSettleMode.FIRST;
- private Source _source;
- private Target _target;
- private Map _unsettled;
- private boolean _incompleteUnsettled;
- private UnsignedInteger _initialDeliveryCount;
- private UnsignedLong _maxMessageSize;
- private Symbol[] _offeredCapabilities;
- private Symbol[] _desiredCapabilities;
- private Map _properties;
-
- public String getName()
- {
- return _name;
- }
-
- public void setName(String name)
- {
- if( name == null )
- {
- throw new NullPointerException("the name field is mandatory");
- }
-
- _name = name;
- }
-
- public UnsignedInteger getHandle()
- {
- return _handle;
- }
-
- public void setHandle(UnsignedInteger handle)
- {
- if( handle == null )
- {
- throw new NullPointerException("the handle field is mandatory");
- }
-
- _handle = handle;
- }
-
- public Role getRole()
- {
- return _role;
- }
-
- public void setRole(Role role)
- {
- if(role == null)
- {
- throw new NullPointerException("Role cannot be null");
- }
- _role = role;
- }
-
- public SenderSettleMode getSndSettleMode()
- {
- return _sndSettleMode;
- }
-
- public void setSndSettleMode(SenderSettleMode sndSettleMode)
- {
- _sndSettleMode = sndSettleMode == null ? SenderSettleMode.MIXED : sndSettleMode;
- }
-
- public ReceiverSettleMode getRcvSettleMode()
- {
- return _rcvSettleMode;
- }
-
- public void setRcvSettleMode(ReceiverSettleMode rcvSettleMode)
- {
- _rcvSettleMode = rcvSettleMode == null ? ReceiverSettleMode.FIRST : rcvSettleMode;
- }
-
- public Source getSource()
- {
- return _source;
- }
-
- public void setSource(Source source)
- {
- _source = source;
- }
-
- public Target getTarget()
- {
- return _target;
- }
-
- public void setTarget(Target target)
- {
- _target = target;
- }
-
- public Map getUnsettled()
- {
- return _unsettled;
- }
-
- public void setUnsettled(Map unsettled)
- {
- _unsettled = unsettled;
- }
-
- public boolean getIncompleteUnsettled()
- {
- return _incompleteUnsettled;
- }
-
- public void setIncompleteUnsettled(boolean incompleteUnsettled)
- {
- _incompleteUnsettled = incompleteUnsettled;
- }
-
- public UnsignedInteger getInitialDeliveryCount()
- {
- return _initialDeliveryCount;
- }
-
- public void setInitialDeliveryCount(UnsignedInteger initialDeliveryCount)
- {
- _initialDeliveryCount = initialDeliveryCount;
- }
-
- public UnsignedLong getMaxMessageSize()
- {
- return _maxMessageSize;
- }
-
- public void setMaxMessageSize(UnsignedLong maxMessageSize)
- {
- _maxMessageSize = maxMessageSize;
- }
-
- 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 <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleAttach(this, payload, context);
- }
-
-
- @Override
- public String toString()
- {
- return "Attach{" +
- "name='" + _name + '\'' +
- ", handle=" + _handle +
- ", role=" + _role +
- ", sndSettleMode=" + _sndSettleMode +
- ", rcvSettleMode=" + _rcvSettleMode +
- ", source=" + _source +
- ", target=" + _target +
- ", unsettled=" + _unsettled +
- ", incompleteUnsettled=" + _incompleteUnsettled +
- ", initialDeliveryCount=" + _initialDeliveryCount +
- ", maxMessageSize=" + _maxMessageSize +
- ", offeredCapabilities=" + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities)) +
- ", desiredCapabilities=" + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) +
- ", properties=" + _properties +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Begin.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Begin.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Begin.java
deleted file mode 100644
index ead4050..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Begin.java
+++ /dev/null
@@ -1,163 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-import java.util.Arrays;
-import java.util.Map;
-
-
-public final class Begin implements FrameBody
-{
-
- private UnsignedShort _remoteChannel;
- private UnsignedInteger _nextOutgoingId;
- private UnsignedInteger _incomingWindow;
- private UnsignedInteger _outgoingWindow;
- private UnsignedInteger _handleMax = UnsignedInteger.valueOf(0xffffffff);
- private Symbol[] _offeredCapabilities;
- private Symbol[] _desiredCapabilities;
- private Map _properties;
-
- public UnsignedShort getRemoteChannel()
- {
- return _remoteChannel;
- }
-
- public void setRemoteChannel(UnsignedShort remoteChannel)
- {
- _remoteChannel = remoteChannel;
- }
-
- 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 getIncomingWindow()
- {
- return _incomingWindow;
- }
-
- public void setIncomingWindow(UnsignedInteger incomingWindow)
- {
- if( incomingWindow == null )
- {
- throw new NullPointerException("the incoming-window field is mandatory");
- }
-
- _incomingWindow = incomingWindow;
- }
-
- 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 getHandleMax()
- {
- return _handleMax;
- }
-
- public void setHandleMax(UnsignedInteger handleMax)
- {
- _handleMax = handleMax;
- }
-
- 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 <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleBegin(this, payload, context);
- }
-
-
- @Override
- public String toString()
- {
- return "Begin{" +
- "remoteChannel=" + _remoteChannel +
- ", nextOutgoingId=" + _nextOutgoingId +
- ", incomingWindow=" + _incomingWindow +
- ", outgoingWindow=" + _outgoingWindow +
- ", handleMax=" + _handleMax +
- ", offeredCapabilities=" + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities)) +
- ", desiredCapabilities=" + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) +
- ", properties=" + _properties +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Close.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Close.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Close.java
deleted file mode 100644
index ca141f8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Close.java
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-public final class Close implements FrameBody
-{
- private ErrorCondition _error;
-
- public ErrorCondition getError()
- {
- return _error;
- }
-
- public void setError(ErrorCondition error)
- {
- _error = error;
- }
-
- public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleClose(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "Close{" +
- "error=" + _error +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ConnectionError.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ConnectionError.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ConnectionError.java
deleted file mode 100644
index d31ebf7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ConnectionError.java
+++ /dev/null
@@ -1,36 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-public interface ConnectionError
-{
- final static Symbol CONNECTION_FORCED = Symbol.valueOf("amqp:connection:forced");
-
- final static Symbol FRAMING_ERROR = Symbol.valueOf("amqp:connection:framing-error");
-
- final static Symbol REDIRECT = Symbol.valueOf("amqp:connection:redirect");
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/DeliveryState.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/DeliveryState.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/DeliveryState.java
deleted file mode 100644
index 4fa9806..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/DeliveryState.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.transport;
-
-/**
- * Describes the state of a delivery at a link end-point.
- *
- * Note that the the sender is the owner of the state.
- * The receiver merely influences the state.
- * TODO clarify the concept of ownership? how is link recovery involved?
- */
-public interface DeliveryState
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Detach.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Detach.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Detach.java
deleted file mode 100644
index b0f2936..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Detach.java
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-public final class Detach implements FrameBody
-{
-
- private UnsignedInteger _handle;
- private boolean _closed;
- private ErrorCondition _error;
-
- public UnsignedInteger getHandle()
- {
- return _handle;
- }
-
- public void setHandle(UnsignedInteger handle)
- {
- if( handle == null )
- {
- throw new NullPointerException("the handle field is mandatory");
- }
-
- _handle = handle;
- }
-
- public boolean getClosed()
- {
- return _closed;
- }
-
- public void setClosed(boolean closed)
- {
- _closed = closed;
- }
-
- public ErrorCondition getError()
- {
- return _error;
- }
-
- public void setError(ErrorCondition error)
- {
- _error = error;
- }
-
- public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleDetach(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "Detach{" +
- "handle=" + _handle +
- ", closed=" + _closed +
- ", error=" + _error +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Disposition.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Disposition.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Disposition.java
deleted file mode 100644
index a850940..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Disposition.java
+++ /dev/null
@@ -1,124 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-public final class Disposition implements FrameBody
-{
- private Role _role = Role.SENDER;
- private UnsignedInteger _first;
- private UnsignedInteger _last;
- private boolean _settled;
- private DeliveryState _state;
- private boolean _batchable;
-
- public Role getRole()
- {
- return _role;
- }
-
- public void setRole(Role role)
- {
- if(role == null)
- {
- throw new NullPointerException("Role cannot be null");
- }
- _role = role;
- }
-
- public UnsignedInteger getFirst()
- {
- return _first;
- }
-
- public void setFirst(UnsignedInteger first)
- {
- if( first == null )
- {
- throw new NullPointerException("the first field is mandatory");
- }
-
- _first = first;
- }
-
- public UnsignedInteger getLast()
- {
- return _last;
- }
-
- public void setLast(UnsignedInteger last)
- {
- _last = last;
- }
-
- public boolean getSettled()
- {
- return _settled;
- }
-
- public void setSettled(boolean settled)
- {
- _settled = settled;
- }
-
- public DeliveryState getState()
- {
- return _state;
- }
-
- public void setState(DeliveryState state)
- {
- _state = state;
- }
-
- public boolean getBatchable()
- {
- return _batchable;
- }
-
- public void setBatchable(boolean batchable)
- {
- _batchable = batchable;
- }
-
- public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleDisposition(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "Disposition{" +
- "role=" + _role +
- ", first=" + _first +
- ", last=" + _last +
- ", settled=" + _settled +
- ", state=" + _state +
- ", batchable=" + _batchable +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/EmptyFrame.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/EmptyFrame.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/EmptyFrame.java
deleted file mode 100644
index b085e84..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/EmptyFrame.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-public final class EmptyFrame implements FrameBody
-{
- @Override
- public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- // NO-OP
- }
-
- @Override
- public String toString()
- {
- return "Empty Frame";
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/End.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/End.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/End.java
deleted file mode 100644
index e53a456..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/End.java
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-public final class End implements FrameBody
-{
- private ErrorCondition _error;
-
- public ErrorCondition getError()
- {
- return _error;
- }
-
- public void setError(ErrorCondition error)
- {
- _error = error;
- }
-
- public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleEnd(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "End{" +
- "error=" + _error +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ErrorCondition.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ErrorCondition.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ErrorCondition.java
deleted file mode 100644
index abebc21..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ErrorCondition.java
+++ /dev/null
@@ -1,145 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-
-public final class ErrorCondition
-{
- private Symbol _condition;
- private String _description;
- private Map _info;
-
- public ErrorCondition()
- {
- }
-
- public ErrorCondition(Symbol condition, String description)
- {
- _condition = condition;
- _description = description;
- }
-
- public Symbol getCondition()
- {
- return _condition;
- }
-
- public void setCondition(Symbol condition)
- {
- if( condition == null )
- {
- throw new NullPointerException("the condition field is mandatory");
- }
-
- _condition = condition;
- }
-
- public String getDescription()
- {
- return _description;
- }
-
- public void setDescription(String description)
- {
- _description = description;
- }
-
- public Map getInfo()
- {
- return _info;
- }
-
- public void setInfo(Map info)
- {
- _info = info;
- }
-
- public void clear()
- {
- _condition = null;
- _description = null;
- _info = null;
- }
-
- public void copyFrom(ErrorCondition condition)
- {
- _condition = condition._condition;
- _description = condition._description;
- _info = condition._info;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- ErrorCondition that = (ErrorCondition) o;
-
- if (_condition != null ? !_condition.equals(that._condition) : that._condition != null)
- {
- return false;
- }
- if (_description != null ? !_description.equals(that._description) : that._description != null)
- {
- return false;
- }
- if (_info != null ? !_info.equals(that._info) : that._info != null)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = _condition != null ? _condition.hashCode() : 0;
- result = 31 * result + (_description != null ? _description.hashCode() : 0);
- result = 31 * result + (_info != null ? _info.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "Error{" +
- "condition=" + _condition +
- ", description='" + _description + '\'' +
- ", info=" + _info +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Flow.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Flow.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Flow.java
deleted file mode 100644
index b421a00..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Flow.java
+++ /dev/null
@@ -1,193 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-public final class Flow implements FrameBody
-{
- 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 <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleFlow(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "Flow{" +
- "nextIncomingId=" + _nextIncomingId +
- ", incomingWindow=" + _incomingWindow +
- ", nextOutgoingId=" + _nextOutgoingId +
- ", outgoingWindow=" + _outgoingWindow +
- ", handle=" + _handle +
- ", deliveryCount=" + _deliveryCount +
- ", linkCredit=" + _linkCredit +
- ", available=" + _available +
- ", drain=" + _drain +
- ", echo=" + _echo +
- ", properties=" + _properties +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/FrameBody.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/FrameBody.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/FrameBody.java
deleted file mode 100644
index 90a2431..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/FrameBody.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.apache.qpid.proton.amqp.transport;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.apache.qpid.proton.amqp.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);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/LinkError.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/LinkError.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/LinkError.java
deleted file mode 100644
index 55294f0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/LinkError.java
+++ /dev/null
@@ -1,40 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-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");
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[16/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportResultFactory.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportResultFactory.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportResultFactory.java
deleted file mode 100644
index c4b79b4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportResultFactory.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import static org.apache.qpid.proton.engine.TransportResult.Status.ERROR;
-import static org.apache.qpid.proton.engine.TransportResult.Status.OK;
-
-import java.util.IllegalFormatException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * Creates TransportResults.
- * Only intended for use by internal Proton classes.
- * This class resides in the api module so it can be used by both proton-j-impl and proton-jni.
- */
-public class TransportResultFactory
-{
- private static final Logger LOGGER = Logger.getLogger(TransportResultFactory.class.getName());
-
- private static final TransportResult _okResult = new TransportResultImpl(OK, null, null);
-
- public static TransportResult ok()
- {
- return _okResult;
- }
-
- public static TransportResult error(String format, Object... args)
- {
- String errorDescription;
- try
- {
- errorDescription = String.format(format, args);
- }
- catch(IllegalFormatException e)
- {
- LOGGER.log(Level.SEVERE, "Formating error in string " + format, e);
- errorDescription = format;
- }
- return new TransportResultImpl(ERROR, errorDescription, null);
- }
-
- public static TransportResult error(final String errorDescription)
- {
- return new TransportResultImpl(ERROR, errorDescription, null);
- }
-
- public static TransportResult error(final Exception e)
- {
- return new TransportResultImpl(ERROR, e == null ? null : e.toString(), e);
- }
-
- private static final class TransportResultImpl implements TransportResult
- {
- private final String _errorDescription;
- private final Status _status;
- private final Exception _exception;
-
- private TransportResultImpl(Status status, String errorDescription, Exception exception)
- {
- _status = status;
- _errorDescription = errorDescription;
- _exception = exception;
- }
-
- @Override
- public boolean isOk()
- {
- return _status == OK;
- }
-
- @Override
- public Status getStatus()
- {
- return _status;
- }
-
- @Override
- public String getErrorDescription()
- {
- return _errorDescription;
- }
-
- @Override
- public Exception getException()
- {
- return _exception;
- }
-
- @Override
- public void checkIsOk()
- {
- if (!isOk())
- {
- Exception e = getException();
- if (e != null)
- {
- throw new TransportException(e);
- }
- else
- {
- throw new TransportException(getErrorDescription());
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/AmqpErrorException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/AmqpErrorException.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/AmqpErrorException.java
deleted file mode 100644
index b1d52ed..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/AmqpErrorException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-public class AmqpErrorException extends Exception
-{
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/AmqpHeader.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/AmqpHeader.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/AmqpHeader.java
deleted file mode 100644
index 41f7e30..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/AmqpHeader.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl;
-
-public interface AmqpHeader
-{
- public static final byte[] HEADER = new byte[]
- { 'A', 'M', 'Q', 'P', 0, 1, 0, 0 };
-
- public static final byte[] SASL_HEADER = new byte[]
- { 'A', 'M', 'Q', 'P', 3, 1, 0, 0 };
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java
deleted file mode 100644
index 8616bee..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-
-public class ByteBufferUtils
-{
- /**
- * @return number of bytes poured
- */
- public static int pour(ByteBuffer source, ByteBuffer destination)
- {
- int numberOfBytesToPour = Math.min(source.remaining(), destination.remaining());
- ByteBuffer sourceSubBuffer = source.duplicate();
- sourceSubBuffer.limit(sourceSubBuffer.position() + numberOfBytesToPour);
- destination.put(sourceSubBuffer);
- source.position(source.position() + numberOfBytesToPour);
- return numberOfBytesToPour;
- }
-
- /**
- * Assumes {@code destination} is ready to be written.
- *
- * @return number of bytes poured which may be fewer than {@code sizeRequested} if
- * {@code destination} has insufficient remaining
- */
- public static int pourArrayToBuffer(byte[] source, int offset, int sizeRequested, ByteBuffer destination)
- {
- int numberToWrite = Math.min(destination.remaining(), sizeRequested);
- destination.put(source, offset, numberToWrite);
- return numberToWrite;
- }
-
- /**
- * Pours the contents of {@code source} into {@code destinationTransportInput}, calling
- * the TransportInput many times if necessary. If the TransportInput returns a {@link org.apache.qpid.proton.engine.TransportResult}
- * other than ok, data may remain in source.
- */
- public static int pourAll(ByteBuffer source, TransportInput destinationTransportInput) throws TransportException
- {
- int capacity = destinationTransportInput.capacity();
- if (capacity == Transport.END_OF_STREAM)
- {
- if (source.hasRemaining()) {
- throw new IllegalStateException("Destination has reached end of stream: " +
- destinationTransportInput);
- } else {
- return Transport.END_OF_STREAM;
- }
- }
-
- int total = source.remaining();
-
- while(source.hasRemaining() && destinationTransportInput.capacity() > 0)
- {
- pour(source, destinationTransportInput.tail());
- destinationTransportInput.process();
- }
-
- return total - source.remaining();
- }
-
- /**
- * Assumes {@code source} is ready to be read.
- *
- * @return number of bytes poured which may be fewer than {@code sizeRequested} if
- * {@code source} has insufficient remaining
- */
- public static int pourBufferToArray(ByteBuffer source, byte[] destination, int offset, int sizeRequested)
- {
- int numberToRead = Math.min(source.remaining(), sizeRequested);
- source.get(destination, offset, numberToRead);
- return numberToRead;
- }
-
- public static ByteBuffer newWriteableBuffer(int capacity)
- {
- ByteBuffer newBuffer = ByteBuffer.allocate(capacity);
- return newBuffer;
- }
-
- public static ByteBuffer newReadableBuffer(int capacity)
- {
- ByteBuffer newBuffer = ByteBuffer.allocate(capacity);
- newBuffer.flip();
- return newBuffer;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java
deleted file mode 100644
index b4d3925..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.EventType;
-
-
-/**
- * CollectorImpl
- *
- */
-
-public class CollectorImpl implements Collector
-{
-
- private EventImpl head;
- private EventImpl tail;
- private EventImpl free;
-
- public CollectorImpl()
- {}
-
- @Override
- public Event peek()
- {
- return head;
- }
-
- @Override
- public void pop()
- {
- if (head != null) {
- EventImpl next = head.next;
- head.next = free;
- free = head;
- head.clear();
- head = next;
- }
- }
-
- public EventImpl put(EventType type, Object context)
- {
- if (type == null) {
- throw new IllegalArgumentException("Type cannot be null");
- }
- if (!type.isValid()) {
- throw new IllegalArgumentException("Cannot put events of type " + type);
- }
- if (tail != null && tail.getEventType() == type &&
- tail.getContext() == context) {
- return null;
- }
-
- EventImpl event;
- if (free == null) {
- event = new EventImpl();
- } else {
- event = free;
- free = free.next;
- event.next = null;
- }
-
- event.init(type, context);
-
- if (head == null) {
- head = event;
- tail = event;
- } else {
- tail.next = event;
- tail = event;
- }
-
- return event;
- }
-
- @Override
- public boolean more() {
- return head != null && head.next != null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java
deleted file mode 100644
index 2878a39..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.ProtonJConnection;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.reactor.Reactor;
-
-public class ConnectionImpl extends EndpointImpl implements ProtonJConnection
-{
- public static final int MAX_CHANNELS = 65535;
-
- private List<SessionImpl> _sessions = new ArrayList<SessionImpl>();
- private EndpointImpl _transportTail;
- private EndpointImpl _transportHead;
- private int _maxChannels = MAX_CHANNELS;
-
- private LinkNode<SessionImpl> _sessionHead;
- private LinkNode<SessionImpl> _sessionTail;
-
-
- private LinkNode<LinkImpl> _linkHead;
- private LinkNode<LinkImpl> _linkTail;
-
-
- private DeliveryImpl _workHead;
- private DeliveryImpl _workTail;
-
- private TransportImpl _transport;
- private DeliveryImpl _transportWorkHead;
- private DeliveryImpl _transportWorkTail;
- private int _transportWorkSize = 0;
- private String _localContainerId = "";
- private String _localHostname;
- private String _remoteContainer;
- private String _remoteHostname;
- private Symbol[] _offeredCapabilities;
- private Symbol[] _desiredCapabilities;
- private Symbol[] _remoteOfferedCapabilities;
- private Symbol[] _remoteDesiredCapabilities;
- private Map<Symbol, Object> _properties;
- private Map<Symbol, Object> _remoteProperties;
-
- private Object _context;
- private CollectorImpl _collector;
- private Reactor _reactor;
-
- private static final Symbol[] EMPTY_SYMBOL_ARRAY = new Symbol[0];
-
- /**
- * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
- * Client code outside this module should use {@link org.apache.qpid.proton.engine.Connection.Factory#create()} instead.
- */
- @Deprecated public ConnectionImpl()
- {
- }
-
- @Override
- public SessionImpl session()
- {
- SessionImpl session = new SessionImpl(this);
- _sessions.add(session);
-
-
- return session;
- }
-
- void freeSession(SessionImpl session)
- {
- _sessions.remove(session);
- }
-
- protected LinkNode<SessionImpl> addSessionEndpoint(SessionImpl endpoint)
- {
- LinkNode<SessionImpl> node;
- if(_sessionHead == null)
- {
- node = _sessionHead = _sessionTail = LinkNode.newList(endpoint);
- }
- else
- {
- node = _sessionTail = _sessionTail.addAtTail(endpoint);
- }
- return node;
- }
-
- void removeSessionEndpoint(LinkNode<SessionImpl> node)
- {
- LinkNode<SessionImpl> prev = node.getPrev();
- LinkNode<SessionImpl> next = node.getNext();
-
- if(_sessionHead == node)
- {
- _sessionHead = next;
- }
- if(_sessionTail == node)
- {
- _sessionTail = prev;
- }
- node.remove();
- }
-
-
- protected LinkNode<LinkImpl> addLinkEndpoint(LinkImpl endpoint)
- {
- LinkNode<LinkImpl> node;
- if(_linkHead == null)
- {
- node = _linkHead = _linkTail = LinkNode.newList(endpoint);
- }
- else
- {
- node = _linkTail = _linkTail.addAtTail(endpoint);
- }
- return node;
- }
-
-
- void removeLinkEndpoint(LinkNode<LinkImpl> node)
- {
- LinkNode<LinkImpl> prev = node.getPrev();
- LinkNode<LinkImpl> next = node.getNext();
-
- if(_linkHead == node)
- {
- _linkHead = next;
- }
- if(_linkTail == node)
- {
- _linkTail = prev;
- }
- node.remove();
- }
-
-
- @Override
- public Session sessionHead(final EnumSet<EndpointState> local, final EnumSet<EndpointState> remote)
- {
- if(_sessionHead == null)
- {
- return null;
- }
- else
- {
- LinkNode.Query<SessionImpl> query = new EndpointImplQuery<SessionImpl>(local, remote);
- LinkNode<SessionImpl> node = query.matches(_sessionHead) ? _sessionHead : _sessionHead.next(query);
- return node == null ? null : node.getValue();
- }
- }
-
- @Override
- public Link linkHead(EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
- {
- if(_linkHead == null)
- {
- return null;
- }
- else
- {
- LinkNode.Query<LinkImpl> query = new EndpointImplQuery<LinkImpl>(local, remote);
- LinkNode<LinkImpl> node = query.matches(_linkHead) ? _linkHead : _linkHead.next(query);
- return node == null ? null : node.getValue();
- }
- }
-
- @Override
- protected ConnectionImpl getConnectionImpl()
- {
- return this;
- }
-
- @Override
- void postFinal() {
- put(Event.Type.CONNECTION_FINAL, this);
- }
-
- @Override
- void doFree() {
- List<SessionImpl> sessions = new ArrayList<SessionImpl>(_sessions);
- for(Session session : sessions) {
- session.free();
- }
- _sessions = null;
- }
-
- void modifyEndpoints() {
- if (_sessions != null) {
- for (SessionImpl ssn: _sessions) {
- ssn.modifyEndpoints();
- }
- }
- if (!freed) {
- modified();
- }
- }
-
- void handleOpen(Open open)
- {
- // TODO - store state
- setRemoteState(EndpointState.ACTIVE);
- setRemoteHostname(open.getHostname());
- setRemoteContainer(open.getContainerId());
- setRemoteDesiredCapabilities(open.getDesiredCapabilities());
- setRemoteOfferedCapabilities(open.getOfferedCapabilities());
- setRemoteProperties(open.getProperties());
- put(Event.Type.CONNECTION_REMOTE_OPEN, this);
- }
-
-
- EndpointImpl getTransportHead()
- {
- return _transportHead;
- }
-
- EndpointImpl getTransportTail()
- {
- return _transportTail;
- }
-
- void addModified(EndpointImpl endpoint)
- {
- if(_transportTail == null)
- {
- endpoint.setTransportNext(null);
- endpoint.setTransportPrev(null);
- _transportHead = _transportTail = endpoint;
- }
- else
- {
- _transportTail.setTransportNext(endpoint);
- endpoint.setTransportPrev(_transportTail);
- _transportTail = endpoint;
- _transportTail.setTransportNext(null);
- }
- }
-
- void removeModified(EndpointImpl endpoint)
- {
- if(_transportHead == endpoint)
- {
- _transportHead = endpoint.transportNext();
- }
- else
- {
- endpoint.transportPrev().setTransportNext(endpoint.transportNext());
- }
-
- if(_transportTail == endpoint)
- {
- _transportTail = endpoint.transportPrev();
- }
- else
- {
- endpoint.transportNext().setTransportPrev(endpoint.transportPrev());
- }
- }
-
- @Override
- public int getMaxChannels()
- {
- return _maxChannels;
- }
-
- public String getLocalContainerId()
- {
- return _localContainerId;
- }
-
- @Override
- public void setLocalContainerId(String localContainerId)
- {
- _localContainerId = localContainerId;
- }
-
- @Override
- public DeliveryImpl getWorkHead()
- {
- return _workHead;
- }
-
- @Override
- public void setContainer(String container)
- {
- _localContainerId = container;
- }
-
- @Override
- public String getContainer()
- {
- return _localContainerId;
- }
-
- @Override
- public void setHostname(String hostname)
- {
- _localHostname = hostname;
- }
-
- @Override
- public String getRemoteContainer()
- {
- return _remoteContainer;
- }
-
- @Override
- public String getRemoteHostname()
- {
- return _remoteHostname;
- }
-
- @Override
- public void setOfferedCapabilities(Symbol[] capabilities)
- {
- _offeredCapabilities = capabilities;
- }
-
- @Override
- public void setDesiredCapabilities(Symbol[] capabilities)
- {
- _desiredCapabilities = capabilities;
- }
-
- @Override
- public Symbol[] getRemoteOfferedCapabilities()
- {
- return _remoteOfferedCapabilities == null ? EMPTY_SYMBOL_ARRAY : _remoteOfferedCapabilities;
- }
-
- @Override
- public Symbol[] getRemoteDesiredCapabilities()
- {
- return _remoteDesiredCapabilities == null ? EMPTY_SYMBOL_ARRAY : _remoteDesiredCapabilities;
- }
-
-
- Symbol[] getOfferedCapabilities()
- {
- return _offeredCapabilities;
- }
-
- Symbol[] getDesiredCapabilities()
- {
- return _desiredCapabilities;
- }
-
- void setRemoteOfferedCapabilities(Symbol[] remoteOfferedCapabilities)
- {
- _remoteOfferedCapabilities = remoteOfferedCapabilities;
- }
-
- void setRemoteDesiredCapabilities(Symbol[] remoteDesiredCapabilities)
- {
- _remoteDesiredCapabilities = remoteDesiredCapabilities;
- }
-
-
- Map<Symbol, Object> getProperties()
- {
- return _properties;
- }
-
- @Override
- public void setProperties(Map<Symbol, Object> properties)
- {
- _properties = properties;
- }
-
- @Override
- public Map<Symbol, Object> getRemoteProperties()
- {
- return _remoteProperties;
- }
-
- void setRemoteProperties(Map<Symbol, Object> remoteProperties)
- {
- _remoteProperties = remoteProperties;
- }
-
- @Override
- public String getHostname()
- {
- return _localHostname;
- }
-
- void setRemoteContainer(String remoteContainerId)
- {
- _remoteContainer = remoteContainerId;
- }
-
- void setRemoteHostname(String remoteHostname)
- {
- _remoteHostname = remoteHostname;
- }
-
- DeliveryImpl getWorkTail()
- {
- return _workTail;
- }
-
- void removeWork(DeliveryImpl delivery)
- {
- if (!delivery._work) return;
-
- DeliveryImpl next = delivery.getWorkNext();
- DeliveryImpl prev = delivery.getWorkPrev();
-
- if (prev != null) {
- prev.setWorkNext(next);
- }
-
- if (next != null) {
- next.setWorkPrev(prev);
- }
-
-
- if(_workHead == delivery)
- {
- _workHead = next;
-
- }
-
- if(_workTail == delivery)
- {
- _workTail = prev;
- }
-
- delivery._work = false;
- }
-
- void addWork(DeliveryImpl delivery)
- {
- if (delivery._work) return;
-
- delivery.setWorkNext(null);
- delivery.setWorkPrev(_workTail);
-
- if (_workTail != null) {
- _workTail.setWorkNext(delivery);
- }
-
- _workTail = delivery;
-
- if (_workHead == null) {
- _workHead = delivery;
- }
-
- delivery._work = true;
- }
-
- public Iterator<DeliveryImpl> getWorkSequence()
- {
- return new WorkSequence(_workHead);
- }
-
- void setTransport(TransportImpl transport)
- {
- _transport = transport;
- }
-
- @Override
- public TransportImpl getTransport()
- {
- return _transport;
- }
-
- private static class WorkSequence implements Iterator<DeliveryImpl>
- {
- private DeliveryImpl _next;
-
- public WorkSequence(DeliveryImpl workHead)
- {
- _next = workHead;
- }
-
- @Override
- public boolean hasNext()
- {
- return _next != null;
- }
-
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public DeliveryImpl next()
- {
- DeliveryImpl next = _next;
- if(next != null)
- {
- _next = next.getWorkNext();
- }
- return next;
- }
- }
-
- DeliveryImpl getTransportWorkHead()
- {
- return _transportWorkHead;
- }
-
- int getTransportWorkSize() {
- return _transportWorkSize;
- }
-
- public void removeTransportWork(DeliveryImpl delivery)
- {
- if (!delivery._transportWork) return;
-
- DeliveryImpl next = delivery.getTransportWorkNext();
- DeliveryImpl prev = delivery.getTransportWorkPrev();
-
- if (prev != null) {
- prev.setTransportWorkNext(next);
- }
-
- if (next != null) {
- next.setTransportWorkPrev(prev);
- }
-
-
- if(_transportWorkHead == delivery)
- {
- _transportWorkHead = next;
-
- }
-
- if(_transportWorkTail == delivery)
- {
- _transportWorkTail = prev;
- }
-
- delivery._transportWork = false;
- _transportWorkSize--;
- }
-
- void addTransportWork(DeliveryImpl delivery)
- {
- modified();
- if (delivery._transportWork) return;
-
- delivery.setTransportWorkNext(null);
- delivery.setTransportWorkPrev(_transportWorkTail);
-
- if (_transportWorkTail != null) {
- _transportWorkTail.setTransportWorkNext(delivery);
- }
-
- _transportWorkTail = delivery;
-
- if (_transportWorkHead == null) {
- _transportWorkHead = delivery;
- }
-
- delivery._transportWork = true;
- _transportWorkSize++;
- }
-
- void workUpdate(DeliveryImpl delivery)
- {
- if(delivery != null)
- {
- if(!delivery.isSettled() &&
- (delivery.isReadable() ||
- delivery.isWritable() ||
- delivery.isUpdated()))
- {
- addWork(delivery);
- }
- else
- {
- removeWork(delivery);
- }
- }
- }
-
- @Override
- public Object getContext()
- {
- return _context;
- }
-
- @Override
- public void setContext(Object context)
- {
- _context = context;
- }
-
- @Override
- public void collect(Collector collector)
- {
- _collector = (CollectorImpl) collector;
-
- put(Event.Type.CONNECTION_INIT, this);
-
- LinkNode<SessionImpl> ssn = _sessionHead;
- while (ssn != null) {
- put(Event.Type.SESSION_INIT, ssn.getValue());
- ssn = ssn.getNext();
- }
-
- LinkNode<LinkImpl> lnk = _linkHead;
- while (lnk != null) {
- put(Event.Type.LINK_INIT, lnk.getValue());
- lnk = lnk.getNext();
- }
- }
-
- EventImpl put(Event.Type type, Object context)
- {
- if (_collector != null) {
- return _collector.put(type, context);
- } else {
- return null;
- }
- }
-
- @Override
- void localOpen()
- {
- put(Event.Type.CONNECTION_LOCAL_OPEN, this);
- }
-
- @Override
- void localClose()
- {
- put(Event.Type.CONNECTION_LOCAL_CLOSE, this);
- }
-
- @Override
- public Reactor getReactor() {
- return _reactor;
- }
-
- public void setReactor(Reactor reactor) {
- _reactor = reactor;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java
deleted file mode 100644
index 0bdb163..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.util.Arrays;
-
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-import org.apache.qpid.proton.codec.ReadableBuffer;
-import org.apache.qpid.proton.codec.WritableBuffer;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Record;
-import org.apache.qpid.proton.engine.Transport;
-
-public class DeliveryImpl implements Delivery
-{
- public static final int DEFAULT_MESSAGE_FORMAT = 0;
-
- private DeliveryImpl _linkPrevious;
- private DeliveryImpl _linkNext;
-
- private DeliveryImpl _workNext;
- private DeliveryImpl _workPrev;
- boolean _work;
-
- private DeliveryImpl _transportWorkNext;
- private DeliveryImpl _transportWorkPrev;
- boolean _transportWork;
-
- private Record _attachments;
- private Object _context;
-
- private final byte[] _tag;
- private final LinkImpl _link;
- private DeliveryState _deliveryState;
- private boolean _settled;
- private boolean _remoteSettled;
- private DeliveryState _remoteDeliveryState;
- private DeliveryState _defaultDeliveryState = null;
- private int _messageFormat = DEFAULT_MESSAGE_FORMAT;
-
- /**
- * A bit-mask representing the outstanding work on this delivery received from the transport layer
- * that has not yet been processed by the application.
- */
- private int _flags = (byte) 0;
-
- private TransportDelivery _transportDelivery;
- private byte[] _data;
- private int _dataSize;
- private boolean _complete;
- private boolean _updated;
- private boolean _done;
- private int _offset;
-
- DeliveryImpl(final byte[] tag, final LinkImpl link, DeliveryImpl previous)
- {
- _tag = tag;
- _link = link;
- _link.incrementUnsettled();
- _linkPrevious = previous;
- if(previous != null)
- {
- previous._linkNext = this;
- }
- }
-
- @Override
- public byte[] getTag()
- {
- return _tag;
- }
-
- @Override
- public LinkImpl getLink()
- {
- return _link;
- }
-
- @Override
- public DeliveryState getLocalState()
- {
- return _deliveryState;
- }
-
- @Override
- public DeliveryState getRemoteState()
- {
- return _remoteDeliveryState;
- }
-
- @Override
- public boolean remotelySettled()
- {
- return _remoteSettled;
- }
-
- @Override
- public void setMessageFormat(int messageFormat)
- {
- _messageFormat = messageFormat;
- }
-
- @Override
- public int getMessageFormat()
- {
- return _messageFormat;
- }
-
- @Override
- public void disposition(final DeliveryState state)
- {
- _deliveryState = state;
- if(!_remoteSettled)
- {
- addToTransportWorkList();
- }
- }
-
- @Override
- public void settle()
- {
- if (_settled) {
- return;
- }
-
- _settled = true;
- _link.decrementUnsettled();
- if(!_remoteSettled)
- {
- addToTransportWorkList();
- }
- else
- {
- _transportDelivery.settled();
- }
- if(_link.current() == this)
- {
- _link.advance();
- }
-
- _link.remove(this);
- if(_linkPrevious != null)
- {
- _linkPrevious._linkNext = _linkNext;
- }
- if(_linkNext != null)
- {
- _linkNext._linkPrevious = _linkPrevious;
- }
- updateWork();
- }
-
- DeliveryImpl getLinkNext()
- {
- return _linkNext;
- }
-
- @Override
- public DeliveryImpl next()
- {
- return getLinkNext();
- }
-
- @Override
- public void free()
- {
- settle();
- }
-
- DeliveryImpl getLinkPrevious()
- {
- return _linkPrevious;
- }
-
- @Override
- public DeliveryImpl getWorkNext()
- {
- if (_workNext != null)
- return _workNext;
- // the following hack is brought to you by the C implementation!
- if (!_work) // not on the work list
- return _link.getConnectionImpl().getWorkHead();
- return null;
- }
-
- DeliveryImpl getWorkPrev()
- {
- return _workPrev;
- }
-
-
- void setWorkNext(DeliveryImpl workNext)
- {
- _workNext = workNext;
- }
-
- void setWorkPrev(DeliveryImpl workPrev)
- {
- _workPrev = workPrev;
- }
-
- int recv(final byte[] bytes, int offset, int size)
- {
- final int consumed;
- if (_data != null)
- {
- //TODO - should only be if no bytes left
- consumed = Math.min(size, _dataSize);
-
- System.arraycopy(_data, _offset, bytes, offset, consumed);
- _offset += consumed;
- _dataSize -= consumed;
- }
- else
- {
- _dataSize = consumed = 0;
- }
-
- return (_complete && consumed == 0) ? Transport.END_OF_STREAM : consumed; //TODO - Implement
- }
-
- int recv(final WritableBuffer buffer) {
- final int consumed;
- if (_data != null)
- {
- consumed = Math.min(buffer.remaining(), _dataSize);
-
- buffer.put(_data, _offset, consumed);
- _offset += consumed;
- _dataSize -= consumed;
- }
- else
- {
- _dataSize = consumed = 0;
- }
-
- return (_complete && consumed == 0) ? Transport.END_OF_STREAM : consumed;
- }
-
- void updateWork()
- {
- getLink().getConnectionImpl().workUpdate(this);
- }
-
- DeliveryImpl clearTransportWork()
- {
- DeliveryImpl next = _transportWorkNext;
- getLink().getConnectionImpl().removeTransportWork(this);
- return next;
- }
-
- void addToTransportWorkList()
- {
- getLink().getConnectionImpl().addTransportWork(this);
- }
-
-
- DeliveryImpl getTransportWorkNext()
- {
- return _transportWorkNext;
- }
-
-
- DeliveryImpl getTransportWorkPrev()
- {
- return _transportWorkPrev;
- }
-
- void setTransportWorkNext(DeliveryImpl transportWorkNext)
- {
- _transportWorkNext = transportWorkNext;
- }
-
- void setTransportWorkPrev(DeliveryImpl transportWorkPrev)
- {
- _transportWorkPrev = transportWorkPrev;
- }
-
- TransportDelivery getTransportDelivery()
- {
- return _transportDelivery;
- }
-
- void setTransportDelivery(TransportDelivery transportDelivery)
- {
- _transportDelivery = transportDelivery;
- }
-
- @Override
- public boolean isSettled()
- {
- return _settled;
- }
-
- int send(byte[] bytes, int offset, int length)
- {
- if(_data == null)
- {
- _data = new byte[length];
- }
- else if(_data.length - _dataSize < length)
- {
- byte[] oldData = _data;
- _data = new byte[oldData.length + _dataSize];
- System.arraycopy(oldData, _offset, _data, 0, _dataSize);
- _offset = 0;
- }
- System.arraycopy(bytes, offset, _data, _dataSize + _offset, length);
- _dataSize += length;
- addToTransportWorkList();
- return length; //TODO - Implement.
- }
-
- int send(final ReadableBuffer buffer)
- {
- int length = buffer.remaining();
-
- if(_data == null)
- {
- _data = new byte[length];
- }
- else if(_data.length - _dataSize < length)
- {
- byte[] oldData = _data;
- _data = new byte[oldData.length + _dataSize];
- System.arraycopy(oldData, _offset, _data, 0, _dataSize);
- _offset = 0;
- }
- buffer.get(_data, _offset, length);
- _dataSize+=length;
- addToTransportWorkList();
- return length;
- }
-
- byte[] getData()
- {
- return _data;
- }
-
- int getDataOffset()
- {
- return _offset;
- }
-
- int getDataLength()
- {
- return _dataSize; //TODO - Implement.
- }
-
- void setData(byte[] data)
- {
- _data = data;
- }
-
- void setDataLength(int length)
- {
- _dataSize = length;
- }
-
- public void setDataOffset(int arrayOffset)
- {
- _offset = arrayOffset;
- }
-
- @Override
- public boolean isWritable()
- {
- return getLink() instanceof SenderImpl
- && getLink().current() == this
- && ((SenderImpl) getLink()).hasCredit();
- }
-
- @Override
- public boolean isReadable()
- {
- return getLink() instanceof ReceiverImpl
- && getLink().current() == this;
- }
-
- void setComplete()
- {
- _complete = true;
- }
-
- @Override
- public boolean isPartial()
- {
- return !_complete;
- }
-
- void setRemoteDeliveryState(DeliveryState remoteDeliveryState)
- {
- _remoteDeliveryState = remoteDeliveryState;
- _updated = true;
- }
-
- @Override
- public boolean isUpdated()
- {
- return _updated;
- }
-
- @Override
- public void clear()
- {
- _updated = false;
- getLink().getConnectionImpl().workUpdate(this);
- }
-
-
- void setDone()
- {
- _done = true;
- }
-
- boolean isDone()
- {
- return _done;
- }
-
- void setRemoteSettled(boolean remoteSettled)
- {
- _remoteSettled = remoteSettled;
- _updated = true;
- }
-
- @Override
- public boolean isBuffered()
- {
- if (_remoteSettled) return false;
- if (getLink() instanceof SenderImpl) {
- if (isDone()) {
- return false;
- } else {
- return _complete || _dataSize > 0;
- }
- } else {
- return false;
- }
- }
-
- @Override
- public Object getContext()
- {
- return _context;
- }
-
- @Override
- public void setContext(Object context)
- {
- _context = context;
- }
-
- @Override
- public Record attachments()
- {
- if(_attachments == null)
- {
- _attachments = new RecordImpl();
- }
-
- return _attachments;
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("DeliveryImpl [_tag=").append(Arrays.toString(_tag))
- .append(", _link=").append(_link)
- .append(", _deliveryState=").append(_deliveryState)
- .append(", _settled=").append(_settled)
- .append(", _remoteSettled=").append(_remoteSettled)
- .append(", _remoteDeliveryState=").append(_remoteDeliveryState)
- .append(", _flags=").append(_flags)
- .append(", _defaultDeliveryState=").append(_defaultDeliveryState)
- .append(", _transportDelivery=").append(_transportDelivery)
- .append(", _dataSize=").append(_dataSize)
- .append(", _complete=").append(_complete)
- .append(", _updated=").append(_updated)
- .append(", _done=").append(_done)
- .append(", _offset=").append(_offset).append("]");
- return builder.toString();
- }
-
- @Override
- public int pending()
- {
- return _dataSize;
- }
-
- @Override
- public void setDefaultDeliveryState(DeliveryState state)
- {
- _defaultDeliveryState = state;
- }
-
- @Override
- public DeliveryState getDefaultDeliveryState()
- {
- return _defaultDeliveryState;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java
deleted file mode 100644
index bbcc9d9..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.ProtonJEndpoint;
-import org.apache.qpid.proton.engine.Record;
-
-public abstract class EndpointImpl implements ProtonJEndpoint
-{
- private EndpointState _localState = EndpointState.UNINITIALIZED;
- private EndpointState _remoteState = EndpointState.UNINITIALIZED;
- private ErrorCondition _localError = new ErrorCondition();
- private ErrorCondition _remoteError = new ErrorCondition();
- private boolean _modified;
- private EndpointImpl _transportNext;
- private EndpointImpl _transportPrev;
- private Object _context;
- private Record _attachments = new RecordImpl();
-
- private int refcount = 1;
- boolean freed = false;
-
- void incref() {
- refcount++;
- }
-
- void decref() {
- refcount--;
- if (refcount == 0) {
- postFinal();
- } else if (refcount < 0) {
- throw new IllegalStateException();
- }
- }
-
- abstract void postFinal();
-
- abstract void localOpen();
-
- abstract void localClose();
-
- @Override
- public void open()
- {
- if (getLocalState() != EndpointState.ACTIVE)
- {
- _localState = EndpointState.ACTIVE;
- localOpen();
- modified();
- }
- }
-
- @Override
- public void close()
- {
- if (getLocalState() != EndpointState.CLOSED)
- {
- _localState = EndpointState.CLOSED;
- localClose();
- modified();
- }
- }
-
- @Override
- public EndpointState getLocalState()
- {
- return _localState;
- }
-
- @Override
- public EndpointState getRemoteState()
- {
- return _remoteState;
- }
-
- @Override
- public ErrorCondition getCondition()
- {
- return _localError;
- }
-
- @Override
- public void setCondition(ErrorCondition condition)
- {
- if(condition != null)
- {
- _localError.copyFrom(condition);
- }
- else
- {
- _localError.clear();
- }
- }
-
- @Override
- public ErrorCondition getRemoteCondition()
- {
- return _remoteError;
- }
-
- void setLocalState(EndpointState localState)
- {
- _localState = localState;
- }
-
- void setRemoteState(EndpointState remoteState)
- {
- // TODO - check state change legal
- _remoteState = remoteState;
- }
-
- void modified()
- {
- modified(true);
- }
-
- void modified(boolean emit)
- {
- if(!_modified)
- {
- _modified = true;
- getConnectionImpl().addModified(this);
- }
-
- if (emit) {
- ConnectionImpl conn = getConnectionImpl();
- TransportImpl trans = conn.getTransport();
- if (trans != null) {
- conn.put(Event.Type.TRANSPORT, trans);
- }
- }
- }
-
- protected abstract ConnectionImpl getConnectionImpl();
-
- void clearModified()
- {
- if(_modified)
- {
- _modified = false;
- getConnectionImpl().removeModified(this);
- }
- }
-
- boolean isModified()
- {
- return _modified;
- }
-
- EndpointImpl transportNext()
- {
- return _transportNext;
- }
-
- EndpointImpl transportPrev()
- {
- return _transportPrev;
- }
-
- abstract void doFree();
-
- @Override
- final public void free()
- {
- if (freed) return;
- freed = true;
-
- doFree();
- decref();
- }
-
- void setTransportNext(EndpointImpl transportNext)
- {
- _transportNext = transportNext;
- }
-
- void setTransportPrev(EndpointImpl transportPrevious)
- {
- _transportPrev = transportPrevious;
- }
-
- @Override
- public Object getContext()
- {
- return _context;
- }
-
- @Override
- public void setContext(Object context)
- {
- _context = context;
- }
-
- @Override
- public Record attachments()
- {
- return _attachments;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImplQuery.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImplQuery.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImplQuery.java
deleted file mode 100644
index 33519b1..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImplQuery.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.apache.qpid.proton.engine.impl;
-/*
- *
- * 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.
- *
-*/
-
-
-import java.util.EnumSet;
-import org.apache.qpid.proton.engine.EndpointState;
-
-class EndpointImplQuery<T extends EndpointImpl> implements LinkNode.Query<T>
-{
- private final EnumSet<EndpointState> _local;
- private final EnumSet<EndpointState> _remote;
-
- EndpointImplQuery(EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
- {
- _local = local;
- _remote = remote;
- }
-
- public boolean matches(LinkNode<T> node)
- {
- return (_local == null || _local.contains(node.getValue().getLocalState()))
- && (_remote == null || _remote.contains(node.getValue().getRemoteState()));
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java
deleted file mode 100644
index 3bcecb5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.util.Iterator;
-
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.EventType;
-import org.apache.qpid.proton.engine.Handler;
-import org.apache.qpid.proton.engine.HandlerException;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Receiver;
-import org.apache.qpid.proton.engine.Record;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Selectable;
-import org.apache.qpid.proton.reactor.Task;
-import org.apache.qpid.proton.reactor.impl.ReactorImpl;
-
-/**
- * EventImpl
- *
- */
-
-class EventImpl implements Event
-{
-
- EventType type;
- Object context;
- EventImpl next;
- RecordImpl attachments = new RecordImpl();
-
- EventImpl()
- {
- this.type = null;
- }
-
- void init(EventType type, Object context)
- {
- this.type = type;
- this.context = context;
- this.attachments.clear();
- }
-
- void clear()
- {
- type = null;
- context = null;
- attachments.clear();
- }
-
- @Override
- public EventType getEventType()
- {
- return type;
- }
-
- @Override
- public Type getType() {
- if (type instanceof Type) {
- return (Type)type;
- }
- return Type.NON_CORE_EVENT;
- }
-
- @Override
- public Object getContext()
- {
- return context;
- }
-
- @Override
- public Handler getRootHandler() {
- return ReactorImpl.ROOT.get(this);
- }
-
- private Handler delegated = null;
-
- @Override
- public void dispatch(Handler handler) throws HandlerException
- {
- Handler old_delegated = delegated;
- try {
- delegated = handler;
- try {
- handler.handle(this);
- } catch(HandlerException handlerException) {
- throw handlerException;
- } catch(RuntimeException runtimeException) {
- throw new HandlerException(handler, runtimeException);
- }
- delegate();
- } finally {
- delegated = old_delegated;
- }
- }
-
- @Override
- public void delegate() throws HandlerException
- {
- if (delegated == null) {
- return; // short circuit
- }
- Iterator<Handler> children = delegated.children();
- delegated = null;
- while(children.hasNext()) {
- dispatch(children.next());
- }
- }
-
- @Override
- public void redispatch(EventType as_type, Handler handler) throws HandlerException
- {
- if (!as_type.isValid()) {
- throw new IllegalArgumentException("Can only redispatch valid event types");
- }
- EventType old = type;
- try {
- type = as_type;
- dispatch(handler);
- }
- finally {
- type = old;
- }
- }
-
- @Override
- public Connection getConnection()
- {
- if (context instanceof Connection) {
- return (Connection) context;
- } else if (context instanceof Transport) {
- Transport transport = getTransport();
- if (transport == null) {
- return null;
- }
- return ((TransportImpl) transport).getConnectionImpl();
- } else {
- Session ssn = getSession();
- if (ssn == null) {
- return null;
- }
- return ssn.getConnection();
- }
- }
-
- @Override
- public Session getSession()
- {
- if (context instanceof Session) {
- return (Session) context;
- } else {
- Link link = getLink();
- if (link == null) {
- return null;
- }
- return link.getSession();
- }
- }
-
- @Override
- public Link getLink()
- {
- if (context instanceof Link) {
- return (Link) context;
- } else {
- Delivery dlv = getDelivery();
- if (dlv == null) {
- return null;
- }
- return dlv.getLink();
- }
- }
-
- @Override
- public Sender getSender()
- {
- if (context instanceof Sender) {
- return (Sender) context;
- } else {
- Link link = getLink();
- if (link instanceof Sender) {
- return (Sender) link;
- }
- return null;
- }
- }
-
- @Override
- public Receiver getReceiver()
- {
- if (context instanceof Receiver) {
- return (Receiver) context;
- } else {
- Link link = getLink();
- if (link instanceof Receiver) {
- return (Receiver) link;
- }
- return null;
- }
- }
-
- @Override
- public Delivery getDelivery()
- {
- if (context instanceof Delivery) {
- return (Delivery) context;
- } else {
- return null;
- }
- }
-
- @Override
- public Transport getTransport()
- {
- if (context instanceof Transport) {
- return (Transport) context;
- } else if (context instanceof Connection) {
- return ((Connection)context).getTransport();
- } else {
- Session session = getSession();
- if (session == null) {
- return null;
- }
-
- Connection connection = session.getConnection();
- if (connection == null) {
- return null;
- }
-
- return connection.getTransport();
- }
- }
-
- @Override
- public Selectable getSelectable() {
- if (context instanceof Selectable) {
- return (Selectable) context;
- } else {
- return null;
- }
- }
-
- @Override
- public Reactor getReactor() {
- if (context instanceof Reactor) {
- return (Reactor) context;
- } else if (context instanceof Task) {
- return ((Task)context).getReactor();
- } else if (context instanceof Transport) {
- return ((TransportImpl)context).getReactor();
- } else if (context instanceof Delivery) {
- return ((Delivery)context).getLink().getSession().getConnection().getReactor();
- } else if (context instanceof Link) {
- return ((Link)context).getSession().getConnection().getReactor();
- } else if (context instanceof Session) {
- return ((Session)context).getConnection().getReactor();
- } else if (context instanceof Connection) {
- return ((Connection)context).getReactor();
- } else if (context instanceof Selectable) {
- return ((Selectable)context).getReactor();
- }
- return null;
- }
-
- @Override
- public Task getTask() {
- if (context instanceof Task) {
- return (Task) context;
- } else {
- return null;
- }
- }
-
- @Override
- public Record attachments() {
- return attachments;
- }
-
- @Override
- public Event copy()
- {
- EventImpl newEvent = new EventImpl();
- newEvent.init(type, context);
- newEvent.attachments.copy(attachments);
- return newEvent;
- }
-
- @Override
- public String toString()
- {
- return "EventImpl{" + "type=" + type + ", context=" + context + '}';
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java
deleted file mode 100644
index dfbb201..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.framing.TransportFrame;
-
-public interface FrameHandler
-{
- /**
- * @throws IllegalStateException if I am not currently accepting input
- * @see #isHandlingFrames()
- * @return false on end of stream
- */
- boolean handleFrame(TransportFrame frame);
-
- void closed(TransportException error);
-
- /**
- * Returns whether I am currently able to handle frames.
- * MUST be checked before calling {@link #handleFrame(TransportFrame)}.
- */
- boolean isHandlingFrames();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java
deleted file mode 100644
index 6aede84..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import static org.apache.qpid.proton.engine.impl.AmqpHeader.HEADER;
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.newWriteableBuffer;
-
-import java.nio.ByteBuffer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.transport.EmptyFrame;
-import org.apache.qpid.proton.amqp.transport.FrameBody;
-import org.apache.qpid.proton.codec.ByteBufferDecoder;
-import org.apache.qpid.proton.codec.DecodeException;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.framing.TransportFrame;
-
-class FrameParser implements TransportInput
-{
- private static final Logger TRACE_LOGGER = Logger.getLogger("proton.trace");
-
- private static final ByteBuffer _emptyInputBuffer = newWriteableBuffer(0);
-
- private enum State
- {
- HEADER0,
- HEADER1,
- HEADER2,
- HEADER3,
- HEADER4,
- HEADER5,
- HEADER6,
- HEADER7,
- SIZE_0,
- SIZE_1,
- SIZE_2,
- SIZE_3,
- PRE_PARSE,
- BUFFERING,
- PARSING,
- ERROR
- }
-
- private final FrameHandler _frameHandler;
- private final ByteBufferDecoder _decoder;
- private final int _inputBufferSize;
- private final int _localMaxFrameSize;
-
- private ByteBuffer _inputBuffer = null;
- private boolean _tail_closed = false;
-
- private State _state = State.HEADER0;
-
- private long _framesInput = 0;
-
- /** the stated size of the current frame */
- private int _size;
-
- /** holds the current frame that is being parsed */
- private ByteBuffer _frameBuffer;
-
- private TransportFrame _heldFrame;
- private TransportException _parsingError;
-
-
- /**
- * We store the last result when processing input so that
- * we know not to process any more input if it was an error.
- */
- FrameParser(FrameHandler frameHandler, ByteBufferDecoder decoder, int localMaxFrameSize)
- {
- _frameHandler = frameHandler;
- _decoder = decoder;
- _localMaxFrameSize = localMaxFrameSize;
- _inputBufferSize = _localMaxFrameSize > 0 ? _localMaxFrameSize : 4*1024;
- }
-
- private void input(ByteBuffer in) throws TransportException
- {
- flushHeldFrame();
- if (_heldFrame != null)
- {
- return;
- }
-
- TransportException frameParsingError = null;
- int size = _size;
- State state = _state;
- ByteBuffer oldIn = null;
-
- boolean transportAccepting = true;
-
- while(in.hasRemaining() && state != State.ERROR && transportAccepting)
- {
- switch(state)
- {
- case HEADER0:
- if(in.hasRemaining())
- {
- byte c = in.get();
- if(c != HEADER[0])
- {
- frameParsingError = new TransportException("AMQP header mismatch value %x, expecting %x. In state: %s", c, HEADER[0], state);
- state = State.ERROR;
- break;
- }
- state = State.HEADER1;
- }
- else
- {
- break;
- }
- case HEADER1:
- if(in.hasRemaining())
- {
- byte c = in.get();
- if(c != HEADER[1])
- {
- frameParsingError = new TransportException("AMQP header mismatch value %x, expecting %x. In state: %s", c, HEADER[1], state);
- state = State.ERROR;
- break;
- }
- state = State.HEADER2;
- }
- else
- {
- break;
- }
- case HEADER2:
- if(in.hasRemaining())
- {
- byte c = in.get();
- if(c != HEADER[2])
- {
- frameParsingError = new TransportException("AMQP header mismatch value %x, expecting %x. In state: %s", c, HEADER[2], state);
- state = State.ERROR;
- break;
- }
- state = State.HEADER3;
- }
- else
- {
- break;
- }
- case HEADER3:
- if(in.hasRemaining())
- {
- byte c = in.get();
- if(c != HEADER[3])
- {
- frameParsingError = new TransportException("AMQP header mismatch value %x, expecting %x. In state: %s", c, HEADER[3], state);
- state = State.ERROR;
- break;
- }
- state = State.HEADER4;
- }
- else
- {
- break;
- }
- case HEADER4:
- if(in.hasRemaining())
- {
- byte c = in.get();
- if(c != HEADER[4])
- {
- frameParsingError = new TransportException("AMQP header mismatch value %x, expecting %x. In state: %s", c, HEADER[4], state);
- state = State.ERROR;
- break;
- }
- state = State.HEADER5;
- }
- else
- {
- break;
- }
- case HEADER5:
- if(in.hasRemaining())
- {
- byte c = in.get();
- if(c != HEADER[5])
- {
- frameParsingError = new TransportException("AMQP header mismatch value %x, expecting %x. In state: %s", c, HEADER[5], state);
- state = State.ERROR;
- break;
- }
- state = State.HEADER6;
- }
- else
- {
- break;
- }
- case HEADER6:
- if(in.hasRemaining())
- {
- byte c = in.get();
- if(c != HEADER[6])
- {
- frameParsingError = new TransportException("AMQP header mismatch value %x, expecting %x. In state: %s", c, HEADER[6], state);
- state = State.ERROR;
- break;
- }
- state = State.HEADER7;
- }
- else
- {
- break;
- }
- case HEADER7:
- if(in.hasRemaining())
- {
- byte c = in.get();
- if(c != HEADER[7])
- {
- frameParsingError = new TransportException("AMQP header mismatch value %x, expecting %x. In state: %s", c, HEADER[7], state);
- state = State.ERROR;
- break;
- }
- state = State.SIZE_0;
- }
- else
- {
- break;
- }
- case SIZE_0:
- if(!in.hasRemaining())
- {
- break;
- }
- if(in.remaining() >= 4)
- {
- size = in.getInt();
- state = State.PRE_PARSE;
- break;
- }
- else
- {
- size = (in.get() << 24) & 0xFF000000;
- if(!in.hasRemaining())
- {
- state = State.SIZE_1;
- break;
- }
- }
- case SIZE_1:
- size |= (in.get() << 16) & 0xFF0000;
- if(!in.hasRemaining())
- {
- state = State.SIZE_2;
- break;
- }
- case SIZE_2:
- size |= (in.get() << 8) & 0xFF00;
- if(!in.hasRemaining())
- {
- state = State.SIZE_3;
- break;
- }
- case SIZE_3:
- size |= in.get() & 0xFF;
- state = State.PRE_PARSE;
-
- case PRE_PARSE:
- if(size < 8)
- {
- frameParsingError = new TransportException("specified frame size %d smaller than minimum frame header "
- + "size %d",
- size, 8);
- state = State.ERROR;
- break;
- }
-
- if (_localMaxFrameSize > 0 && size > _localMaxFrameSize)
- {
- frameParsingError = new TransportException("specified frame size %d greater than maximum valid frame size %d",
- size, _localMaxFrameSize);
- state = State.ERROR;
- break;
- }
-
- if(in.remaining() < size-4)
- {
- _frameBuffer = ByteBuffer.allocate(size-4);
- _frameBuffer.put(in);
- state = State.BUFFERING;
- break;
- }
- case BUFFERING:
- if(_frameBuffer != null)
- {
- if(in.remaining() < _frameBuffer.remaining())
- {
- _frameBuffer.put(in);
- break;
- }
- else
- {
- ByteBuffer dup = in.duplicate();
- dup.limit(dup.position()+_frameBuffer.remaining());
- in.position(in.position()+_frameBuffer.remaining());
- _frameBuffer.put(dup);
- oldIn = in;
- _frameBuffer.flip();
- in = _frameBuffer;
- state = State.PARSING;
- }
- }
-
- case PARSING:
-
- int dataOffset = (in.get() << 2) & 0x3FF;
-
- if(dataOffset < 8)
- {
- frameParsingError = new TransportException("specified frame data offset %d smaller than minimum frame header size %d", dataOffset, 8);
- state = State.ERROR;
- break;
- }
- else if(dataOffset > size)
- {
- frameParsingError = new TransportException("specified frame data offset %d larger than the frame size %d", dataOffset, _size);
- state = State.ERROR;
- break;
- }
-
- // type
-
- int type = in.get() & 0xFF;
- int channel = in.getShort() & 0xFFFF;
-
- if(type != 0)
- {
- frameParsingError = new TransportException("unknown frame type: %d", type);
- state = State.ERROR;
- break;
- }
-
- // note that this skips over the extended header if it's present
- if(dataOffset!=8)
- {
- in.position(in.position()+dataOffset-8);
- }
-
- // oldIn null iff not working on duplicated buffer
- final int frameBodySize = size - dataOffset;
- if(oldIn == null)
- {
- oldIn = in;
- in = in.duplicate();
- final int endPos = in.position() + frameBodySize;
- in.limit(endPos);
- oldIn.position(endPos);
-
- }
-
- try
- {
- _framesInput += 1;
-
- Binary payload = null;
- Object val = null;
-
- if (frameBodySize > 0)
- {
- _decoder.setByteBuffer(in);
- val = _decoder.readObject();
- _decoder.setByteBuffer(null);
-
- if(in.hasRemaining())
- {
- byte[] payloadBytes = new byte[in.remaining()];
- in.get(payloadBytes);
- payload = new Binary(payloadBytes);
- }
- else
- {
- payload = null;
- }
- }
- else
- {
- val = new EmptyFrame();
- }
-
- if(val instanceof FrameBody)
- {
- FrameBody frameBody = (FrameBody) val;
- if(TRACE_LOGGER.isLoggable(Level.FINE))
- {
- TRACE_LOGGER.log(Level.FINE, "IN: CH["+channel+"] : " + frameBody + (payload == null ? "" : "[" + payload + "]"));
- }
- TransportFrame frame = new TransportFrame(channel, frameBody, payload);
-
- if(_frameHandler.isHandlingFrames())
- {
- _tail_closed = _frameHandler.handleFrame(frame);
- }
- else
- {
- transportAccepting = false;
- _heldFrame = frame;
- }
- }
- else
- {
- throw new TransportException("Frameparser encountered a "
- + (val == null? "null" : val.getClass())
- + " which is not a " + FrameBody.class);
- }
-
- reset();
- in = oldIn;
- oldIn = null;
- _frameBuffer = null;
- state = State.SIZE_0;
- }
- catch (DecodeException ex)
- {
- state = State.ERROR;
- frameParsingError = new TransportException(ex);
- }
- break;
- case ERROR:
- // do nothing
- }
-
- }
-
- if (_tail_closed)
- {
- if (in.hasRemaining()) {
- state = State.ERROR;
- frameParsingError = new TransportException("framing error");
- } else if (state != State.SIZE_0) {
- state = State.ERROR;
- frameParsingError = new TransportException("connection aborted");
- } else {
- _frameHandler.closed(null);
- }
- }
-
- _state = state;
- _size = size;
-
- if(_state == State.ERROR)
- {
- _tail_closed = true;
- if(frameParsingError != null)
- {
- _parsingError = frameParsingError;
- _frameHandler.closed(frameParsingError);
- }
- else
- {
- throw new TransportException("Unable to parse, probably because of a previous error");
- }
- }
- }
-
- @Override
- public int capacity()
- {
- if (_tail_closed) {
- return Transport.END_OF_STREAM;
- } else {
- if (_inputBuffer != null) {
- return _inputBuffer.remaining();
- } else {
- return _inputBufferSize;
- }
- }
- }
-
- @Override
- public int position() {
- if (_tail_closed) {
- return Transport.END_OF_STREAM;
- }
- return (_inputBuffer == null) ? 0 : _inputBuffer.position();
- }
-
- @Override
- public ByteBuffer tail()
- {
- if (_tail_closed) {
- throw new TransportException("tail closed");
- }
-
- if (_inputBuffer == null) {
- _inputBuffer = newWriteableBuffer(_inputBufferSize);
- }
-
- return _inputBuffer;
- }
-
- @Override
- public void process() throws TransportException
- {
- if (_inputBuffer != null)
- {
- _inputBuffer.flip();
-
- try
- {
- input(_inputBuffer);
- }
- finally
- {
- if (_inputBuffer.hasRemaining()) {
- _inputBuffer.compact();
- } else if (_inputBuffer.capacity() > TransportImpl.BUFFER_RELEASE_THRESHOLD) {
- _inputBuffer = null;
- } else {
- _inputBuffer.clear();
- }
- }
- }
- else
- {
- input(_emptyInputBuffer);
- }
- }
-
- @Override
- public void close_tail()
- {
- _tail_closed = true;
- process();
- }
-
- /**
- * Attempt to flush any cached data to the frame transport. This function
- * is useful if the {@link FrameHandler} state has changed.
- */
- public void flush()
- {
- flushHeldFrame();
-
- if (_heldFrame == null)
- {
- process();
- }
- }
-
- private void flushHeldFrame()
- {
- if(_heldFrame != null && _frameHandler.isHandlingFrames())
- {
- _tail_closed = _frameHandler.handleFrame(_heldFrame);
- _heldFrame = null;
- }
- }
-
- private void reset()
- {
- _size = 0;
- _state = State.SIZE_0;
- }
-
- long getFramesInput()
- {
- return _framesInput;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[09/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/amqp/BinaryTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/BinaryTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/BinaryTest.java
deleted file mode 100644
index 4ab4766..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/amqp/BinaryTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-
-import org.junit.Test;
-
-public class BinaryTest
-{
-
- @Test
- public void testNotEqualsWithDifferentTypeObject()
- {
- Binary bin = createSteppedValueBinary(10);
-
- assertFalse("Objects should not be equal with different type", bin.equals("not-a-Binary"));
- }
-
- @Test
- public void testEqualsWithItself()
- {
- Binary bin = createSteppedValueBinary(10);
-
- assertTrue("Object should be equal to itself", bin.equals(bin));
- }
-
- @Test
- public void testEqualsWithDifferentBinaryOfSameLengthAndContent()
- {
- int length = 10;
- Binary bin1 = createSteppedValueBinary(length);
- Binary bin2 = createSteppedValueBinary(length);
-
- assertTrue("Objects should be equal", bin1.equals(bin2));
- assertTrue("Objects should be equal", bin2.equals(bin1));
- }
-
- @Test
- public void testEqualsWithDifferentLengthBinaryOfDifferentBytes()
- {
- int length1 = 10;
- Binary bin1 = createSteppedValueBinary(length1);
- Binary bin2 = createSteppedValueBinary(length1 + 1);
-
- assertFalse("Objects should not be equal", bin1.equals(bin2));
- assertFalse("Objects should not be equal", bin2.equals(bin1));
- }
-
- @Test
- public void testEqualsWithDifferentLengthBinaryOfSameByte()
- {
- Binary bin1 = createNewRepeatedValueBinary(10, (byte) 1);
- Binary bin2 = createNewRepeatedValueBinary(123, (byte) 1);
-
- assertFalse("Objects should not be equal", bin1.equals(bin2));
- assertFalse("Objects should not be equal", bin2.equals(bin1));
- }
-
- @Test
- public void testEqualsWithDifferentContentBinary()
- {
- int length = 10;
- Binary bin1 = createNewRepeatedValueBinary(length, (byte) 1);
-
- Binary bin2 = createNewRepeatedValueBinary(length, (byte) 1);
- bin2.getArray()[5] = (byte) 0;
-
- assertFalse("Objects should not be equal", bin1.equals(bin2));
- assertFalse("Objects should not be equal", bin2.equals(bin1));
- }
-
- private Binary createSteppedValueBinary(int length) {
- byte[] bytes = new byte[length];
- for (int i = 0; i < length; i++) {
- bytes[i] = (byte) (length - i);
- }
-
- return new Binary(bytes);
- }
-
- private Binary createNewRepeatedValueBinary(int length, byte repeatedByte){
- byte[] bytes = new byte[length];
- Arrays.fill(bytes, repeatedByte);
-
- return new Binary(bytes);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/amqp/UnsignedLongTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/UnsignedLongTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/UnsignedLongTest.java
deleted file mode 100644
index 8429017..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/amqp/UnsignedLongTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.math.BigInteger;
-
-import org.junit.Test;
-
-public class UnsignedLongTest
-{
- private static final byte[] TWO_TO_64_PLUS_ONE_BYTES = new byte[] { (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1 };
- private static final byte[] TWO_TO_64_MINUS_ONE_BYTES = new byte[] {(byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1 };
-
- @Test
- public void testValueOfStringWithNegativeNumberThrowsNFE() throws Exception
- {
- try
- {
- UnsignedLong.valueOf("-1");
- fail("Expected exception was not thrown");
- }
- catch(NumberFormatException nfe)
- {
- //expected
- }
- }
-
- @Test
- public void testValueOfBigIntegerWithNegativeNumberThrowsNFE() throws Exception
- {
- try
- {
- UnsignedLong.valueOf(BigInteger.valueOf(-1L));
- fail("Expected exception was not thrown");
- }
- catch(NumberFormatException nfe)
- {
- //expected
- }
- }
-
- @Test
- public void testValuesOfStringWithinRangeSucceed() throws Exception
- {
- //check 0 (min) to confirm success
- UnsignedLong min = UnsignedLong.valueOf("0");
- assertEquals("unexpected value", 0, min.longValue());
-
- //check 2^64 -1 (max) to confirm success
- BigInteger onLimit = new BigInteger(TWO_TO_64_MINUS_ONE_BYTES);
- String onlimitString = onLimit.toString();
- UnsignedLong max = UnsignedLong.valueOf(onlimitString);
- assertEquals("unexpected value", onLimit, max.bigIntegerValue());
- }
-
- @Test
- public void testValuesOfBigIntegerWithinRangeSucceed() throws Exception
- {
- //check 0 (min) to confirm success
- UnsignedLong min = UnsignedLong.valueOf(BigInteger.ZERO);
- assertEquals("unexpected value", 0, min.longValue());
-
- //check 2^64 -1 (max) to confirm success
- BigInteger onLimit = new BigInteger(TWO_TO_64_MINUS_ONE_BYTES);
- UnsignedLong max = UnsignedLong.valueOf(onLimit);
- assertEquals("unexpected value", onLimit, max.bigIntegerValue());
-
- //check Long.MAX_VALUE to confirm success
- UnsignedLong longMax = UnsignedLong.valueOf(BigInteger.valueOf(Long.MAX_VALUE));
- assertEquals("unexpected value", Long.MAX_VALUE, longMax.longValue());
- }
-
- @Test
- public void testValueOfStringAboveMaxValueThrowsNFE() throws Exception
- {
- //2^64 + 1 (value 2 over max)
- BigInteger aboveLimit = new BigInteger(TWO_TO_64_PLUS_ONE_BYTES);
- try
- {
- UnsignedLong.valueOf(aboveLimit.toString());
- fail("Expected exception was not thrown");
- }
- catch(NumberFormatException nfe)
- {
- //expected
- }
-
- //2^64 (value 1 over max)
- aboveLimit = aboveLimit.subtract(BigInteger.ONE);
- try
- {
- UnsignedLong.valueOf(aboveLimit.toString());
- fail("Expected exception was not thrown");
- }
- catch(NumberFormatException nfe)
- {
- //expected
- }
- }
-
- @Test
- public void testValueOfBigIntegerAboveMaxValueThrowsNFE() throws Exception
- {
- //2^64 + 1 (value 2 over max)
- BigInteger aboveLimit = new BigInteger(TWO_TO_64_PLUS_ONE_BYTES);
- try
- {
- UnsignedLong.valueOf(aboveLimit);
- fail("Expected exception was not thrown");
- }
- catch(NumberFormatException nfe)
- {
- //expected
- }
-
- //2^64 (value 1 over max)
- aboveLimit = aboveLimit.subtract(BigInteger.ONE);
- try
- {
- UnsignedLong.valueOf(aboveLimit);
- fail("Expected exception was not thrown");
- }
- catch(NumberFormatException nfe)
- {
- //expected
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ErrorConditionTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ErrorConditionTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ErrorConditionTest.java
deleted file mode 100644
index 8ebb8cb..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ErrorConditionTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.transport;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-import java.util.Collections;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.junit.Test;
-
-public class ErrorConditionTest
-{
- @Test
- public void testEqualityOfNewlyConstructed()
- {
- ErrorCondition new1 = new ErrorCondition();
- ErrorCondition new2 = new ErrorCondition();
- assertErrorConditionsEqual(new1, new2);
- }
-
- @Test
- public void testSameObject()
- {
- ErrorCondition error = new ErrorCondition();
- assertErrorConditionsEqual(error, error);
- }
-
- @Test
- public void testConditionEquality()
- {
- String symbolValue = "symbol";
-
- ErrorCondition same1 = new ErrorCondition();
- same1.setCondition(Symbol.getSymbol(new String(symbolValue)));
-
- ErrorCondition same2 = new ErrorCondition();
- same2.setCondition(Symbol.getSymbol(new String(symbolValue)));
-
- assertErrorConditionsEqual(same1, same2);
-
- ErrorCondition different = new ErrorCondition();
- different.setCondition(Symbol.getSymbol("other"));
-
- assertErrorConditionsNotEqual(same1, different);
- }
-
- @Test
- public void testConditionAndDescriptionEquality()
- {
- String symbolValue = "symbol";
- String descriptionValue = "description";
-
- ErrorCondition same1 = new ErrorCondition();
- same1.setCondition(Symbol.getSymbol(new String(symbolValue)));
- same1.setDescription(new String(descriptionValue));
-
- ErrorCondition same2 = new ErrorCondition();
- same2.setCondition(Symbol.getSymbol(new String(symbolValue)));
- same2.setDescription(new String(descriptionValue));
-
- assertErrorConditionsEqual(same1, same2);
-
- ErrorCondition different = new ErrorCondition();
- different.setCondition(Symbol.getSymbol(symbolValue));
- different.setDescription("other");
-
- assertErrorConditionsNotEqual(same1, different);
- }
-
- @Test
- public void testConditionDescriptionInfoEquality()
- {
- String symbolValue = "symbol";
- String descriptionValue = "description";
-
- ErrorCondition same1 = new ErrorCondition();
- same1.setCondition(Symbol.getSymbol(new String(symbolValue)));
- same1.setDescription(new String(descriptionValue));
- same1.setInfo(Collections.singletonMap(Symbol.getSymbol("key"), "value"));
-
- ErrorCondition same2 = new ErrorCondition();
- same2.setCondition(Symbol.getSymbol(new String(symbolValue)));
- same2.setDescription(new String(descriptionValue));
- same2.setInfo(Collections.singletonMap(Symbol.getSymbol("key"), "value"));
-
- assertErrorConditionsEqual(same1, same2);
-
- ErrorCondition different = new ErrorCondition();
- different.setCondition(Symbol.getSymbol(symbolValue));
- different.setDescription(new String(descriptionValue));
- different.setInfo(Collections.singletonMap(Symbol.getSymbol("other"), "value"));
-
- assertErrorConditionsNotEqual(same1, different);
- }
-
- private void assertErrorConditionsNotEqual(ErrorCondition error1, ErrorCondition error2)
- {
- assertThat(error1, is(not(error2)));
- assertThat(error2, is(not(error1)));
- }
-
- private void assertErrorConditionsEqual(ErrorCondition error1, ErrorCondition error2)
- {
- assertEquals(error1, error2);
- assertEquals(error2, error1);
- assertEquals(error1.hashCode(), error2.hashCode());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleModeTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleModeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleModeTest.java
deleted file mode 100644
index eb8472b..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleModeTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-public class ReceiverSettleModeTest {
-
- @Test
- public void testEquality() {
-
- ReceiverSettleMode first = ReceiverSettleMode.FIRST;
- ReceiverSettleMode second = ReceiverSettleMode.SECOND;
-
- assertEquals(first, ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)0)));
- assertEquals(second, ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)1)));
-
- assertEquals(first.getValue(), UnsignedByte.valueOf((byte)0));
- assertEquals(second.getValue(), UnsignedByte.valueOf((byte)1));
- }
-
- @Test
- public void testNotEquality() {
-
- ReceiverSettleMode first = ReceiverSettleMode.FIRST;
- ReceiverSettleMode second = ReceiverSettleMode.SECOND;
-
- assertNotEquals(first, ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)1)));
- assertNotEquals(second, ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)0)));
-
- assertNotEquals(first.getValue(), UnsignedByte.valueOf((byte)1));
- assertNotEquals(second.getValue(), UnsignedByte.valueOf((byte)0));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testIllegalArgument() {
-
- ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)2));
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/SenderSettleModeTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/SenderSettleModeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/SenderSettleModeTest.java
deleted file mode 100644
index 1ef5da1..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/SenderSettleModeTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-public class SenderSettleModeTest {
-
- @Test
- public void testEquality() {
-
- SenderSettleMode unsettled = SenderSettleMode.UNSETTLED;
- SenderSettleMode settled = SenderSettleMode.SETTLED;
- SenderSettleMode mixed = SenderSettleMode.MIXED;
-
- assertEquals(unsettled, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)0)));
- assertEquals(settled, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)1)));
- assertEquals(mixed, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)2)));
-
- assertEquals(unsettled.getValue(), UnsignedByte.valueOf((byte)0));
- assertEquals(settled.getValue(), UnsignedByte.valueOf((byte)1));
- assertEquals(mixed.getValue(), UnsignedByte.valueOf((byte)2));
- }
-
- @Test
- public void testNotEquality() {
-
- SenderSettleMode unsettled = SenderSettleMode.UNSETTLED;
- SenderSettleMode settled = SenderSettleMode.SETTLED;
- SenderSettleMode mixed = SenderSettleMode.MIXED;
-
- assertNotEquals(unsettled, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)2)));
- assertNotEquals(settled, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)0)));
- assertNotEquals(mixed, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)1)));
-
- assertNotEquals(unsettled.getValue(), UnsignedByte.valueOf((byte)2));
- assertNotEquals(settled.getValue(), UnsignedByte.valueOf((byte)0));
- assertNotEquals(mixed.getValue(), UnsignedByte.valueOf((byte)1));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testIllegalArgument() {
-
- SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)3));
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java
deleted file mode 100644
index 90cfe26..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import static org.junit.Assert.assertEquals;
-
-import java.lang.Character.UnicodeBlock;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.junit.Test;
-
-/**
- * Test the encoding and decoding of {@link StringType} values.
- */
-public class StringTypeTest
-{
- private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8");
-
- private static final List<String> TEST_DATA = generateTestData();
-
- /**
- * Loop over all the chars in given {@link UnicodeBlock}s and return a
- * {@link Set <String>} containing all the possible values as their
- * {@link String} values.
- *
- * @param blocks the {@link UnicodeBlock}s to loop over
- * @return a {@link Set <String>} containing all the possible values as
- * {@link String} values
- */
- private static Set<String> getAllStringsFromUnicodeBlocks(final UnicodeBlock... blocks)
- {
- final Set<UnicodeBlock> blockSet = new HashSet<UnicodeBlock>(Arrays.asList(blocks));
- final Set<String> strings = new HashSet<String>();
- for (int codePoint = 0; codePoint <= Character.MAX_CODE_POINT; codePoint++)
- {
- if (blockSet.contains(UnicodeBlock.of(codePoint)))
- {
- final int charCount = Character.charCount(codePoint);
- final StringBuilder sb = new StringBuilder(
- charCount);
- if (charCount == 1)
- {
- sb.append(String.valueOf((char) codePoint));
- }
- else if (charCount == 2)
- {
- //TODO: use Character.highSurrogate(codePoint) and Character.lowSurrogate(codePoint) when Java 7 is baseline
- char highSurrogate = (char) ((codePoint >>> 10) + ('\uD800' - (0x010000 >>> 10)));
- char lowSurrogate = (char) ((codePoint & 0x3ff) + '\uDC00');
-
- sb.append(highSurrogate);
- sb.append(lowSurrogate);
- }
- else
- {
- throw new IllegalArgumentException("Character.charCount of "
- + charCount + " not supported.");
- }
- strings.add(sb.toString());
- }
- }
- return strings;
- }
-
-
- /**
- * Test the encoding and decoding of various complicated Unicode characters
- * which will end up as "surrogate pairs" when encoded to UTF-8
- */
- @Test
- public void calculateUTF8Length()
- {
- for (final String input : TEST_DATA)
- {
- assertEquals("Incorrect string length calculated for string '"+input+"'",input.getBytes(CHARSET_UTF8).length, StringType.calculateUTF8Length(input));
- }
- }
-
- /**
- * Test the encoding and decoding of various Unicode characters
- */
- @Test
- public void encodeDecodeStrings()
- {
- final DecoderImpl decoder = new DecoderImpl();
- final EncoderImpl encoder = new EncoderImpl(decoder);
- AMQPDefinedTypes.registerAllTypes(decoder, encoder);
- final ByteBuffer bb = ByteBuffer.allocate(16);
-
- for (final String input : TEST_DATA)
- {
- bb.clear();
- final AmqpValue inputValue = new AmqpValue(input);
- encoder.setByteBuffer(bb);
- encoder.writeObject(inputValue);
- bb.clear();
- decoder.setByteBuffer(bb);
- final AmqpValue outputValue = (AmqpValue) decoder.readObject();
- assertEquals("Failed to round trip String correctly: ", input, outputValue.getValue());
- }
- }
-
- // build up some test data with a set of suitable Unicode characters
- private static List<String> generateTestData()
- {
- return new LinkedList<String>()
- {
- private static final long serialVersionUID = 7331717267070233454L;
- {
- // non-surrogate pair blocks
- addAll(getAllStringsFromUnicodeBlocks(UnicodeBlock.BASIC_LATIN,
- UnicodeBlock.LATIN_1_SUPPLEMENT,
- UnicodeBlock.GREEK,
- UnicodeBlock.LETTERLIKE_SYMBOLS));
- // blocks with surrogate pairs
- //TODO: restore others when Java 7 is baseline
- addAll(getAllStringsFromUnicodeBlocks(UnicodeBlock.LINEAR_B_SYLLABARY,
- /*UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS,*/
- UnicodeBlock.MUSICAL_SYMBOLS,
- /*UnicodeBlock.EMOTICONS,*/
- /*UnicodeBlock.PLAYING_CARDS,*/
- UnicodeBlock.BOX_DRAWING,
- UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS,
- UnicodeBlock.PRIVATE_USE_AREA,
- UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A,
- UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B));
- // some additional combinations of characters that could cause problems to the encoder
- String[] boxDrawing = getAllStringsFromUnicodeBlocks(UnicodeBlock.BOX_DRAWING).toArray(new String[0]);
- String[] halfFullWidthForms = getAllStringsFromUnicodeBlocks(UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS).toArray(new String[0]);
- for (int i = 0; i < halfFullWidthForms.length; i++)
- {
- add(halfFullWidthForms[i] + boxDrawing[i % boxDrawing.length]);
- }
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/codec/UnsignedIntegerTypeTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/codec/UnsignedIntegerTypeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/codec/UnsignedIntegerTypeTest.java
deleted file mode 100644
index 45523e2..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/codec/UnsignedIntegerTypeTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import static org.junit.Assert.*;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.codec.UnsignedIntegerType.UnsignedIntegerEncoding;
-import org.junit.Test;
-
-public class UnsignedIntegerTypeTest
-{
- @Test
- public void testGetEncodingWithZero()
- {
- DecoderImpl decoder = new DecoderImpl();
- EncoderImpl encoder = new EncoderImpl(decoder);
- UnsignedIntegerType ult = new UnsignedIntegerType(encoder, decoder);
-
- //values of 0 are encoded as a specific type
- UnsignedIntegerEncoding encoding = ult.getEncoding(UnsignedInteger.valueOf(0L));
- assertEquals("incorrect encoding returned", EncodingCodes.UINT0, encoding.getEncodingCode());
- }
-
- @Test
- public void testGetEncodingWithSmallPositiveValue()
- {
- DecoderImpl decoder = new DecoderImpl();
- EncoderImpl encoder = new EncoderImpl(decoder);
- UnsignedIntegerType ult = new UnsignedIntegerType(encoder, decoder);
-
- //values between 0 and 255 are encoded as a specific 'small' type using a single byte
- UnsignedIntegerEncoding encoding = ult.getEncoding(UnsignedInteger.valueOf(1L));
- assertEquals("incorrect encoding returned", EncodingCodes.SMALLUINT, encoding.getEncodingCode());
- }
-
- @Test
- public void testGetEncodingWithTwoToThirtyOne()
- {
- DecoderImpl decoder = new DecoderImpl();
- EncoderImpl encoder = new EncoderImpl(decoder);
- UnsignedIntegerType ult = new UnsignedIntegerType(encoder, decoder);
-
- long val = Integer.MAX_VALUE + 1L;
- UnsignedIntegerEncoding encoding = ult.getEncoding(UnsignedInteger.valueOf(val));
- assertEquals("incorrect encoding returned", EncodingCodes.UINT, encoding.getEncodingCode());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/codec/UnsignedLongTypeTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/codec/UnsignedLongTypeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/codec/UnsignedLongTypeTest.java
deleted file mode 100644
index bcc6ff8..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/codec/UnsignedLongTypeTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import static org.junit.Assert.*;
-
-import java.math.BigInteger;
-
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.codec.UnsignedLongType.UnsignedLongEncoding;
-import org.junit.Test;
-
-public class UnsignedLongTypeTest
-{
- @Test
- public void testGetEncodingWithZero()
- {
- DecoderImpl decoder = new DecoderImpl();
- EncoderImpl encoder = new EncoderImpl(decoder);
- UnsignedLongType ult = new UnsignedLongType(encoder, decoder);
-
- //values of 0 are encoded as a specific type
- UnsignedLongEncoding encoding = ult.getEncoding(UnsignedLong.valueOf(0L));
- assertEquals("incorrect encoding returned", EncodingCodes.ULONG0, encoding.getEncodingCode());
- }
-
- @Test
- public void testGetEncodingWithSmallPositiveValue()
- {
- DecoderImpl decoder = new DecoderImpl();
- EncoderImpl encoder = new EncoderImpl(decoder);
- UnsignedLongType ult = new UnsignedLongType(encoder, decoder);
-
- //values between 0 and 255 are encoded as a specific 'small' type using a single byte
- UnsignedLongEncoding encoding = ult.getEncoding(UnsignedLong.valueOf(1L));
- assertEquals("incorrect encoding returned", EncodingCodes.SMALLULONG, encoding.getEncodingCode());
- }
-
- @Test
- public void testGetEncodingWithTwoToSixtyThree()
- {
- DecoderImpl decoder = new DecoderImpl();
- EncoderImpl encoder = new EncoderImpl(decoder);
- UnsignedLongType ult = new UnsignedLongType(encoder, decoder);
-
- BigInteger bigInt = BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE);
- UnsignedLongEncoding encoding = ult.getEncoding(UnsignedLong.valueOf(bigInt));
- assertEquals("incorrect encoding returned", EncodingCodes.ULONG, encoding.getEncodingCode());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
deleted file mode 100644
index 6bb3f2c..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/codec/impl/DataImplTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec.impl;
-
-import static org.junit.Assert.*;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.codec.Data;
-import org.junit.Test;
-
-public class DataImplTest
-{
- @Test
- public void testEncodeDecodeSymbolArrayUsingPutArray()
- {
- Symbol symbol1 = Symbol.valueOf("testRoundtripSymbolArray1");
- Symbol symbol2 = Symbol.valueOf("testRoundtripSymbolArray2");
-
- Data data1 = new DataImpl();
- data1.putArray(false, Data.DataType.SYMBOL);
- data1.enter();
- data1.putSymbol(symbol1);
- data1.putSymbol(symbol2);
- data1.exit();
-
- Binary encoded = data1.encode();
- encoded.asByteBuffer();
-
- Data data2 = new DataImpl();
- data2.decode(encoded.asByteBuffer());
-
- assertEquals("unexpected array length", 2, data2.getArray());
- assertEquals("unexpected array length", Data.DataType.SYMBOL, data2.getArrayType());
-
- Object[] array = data2.getJavaArray();
- assertNotNull("Array should not be null", array);
- assertEquals("Expected a Symbol array", Symbol[].class, array.getClass());
- assertEquals("unexpected array length", 2, array.length);
- assertEquals("unexpected value", symbol1, array[0]);
- assertEquals("unexpected value", symbol2, array[1]);
- }
-
- @Test
- public void testEncodeDecodeSymbolArrayUsingPutObject()
- {
- Symbol symbol1 = Symbol.valueOf("testRoundtripSymbolArray1");
- Symbol symbol2 = Symbol.valueOf("testRoundtripSymbolArray2");
- Symbol[] input = new Symbol[]{symbol1, symbol2};
-
- Data data1 = new DataImpl();
- data1.putObject(input);
-
- Binary encoded = data1.encode();
- encoded.asByteBuffer();
-
- Data data2 = new DataImpl();
- data2.decode(encoded.asByteBuffer());
-
- assertEquals("unexpected array length", 2, data2.getArray());
- assertEquals("unexpected array length", Data.DataType.SYMBOL, data2.getArrayType());
-
- Object[] array = data2.getJavaArray();
- assertArrayEquals("Array not as expected", input, array);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/EventDelegationTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/EventDelegationTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/EventDelegationTest.java
deleted file mode 100644
index a36f9cb..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/EventDelegationTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.apache.qpid.proton.engine;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import org.apache.qpid.proton.reactor.Reactor;
-import org.junit.Test;
-
-public class EventDelegationTest {
-
- private ArrayList<String> trace = new ArrayList<String>();
-
- class ExecutionFlowTracer extends BaseHandler {
- protected String name;
-
- ExecutionFlowTracer(String name) {
- this.name = name;
- }
-
- @Override
- public void onReactorInit(Event e) {
- trace.add(name);
- }
- }
-
- class DelegatingFlowTracer extends ExecutionFlowTracer {
- public DelegatingFlowTracer(String name) {
- super(name);
- }
-
- @Override
- public void onReactorInit(Event e) {
- trace.add("(" + name);
- e.delegate();
- trace.add(name + ")");
- }
- }
-
- Handler assemble(Handler outer, Handler...inner) {
- for(Handler h : inner) {
- outer.add(h);
- }
- return outer;
- }
-
- @Test
- public void testImplicitDelegate() throws IOException {
- Handler h =
- assemble(
- new ExecutionFlowTracer("A"),
- assemble(
- new ExecutionFlowTracer("A.A"),
- new ExecutionFlowTracer("A.A.A"),
- new ExecutionFlowTracer("A.A.B")
- ),
- assemble(
- new ExecutionFlowTracer("A.B")
- )
- );
- Reactor r = Reactor.Factory.create();
- r.getHandler().add(h);
- r.run();
- assertArrayEquals(new String[]{"A", "A.A", "A.A.A", "A.A.B", "A.B"}, trace.toArray());
- }
-
- @Test
- public void testExplicitDelegate() throws IOException {
- Handler h =
- assemble(
- new ExecutionFlowTracer("A"),
- assemble(
- new DelegatingFlowTracer("A.A"),
- new ExecutionFlowTracer("A.A.A"),
- new ExecutionFlowTracer("A.A.B")
- ),
- assemble(
- new ExecutionFlowTracer("A.B")
- )
- );
- Reactor r = Reactor.Factory.create();
- r.getHandler().add(h);
- r.run();
- assertArrayEquals(new String[]{"A", "(A.A", "A.A.A", "A.A.B", "A.A)", "A.B"}, trace.toArray());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/EventExtensibilityTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/EventExtensibilityTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/EventExtensibilityTest.java
deleted file mode 100644
index 81c7470..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/EventExtensibilityTest.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.qpid.proton.engine.Event.Type;
-import org.apache.qpid.proton.engine.EventExtensibilityTest.ExtraEvent.ExtraTypes;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Selectable;
-import org.apache.qpid.proton.reactor.Task;
-import org.junit.Test;
-
-public class EventExtensibilityTest extends TestCase {
-
- // //////////////
- // / Extra package public API classes
- // //////////////
-
- /**
- * Sample additional information that gets generated and passed around with
- * the extension events. The information is stored inside
- * {@link Event#attachments()} see {@link ExtraEventImpl#getExtraInfo()}
- */
- public static class ExtraInfo {
- public int foo;
- }
-
- /**
- * Additional events generated by this extension.
- *
- */
- public interface ExtraEvent extends Event {
- /**
- * Enum is a convenient mechanism for defining new event types
- */
- public enum ExtraTypes implements EventType {
- FOO,
- BAR,
- NOT_A_EXTRA_EVENT {
- @Override public boolean isValid() { return false; }
- };
-
- @Override
- public boolean isValid() {
- return true;
- }
- }
-
- /**
- * typesafe access to event type generated by this extension useful for
- * handling in switch statements
- *
- * @return one of enum values. When invoked on an Event that is not an
- * ExtraEvent the return value shall be
- */
- ExtraTypes getExtraEventType();
-
- /**
- * typesafe access to extra information attached to additional events
- *
- * @return ExtraInfo stored in the event attachment
- */
- ExtraInfo getExtraInfo();
- }
-
- /**
- * New handler methods for handling the extended event types. These methods
- * can take {@link ExtraEvent} as a parameter to get typesafe access to
- * {@link ExtraInfo}
- *
- * The interface needs to extend the {@link Handler} interface.
- */
- public interface ExtraHandler extends Handler {
- void onFoo(ExtraEvent e);
-
- void onBar(ExtraEvent e);
- }
-
- /**
- * Implementation of the default base class for ExtraHandler. All events
- * should be forwarded to the {@link Handler#onUnhandled(Event)} method
- */
- public static class ExtraBaseHandler extends BaseHandler implements ExtraHandler {
-
- @Override
- public void onFoo(ExtraEvent e) {
- this.onUnhandled(e);
- }
-
- @Override
- public void onBar(ExtraEvent e) {
- this.onUnhandled(e);
- }
-
- @Override
- public void handle(Event e) {
- EventType type = e.getEventType();
- if (type instanceof ExtraEvent.ExtraTypes) {
- final ExtraEvent event;
- if (e instanceof ExtraEvent) {
- event = (ExtraEvent)e;
- } else {
- event = new ExtraEventImpl(e);
- }
- switch((ExtraEvent.ExtraTypes)type) {
- case BAR:
- onBar(event);
- break;
- case FOO:
- onFoo(event);
- break;
- case NOT_A_EXTRA_EVENT:
- super.handle(e);
- break;
- }
- } else {
- super.handle(e);
- }
- }
-
- }
-
- // //////////////
- // / Extra package implementation classes
- // //////////////
-
-
- /**
- * Typesafe access to ExtraInfo attached to event
- *
- */
- public static class ExtraEventImpl implements ExtraEvent {
- /**
- * making this accessor public allows for easy binding to the scripting language
- */
- public static final ExtendableAccessor<Event, ExtraInfo> extraInfoAccessor = new ExtendableAccessor<>(ExtraInfo.class);
-
- private Event impl;
-
- public ExtraEventImpl(Event impl) {
- this.impl = impl;
- }
-
- @Override
- public ExtraTypes getExtraEventType() {
- EventType type = impl.getEventType();
- if (type instanceof ExtraTypes)
- return (ExtraTypes) type;
- else
- return ExtraTypes.NOT_A_EXTRA_EVENT;
- }
-
- @Override
- public ExtraInfo getExtraInfo() {
- return extraInfoAccessor.get(impl);
- }
-
- // ---- delegate methods for the Event
-
- @Override
- public Record attachments() {
- return impl.attachments();
- }
-
- @Override
- public EventType getEventType() {
- return impl.getEventType();
- }
-
- @Override
- public Type getType() {
- return impl.getType();
- }
-
- @Override
- public Object getContext() {
- return impl.getContext();
- }
-
- @Override
- public Handler getRootHandler() {
- return impl.getRootHandler();
- }
-
- @Override
- public void dispatch(Handler handler) throws HandlerException {
- impl.dispatch(handler);
- }
-
- @Override
- public void redispatch(EventType as_type, Handler handler) throws HandlerException {
- impl.redispatch(as_type, handler);
- }
- @Override
- public Connection getConnection() {
- return impl.getConnection();
- }
-
- @Override
- public Session getSession() {
- return impl.getSession();
- }
-
- @Override
- public Link getLink() {
- return impl.getLink();
- }
-
- @Override
- public Sender getSender() {
- return impl.getSender();
- }
-
- @Override
- public Receiver getReceiver() {
- return impl.getReceiver();
- }
-
- @Override
- public Delivery getDelivery() {
- return impl.getDelivery();
- }
-
- @Override
- public Transport getTransport() {
- return impl.getTransport();
- }
-
- @Override
- public Reactor getReactor() {
- return impl.getReactor();
- }
-
- @Override
- public Selectable getSelectable() {
- return impl.getSelectable();
- }
-
- @Override
- public Task getTask() {
- return impl.getTask();
- }
-
- @Override
- public Event copy() {
- return new ExtraEventImpl(impl.copy());
- }
-
- @Override
- public void delegate() throws HandlerException {
- impl.delegate();
- }
- }
-
- public class ExtendedTestEventGenerator extends BaseHandler {
- @Override
- public void onReactorInit(Event e) {
- ExtraInfo extra = new ExtraInfo();
- extra.foo = 1234;
- ExtraEventImpl.extraInfoAccessor.set(e, extra);
- e.redispatch(ExtraEvent.ExtraTypes.FOO, this);
- }
- }
-
- public class ExtendedTestHandler extends ExtraBaseHandler {
- public boolean didFoo = false;
- @Override
- public void onFoo(ExtraEvent e) {
- assertEquals(ExtraEvent.ExtraTypes.FOO, e.getEventType());
- assertEquals(ExtraEvent.ExtraTypes.FOO, e.getExtraEventType());
- assertEquals(Event.Type.NON_CORE_EVENT, e.getType());
- assertNotNull(e.getExtraInfo());
- assertEquals(1234, e.getExtraInfo().foo);
- didFoo = true;
- }
- }
-
- public class FooUnawareTestHandler extends BaseHandler {
- public boolean seenFoo = false;
- @Override
- public void onUnhandled(Event e) {
- if (e.getEventType() == ExtraTypes.FOO) {
- seenFoo = true;
- }
- }
- }
-
- @Test
- public void testExtendedType() throws IOException {
- Reactor r = Reactor.Factory.create();
- ExtendedTestEventGenerator gen = new ExtendedTestEventGenerator();
- BaseHandler empty = new BaseHandler();
- ExtendedTestHandler extra = new ExtendedTestHandler();
- FooUnawareTestHandler unaware = new FooUnawareTestHandler();
- gen.add(empty);
- empty.add(extra);
- extra.add(unaware);
- r.setGlobalHandler(gen);
- r.run();
- assertTrue(extra.didFoo);
- assertTrue(unaware.seenFoo);
- }
-
- @Test
- public void test() {
- Event.Type t = Type.NON_CORE_EVENT;
- switch (extracted(t)) {
- case CONNECTION_BOUND:
- fail();
- case CONNECTION_FINAL:
- fail();
- case CONNECTION_INIT:
- fail();
- case CONNECTION_LOCAL_CLOSE:
- fail();
- case CONNECTION_LOCAL_OPEN:
- fail();
- case CONNECTION_REMOTE_CLOSE:
- fail();
- case CONNECTION_REMOTE_OPEN:
- fail();
- case CONNECTION_UNBOUND:
- fail();
- case DELIVERY:
- fail();
- case LINK_FINAL:
- fail();
- case LINK_FLOW:
- fail();
- case LINK_INIT:
- fail();
- case LINK_LOCAL_CLOSE:
- fail();
- case LINK_LOCAL_DETACH:
- fail();
- case LINK_LOCAL_OPEN:
- fail();
- case LINK_REMOTE_CLOSE:
- fail();
- case LINK_REMOTE_DETACH:
- fail();
- case LINK_REMOTE_OPEN:
- fail();
- case REACTOR_FINAL:
- fail();
- case REACTOR_INIT:
- fail();
- case REACTOR_QUIESCED:
- fail();
- case SELECTABLE_ERROR:
- fail();
- case SELECTABLE_EXPIRED:
- fail();
- case SELECTABLE_FINAL:
- fail();
- case SELECTABLE_INIT:
- fail();
- case SELECTABLE_READABLE:
- fail();
- case SELECTABLE_UPDATED:
- fail();
- case SELECTABLE_WRITABLE:
- fail();
- case SESSION_FINAL:
- fail();
- case SESSION_INIT:
- fail();
- case SESSION_LOCAL_CLOSE:
- fail();
- case SESSION_LOCAL_OPEN:
- fail();
- case SESSION_REMOTE_CLOSE:
- fail();
- case SESSION_REMOTE_OPEN:
- fail();
- case TIMER_TASK:
- fail();
- case TRANSPORT:
- fail();
- case TRANSPORT_CLOSED:
- fail();
- case TRANSPORT_ERROR:
- fail();
- case TRANSPORT_HEAD_CLOSED:
- fail();
- case TRANSPORT_TAIL_CLOSED:
- fail();
- case NON_CORE_EVENT:
- break;
- }
- }
-
- private Type extracted(Event.Type t) {
- return t;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/AmqpFramer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/AmqpFramer.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/AmqpFramer.java
deleted file mode 100644
index 8195ccb..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/AmqpFramer.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.security.SaslFrameBody;
-import org.apache.qpid.proton.amqp.transport.FrameBody;
-import org.apache.qpid.proton.codec.AMQPDefinedTypes;
-import org.apache.qpid.proton.codec.DecoderImpl;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.codec.WritableBuffer;
-
-/**
- * Generates frames as per section 2.3.1 of the AMQP spec
- */
-public class AmqpFramer
-{
- // My test data is generated by the decoder and encoder from proton-j
- // although at run-time the Engine internally uses its own implementation.
-
- private DecoderImpl _decoder = new DecoderImpl();
- private EncoderImpl _encoder = new EncoderImpl(_decoder);
-
- public AmqpFramer()
- {
- AMQPDefinedTypes.registerAllTypes(_decoder, _encoder);
- }
-
- public byte[] createEmptyFrame(int channel)
- {
- byte[] emptyFrame = generateFrame(channel, null);
- return emptyFrame;
- }
-
- public byte[] generateFrame(int channel, FrameBody frameBody)
- {
- byte[] emptyExtendedHeader = new byte[] {};
- return generateFrame(channel, emptyExtendedHeader, frameBody);
- }
-
- public byte[] generateFrame(int channel, byte[] extendedHeader, FrameBody frameBody)
- {
- return generateFrame(channel, extendedHeader, frameBody, (byte)0);
- }
-
- public byte[] generateSaslFrame(int channel, byte[] extendedHeader, SaslFrameBody frameBody)
- {
- return generateFrame(channel, extendedHeader, frameBody, (byte)1);
- }
-
- /**
- * @param amqpFrameType indicates either AMQP or SASL
- * @param frameBody is currently expected to be a {@link FrameBody} or a {@link SaslFrameBody}
- */
- public byte[] generateFrame(int channel, byte[] extendedHeader, Object frameBody, byte amqpFrameType)
- {
- assertEquals("Extended header must be multiple of 4 bytes", 0, extendedHeader.length % 4);
- int numberOfExtendedHeaderFourByteWords = extendedHeader.length / 4;
-
- ByteBuffer buffer = ByteBuffer.allocate(1024);
-
- buffer.position(8); // leave hole for frame header
- _encoder.setByteBuffer(new WritableBuffer.ByteBufferWrapper(buffer));
-
- // write extended header - maybe empty
- buffer.put(extendedHeader);
- // write frame body
- if (frameBody != null)
- {
- _encoder.writeObject(frameBody);
- }
-
- int frameSize = buffer.position();
- int framePreambleSizeInFourByteWords = 2;
- byte dataOffsetFourByteWords = (byte)(framePreambleSizeInFourByteWords + numberOfExtendedHeaderFourByteWords);
- buffer.rewind();
- buffer.putInt(frameSize);
- buffer.put(dataOffsetFourByteWords);
- buffer.put(amqpFrameType);
- buffer.putShort((short)channel);
-
- byte[] target = new byte[frameSize];
-
- buffer.rewind();
- buffer.get(target, 0, frameSize);
- return target;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java
deleted file mode 100644
index a063265..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-
-import org.apache.qpid.proton.engine.Record;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-public class DeliveryImplTest
-{
- @Test
- public void testDefaultMessageFormat() throws Exception
- {
- DeliveryImpl delivery = new DeliveryImpl(null, Mockito.mock(LinkImpl.class), null);
- assertEquals("Unexpected value", 0L, DeliveryImpl.DEFAULT_MESSAGE_FORMAT);
- assertEquals("Unexpected message format", DeliveryImpl.DEFAULT_MESSAGE_FORMAT, delivery.getMessageFormat());
- }
-
- @Test
- public void testSetGetMessageFormat() throws Exception
- {
- DeliveryImpl delivery = new DeliveryImpl(null, Mockito.mock(LinkImpl.class), null);
-
- // lowest value and default
- int newFormat = 0;
- delivery.setMessageFormat(newFormat);
- assertEquals("Unexpected message format", newFormat, delivery.getMessageFormat());
-
- newFormat = 123456;
- delivery.setMessageFormat(newFormat);
- assertEquals("Unexpected message format", newFormat, delivery.getMessageFormat());
-
- // Highest value
- newFormat = (1 << 32) - 1;
- delivery.setMessageFormat(newFormat);
- assertEquals("Unexpected message format", newFormat, delivery.getMessageFormat());
- }
-
- @Test
- public void testAttachmentsNonNull() throws Exception
- {
- DeliveryImpl delivery = new DeliveryImpl(null, Mockito.mock(LinkImpl.class), null);
-
- assertNotNull("Expected attachments to be non-null", delivery.attachments());
- }
-
- @Test
- public void testAttachmentsReturnsSameRecordOnSuccessiveCalls() throws Exception
- {
- DeliveryImpl delivery = new DeliveryImpl(null, Mockito.mock(LinkImpl.class), null);
-
- Record attachments = delivery.attachments();
- Record attachments2 = delivery.attachments();
- assertSame("Expected to get the same attachments", attachments, attachments2);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/EndpointImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/EndpointImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/EndpointImplTest.java
deleted file mode 100644
index b83f214..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/EndpointImplTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-
-public class EndpointImplTest
-{
- @Test
- public void testRepeatOpenDoesNotModifyEndpoint()
- {
- ConnectionImpl mockConnection = Mockito.mock(ConnectionImpl.class);
- MockEndpointImpl endpoint = new MockEndpointImpl(mockConnection);
-
- // Check starting state
- assertFalse("Should not be modified", endpoint.isModified());
- assertEquals("Unexpected localOpen call count", 0, endpoint.getLocalOpenCallCount());
- Mockito.verify(mockConnection, Mockito.times(0)).addModified(Mockito.any(EndpointImpl.class));
-
- endpoint.open();
-
- // Check endpoint was modified
- assertTrue("Should be modified", endpoint.isModified());
- assertEquals("Unexpected localOpen call count", 1, endpoint.getLocalOpenCallCount());
- Mockito.verify(mockConnection, Mockito.times(1)).addModified(Mockito.any(EndpointImpl.class));
-
- // Clear the modified state, open again, verify no change
- endpoint.clearModified();
- assertFalse("Should no longer be modified", endpoint.isModified());
-
- endpoint.open();
-
- assertFalse("Should not be modified", endpoint.isModified());
- assertEquals("Unexpected localOpen call count", 1, endpoint.getLocalOpenCallCount());
- Mockito.verify(mockConnection, Mockito.times(1)).addModified(Mockito.any(EndpointImpl.class));
- }
-
- @Test
- public void testRepeatCloseDoesNotModifyEndpoint()
- {
- ConnectionImpl mockConnection = Mockito.mock(ConnectionImpl.class);
- MockEndpointImpl endpoint = new MockEndpointImpl(mockConnection);
-
- // Open endpoint, clear the modified state, verify current state
- endpoint.open();
- endpoint.clearModified();
- assertFalse("Should no longer be modified", endpoint.isModified());
- assertEquals("Unexpected localClose call count", 0, endpoint.getLocalCloseCallCount());
- Mockito.verify(mockConnection, Mockito.times(1)).addModified(Mockito.any(EndpointImpl.class));
-
- // Now close, verify changes
- endpoint.close();
-
- // Check endpoint was modified
- assertTrue("Should be modified", endpoint.isModified());
- assertEquals("Unexpected localClose call count", 1, endpoint.getLocalCloseCallCount());
- Mockito.verify(mockConnection, Mockito.times(2)).addModified(Mockito.any(EndpointImpl.class));
-
- // Clear the modified state, close again, verify no change
- endpoint.clearModified();
- assertFalse("Should no longer be modified", endpoint.isModified());
-
- endpoint.close();
-
- assertFalse("Should not be modified", endpoint.isModified());
- assertEquals("Unexpected localClose call count", 1, endpoint.getLocalCloseCallCount());
- Mockito.verify(mockConnection, Mockito.times(2)).addModified(Mockito.any(EndpointImpl.class));
- }
-
- private class MockEndpointImpl extends EndpointImpl
- {
- private int localOpenCallCount;
- private int localCloseCallCount;
- private ConnectionImpl connectionImpl;
- public MockEndpointImpl(ConnectionImpl connectionImpl)
- {
- this.connectionImpl = connectionImpl;
- }
-
- @Override
- void localOpen()
- {
- localOpenCallCount++;
- }
-
- @Override
- void localClose()
- {
- localCloseCallCount++;
- }
-
- @Override
- protected ConnectionImpl getConnectionImpl()
- {
- return connectionImpl;
- }
-
- @Override
- void doFree() { }
-
- @Override
- void postFinal() { }
-
- public int getLocalOpenCallCount()
- {
- return localOpenCallCount;
- }
-
- public int getLocalCloseCallCount()
- {
- return localCloseCallCount;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/EventImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/EventImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/EventImplTest.java
deleted file mode 100644
index e46f45c..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/EventImplTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.EventType;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.engine.Transport;
-import org.junit.Test;
-
-public class EventImplTest
-{
- @Test
- public void testGetTransportWithConnectionContext()
- {
- Transport transport = Transport.Factory.create();
- Connection connection = Connection.Factory.create();
- transport.bind(connection);
-
- EventImpl event = createEvent(connection, Event.Type.CONNECTION_BOUND);
-
- assertNotNull("No transport returned", event.getTransport());
- assertSame("Incorrect transport returned", transport, event.getTransport());
- }
-
- @Test
- public void testGetTransportWithTransportContext()
- {
- Transport transport = Transport.Factory.create();
- Connection connection = Connection.Factory.create();
- transport.bind(connection);
-
- EventImpl event = createEvent(transport, Event.Type.TRANSPORT);
-
- assertNotNull("No transport returned", event.getTransport());
- assertSame("Incorrect transport returned", transport, event.getTransport());
- }
-
- @Test
- public void testGetTransportWithSessionContext()
- {
- Transport transport = Transport.Factory.create();
- Connection connection = Connection.Factory.create();
- transport.bind(connection);
-
- Session session = connection.session();
-
- EventImpl event = createEvent(session, Event.Type.SESSION_INIT);
-
- assertNotNull("No transport returned", event.getTransport());
- assertSame("Incorrect transport returned", transport, event.getTransport());
- }
-
- @Test
- public void testGetTransportWithLinkContext()
- {
- Transport transport = Transport.Factory.create();
- Connection connection = Connection.Factory.create();
- transport.bind(connection);
-
- Session session = connection.session();
- Link link = session.receiver("myReceiver");
-
- EventImpl event = createEvent(link, Event.Type.LINK_INIT);
-
- assertNotNull("No transport returned", event.getTransport());
- assertSame("Incorrect transport returned", transport, event.getTransport());
- }
-
- @Test
- public void testGetTransportWithDeliveryContext()
- {
- Transport transport = Transport.Factory.create();
- Connection connection = Connection.Factory.create();
- transport.bind(connection);
-
- Session session = connection.session();
- Sender sender = session.sender("mySender");
-
- Delivery delivery = sender.delivery("tag".getBytes());
-
- EventImpl event = createEvent(delivery, Event.Type.DELIVERY);
-
- assertNotNull("No transport returned", event.getTransport());
- assertSame("Incorrect transport returned", transport, event.getTransport());
- }
-
- EventImpl createEvent(Object context, EventType type)
- {
- EventImpl event = new EventImpl();
- event.init(type, context);
- return event;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/FrameParserTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/FrameParserTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/FrameParserTest.java
deleted file mode 100644
index be66b3b..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/FrameParserTest.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.apache.qpid.proton.engine.Transport.DEFAULT_MAX_FRAME_SIZE;
-import static org.apache.qpid.proton.engine.impl.AmqpHeader.HEADER;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.transport.Close;
-import org.apache.qpid.proton.amqp.transport.FrameBody;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.codec.AMQPDefinedTypes;
-import org.apache.qpid.proton.codec.DecoderImpl;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.framing.TransportFrame;
-import org.hamcrest.Description;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentMatcher;
-import org.mockito.InOrder;
-
-// TODO test a frame with a payload (potentially followed by another frame)
-public class FrameParserTest
-{
- private FrameHandler _mockFrameHandler = mock(FrameHandler.class);
- private DecoderImpl _decoder = new DecoderImpl();
- private EncoderImpl _encoder = new EncoderImpl(_decoder);
- private final FrameParser _frameParser = new FrameParser(_mockFrameHandler, _decoder, DEFAULT_MAX_FRAME_SIZE);
-
- private final AmqpFramer _amqpFramer = new AmqpFramer();
-
- @Before
- public void setUp()
- {
- AMQPDefinedTypes.registerAllTypes(_decoder, _encoder);
-
- when(_mockFrameHandler.isHandlingFrames()).thenReturn(true);
- }
-
- @Test
- public void testInputOfInvalidProtocolHeader_causesErrorAndRefusesFurtherInput()
- {
- ByteBuffer buffer = _frameParser.tail();
- buffer.put("hello".getBytes());
- _frameParser.process();
- assertEquals(_frameParser.capacity(), Transport.END_OF_STREAM);
- }
-
- @Test
- public void testInputOfValidProtocolHeader()
- {
- ByteBuffer buffer = _frameParser.tail();
- buffer.put(HEADER);
- _frameParser.process();
-
- assertNotNull(_frameParser.tail());
- }
-
- @Test
- public void testInputOfValidProtocolHeaderInMultipleChunks()
- {
- {
- ByteBuffer buffer = _frameParser.tail();
- buffer.put(HEADER, 0, 2);
- _frameParser.process();
- }
-
- {
- ByteBuffer buffer = _frameParser.tail();
- buffer.put(HEADER, 2, HEADER.length - 2);
- _frameParser.process();
- }
-
- assertNotNull(_frameParser.tail());
- }
-
- @Test
- public void testInputOfValidFrame_invokesFrameTransportCallback()
- {
- sendHeader();
-
- // now send an open frame
- ByteBuffer buffer = _frameParser.tail();
-
- Open openFrame = generateOpenFrame();
- int channel = 0;
- byte[] frame = _amqpFramer.generateFrame(channel, openFrame);
- buffer.put(frame);
-
- _frameParser.process();
- verify(_mockFrameHandler).handleFrame(frameMatching(channel, openFrame));
- }
-
- @Test
- public void testInputOfFrameInMultipleChunks_invokesFrameTransportCallback()
- {
- sendHeader();
-
- Open openFrame = generateOpenFrame();
- int channel = 0;
- byte[] frame = _amqpFramer.generateFrame(channel, openFrame);
- int lengthOfFirstChunk = 2;
- int lengthOfSecondChunk = (frame.length - lengthOfFirstChunk)/2;
- int lengthOfThirdChunk = frame.length - lengthOfFirstChunk - lengthOfSecondChunk;
-
- // send the first chunk
- {
- ByteBuffer buffer = _frameParser.tail();
-
- buffer.put(frame, 0, lengthOfFirstChunk);
-
- _frameParser.process();
-
- verify(_mockFrameHandler, never()).handleFrame(any(TransportFrame.class));
- }
-
- // send the second chunk
- {
- ByteBuffer buffer = _frameParser.tail();
-
- int secondChunkOffset = lengthOfFirstChunk;
- buffer.put(frame, secondChunkOffset, lengthOfSecondChunk);
-
- _frameParser.process();
- verify(_mockFrameHandler, never()).handleFrame(any(TransportFrame.class));
- }
-
- // send the third and final chunk
- {
- ByteBuffer buffer = _frameParser.tail();
-
- int thirdChunkOffset = lengthOfFirstChunk + lengthOfSecondChunk;
- buffer.put(frame, thirdChunkOffset, lengthOfThirdChunk);
-
- _frameParser.process();
- verify(_mockFrameHandler).handleFrame(frameMatching(channel, openFrame));
- }
- }
-
- @Test
- public void testInputOfTwoFrames_invokesFrameTransportTwice()
- {
- sendHeader();
-
- int channel = 0;
- Open openFrame = generateOpenFrame();
- byte[] openFrameBytes = _amqpFramer.generateFrame(channel, openFrame);
-
- Close closeFrame = generateCloseFrame();
- byte[] closeFrameBytes = _amqpFramer.generateFrame(channel, closeFrame);
-
- _frameParser.tail()
- .put(openFrameBytes)
- .put(closeFrameBytes);
-
- _frameParser.process();
-
- InOrder inOrder = inOrder(_mockFrameHandler);
- inOrder.verify(_mockFrameHandler).handleFrame(frameMatching(channel, openFrame));
- inOrder.verify(_mockFrameHandler).handleFrame(frameMatching(channel, closeFrame));
- }
-
- @Test
- public void testFrameTransportTemporarilyRefusesOpenFrame()
- {
- when(_mockFrameHandler.isHandlingFrames()).thenReturn(false);
-
- sendHeader();
-
- // now send an open frame
- int channel = 0;
- Open openFrame = generateOpenFrame();
- {
- ByteBuffer buffer = _frameParser.tail();
-
- byte[] frame = _amqpFramer.generateFrame(channel, openFrame);
- buffer.put(frame);
-
- _frameParser.process();
- }
-
- verify(_mockFrameHandler, never()).handleFrame(any(TransportFrame.class));
-
- when(_mockFrameHandler.isHandlingFrames()).thenReturn(true);
-
- // now ensure that the held frame gets sent on second input
- Close closeFrame = generateCloseFrame();
- {
- ByteBuffer buffer = _frameParser.tail();
-
- byte[] frame = _amqpFramer.generateFrame(channel, closeFrame);
- buffer.put(frame);
-
- _frameParser.process();
- }
-
- InOrder inOrder = inOrder(_mockFrameHandler);
- inOrder.verify(_mockFrameHandler).handleFrame(frameMatching(channel, openFrame));
- inOrder.verify(_mockFrameHandler).handleFrame(frameMatching(channel, closeFrame));
- }
-
- @Test
- public void testFrameTransportTemporarilyRefusesOpenAndCloseFrame()
- {
- when(_mockFrameHandler.isHandlingFrames()).thenReturn(false);
-
- sendHeader();
-
- // now send an open frame
- int channel = 0;
- Open openFrame = generateOpenFrame();
- {
- ByteBuffer buffer = _frameParser.tail();
-
- byte[] frame = _amqpFramer.generateFrame(channel, openFrame);
- buffer.put(frame);
-
- _frameParser.process();
- }
- verify(_mockFrameHandler, never()).handleFrame(any(TransportFrame.class));
-
- // now send a close frame
- Close closeFrame = generateCloseFrame();
- {
- ByteBuffer buffer = _frameParser.tail();
-
- byte[] frame = _amqpFramer.generateFrame(channel, closeFrame);
- buffer.put(frame);
-
- _frameParser.process();
- }
- verify(_mockFrameHandler, never()).handleFrame(any(TransportFrame.class));
-
- when(_mockFrameHandler.isHandlingFrames()).thenReturn(true);
-
- _frameParser.flush();
-
- InOrder inOrder = inOrder(_mockFrameHandler);
- inOrder.verify(_mockFrameHandler).handleFrame(frameMatching(channel, openFrame));
- inOrder.verify(_mockFrameHandler).handleFrame(frameMatching(channel, closeFrame));
- }
-
- private void sendHeader() throws TransportException
- {
- ByteBuffer buffer = _frameParser.tail();
- buffer.put(HEADER);
- _frameParser.process();
- }
-
- private Open generateOpenFrame()
- {
- Open open = new Open();
- open.setContainerId("containerid");
- return open;
- }
-
- private Close generateCloseFrame()
- {
- Close close = new Close();
- return close;
- }
-
- private TransportFrame frameMatching(int channel, FrameBody frameBody)
- {
- return argThat(new TransportFrameMatcher(channel, frameBody));
- }
-
- private class TransportFrameMatcher extends ArgumentMatcher<TransportFrame>
- {
- private final TransportFrame _expectedTransportFrame;
-
- TransportFrameMatcher(int expectedChannel, FrameBody expectedFrameBody)
- {
- _expectedTransportFrame = new TransportFrame(expectedChannel, expectedFrameBody, null);
- }
-
- @Override
- public boolean matches(Object transportFrameObj)
- {
- if(transportFrameObj == null)
- {
- return false;
- }
-
- TransportFrame transportFrame = (TransportFrame)transportFrameObj;
- FrameBody actualFrame = transportFrame.getBody();
-
- int _expectedChannel = _expectedTransportFrame.getChannel();
- FrameBody expectedFrame = _expectedTransportFrame.getBody();
-
- return _expectedChannel == transportFrame.getChannel()
- && expectedFrame.getClass().equals(actualFrame.getClass());
- }
-
- @Override
- public void describeTo(Description description)
- {
- super.describeTo(description);
- description.appendText("Expected: " + _expectedTransportFrame);
- }
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[11/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java
deleted file mode 100644
index e7c9d9e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java
+++ /dev/null
@@ -1,1555 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.messenger.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.InterruptException;
-import org.apache.qpid.proton.TimeoutException;
-import org.apache.qpid.proton.driver.Connector;
-import org.apache.qpid.proton.driver.Driver;
-import org.apache.qpid.proton.driver.Listener;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-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.Sasl;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.engine.SslDomain;
-import org.apache.qpid.proton.engine.Ssl;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.message.Message;
-import org.apache.qpid.proton.messenger.Messenger;
-import org.apache.qpid.proton.messenger.MessengerException;
-import org.apache.qpid.proton.messenger.Status;
-import org.apache.qpid.proton.messenger.Tracker;
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.amqp.Binary;
-
-/**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public class MessengerImpl implements Messenger
-{
- private enum LinkCreditMode
- {
- // method for replenishing credit
- LINK_CREDIT_EXPLICIT, // recv(N)
- LINK_CREDIT_AUTO; // recv()
- }
-
- private static final EnumSet<EndpointState> UNINIT = EnumSet.of(EndpointState.UNINITIALIZED);
- private static final EnumSet<EndpointState> ACTIVE = EnumSet.of(EndpointState.ACTIVE);
- private static final EnumSet<EndpointState> CLOSED = EnumSet.of(EndpointState.CLOSED);
- private static final EnumSet<EndpointState> ANY = EnumSet.allOf(EndpointState.class);
-
- private final Logger _logger = Logger.getLogger("proton.messenger");
- private final String _name;
- private long _timeout = -1;
- private boolean _blocking = true;
- private long _nextTag = 1;
- private Driver _driver;
- private LinkCreditMode _credit_mode = LinkCreditMode.LINK_CREDIT_EXPLICIT;
- private final int _credit_batch = 1024; // credit_mode == LINK_CREDIT_AUTO
- private int _credit; // available
- private int _distributed; // outstanding credit
- private int _receivers; // total # receiver Links
- private int _draining; // # Links in drain state
- private List<Receiver> _credited = new ArrayList<Receiver>();
- private List<Receiver> _blocked = new ArrayList<Receiver>();
- private long _next_drain;
- private TrackerImpl _incomingTracker;
- private TrackerImpl _outgoingTracker;
- private Store _incomingStore = new Store();
- private Store _outgoingStore = new Store();
- private List<Connector> _awaitingDestruction = new ArrayList<Connector>();
- private int _sendThreshold;
-
- private Transform _routes = new Transform();
- private Transform _rewrites = new Transform();
-
- private String _certificate;
- private String _privateKey;
- private String _password;
- private String _trustedDb;
-
-
- /**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
- @Deprecated public MessengerImpl()
- {
- this(java.util.UUID.randomUUID().toString());
- }
-
- /**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
- @Deprecated public MessengerImpl(String name)
- {
- _name = name;
- }
-
- public void setTimeout(long timeInMillis)
- {
- _timeout = timeInMillis;
- }
-
- public long getTimeout()
- {
- return _timeout;
- }
-
- public boolean isBlocking()
- {
- return _blocking;
- }
-
- public void setBlocking(boolean b)
- {
- _blocking = b;
- }
-
- public void setCertificate(String certificate)
- {
- _certificate = certificate;
- }
-
- public String getCertificate()
- {
- return _certificate;
- }
-
- public void setPrivateKey(String privateKey)
- {
- _privateKey = privateKey;
- }
-
- public String getPrivateKey()
- {
- return _privateKey;
- }
-
- public void setPassword(String password)
- {
- _password = password;
- }
-
- public String getPassword()
- {
- return _password;
- }
-
- public void setTrustedCertificates(String trusted)
- {
- _trustedDb = trusted;
- }
-
- public String getTrustedCertificates()
- {
- return _trustedDb;
- }
-
- public void start() throws IOException
- {
- _driver = Proton.driver();
- }
-
- public void stop()
- {
- if (_driver != null) {
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine(this + " about to stop");
- }
- //close all connections
- for (Connector<?> c : _driver.connectors())
- {
- Connection connection = c.getConnection();
- connection.close();
- }
- //stop listeners
- for (Listener<?> l : _driver.listeners())
- {
- try
- {
- l.close();
- }
- catch (IOException e)
- {
- _logger.log(Level.WARNING, "Error while closing listener", e);
- }
- }
- waitUntil(_allClosed);
- }
- }
-
- public boolean stopped()
- {
- return _allClosed.test();
- }
-
- public boolean work(long timeout) throws TimeoutException
- {
- if (_driver == null) { return false; }
- _worked = false;
- return waitUntil(_workPred, timeout);
- }
-
- public void interrupt()
- {
- if (_driver != null) {
- _driver.wakeup();
- }
- }
-
- private String defaultRewrite(String address) {
- if (address != null && address.contains("@")) {
- Address addr = new Address(address);
- String scheme = addr.getScheme();
- String host = addr.getHost();
- String port = addr.getPort();
- String name = addr.getName();
-
- StringBuilder sb = new StringBuilder();
- if (scheme != null) {
- sb.append(scheme).append("://");
- }
- if (host != null) {
- sb.append(host);
- }
- if (port != null) {
- sb.append(":").append(port);
- }
- if (name != null) {
- sb.append("/").append(name);
- }
- return sb.toString();
- } else {
- return address;
- }
- }
-
-
- private String _original;
-
- private void rewriteMessage(Message m)
- {
- _original = m.getAddress();
- if (_rewrites.apply(_original)) {
- m.setAddress(_rewrites.result());
- } else {
- m.setAddress(defaultRewrite(_original));
- }
- }
-
- private void restoreMessage(Message m)
- {
- m.setAddress(_original);
- }
-
- private String routeAddress(String addr)
- {
- if (_routes.apply(addr)) {
- return _routes.result();
- } else {
- return addr;
- }
- }
-
- public void put(Message m) throws MessengerException
- {
- if (_driver == null) {
- throw new IllegalStateException("cannot put while messenger is stopped");
- }
-
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine(this + " about to put message: " + m);
- }
-
- StoreEntry entry = _outgoingStore.put( m.getAddress() );
- _outgoingTracker = new TrackerImpl(TrackerImpl.Type.OUTGOING,
- _outgoingStore.trackEntry(entry));
-
- String routedAddress = routeAddress(m.getAddress());
- Address address = new Address(routedAddress);
- if (address.getHost() == null)
- {
- throw new MessengerException("unable to send to address: " + routedAddress);
- }
-
- rewriteMessage(m);
-
- try {
- adjustReplyTo(m);
-
- int encoded;
- byte[] buffer = new byte[5*1024];
- while (true)
- {
- try
- {
- encoded = m.encode(buffer, 0, buffer.length);
- break;
- } catch (java.nio.BufferOverflowException e) {
- buffer = new byte[buffer.length*2];
- }
- }
- entry.setEncodedMsg( buffer, encoded );
- }
- finally
- {
- restoreMessage(m);
- }
-
- Sender sender = getLink(address, new SenderFinder(address.getName()));
- pumpOut(m.getAddress(), sender);
- }
-
- private void reclaimLink(Link link)
- {
- if (link instanceof Receiver)
- {
- int credit = link.getCredit();
- if (credit > 0)
- {
- _credit += credit;
- _distributed -= credit;
- }
- }
-
- Delivery delivery = link.head();
- while (delivery != null)
- {
- StoreEntry entry = (StoreEntry) delivery.getContext();
- if (entry != null)
- {
- entry.setDelivery(null);
- if (delivery.isBuffered()) {
- entry.setStatus(Status.ABORTED);
- }
- }
- delivery = delivery.next();
- }
- linkRemoved(link);
- }
-
- private int pumpOut( String address, Sender sender )
- {
- StoreEntry entry = _outgoingStore.get( address );
- if (entry == null) {
- sender.drained();
- return 0;
- }
-
- byte[] tag = String.valueOf(_nextTag++).getBytes();
- Delivery delivery = sender.delivery(tag);
- entry.setDelivery( delivery );
- _logger.log(Level.FINE, "Sending on delivery: " + delivery);
- int n = sender.send( entry.getEncodedMsg(), 0, entry.getEncodedLength());
- if (n < 0) {
- _outgoingStore.freeEntry( entry );
- _logger.log(Level.WARNING, "Send error: " + n);
- return n;
- } else {
- sender.advance();
- _outgoingStore.freeEntry( entry );
- return 0;
- }
- }
-
- public void send() throws TimeoutException
- {
- send(-1);
- }
-
- public void send(int n) throws TimeoutException
- {
- if (_driver == null) {
- throw new IllegalStateException("cannot send while messenger is stopped");
- }
-
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine(this + " about to send");
- }
-
- if (n == -1)
- _sendThreshold = 0;
- else
- {
- _sendThreshold = outgoing() - n;
- if (_sendThreshold < 0)
- _sendThreshold = 0;
- }
-
- waitUntil(_sentSettled);
- }
-
- public void recv(int n) throws TimeoutException
- {
- if (_driver == null) {
- throw new IllegalStateException("cannot recv while messenger is stopped");
- }
-
- if (_logger.isLoggable(Level.FINE) && n != -1)
- {
- _logger.fine(this + " about to wait for up to " + n + " messages to be received");
- }
-
- if (n == -1)
- {
- _credit_mode = LinkCreditMode.LINK_CREDIT_AUTO;
- }
- else
- {
- _credit_mode = LinkCreditMode.LINK_CREDIT_EXPLICIT;
- if (n > _distributed)
- _credit = n - _distributed;
- else // cancel unallocated
- _credit = 0;
- }
-
- distributeCredit();
-
- waitUntil(_messageAvailable);
- }
-
- public void recv() throws TimeoutException
- {
- recv(-1);
- }
-
- public int receiving()
- {
- return _credit + _distributed;
- }
-
- public Message get()
- {
- StoreEntry entry = _incomingStore.get( null );
- if (entry != null)
- {
- Message message = Proton.message();
- message.decode( entry.getEncodedMsg(), 0, entry.getEncodedLength() );
-
- _incomingTracker = new TrackerImpl(TrackerImpl.Type.INCOMING,
- _incomingStore.trackEntry(entry));
-
- _incomingStore.freeEntry( entry );
- return message;
- }
- return null;
- }
-
- private int pumpIn(String address, Receiver receiver)
- {
- Delivery delivery = receiver.current();
- if (delivery.isReadable() && !delivery.isPartial())
- {
- StoreEntry entry = _incomingStore.put( address );
- entry.setDelivery( delivery );
-
- _logger.log(Level.FINE, "Readable delivery found: " + delivery);
-
- int size = delivery.pending();
- byte[] buffer = new byte[size];
- int read = receiver.recv( buffer, 0, buffer.length );
- if (read != size) {
- throw new IllegalStateException();
- }
- entry.setEncodedMsg( buffer, size );
- receiver.advance();
-
- // account for the used credit, replenish if
- // low (< 20% maximum per-link batch) and
- // extra credit available
- assert(_distributed > 0);
- _distributed--;
- if (!receiver.getDrain() && _blocked.isEmpty() && _credit > 0)
- {
- final int max = perLinkCredit();
- final int lo_thresh = (int)(max * 0.2 + 0.5);
- if (receiver.getRemoteCredit() < lo_thresh)
- {
- final int more = Math.min(_credit, max - receiver.getRemoteCredit());
- _credit -= more;
- _distributed += more;
- receiver.flow(more);
- }
- }
- // check if blocked
- if (receiver.getRemoteCredit() == 0 && _credited.contains(receiver))
- {
- _credited.remove(receiver);
- if (receiver.getDrain())
- {
- receiver.setDrain(false);
- assert( _draining > 0 );
- _draining--;
- }
- _blocked.add(receiver);
- }
- }
- return 0;
- }
-
- public void subscribe(String source) throws MessengerException
- {
- if (_driver == null) {
- throw new IllegalStateException("messenger is stopped");
- }
-
- String routed = routeAddress(source);
- Address address = new Address(routed);
-
- String hostName = address.getHost();
- if (hostName == null) throw new MessengerException("Invalid address (hostname cannot be null): " + routed);
- int port = Integer.valueOf(address.getImpliedPort());
- if (address.isPassive())
- {
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine(this + " about to subscribe to source " + source + " using address " + hostName + ":" + port);
- }
- ListenerContext ctx = new ListenerContext(address);
- _driver.createListener(hostName, port, ctx);
- }
- else
- {
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine(this + " about to subscribe to source " + source);
- }
- getLink(address, new ReceiverFinder(address.getName()));
- }
- }
-
- public int outgoing()
- {
- return _outgoingStore.size() + queued(true);
- }
-
- public int incoming()
- {
- return _incomingStore.size() + queued(false);
- }
-
- public int getIncomingWindow()
- {
- return _incomingStore.getWindow();
- }
-
- public void setIncomingWindow(int window)
- {
- _incomingStore.setWindow(window);
- }
-
- public int getOutgoingWindow()
- {
- return _outgoingStore.getWindow();
- }
-
- public void setOutgoingWindow(int window)
- {
- _outgoingStore.setWindow(window);
- }
-
- public Tracker incomingTracker()
- {
- return _incomingTracker;
- }
- public Tracker outgoingTracker()
- {
- return _outgoingTracker;
- }
-
- private Store getTrackerStore(Tracker tracker)
- {
- return ((TrackerImpl)tracker).isOutgoing() ? _outgoingStore : _incomingStore;
- }
-
- @Override
- public void reject(Tracker tracker, int flags)
- {
- int id = ((TrackerImpl)tracker).getSequence();
- getTrackerStore(tracker).update(id, Status.REJECTED, flags, false, false);
- }
-
- @Override
- public void accept(Tracker tracker, int flags)
- {
- int id = ((TrackerImpl)tracker).getSequence();
- getTrackerStore(tracker).update(id, Status.ACCEPTED, flags, false, false);
- }
-
- @Override
- public void settle(Tracker tracker, int flags)
- {
- int id = ((TrackerImpl)tracker).getSequence();
- getTrackerStore(tracker).update(id, Status.UNKNOWN, flags, true, true);
- }
-
- public Status getStatus(Tracker tracker)
- {
- int id = ((TrackerImpl)tracker).getSequence();
- StoreEntry e = getTrackerStore(tracker).getEntry(id);
- if (e != null)
- {
- return e.getStatus();
- }
- return Status.UNKNOWN;
- }
-
- @Override
- public void route(String pattern, String address)
- {
- _routes.rule(pattern, address);
- }
-
- @Override
- public void rewrite(String pattern, String address)
- {
- _rewrites.rule(pattern, address);
- }
-
- private int queued(boolean outgoing)
- {
- int count = 0;
- if (_driver != null) {
- for (Connector<?> c : _driver.connectors())
- {
- Connection connection = c.getConnection();
- for (Link link : new Links(connection, ACTIVE, ANY))
- {
- if (outgoing)
- {
- if (link instanceof Sender) count += link.getQueued();
- }
- else
- {
- if (link instanceof Receiver) count += link.getQueued();
- }
- }
- }
- }
- return count;
- }
-
- private void bringDestruction()
- {
- for (Connector<?> c : _awaitingDestruction)
- {
- c.destroy();
- }
- _awaitingDestruction.clear();
- }
-
- private void processAllConnectors()
- {
- distributeCredit();
- for (Connector<?> c : _driver.connectors())
- {
- processEndpoints(c);
- try
- {
- if (c.process()) {
- _worked = true;
- }
- }
- catch (IOException e)
- {
- _logger.log(Level.SEVERE, "Error processing connection", e);
- }
- }
- bringDestruction();
- distributeCredit();
- }
-
- private void processActive()
- {
- //process active listeners
- for (Listener<?> l = _driver.listener(); l != null; l = _driver.listener())
- {
- _worked = true;
- Connector<?> c = l.accept();
- Connection connection = Proton.connection();
- connection.setContainer(_name);
- ListenerContext ctx = (ListenerContext) l.getContext();
- connection.setContext(new ConnectionContext(ctx.getAddress(), c));
- c.setConnection(connection);
- Transport transport = c.getTransport();
- //TODO: full SASL
- Sasl sasl = c.sasl();
- if (sasl != null)
- {
- sasl.server();
- sasl.setMechanisms(new String[]{"ANONYMOUS"});
- sasl.done(Sasl.SaslOutcome.PN_SASL_OK);
- }
- transport.ssl(ctx.getDomain());
- connection.open();
- }
- // process connectors, reclaiming credit on closed connectors
- for (Connector<?> c = _driver.connector(); c != null; c = _driver.connector())
- {
- _worked = true;
- if (c.isClosed())
- {
- _awaitingDestruction.add(c);
- reclaimCredit(c.getConnection());
- }
- else
- {
- _logger.log(Level.FINE, "Processing active connector " + c);
- try
- {
- c.process();
- processEndpoints(c);
- c.process();
- }
- catch (IOException e)
- {
- _logger.log(Level.SEVERE, "Error processing connection", e);
- }
- }
- }
- bringDestruction();
- distributeCredit();
- }
-
- private void processEndpoints(Connector c)
- {
- Connection connection = c.getConnection();
-
- if (connection.getLocalState() == EndpointState.UNINITIALIZED)
- {
- connection.open();
- }
-
- Delivery delivery = connection.getWorkHead();
- while (delivery != null)
- {
- Link link = delivery.getLink();
- if (delivery.isUpdated())
- {
- if (link instanceof Sender)
- {
- delivery.disposition(delivery.getRemoteState());
- }
- StoreEntry e = (StoreEntry) delivery.getContext();
- if (e != null) e.updated();
- }
-
- if (delivery.isReadable())
- {
- pumpIn( link.getSource().getAddress(), (Receiver)link );
- }
-
- Delivery next = delivery.getWorkNext();
- delivery.clear();
- delivery = next;
- }
-
- for (Session session : new Sessions(connection, UNINIT, ANY))
- {
- session.open();
- _logger.log(Level.FINE, "Opened session " + session);
- }
- for (Link link : new Links(connection, UNINIT, ANY))
- {
- //TODO: the following is not correct; should only copy those properties that we understand
- //TODO: is this any better:
- if (link.getRemoteSource() != null) {
- link.setSource(link.getRemoteSource().copy());
- }
- if (link.getRemoteTarget() != null) {
- link.setTarget(link.getRemoteTarget().copy());
- }
- linkAdded(link);
- link.open();
- _logger.log(Level.FINE, "Opened link " + link);
- }
-
- distributeCredit();
-
- for (Link link : new Links(connection, ACTIVE, ACTIVE))
- {
- if (link instanceof Sender)
- {
- pumpOut(link.getTarget().getAddress(), (Sender)link);
- }
- }
-
- for (Session session : new Sessions(connection, ACTIVE, CLOSED))
- {
- session.close();
- }
-
- for (Link link : new Links(connection, ANY, CLOSED))
- {
- if (link.getLocalState() == EndpointState.ACTIVE)
- {
- link.close();
- }
- else
- {
- reclaimLink(link);
- }
- }
-
- if (connection.getRemoteState() == EndpointState.CLOSED)
- {
- if (connection.getLocalState() == EndpointState.ACTIVE)
- {
- connection.close();
- }
- }
- }
-
- private boolean waitUntil(Predicate condition) throws TimeoutException
- {
- if (_blocking) {
- boolean done = waitUntil(condition, _timeout);
- if (!done) {
- _logger.log(Level.SEVERE, String.format
- ("Timeout when waiting for condition %s after %s ms",
- condition, _timeout));
- throw new TimeoutException();
- }
- return done;
- } else {
- return waitUntil(condition, 0);
- }
- }
-
- private boolean waitUntil(Predicate condition, long timeout)
- {
- if (_driver == null) {
- throw new IllegalStateException("cannot wait while messenger is stopped");
- }
-
- processAllConnectors();
-
- // wait until timeout expires or until test is true
- long now = System.currentTimeMillis();
- final long deadline = timeout < 0 ? Long.MAX_VALUE : now + timeout;
- boolean done = false;
-
- while (true)
- {
- done = condition.test();
- if (done) break;
-
- long remaining;
- if (timeout < 0)
- remaining = -1;
- else {
- remaining = deadline - now;
- if (remaining < 0) break;
- }
-
- // Update the credit scheduler. If the scheduler detects
- // credit imbalance on the links, wake up in time to
- // service credit drain
- distributeCredit();
- if (_next_drain != 0)
- {
- long wakeup = (_next_drain > now) ? _next_drain - now : 0;
- remaining = (remaining == -1) ? wakeup : Math.min(remaining, wakeup);
- }
-
- boolean woken;
- woken = _driver.doWait(remaining);
- processActive();
- if (woken) {
- throw new InterruptException();
- }
- now = System.currentTimeMillis();
- }
-
- return done;
- }
-
- private Connection lookup(Address address)
- {
- for (Connector<?> c : _driver.connectors())
- {
- Connection connection = c.getConnection();
- ConnectionContext ctx = (ConnectionContext) connection.getContext();
- if (ctx.matches(address))
- {
- return connection;
- }
- }
- return null;
- }
-
- private void reclaimCredit(Connection connection)
- {
- for (Link link : new Links(connection, ANY, ANY))
- {
- reclaimLink(link);
- }
- }
-
- private void distributeCredit()
- {
- if (_receivers == 0) return;
-
- if (_credit_mode == LinkCreditMode.LINK_CREDIT_AUTO)
- {
- // replenish, but limit the max total messages buffered
- final int max = _receivers * _credit_batch;
- final int used = _distributed + incoming();
- if (max > used)
- _credit = max - used;
- }
-
- // reclaim any credit left over after draining links has completed
- if (_draining > 0)
- {
- Iterator<Receiver> itr = _credited.iterator();
- while (itr.hasNext())
- {
- Receiver link = (Receiver) itr.next();
- if (link.getDrain())
- {
- if (!link.draining())
- {
- // drain completed for this link
- int drained = link.drained();
- assert(_distributed >= drained);
- _distributed -= drained;
- _credit += drained;
- link.setDrain(false);
- _draining--;
- itr.remove();
- _blocked.add(link);
- }
- }
- }
- }
-
- // distribute available credit to blocked links
- final int batch = perLinkCredit();
- while (_credit > 0 && !_blocked.isEmpty())
- {
- Receiver link = _blocked.get(0);
- _blocked.remove(0);
-
- final int more = Math.min(_credit, batch);
- _distributed += more;
- _credit -= more;
-
- link.flow(more);
- _credited.add(link);
-
- // flow changed, must process it
- ConnectionContext ctx = (ConnectionContext) link.getSession().getConnection().getContext();
- try
- {
- ctx.getConnector().process();
- } catch (IOException e) {
- _logger.log(Level.SEVERE, "Error processing connection", e);
- }
- }
-
- if (_blocked.isEmpty())
- {
- _next_drain = 0;
- }
- else
- {
- // not enough credit for all links - start draining granted credit
- if (_draining == 0)
- {
- // don't do it too often - pace ourselves (it's expensive)
- if (_next_drain == 0)
- {
- _next_drain = System.currentTimeMillis() + 250;
- }
- else if (_next_drain <= System.currentTimeMillis())
- {
- // initiate drain, free up at most enough to satisfy blocked
- _next_drain = 0;
- int needed = _blocked.size() * batch;
-
- for (Receiver link : _credited)
- {
- if (!link.getDrain()) {
- link.setDrain(true);
- needed -= link.getRemoteCredit();
- _draining++;
- // drain requested on link, must process it
- ConnectionContext ctx = (ConnectionContext) link.getSession().getConnection().getContext();
- try
- {
- ctx.getConnector().process();
- } catch (IOException e) {
- _logger.log(Level.SEVERE, "Error processing connection", e);
- }
- if (needed <= 0) break;
- }
- }
- }
- }
- }
- }
-
- private interface Predicate
- {
- boolean test();
- }
-
- private class SentSettled implements Predicate
- {
- public boolean test()
- {
- //are all sent messages settled?
- int total = _outgoingStore.size();
-
- for (Connector<?> c : _driver.connectors())
- {
- // TBD
- // check if transport is done generating output
- // pn_transport_t *transport = pn_connector_transport(ctor);
- // if (transport) {
- // if (!pn_transport_quiesced(transport)) {
- // pn_connector_process(ctor);
- // return false;
- // }
- // }
-
- Connection connection = c.getConnection();
- for (Link link : new Links(connection, ACTIVE, ANY))
- {
- if (link instanceof Sender)
- {
- total += link.getQueued();
- }
- }
-
- // TBD: there is no per-link unsettled
- // deliveries iterator, so for now get the
- // deliveries by walking the outgoing trackers
- Iterator<StoreEntry> entries = _outgoingStore.trackedEntries();
- while (entries.hasNext() && total <= _sendThreshold)
- {
- StoreEntry e = (StoreEntry) entries.next();
- if (e != null )
- {
- Delivery d = e.getDelivery();
- if (d != null)
- {
- if (d.getRemoteState() == null && !d.remotelySettled())
- {
- total++;
- }
- }
- }
- }
- }
- return total <= _sendThreshold;
- }
- }
-
- private class MessageAvailable implements Predicate
- {
- public boolean test()
- {
- //do we have at least one pending message?
- if (_incomingStore.size() > 0) return true;
- for (Connector<?> c : _driver.connectors())
- {
- Connection connection = c.getConnection();
- Delivery delivery = connection.getWorkHead();
- while (delivery != null)
- {
- if (delivery.isReadable() && !delivery.isPartial())
- {
- return true;
- }
- else
- {
- delivery = delivery.getWorkNext();
- }
- }
- }
- // if no connections, or not listening, exit as there won't ever be a message
- if (!_driver.listeners().iterator().hasNext() && !_driver.connectors().iterator().hasNext())
- return true;
-
- return false;
- }
- }
-
- private class AllClosed implements Predicate
- {
- public boolean test()
- {
- if (_driver == null) {
- return true;
- }
-
- for (Connector<?> c : _driver.connectors()) {
- if (!c.isClosed()) {
- return false;
- }
- }
-
- _driver.destroy();
- _driver = null;
-
- return true;
- }
- }
-
- private boolean _worked = false;
-
- private class WorkPred implements Predicate
- {
- public boolean test()
- {
- return _worked;
- }
- }
-
- private final SentSettled _sentSettled = new SentSettled();
- private final MessageAvailable _messageAvailable = new MessageAvailable();
- private final AllClosed _allClosed = new AllClosed();
- private final WorkPred _workPred = new WorkPred();
-
- private interface LinkFinder<C extends Link>
- {
- C test(Link link);
- C create(Session session);
- }
-
- private class SenderFinder implements LinkFinder<Sender>
- {
- private final String _path;
-
- SenderFinder(String path)
- {
- _path = path == null ? "" : path;
- }
-
- public Sender test(Link link)
- {
- if (link instanceof Sender && matchTarget((Target) link.getTarget(), _path))
- {
- return (Sender) link;
- }
- else
- {
- return null;
- }
- }
-
- public Sender create(Session session)
- {
- Sender sender = session.sender(_path);
- Target target = new Target();
- target.setAddress(_path);
- sender.setTarget(target);
- // the C implemenation does this:
- Source source = new Source();
- source.setAddress(_path);
- sender.setSource(source);
- if (getOutgoingWindow() > 0)
- {
- // use explicit settlement via dispositions (not pre-settled)
- sender.setSenderSettleMode(SenderSettleMode.UNSETTLED);
- sender.setReceiverSettleMode(ReceiverSettleMode.SECOND); // desired
- }
- return sender;
- }
- }
-
- private class ReceiverFinder implements LinkFinder<Receiver>
- {
- private final String _path;
-
- ReceiverFinder(String path)
- {
- _path = path == null ? "" : path;
- }
-
- public Receiver test(Link link)
- {
- if (link instanceof Receiver && matchSource((Source) link.getSource(), _path))
- {
- return (Receiver) link;
- }
- else
- {
- return null;
- }
- }
-
- public Receiver create(Session session)
- {
- Receiver receiver = session.receiver(_path);
- Source source = new Source();
- source.setAddress(_path);
- receiver.setSource(source);
- // the C implemenation does this:
- Target target = new Target();
- target.setAddress(_path);
- receiver.setTarget(target);
- if (getIncomingWindow() > 0)
- {
- // use explicit settlement via dispositions (not pre-settled)
- receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED); // desired
- receiver.setReceiverSettleMode(ReceiverSettleMode.SECOND);
- }
- return receiver;
- }
- }
-
- private <C extends Link> C getLink(Address address, LinkFinder<C> finder)
- {
- Connection connection = lookup(address);
- if (connection == null)
- {
- String host = address.getHost();
- int port = Integer.valueOf(address.getImpliedPort());
- Connector<?> connector = _driver.createConnector(host, port, null);
- _logger.log(Level.FINE, "Connecting to " + host + ":" + port);
- connection = Proton.connection();
- connection.setContainer(_name);
- connection.setHostname(host);
- connection.setContext(new ConnectionContext(address, connector));
- connector.setConnection(connection);
- Sasl sasl = connector.sasl();
- if (sasl != null)
- {
- sasl.client();
- sasl.setMechanisms(new String[]{"ANONYMOUS"});
- }
- if ("amqps".equalsIgnoreCase(address.getScheme())) {
- Transport transport = connector.getTransport();
- SslDomain domain = makeDomain(address, SslDomain.Mode.CLIENT);
- if (_trustedDb != null) {
- domain.setPeerAuthentication(SslDomain.VerifyMode.VERIFY_PEER);
- //domain.setPeerAuthentication(SslDomain.VerifyMode.VERIFY_PEER_NAME);
- } else {
- domain.setPeerAuthentication(SslDomain.VerifyMode.ANONYMOUS_PEER);
- }
- Ssl ssl = transport.ssl(domain);
- //ssl.setPeerHostname(host);
- }
- connection.open();
- }
-
- for (Link link : new Links(connection, ACTIVE, ANY))
- {
- C result = finder.test(link);
- if (result != null) return result;
- }
- Session session = connection.session();
- session.open();
- C link = finder.create(session);
- linkAdded(link);
- link.open();
- return link;
- }
-
- private static class Links implements Iterable<Link>
- {
- private final Connection _connection;
- private final EnumSet<EndpointState> _local;
- private final EnumSet<EndpointState> _remote;
-
- Links(Connection connection, EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
- {
- _connection = connection;
- _local = local;
- _remote = remote;
- }
-
- public java.util.Iterator<Link> iterator()
- {
- return new LinkIterator(_connection, _local, _remote);
- }
- }
-
- private static class LinkIterator implements java.util.Iterator<Link>
- {
- private final EnumSet<EndpointState> _local;
- private final EnumSet<EndpointState> _remote;
- private Link _next;
-
- LinkIterator(Connection connection, EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
- {
- _local = local;
- _remote = remote;
- _next = connection.linkHead(_local, _remote);
- }
-
- public boolean hasNext()
- {
- return _next != null;
- }
-
- public Link next()
- {
- try
- {
- return _next;
- }
- finally
- {
- _next = _next.next(_local, _remote);
- }
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class Sessions implements Iterable<Session>
- {
- private final Connection _connection;
- private final EnumSet<EndpointState> _local;
- private final EnumSet<EndpointState> _remote;
-
- Sessions(Connection connection, EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
- {
- _connection = connection;
- _local = local;
- _remote = remote;
- }
-
- public java.util.Iterator<Session> iterator()
- {
- return new SessionIterator(_connection, _local, _remote);
- }
- }
-
- private static class SessionIterator implements java.util.Iterator<Session>
- {
- private final EnumSet<EndpointState> _local;
- private final EnumSet<EndpointState> _remote;
- private Session _next;
-
- SessionIterator(Connection connection, EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
- {
- _local = local;
- _remote = remote;
- _next = connection.sessionHead(_local, _remote);
- }
-
- public boolean hasNext()
- {
- return _next != null;
- }
-
- public Session next()
- {
- try
- {
- return _next;
- }
- finally
- {
- _next = _next.next(_local, _remote);
- }
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- }
-
- private void adjustReplyTo(Message m)
- {
- String original = m.getReplyTo();
- if (original != null) {
- if (original.startsWith("~/"))
- {
- m.setReplyTo("amqp://" + _name + "/" + original.substring(2));
- }
- else if (original.equals("~"))
- {
- m.setReplyTo("amqp://" + _name);
- }
- }
- }
-
- private static boolean matchTarget(Target target, String path)
- {
- if (target == null) return path.isEmpty();
- else return path.equals(target.getAddress());
- }
-
- private static boolean matchSource(Source source, String path)
- {
- if (source == null) return path.isEmpty();
- else return path.equals(source.getAddress());
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("MessengerImpl [_name=").append(_name).append("]");
- return builder.toString();
- }
-
- // compute the maximum amount of credit each receiving link is
- // entitled to. The actual credit given to the link depends on
- // what amount of credit is actually available.
- private int perLinkCredit()
- {
- if (_receivers == 0) return 0;
- int total = _credit + _distributed;
- return Math.max(total/_receivers, 1);
- }
-
- // a new link has been created, account for it.
- private void linkAdded(Link link)
- {
- if (link instanceof Receiver)
- {
- _receivers++;
- _blocked.add((Receiver)link);
- link.setContext(Boolean.TRUE);
- }
- }
-
- // a link is being removed, account for it.
- private void linkRemoved(Link _link)
- {
- if (_link instanceof Receiver && (Boolean) _link.getContext())
- {
- _link.setContext(Boolean.FALSE);
- Receiver link = (Receiver)_link;
- assert _receivers > 0;
- _receivers--;
- if (link.getDrain())
- {
- link.setDrain(false);
- assert _draining > 0;
- _draining--;
- }
- if (_blocked.contains(link))
- _blocked.remove(link);
- else if (_credited.contains(link))
- _credited.remove(link);
- else
- assert(false);
- }
- }
-
- private static class ConnectionContext
- {
- private Address _address;
- private Connector _connector;
-
- public ConnectionContext(Address address, Connector connector)
- {
- _address = address;
- _connector = connector;
- }
-
- public Address getAddress()
- {
- return _address;
- }
-
- public boolean matches(Address address)
- {
- String host = address.getHost();
- String port = address.getImpliedPort();
- Connection conn = _connector.getConnection();
- return host.equals(conn.getRemoteContainer()) ||
- (_address.getHost().equals(host) && _address.getImpliedPort().equals(port));
- }
-
- public Connector getConnector()
- {
- return _connector;
- }
- }
-
- private SslDomain makeDomain(Address address, SslDomain.Mode mode)
- {
- SslDomain domain = Proton.sslDomain();
- domain.init(mode);
- if (_certificate != null) {
- domain.setCredentials(_certificate, _privateKey, _password);
- }
- if (_trustedDb != null) {
- domain.setTrustedCaDb(_trustedDb);
- }
-
- if ("amqps".equalsIgnoreCase(address.getScheme())) {
- domain.allowUnsecuredClient(false);
- } else {
- domain.allowUnsecuredClient(true);
- }
-
- return domain;
- }
-
-
- private class ListenerContext
- {
- private Address _address;
- private SslDomain _domain;
-
- public ListenerContext(Address address)
- {
- _address = address;
- _domain = makeDomain(address, SslDomain.Mode.SERVER);
- }
-
- public SslDomain getDomain()
- {
- return _domain;
- }
-
- public Address getAddress()
- {
- return _address;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Store.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Store.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Store.java
deleted file mode 100644
index b60e8ed..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Store.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.messenger.impl;
-
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.qpid.proton.messenger.Status;
-import org.apache.qpid.proton.messenger.Messenger;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.amqp.messaging.Accepted;
-import org.apache.qpid.proton.amqp.messaging.Rejected;
-
-/**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-class Store
-{
- private static final Accepted ACCEPTED = Accepted.getInstance();
- private static final Rejected REJECTED = new Rejected();
-
- private LinkedList<StoreEntry> _store = new LinkedList<StoreEntry>();
- private HashMap<String, LinkedList<StoreEntry>> _stream = new HashMap<String, LinkedList<StoreEntry>>();
-
- // for incoming/outgoing window tracking
- int _window;
- int _lwm;
- int _hwm;
- private HashMap<Integer, StoreEntry> _tracked = new HashMap<Integer, StoreEntry>();
-
- Store()
- {
- }
-
- private boolean isTracking( Integer id )
- {
- return id != null && (id.intValue() - _lwm >= 0) && (_hwm - id.intValue() > 0);
- }
-
- int size()
- {
- return _store.size();
- }
-
- int getWindow()
- {
- return _window;
- }
-
- void setWindow(int window)
- {
- _window = window;
- }
-
- StoreEntry put(String address)
- {
- if (address == null) address = "";
- StoreEntry entry = new StoreEntry(this, address);
- _store.add( entry );
- LinkedList<StoreEntry> list = _stream.get( address );
- if (list != null) {
- list.add( entry );
- } else {
- list = new LinkedList<StoreEntry>();
- list.add( entry );
- _stream.put( address, list );
- }
- entry.stored();
- return entry;
- }
-
- StoreEntry get(String address)
- {
- if (address != null) {
- LinkedList<StoreEntry> list = _stream.get( address );
- if (list != null) return list.peekFirst();
- } else {
- return _store.peekFirst();
- }
- return null;
- }
-
- StoreEntry getEntry(int id)
- {
- return _tracked.get(id);
- }
-
- Iterator<StoreEntry> trackedEntries()
- {
- return _tracked.values().iterator();
- }
-
- void freeEntry(StoreEntry entry)
- {
- if (entry.isStored()) {
- _store.remove( entry );
- LinkedList<StoreEntry> list = _stream.get( entry.getAddress() );
- if (list != null) list.remove( entry );
- entry.notStored();
- }
- // note well: may still be in _tracked map if still in window!
- }
-
- public int trackEntry(StoreEntry entry)
- {
- assert( entry.getStore() == this );
- entry.setId(_hwm++);
- _tracked.put(entry.getId(), entry);
- slideWindow();
- return entry.getId();
- }
-
- private void slideWindow()
- {
- if (_window >= 0)
- {
- while (_hwm - _lwm > _window)
- {
- StoreEntry old = getEntry(_lwm);
- if (old != null)
- {
- _tracked.remove( old.getId() );
- Delivery d = old.getDelivery();
- if (d != null) {
- if (d.getLocalState() == null)
- d.disposition(ACCEPTED);
- d.settle();
- }
- }
- _lwm++;
- }
- }
- }
-
- int update(int id, Status status, int flags, boolean settle, boolean match )
- {
- if (!isTracking(id)) return 0;
-
- int start = (Messenger.CUMULATIVE & flags) != 0 ? _lwm : id;
- for (int i = start; (id - i) >= 0; i++)
- {
- StoreEntry e = getEntry(i);
- if (e != null)
- {
- Delivery d = e.getDelivery();
- if (d != null)
- {
- if (d.getLocalState() == null)
- {
- if (match)
- {
- d.disposition(d.getRemoteState());
- }
- else
- {
- switch (status)
- {
- case ACCEPTED:
- d.disposition(ACCEPTED);
- break;
- case REJECTED:
- d.disposition(REJECTED);
- break;
- default:
- break;
- }
- }
- e.updated();
- }
- }
- if (settle)
- {
- if (d != null)
- {
- d.settle();
- }
- _tracked.remove(e.getId());
- }
- }
- }
-
- while (_hwm - _lwm > 0 && !_tracked.containsKey(_lwm))
- {
- _lwm++;
- }
-
- return 0;
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/StoreEntry.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/StoreEntry.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/StoreEntry.java
deleted file mode 100644
index 1687b94..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/StoreEntry.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.messenger.impl;
-
-import org.apache.qpid.proton.messenger.Tracker;
-import org.apache.qpid.proton.messenger.Status;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.amqp.messaging.Accepted;
-import org.apache.qpid.proton.amqp.messaging.Modified;
-import org.apache.qpid.proton.amqp.messaging.Rejected;
-import org.apache.qpid.proton.amqp.messaging.Released;
-import org.apache.qpid.proton.amqp.messaging.Received;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-
-/**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-class StoreEntry
-{
- private Store _store;
- private Integer _id;
- private String _address;
- private byte[] _encodedMsg;
- private int _encodedLength;
- private Delivery _delivery;
- private Status _status = Status.UNKNOWN;
- private Object _context;
- private boolean _inStore = false;
-
- public StoreEntry(Store store, String address)
- {
- _store = store;
- _address = address;
- }
-
- public Store getStore()
- {
- return _store;
- }
-
- public boolean isStored()
- {
- return _inStore;
- }
-
- public void stored()
- {
- _inStore = true;
- }
-
- public void notStored()
- {
- _inStore = false;
- }
-
- public String getAddress()
- {
- return _address;
- }
-
- public byte[] getEncodedMsg()
- {
- return _encodedMsg;
- }
-
- public int getEncodedLength()
- {
- return _encodedLength;
- }
-
- public void setEncodedMsg( byte[] encodedMsg, int length )
- {
- _encodedMsg = encodedMsg;
- _encodedLength = length;
- }
-
- public void setId(int id)
- {
- _id = new Integer(id);
- }
-
- public Integer getId()
- {
- return _id;
- }
-
- public void setDelivery( Delivery d )
- {
- if (_delivery != null)
- {
- _delivery.setContext(null);
- }
- _delivery = d;
- if (_delivery != null)
- {
- _delivery.setContext(this);
- }
- updated();
- }
-
- public Delivery getDelivery()
- {
- return _delivery;
- }
-
- public Status getStatus()
- {
- return _status;
- }
-
- public void setStatus(Status status)
- {
- _status = status;
- }
-
- private static Status _disp2status(DeliveryState disp)
- {
- if (disp == null) return Status.PENDING;
-
- if (disp instanceof Received)
- return Status.PENDING;
- if (disp instanceof Accepted)
- return Status.ACCEPTED;
- if (disp instanceof Rejected)
- return Status.REJECTED;
- if (disp instanceof Released)
- return Status.RELEASED;
- if (disp instanceof Modified)
- return Status.MODIFIED;
- assert(false);
- return null;
- }
-
- public void updated()
- {
- if (_delivery != null)
- {
- if (_delivery.getRemoteState() != null)
- {
- _status = _disp2status(_delivery.getRemoteState());
- }
- else if (_delivery.remotelySettled())
- {
- DeliveryState disp = _delivery.getLocalState();
- if (disp == null) {
- _status = Status.SETTLED;
- } else {
- _status = _disp2status(_delivery.getLocalState());
- }
- }
- else
- {
- _status = Status.PENDING;
- }
- }
- }
-
- public void setContext(Object context)
- {
- _context = context;
- }
-
- public Object getContext()
- {
- return _context;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/TrackerImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/TrackerImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/TrackerImpl.java
deleted file mode 100644
index 2d8b584..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/TrackerImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.messenger.impl;
-
-import org.apache.qpid.proton.messenger.Tracker;
-
-/**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-class TrackerImpl implements Tracker
-{
- public enum Type {
- OUTGOING,
- INCOMING
- }
-
- private Type _type;
- private int _sequence;
-
- TrackerImpl(Type type, int sequence)
- {
- _type = type;
- _sequence = sequence;
- }
-
- boolean isOutgoing()
- {
- return _type == Type.OUTGOING;
- }
-
- int getSequence()
- {
- return _sequence;
- }
-
- public String toString()
- {
- return (isOutgoing() ? "O:" : "I:") + Integer.toString(_sequence);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Transform.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Transform.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Transform.java
deleted file mode 100644
index c3a08ea..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Transform.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.messenger.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-/**
- * Transform
- *
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-class Transform
-{
-
- private static class Rule {
-
- String _pattern;
- String _substitution;
-
- Pattern _compiled;
- StringBuilder _sb = new StringBuilder();
- boolean _matched = false;
- String _result = null;
-
- Rule(String pattern, String substitution)
- {
- _pattern = pattern;
- _substitution = substitution;
- _compiled = Pattern.compile(_pattern.replace("*", "(.*)").replace("%", "([^/]*)"));
- }
-
- boolean apply(String src) {
- _matched = false;
- _result = null;
- Matcher m = _compiled.matcher(src);
- if (m.matches()) {
- _matched = true;
- if (_substitution != null) {
- _sb.setLength(0);
- int limit = _substitution.length();
- int idx = 0;
- while (idx < limit) {
- char c = _substitution.charAt(idx);
- switch (c) {
- case '$':
- idx++;
- if (idx < limit) {
- c = _substitution.charAt(idx);
- } else {
- throw new IllegalStateException("substition index truncated");
- }
-
- if (c == '$') {
- _sb.append(c);
- idx++;
- } else {
- int num = 0;
- while (Character.isDigit(c)) {
- num *= 10;
- num += c - '0';
- idx++;
- c = idx < limit ? _substitution.charAt(idx) : '\0';
- }
- if (num > 0) {
- _sb.append(m.group(num));
- } else {
- throw new IllegalStateException
- ("bad substitution index at character[" +
- idx + "]: " + _substitution);
- }
- }
- break;
- default:
- _sb.append(c);
- idx++;
- break;
- }
- }
- _result = _sb.toString();
- }
- }
-
- return _matched;
- }
-
- boolean matched() {
- return _matched;
- }
-
- String result() {
- return _result;
- }
-
- }
-
- private List<Rule> _rules = new ArrayList<Rule>();
- private Rule _matched = null;
-
- public void rule(String pattern, String substitution)
- {
- _rules.add(new Rule(pattern, substitution));
- }
-
- public boolean apply(String src)
- {
- _matched = null;
-
- for (Rule rule: _rules) {
- if (rule.apply(src)) {
- _matched = rule;
- break;
- }
- }
-
- return _matched != null;
- }
-
- public boolean matched()
- {
- return _matched != null;
- }
-
- public String result()
- {
- return _matched != null ? _matched.result() : null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java
deleted file mode 100644
index 222ce40..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-import org.apache.qpid.proton.engine.Extendable;
-
-/**
- * Acceptors are children of a {@link Reactor} that accept in-bound network
- * connections.
- */
-public interface Acceptor extends ReactorChild, Extendable {
-
- /**
- * Closes the acceptor, stopping it accepting any further in-bound
- * connections. Already accepted connections continue to be processed by
- * the associated reactor.
- */
- void close();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/FlowController.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/FlowController.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/FlowController.java
deleted file mode 100644
index 716b2a7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/FlowController.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Receiver;
-
-/**
- * A handler that applies flow control to a connection. This handler tops-up
- * link credit each time credit is expended by the receipt of messages.
- */
-public class FlowController extends BaseHandler {
-
- private int drained;
- private int window;
-
- public FlowController(int window) {
- // XXX: a window of 1 doesn't work because we won't necessarily get
- // notified when the one allowed delivery is settled
- if (window <= 1) throw new IllegalArgumentException();
- this.window = window;
- this.drained = 0;
- }
-
- public FlowController() {
- this(1024);
- }
-
- private void topup(Receiver link, int window) {
- int delta = window - link.getCredit();
- link.flow(delta);
- }
-
- @Override
- public void onUnhandled(Event event) {
- int window = this.window;
- Link link = event.getLink();
-
- switch(event.getType()) {
- case LINK_LOCAL_OPEN:
- case LINK_REMOTE_OPEN:
- case LINK_FLOW:
- case DELIVERY:
- if (link instanceof Receiver) {
- this.drained += link.drained();
- if (this.drained == 0) {
- topup((Receiver)link, window);
- }
- }
- break;
- default:
- break;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/Handshaker.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Handshaker.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Handshaker.java
deleted file mode 100644
index 1423f32..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Handshaker.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Endpoint;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-
-/**
- * A handler that mirrors the actions of the remote end of a connection. This
- * handler responds in kind when the remote end of the connection is opened and
- * closed. Likewise if the remote end of the connection opens or closes
- * sessions and links, this handler responds by opening or closing the local end
- * of the session or link.
- */
-public class Handshaker extends BaseHandler {
-
- private void open(Endpoint endpoint) {
- if (endpoint.getLocalState() == EndpointState.UNINITIALIZED) {
- endpoint.open();
- }
- }
-
- private void close(Endpoint endpoint) {
- if (endpoint.getLocalState() != EndpointState.CLOSED) {
- endpoint.close();
- }
- }
-
- @Override
- public void onConnectionRemoteOpen(Event event) {
- open(event.getConnection());
- }
-
- @Override
- public void onSessionRemoteOpen(Event event) {
- open(event.getSession());
- }
-
- @Override
- public void onLinkRemoteOpen(Event event) {
- Link link = event.getLink();
- if (link.getLocalState() == EndpointState.UNINITIALIZED) {
- if (link.getRemoteSource() != null) {
- link.setSource(link.getRemoteSource().copy());
- }
- if (link.getRemoteTarget() != null) {
- link.setTarget(link.getRemoteTarget().copy());
- }
- }
- open(link);
- }
-
- @Override
- public void onConnectionRemoteClose(Event event) {
- close(event.getConnection());
- }
-
- @Override
- public void onSessionRemoteClose(Event event) {
- close(event.getSession());
- }
-
- @Override
- public void onLinkRemoteClose(Event event) {
- close(event.getLink());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java
deleted file mode 100644
index f687bb3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-import java.io.IOException;
-import java.util.Set;
-
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Event.Type;
-import org.apache.qpid.proton.engine.Handler;
-import org.apache.qpid.proton.engine.HandlerException;
-import org.apache.qpid.proton.engine.Record;
-import org.apache.qpid.proton.reactor.impl.ReactorImpl;
-
-/**
- * The proton reactor provides a general purpose event processing
- * library for writing reactive programs. A reactive program is defined
- * by a set of event handlers. An event handler is just any class or
- * object that extends the Handler interface. For convenience, a class
- * can extend {@link BaseHandler} and only handle the events that it cares to
- * implement methods for.
- * <p>
- * This class is not thread safe (with the exception of the {@link #wakeup()}
- * method) and should only be used by a single thread at any given time.
- */
-public interface Reactor {
-
- public static final class Factory
- {
- public static Reactor create() throws IOException {
- return new ReactorImpl();
- }
- }
-
- /**
- * Updates the last time that the reactor's state has changed, potentially
- * resulting in events being generated.
- * @return the current time in milliseconds
- * {@link System#currentTimeMillis()}.
- */
- long mark();
-
- /** @return the last time that {@link #mark()} was called. */
- long now();
-
- /** @return an instance of {@link Record} that can be used to associate
- * other objects (attachments) with this instance of the
- * Reactor class.
- */
- Record attachments();
-
- /**
- * The value the reactor will use for {@link Selector#select(long)} that is called as part of {@link #process()}.
- *
- * @param timeout a timeout value in milliseconds, to associate with this instance of
- * the reactor. This can be retrieved using the
- * {@link #getTimeout()} method
- */
- void setTimeout(long timeout);
-
- /**
- * @return the value previously set using {@link #setTimeout(long)} or
- * 0 if no previous value has been set.
- */
- long getTimeout();
-
- /**
- * @return the global handler for this reactor. Every event the reactor
- * sees is dispatched to the global handler. To receive every
- * event generated by the reactor, associate a child handler
- * with the global handler. For example:
- * <pre>
- * getGlobalHandler().add(yourHandler);
- * </pre>
- */
- Handler getGlobalHandler();
-
- /**
- * Sets a new global handler. You probably don't want to do this and
- * would be better adding a handler to the value returned by the
- * {{@link #getGlobalHandler()} method.
- * @param handler the new global handler.
- */
- void setGlobalHandler(Handler handler);
-
- /**
- * @return the handler for this reactor. Every event the reactor sees,
- * which is not handled by a child of the reactor (such as a
- * timer, connection, acceptor, or selector) is passed to this
- * handler. To receive these events, it is recommend that you
- * associate a child handler with the handler returned by this
- * method. For example:
- * <pre>
- * getHandler().add(yourHandler);
- * </pre>
- */
- Handler getHandler();
-
- /**
- * Sets a new handler, that will receive any events not handled by a child
- * of the reactor. Note that setting a handler via this method replaces
- * the previous handler, and will result in no further events being
- * dispatched to the child handlers associated with the previous handler.
- * For this reason it is recommended that you do not use this method and
- * instead add child handlers to the value returned by the
- * {@link #getHandler()} method.
- * @param handler the new handler for this reactor.
- */
- void setHandler(Handler handler);
-
- /**
- * @return a set containing the child objects associated with this reactor.
- * This will contain any active instances of: {@link Task} -
- * created using the {@link #schedule(int, Handler)} method,
- * {@link Connection} - created using the
- * {@link #connectionToHost(String, int, Handler)} method,
- * {@link Acceptor} - created using the
- * {@link #acceptor(String, int)} method,
- * {@link #acceptor(String, int, Handler)} method, or
- * {@link Selectable} - created using the
- * {@link #selectable()} method.
- */
- Set<ReactorChild> children();
-
- /**
- * @return the Collector used to gather events generated by this reactor.
- */
- Collector collector();
-
- /**
- * Creates a new <code>Selectable</code> as a child of this reactor.
- * @return the newly created <code>Selectable</code>.
- */
- Selectable selectable();
-
- /**
- * Updates the specified <code>Selectable</code> either emitting a
- * {@link Type#SELECTABLE_UPDATED} event if the selectable is not terminal,
- * or {@link Type#SELECTABLE_FINAL} if the selectable is terminal and has
- * not already emitted a {@link Type#SELECTABLE_FINAL} event.
- * @param selectable
- */
- void update(Selectable selectable);
-
- /**
- * Yields, causing the next call to {@link #process()} to return
- * successfully - without processing any events. If multiple calls
- * can be made to <code>yield</code> and only the next invocation of
- * {@link #process()} will be affected.
- */
- void yield() ;
-
- /**
- * @return <code>true</code> if the reactor is in quiesced state (e.g. has
- * no events to process). <code>false</code> is returned otherwise.
- */
- boolean quiesced();
-
- /**
- * Process any events pending for this reactor. Events are dispatched to
- * the handlers registered with the reactor, or child objects associated
- * with the reactor. This method blocks until the reactor has no more work
- * to do (and no more work pending, in terms of scheduled tasks or open
- * selectors to process).
- * @return <code>true</code> if the reactor may have more events in the
- * future. For example: if there are scheduled tasks, or open
- * selectors. <code>false</code> is returned if the reactor has
- * (and will have) no more events to process.
- * @throws HandlerException if an unchecked exception is thrown by one of
- * the handlers - it will be re-thrown attached to an instance of
- * <code>HandlerException</code>.
- */
- boolean process() throws HandlerException;
-
- /**
- * Wakes up the thread (if any) blocked in the {@link #process()} method.
- * This is the only method of this class that is thread safe, in that it
- * can be used at the same time as another thread is using the reactor.
- */
- void wakeup();
-
- /**
- * Starts the reactor. This method should be invoked before the first call
- * to {@link #process()}.
- */
- void start();
-
- /**
- * Stops the reactor. This method should be invoked after the last call to
- * {@link #process()}.
- * @throws HandlerException
- */
- void stop() throws HandlerException;
-
- /**
- * Simplifies the use of the reactor by wrapping the use of
- * <code>start</code>, <code>run</code>, and <code>stop</code> method
- * calls.
- * <p>
- * Logically the implementation of this method is:
- * <pre>
- * start();
- * while(process()) {}
- * stop();
- * </pre>
- * @throws HandlerException if an unchecked exception is thrown by one of
- * the handlers - it will be re-thrown attached to an instance of
- * <code>HandlerException</code>.
- */
- void run() throws HandlerException;
-
- /**
- * Schedules execution of a task to take place at some point in the future.
- * @param delay the number of milliseconds, in the future, to schedule the
- * task for.
- * @param handler a handler to associate with the task. This is notified
- * when the deadline for the task is reached.
- * @return an object representing the task that has been scheduled.
- */
- Task schedule(int delay, Handler handler);
-
- /**
- * Creates a new out-bound connection.
- * @param handler a handler that is notified when events occur for the
- * connection. Typically the host and port to connect to
- * would be supplied to the connection object inside the
- * logic which handles the {@link Type#CONNECTION_INIT}
- * event via
- * {@link #setConnectionHost(Connection, String, int)}
- * @return the newly created connection object.
- * @deprecated Use {@link #connectionToHost(String, int, Handler)} instead.
- */
- @Deprecated
- Connection connection(Handler handler);
-
- /**
- * Creates a new out-bound connection to the given host and port.
- * <p>
- * This method will cause Reactor to set up a network connection to the
- * host and create a Connection for it.
- * @param host the host to connect to (e.g. "localhost")
- * @param port the port used for the connection.
- * @param handler a handler that is notified when events occur for the
- * connection.
- * @return the newly created connection object.
- */
- Connection connectionToHost(String host, int port, Handler handler);
-
- /**
- * Set the host address used by the connection
- * <p>
- * This method will set/change the host address used by the Reactor to
- * create an outbound network connection for the given Connection
- * @param c the Connection to assign the address to
- * @param host the address of the host to connect to (e.g. "localhost")
- * @param port the port to use for the connection.
- */
- void setConnectionHost(Connection c, String host, int port);
-
- /**
- * Get the address used by the connection
- * <p>
- * This may be used to retrieve the remote peer address.
- * Note that the returned address may be in numeric IP format.
- * @param c the Connection
- * @return a string containing the address in the following format:
- * <pre>
- * host[:port]
- * </pre>
- */
- String getConnectionAddress(Connection c);
-
- /**
- * Creates a new acceptor. This is equivalent to calling:
- * <pre>
- * acceptor(host, port, null);
- * </pre>
- * @param host
- * @param port
- * @return the newly created acceptor object.
- * @throws IOException
- */
- Acceptor acceptor(String host, int port) throws IOException;
-
- /**
- * Creates a new acceptor. This acceptor listens for in-bound connections.
- * @param host the host name or address of the NIC to listen on.
- * @param port the port number to listen on.
- * @param handler if non-<code>null</code> this handler is registered with
- * each new connection accepted by the acceptor.
- * @return the newly created acceptor object.
- * @throws IOException
- */
- Acceptor acceptor(String host, int port, Handler handler)
- throws IOException;
-
- /**
- * Frees any resources (such as sockets and selectors) held by the reactor
- * or its children.
- */
- void free();
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[07/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/CapitalisingDummySslEngine.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/CapitalisingDummySslEngine.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/CapitalisingDummySslEngine.java
deleted file mode 100644
index 10a64d4..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/CapitalisingDummySslEngine.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.ByteBuffer;
-
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLEngineResult.HandshakeStatus;
-import javax.net.ssl.SSLEngineResult.Status;
-import javax.net.ssl.SSLException;
-
-
-
-/**
- * A simpler implementation of an SSLEngine that has predictable human-readable output, and that allows us to
- * easily trigger {@link Status#BUFFER_OVERFLOW} and {@link Status#BUFFER_UNDERFLOW}.
- *
- * Using a true SSLEngine for this would be impractical.
- */
-public class CapitalisingDummySslEngine implements ProtonSslEngine
-{
- static final int SHORT_ENCODED_CHUNK_SIZE = 2;
- static final int MAX_ENCODED_CHUNK_SIZE = 5;
- private static final char ENCODED_TEXT_BEGIN = '<';
- private static final char ENCODED_TEXT_END = '>';
- private static final char ENCODED_TEXT_INNER_CHAR = '-';
-
- private static final int CLEAR_CHUNK_SIZE = 2;
- private static final char CLEARTEXT_PADDING = '_';
- private SSLException _nextException;
- private int _applicationBufferSize = CLEAR_CHUNK_SIZE;
- private int _packetBufferSize = MAX_ENCODED_CHUNK_SIZE;
- private int _unwrapCount;
-
- /**
- * Converts a_ to <-A->. z_ is special and encodes as <> (to give us packets of different lengths).
- * If dst is not sufficiently large ({@value #SHORT_ENCODED_CHUNK_SIZE} in our encoding), we return
- * {@link Status#BUFFER_OVERFLOW}, and the src and dst ByteBuffers are unchanged.
- */
- @Override
- public SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst)
- throws SSLException
- {
- int consumed = 0;
- int produced = 0;
- final Status resultStatus;
-
- if (src.remaining() >= CLEAR_CHUNK_SIZE)
- {
- src.mark();
-
- char uncapitalisedChar = (char) src.get();
- char underscore = (char) src.get();
-
- validateClear(uncapitalisedChar, underscore);
-
- boolean useShortEncoding = uncapitalisedChar == 'z';
- int encodingLength = useShortEncoding ? SHORT_ENCODED_CHUNK_SIZE : MAX_ENCODED_CHUNK_SIZE;
- boolean overflow = dst.remaining() < encodingLength;
-
- if (overflow)
- {
- src.reset();
- resultStatus = Status.BUFFER_OVERFLOW;
- }
- else
- {
- consumed = CLEAR_CHUNK_SIZE;
-
- char capitalisedChar = Character.toUpperCase(uncapitalisedChar);
-
- dst.put((byte)ENCODED_TEXT_BEGIN);
- if (!useShortEncoding)
- {
- dst.put((byte)ENCODED_TEXT_INNER_CHAR);
- dst.put((byte)capitalisedChar);
- dst.put((byte)ENCODED_TEXT_INNER_CHAR);
- }
- dst.put((byte)ENCODED_TEXT_END);
- produced = encodingLength;
-
- resultStatus = Status.OK;
- }
- }
- else
- {
- resultStatus = Status.OK;
- }
-
- return new SSLEngineResult(resultStatus, HandshakeStatus.NOT_HANDSHAKING, consumed, produced);
- }
-
- /**
- * Converts <-A-><-B-><-C-> to a_. <> is special and decodes as z_
- * Input such as "<A" will causes a {@link Status#BUFFER_UNDERFLOW} result status.
- */
- @Override
- public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst)
- throws SSLException
- {
- _unwrapCount++;
-
- if(_nextException != null)
- {
- throw _nextException;
- }
-
- Status resultStatus;
- final int consumed;
- final int produced;
-
- if (src.remaining() >= SHORT_ENCODED_CHUNK_SIZE)
- {
- src.mark();
-
- char begin = (char)src.get();
- char nextChar = (char)src.get(); // Could be - or >
- final int readSoFar = 2;
- final char capitalisedChar;
-
- if (nextChar != ENCODED_TEXT_END)
- {
- int remainingBytesForMaxLengthPacket = MAX_ENCODED_CHUNK_SIZE - readSoFar;
- if (src.remaining() < remainingBytesForMaxLengthPacket )
- {
- src.reset();
- resultStatus = Status.BUFFER_UNDERFLOW;
- return new SSLEngineResult(resultStatus, HandshakeStatus.NOT_HANDSHAKING, 0, 0);
- }
- else
- {
- char beginInner = nextChar;
- capitalisedChar = (char)src.get();
- char endInner = (char)src.get();
- char end = (char)src.get();
- consumed = MAX_ENCODED_CHUNK_SIZE;
- validateEncoded(begin, beginInner, capitalisedChar, endInner, end);
- }
- }
- else
- {
- assertEquals("Unexpected begin", Character.toString(ENCODED_TEXT_BEGIN), Character.toString(begin));
- capitalisedChar = 'Z';
- consumed = SHORT_ENCODED_CHUNK_SIZE;;
- }
-
- char lowerCaseChar = Character.toLowerCase(capitalisedChar);
- dst.put((byte)lowerCaseChar);
- dst.put((byte)CLEARTEXT_PADDING);
- produced = CLEAR_CHUNK_SIZE;
-
- resultStatus = Status.OK;
- }
- else
- {
- resultStatus = Status.BUFFER_UNDERFLOW;
- consumed = 0;
- produced = 0;
- }
-
- return new SSLEngineResult(resultStatus, HandshakeStatus.NOT_HANDSHAKING, consumed, produced);
- }
-
- @Override
- public int getEffectiveApplicationBufferSize()
- {
- return getApplicationBufferSize();
- }
-
- private int getApplicationBufferSize()
- {
- return _applicationBufferSize;
- }
-
- @Override
- public int getPacketBufferSize()
- {
- return _packetBufferSize;
- }
-
- public void setApplicationBufferSize(int value)
- {
- _applicationBufferSize = value;
- }
-
- public void setPacketBufferSize(int value)
- {
- _packetBufferSize = value;
- }
-
- @Override
- public String getProtocol()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public HandshakeStatus getHandshakeStatus()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Runnable getDelegatedTask()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getCipherSuite()
- {
- throw new UnsupportedOperationException();
- }
-
-
- private void validateEncoded(char begin, char beginInner, char capitalisedChar, char endInner, char end)
- {
- assertEquals("Unexpected begin", Character.toString(ENCODED_TEXT_BEGIN), Character.toString(begin));
- assertEquals("Unexpected begin inner", Character.toString(ENCODED_TEXT_INNER_CHAR), Character.toString(beginInner));
- assertEquals("Unexpected end inner", Character.toString(ENCODED_TEXT_INNER_CHAR), Character.toString(endInner));
- assertEquals("Unexpected end", Character.toString(ENCODED_TEXT_END), Character.toString(end));
- assertTrue("Encoded character " + capitalisedChar + " must be capital", Character.isUpperCase(capitalisedChar));
- }
-
- private void validateClear(char uncapitalisedChar, char underscore)
- {
- assertTrue("Clear text character " + uncapitalisedChar + " must be lowercase", Character.isLowerCase(uncapitalisedChar));
- assertEquals("Unexpected clear text pad", Character.toString(CLEARTEXT_PADDING), Character.toString(underscore));
- }
-
- @Override
- public boolean getUseClientMode()
- {
- return true;
- }
-
- public void rejectNextEncodedPacket(SSLException nextException)
- {
- _nextException = nextException;
- }
-
- int getUnwrapCount() {
- return _unwrapCount;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/RememberingTransportInput.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/RememberingTransportInput.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/RememberingTransportInput.java
deleted file mode 100644
index 366feb3..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/RememberingTransportInput.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.engine.impl.TransportInput;
-
-class RememberingTransportInput implements TransportInput
-{
- private StringBuilder _receivedInput = new StringBuilder();
- private String _nextError;
- private int _inputBufferSize = 1024;
- private ByteBuffer _buffer;
- private int _processCount = 0;
- private Integer _zeroCapacityAtCount = null;
- private int _capacityCount = 0;
-
- String getAcceptedInput()
- {
- return _receivedInput.toString();
- }
-
- @Override
- public String toString()
- {
- return "[RememberingTransportInput receivedInput (length " + _receivedInput.length() + ") is:" + _receivedInput.toString() + "]";
- }
-
- @Override
- public int capacity()
- {
- initIntermediateBuffer();
-
- _capacityCount++;
- if(_zeroCapacityAtCount != null && _capacityCount >= _zeroCapacityAtCount) {
- return 0;
- }
-
- return _buffer.remaining();
- }
-
- @Override
- public int position()
- {
- initIntermediateBuffer();
- return _buffer.position();
- }
-
- @Override
- public ByteBuffer tail()
- {
- initIntermediateBuffer();
- return _buffer;
- }
-
- @Override
- public void process() throws TransportException
- {
- _processCount++;
-
- initIntermediateBuffer();
-
- if(_nextError != null)
- {
- throw new TransportException(_nextError);
- }
-
- _buffer.flip();
- byte[] receivedInputBuffer = new byte[_buffer.remaining()];
- _buffer.get(receivedInputBuffer);
- _buffer.compact();
- _receivedInput.append(new String(receivedInputBuffer));
- }
-
- @Override
- public void close_tail()
- {
- // do nothing
- }
-
- public void rejectNextInput(String nextError)
- {
- _nextError = nextError;
- }
-
- /**
- * If called before the object is otherwise used, the intermediate input buffer will be
- * initiated to the given size. If called after use, an ISE will be thrown.
- *
- * @param inputBufferSize size of the intermediate input buffer
- * @throws IllegalStateException if the buffer was already initialised
- */
- public void setInputBufferSize(int inputBufferSize) throws IllegalStateException
- {
- if (_buffer != null)
- {
- throw new IllegalStateException("Intermediate input buffer already initialised");
- }
-
- _inputBufferSize = inputBufferSize;
- }
-
- private void initIntermediateBuffer()
- {
- if (_buffer == null)
- {
- _buffer = ByteBuffer.allocate(_inputBufferSize);
- }
- }
-
- int getProcessCount()
- {
- return _processCount;
- }
-
- int getCapacityCount()
- {
- return _capacityCount;
- }
-
- /**
- * Sets a point at which calls to capacity will return 0 regardless of the actual buffer state.
- *
- * @param zeroCapacityAtCount number of calls to capacity at which zero starts being returned.
- */
- void setZeroCapacityAtCount(Integer zeroCapacityAtCount)
- {
- if(zeroCapacityAtCount != null && zeroCapacityAtCount < 1) {
- throw new IllegalArgumentException("Value must be null, or at least 1");
- }
- _zeroCapacityAtCount = zeroCapacityAtCount;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapperTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapperTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapperTest.java
deleted file mode 100644
index 6ee1582..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapperTest.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.pour;
-import static org.apache.qpid.proton.engine.impl.TransportTestHelper.assertByteBufferContentEquals;
-import static org.apache.qpid.proton.engine.impl.TransportTestHelper.pourBufferToString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-
-import javax.net.ssl.SSLException;
-
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-/**
- * TODO unit test handshaking
- * TODO unit test closing
- * TODO unit test graceful handling of SSLEngine.wrap throwing an SSLException
- */
-public class SimpleSslTransportWrapperTest
-{
- private RememberingTransportInput _underlyingInput;
- private CannedTransportOutput _underlyingOutput;
- private SimpleSslTransportWrapper _sslWrapper;
- private CapitalisingDummySslEngine _dummySslEngine;
-
- @Rule
- public ExpectedException _expectedException = ExpectedException.none();
-
- @Before
- public void setUp()
- {
- _underlyingInput = new RememberingTransportInput();
- _underlyingOutput = new CannedTransportOutput();
- _dummySslEngine = new CapitalisingDummySslEngine();
- _sslWrapper = new SimpleSslTransportWrapper(_dummySslEngine, _underlyingInput, _underlyingOutput);
- }
-
- @Test
- public void testInputDecodesOnePacket()
- {
- String encodedBytes = "<-A->";
-
- putBytesIntoTransport(encodedBytes);
-
- assertEquals("a_", _underlyingInput.getAcceptedInput());
- assertEquals(CapitalisingDummySslEngine.MAX_ENCODED_CHUNK_SIZE, _sslWrapper.capacity());
- assertEquals(2, _dummySslEngine.getUnwrapCount());// 1 packet, 1 underflow
- assertEquals(1, _underlyingInput.getProcessCount());
- }
-
- /**
- * Note that this only feeds 1 encoded packet in at a time due to default settings of the dummy engine,
- * See {@link #testUnderlyingInputUsingSmallBuffer_receivesAllDecodedInputRequiringMultipleUnwraps}
- * for a related test that passes multiple encoded packets into the ssl wrapper at once.
- */
- @Test
- public void testInputWithMultiplePackets()
- {
- String encodedBytes = "<-A-><-B-><-C-><>";
-
- putBytesIntoTransport(encodedBytes);
-
- assertEquals("a_b_c_z_", _underlyingInput.getAcceptedInput());
- assertEquals(CapitalisingDummySslEngine.MAX_ENCODED_CHUNK_SIZE, _sslWrapper.capacity());
- assertEquals(8, _dummySslEngine.getUnwrapCount()); // (1 decode + 1 underflow) * 4 packets
- assertEquals(4, _underlyingInput.getProcessCount()); // 1 process per decoded packet
- }
-
- @Test
- public void testInputIncompletePacket_isNotPassedToUnderlyingInputUntilCompleted()
- {
- String incompleteEncodedBytes = "<-A-><-B-><-C"; // missing the trailing '>' to cause the underflow
- String remainingEncodedBytes = "-><-D->";
-
- putBytesIntoTransport(incompleteEncodedBytes);
- assertEquals("a_b_", _underlyingInput.getAcceptedInput());
- assertEquals(5, _dummySslEngine.getUnwrapCount()); // 2 * (1 decode + 1 underflow) + 1 underflow
- assertEquals(2, _underlyingInput.getProcessCount()); // 1 process per decoded packet
-
- putBytesIntoTransport(remainingEncodedBytes);
- assertEquals("a_b_c_d_", _underlyingInput.getAcceptedInput());
- assertEquals(4, _underlyingInput.getProcessCount()); // earlier + 2
- assertEquals(9, _dummySslEngine.getUnwrapCount()); // Earlier + 2 * (1 decode + 1 underflow)
- // due to way the bytes are fed in across
- // boundary of encoded packets
- }
-
- /**
- * As per {@link #testInputIncompletePacket_isNotPassedToUnderlyingInputUntilCompleted()}
- * but this time it takes TWO chunks to complete the "dangling" packet.
- */
- @Test
- public void testInputIncompletePacketInThreeParts()
- {
- String firstEncodedBytes = "<-A-><-B-><-";
- String secondEncodedBytes = "C"; // Sending this causes the impl to have to hold the data without producing more input yet
- String thirdEncodedBytes = "-><-D->";
-
- putBytesIntoTransport(firstEncodedBytes);
- assertEquals("a_b_", _underlyingInput.getAcceptedInput());
- assertEquals(5, _dummySslEngine.getUnwrapCount()); // 2 * (1 decode + 1 underflow) + 1 underflow
- assertEquals(2, _underlyingInput.getProcessCount()); // 1 process per decoded packet
-
- putBytesIntoTransport(secondEncodedBytes);
- assertEquals("a_b_", _underlyingInput.getAcceptedInput());
- assertEquals(6, _dummySslEngine.getUnwrapCount()); // earlier + 1 underflow
- assertEquals(2, _underlyingInput.getProcessCount()); // as earlier
-
- putBytesIntoTransport(thirdEncodedBytes);
- assertEquals("a_b_c_d_", _underlyingInput.getAcceptedInput());
- assertEquals(4, _underlyingInput.getProcessCount()); // 1 process per decoded packet
- assertEquals(10, _dummySslEngine.getUnwrapCount()); // Earlier + (decode + underflow) * 2
- // due to way the bytes are fed in across
- // boundary of encoded packets
- }
-
- /**
- * Tests that when a small underlying input buffer (1 byte here) is used, all of the encoded
- * data packet (5 bytes each here) can be processed despite multiple attempts being required to
- * pass the decoded bytes (2 bytes here) to the underlying input layer for processing.
- */
- @Test
- public void testUnderlyingInputUsingSmallBuffer_receivesAllDecodedInputRequiringMultipleUnderlyingProcesses()
- {
- int underlyingInputBufferSize = 1;
- int encodedPacketSize = 5;
-
- _underlyingInput.setInputBufferSize(underlyingInputBufferSize);
- assertEquals("Unexpected underlying input capacity", underlyingInputBufferSize, _underlyingInput.capacity());
-
- assertEquals("Unexpected max encoded chunk size", encodedPacketSize, CapitalisingDummySslEngine.MAX_ENCODED_CHUNK_SIZE);
-
- byte[] bytes = "<-A-><-B->".getBytes(StandardCharsets.UTF_8);
- ByteBuffer encodedByteSource = ByteBuffer.wrap(bytes);
-
- assertEquals("Unexpected initial capacity", encodedPacketSize, _sslWrapper.capacity());
-
- // Process the first 'encoded packet' (<-A->)
- int numberPoured = pour(encodedByteSource, _sslWrapper.tail());
- assertEquals("Unexpected number of bytes poured into the wrapper input buffer", encodedPacketSize, numberPoured);
- assertEquals("Unexpected position in encoded source byte buffer", encodedPacketSize * 1, encodedByteSource.position());
- assertEquals("Unexpected capacity", 0, _sslWrapper.capacity());
- _sslWrapper.process();
- assertEquals("Unexpected capacity", encodedPacketSize, _sslWrapper.capacity());
-
- assertEquals("unexpected underlying output after first wrapper process", "a_", _underlyingInput.getAcceptedInput());
- assertEquals("unexpected underlying process count after first wrapper process", 2 , _underlyingInput.getProcessCount());
-
- // Process the second 'encoded packet' (<-B->)
- numberPoured = pour(encodedByteSource, _sslWrapper.tail());
- assertEquals("Unexpected number of bytes poured into the wrapper input buffer", encodedPacketSize, numberPoured);
- assertEquals("Unexpected position in encoded source byte buffer", encodedPacketSize * 2, encodedByteSource.position());
- assertEquals("Unexpected capacity", 0, _sslWrapper.capacity());
- _sslWrapper.process();
- assertEquals("Unexpected capacity", encodedPacketSize, _sslWrapper.capacity());
-
- assertEquals("unexpected underlying output after second wrapper process", "a_b_", _underlyingInput.getAcceptedInput());
- assertEquals("unexpected underlying process count after second wrapper process", 4 , _underlyingInput.getProcessCount());
- }
-
- /**
- * Tests that when a small underlying input buffer (1 byte here) is used, all of the encoded
- * data packets (20 bytes total here) can be processed despite multiple unwraps being required
- * to process a given set of input (3 packets, 15 bytes here) and then as a result also multiple
- * attempts to pass the decoded packet (2 bytes here) to the underlying input layer for processing.
- */
- @Test
- public void testUnderlyingInputUsingSmallBuffer_receivesAllDecodedInputRequiringMultipleUnwraps()
- {
- int underlyingInputBufferSize = 1;
- int encodedPacketSize = 5;
- int sslEngineBufferSize = 15;
-
- assertEquals("Unexpected max encoded chunk size", encodedPacketSize, CapitalisingDummySslEngine.MAX_ENCODED_CHUNK_SIZE);
-
- _underlyingOutput = new CannedTransportOutput();
- _underlyingInput = new RememberingTransportInput();
- _underlyingInput.setInputBufferSize(underlyingInputBufferSize);
- assertEquals("Unexpected underlying input capacity", underlyingInputBufferSize, _underlyingInput.capacity());
-
- // Create a dummy ssl engine that has buffers that holds multiple encoded/decoded
- // packets, but still can't fit all of the input
- _dummySslEngine = new CapitalisingDummySslEngine();
- _dummySslEngine.setApplicationBufferSize(sslEngineBufferSize);
- _dummySslEngine.setPacketBufferSize(sslEngineBufferSize);
-
- _sslWrapper = new SimpleSslTransportWrapper(_dummySslEngine, _underlyingInput, _underlyingOutput);
-
- byte[] bytes = "<-A-><-B-><-C-><-D->".getBytes(StandardCharsets.UTF_8);
- ByteBuffer encodedByteSource = ByteBuffer.wrap(bytes);
-
- assertEquals("Unexpected initial capacity", sslEngineBufferSize, _sslWrapper.capacity());
-
- // Process the first three 'encoded packets' (<-A-><-B-><-C->). This will require 3 'proper' unwraps, and
- // as each decoded packet is 2 bytes, each of those will require 2 underlying input processes.
- int numberPoured = pour(encodedByteSource, _sslWrapper.tail());
- assertEquals("Unexpected number of bytes poured into the wrapper input buffer", sslEngineBufferSize, numberPoured);
- assertEquals("Unexpected position in encoded source byte buffer", encodedPacketSize * 3, encodedByteSource.position());
- assertEquals("Unexpected capacity", 0, _sslWrapper.capacity());
-
- _sslWrapper.process();
-
- assertEquals("a_b_c_", _underlyingInput.getAcceptedInput());
- assertEquals("Unexpected capacity", sslEngineBufferSize, _sslWrapper.capacity());
- assertEquals("unexpected underlying process count after wrapper process", 6 , _underlyingInput.getProcessCount());
- assertEquals(4, _dummySslEngine.getUnwrapCount()); // 3 decodes + 1 underflow
-
- // Process the fourth 'encoded packet' (<-D->)
- numberPoured = pour(encodedByteSource, _sslWrapper.tail());
- assertEquals("Unexpected number of bytes poured into the wrapper input buffer", encodedPacketSize, numberPoured);
- assertEquals("Unexpected position in encoded source byte buffer", encodedPacketSize * 4, encodedByteSource.position());
- assertEquals("Unexpected capacity", sslEngineBufferSize - encodedPacketSize, _sslWrapper.capacity());
-
- _sslWrapper.process();
-
- assertEquals("a_b_c_d_", _underlyingInput.getAcceptedInput());
- assertEquals("Unexpected capacity", sslEngineBufferSize, _sslWrapper.capacity());
- assertEquals("unexpected underlying process count after second wrapper process", 8 , _underlyingInput.getProcessCount());
- assertEquals(6, _dummySslEngine.getUnwrapCount()); // earlier + 1 decode + 1 underflow
- }
-
- /**
- * Tests that an exception is thrown when the underlying input has zero capacity when the call
- * with newly decoded input is initially made.
- */
- @Test (timeout = 5000)
- public void testUnderlyingInputHasZeroCapacityInitially()
- {
- int underlyingInputBufferSize = 1;
- int encodedPacketSize = 5;
-
- assertEquals("Unexpected max encoded chunk size", encodedPacketSize, CapitalisingDummySslEngine.MAX_ENCODED_CHUNK_SIZE);
-
- // Set the input to have a small buffer, but then return 0 from the 2nd capacity call onward.
- _underlyingInput.setInputBufferSize(underlyingInputBufferSize);
- _underlyingInput.setZeroCapacityAtCount(2);
- assertEquals("Unexpected initial underlying input capacity", underlyingInputBufferSize, _underlyingInput.capacity());
- assertEquals("Unexpected underlying input capacity", 0, _underlyingInput.capacity());
-
- // Now try decoding the input, should fail
- byte[] bytes = "<-A->".getBytes(StandardCharsets.UTF_8);
- ByteBuffer encodedByteSource = ByteBuffer.wrap(bytes);
-
- assertEquals("Unexpected initial wrapper capacity", encodedPacketSize, _sslWrapper.capacity());
-
- int numberPoured = pour(encodedByteSource, _sslWrapper.tail());
- assertEquals("Unexpected number of bytes poured into the wrapper input buffer", encodedPacketSize, numberPoured);
- assertEquals("Unexpected position in encoded source byte buffer", encodedPacketSize, encodedByteSource.position());
- assertEquals("Unexpected wrapper capacity", 0, _sslWrapper.capacity());
-
- try
- {
- _sslWrapper.process();
- fail("Expected an exception");
- }
- catch (TransportException te)
- {
- // expected.
- }
-
- //Check we got no chars of decoded output.
- assertEquals("", _underlyingInput.getAcceptedInput());
- assertEquals("Unexpected wrapper capacity", -1, _sslWrapper.capacity());
- assertEquals("unexpected underlying process count after wrapper process", 0 , _underlyingInput.getProcessCount());
- assertEquals("unexpected underlying capacity count after wrapper process", 3, _underlyingInput.getCapacityCount());
- assertEquals("unexpected underlying capacity after wrapper process", 0 , _underlyingInput.capacity());
- assertEquals(1, _dummySslEngine.getUnwrapCount()); // 1 decode (then exception)
- }
-
- /**
- * Tests that an exception is thrown when the underlying input has no capacity (but isn't closed)
- * during the process of incrementally passing the decoded bytes to its smaller input buffer
- * for processing.
- */
- @Test (timeout = 5000)
- public void testUnderlyingInputHasZeroCapacityMidProcessing()
- {
- int underlyingInputBufferSize = 1;
- int encodedPacketSize = 5;
-
- assertEquals("Unexpected max encoded chunk size", encodedPacketSize, CapitalisingDummySslEngine.MAX_ENCODED_CHUNK_SIZE);
-
- // Set the input to have a small buffer, but then return 0 from the 3rd capacity call onward.
- _underlyingInput.setInputBufferSize(underlyingInputBufferSize);
- _underlyingInput.setZeroCapacityAtCount(3);
- assertEquals("Unexpected initial underlying input capacity", underlyingInputBufferSize, _underlyingInput.capacity());
-
- // Now try decoding the input, should fail
- byte[] bytes = "<-A->".getBytes(StandardCharsets.UTF_8);
- ByteBuffer encodedByteSource = ByteBuffer.wrap(bytes);
-
- assertEquals("Unexpected initial wrapper capacity", encodedPacketSize, _sslWrapper.capacity());
-
- int numberPoured = pour(encodedByteSource, _sslWrapper.tail());
- assertEquals("Unexpected number of bytes poured into the wrapper input buffer", encodedPacketSize, numberPoured);
- assertEquals("Unexpected position in encoded source byte buffer", encodedPacketSize, encodedByteSource.position());
- assertEquals("Unexpected wrapper capacity", 0, _sslWrapper.capacity());
-
- try
- {
- _sslWrapper.process();
- fail("Expected an exception");
- }
- catch (TransportException te)
- {
- // expected.
- }
-
- //Check we got the first char (a) of decoded output, but not the second (_).
- assertEquals("a", _underlyingInput.getAcceptedInput());
- assertEquals("Unexpected wrapper capacity", -1, _sslWrapper.capacity());
- assertEquals("unexpected underlying process count after wrapper process", 1 , _underlyingInput.getProcessCount());
- assertEquals("unexpected underlying capacity count after wrapper process", 3, _underlyingInput.getCapacityCount());
- assertEquals("unexpected underlying capacity after wrapper process", 0 , _underlyingInput.capacity());
- assertEquals(1, _dummySslEngine.getUnwrapCount()); // 1 decode (then exception)
- }
-
- @Test
- public void testSslUnwrapThrowsException_returnsErrorResultAndRefusesFurtherInput() throws Exception
- {
- SSLException sslException = new SSLException("unwrap exception");
- _dummySslEngine.rejectNextEncodedPacket(sslException);
-
- _sslWrapper.tail().put("<-A->".getBytes(StandardCharsets.UTF_8));
- _sslWrapper.process();
- assertEquals(_sslWrapper.capacity(), Transport.END_OF_STREAM);
- }
-
- @Test
- public void testUnderlyingInputReturnsErrorResult_returnsErrorResultAndRefusesFurtherInput() throws Exception
- {
- String underlyingErrorDescription = "dummy underlying error";
- _underlyingInput.rejectNextInput(underlyingErrorDescription);
-
- _sslWrapper.tail().put("<-A->".getBytes(StandardCharsets.UTF_8));
-
- try {
- _sslWrapper.process();
- fail("no exception");
- } catch (TransportException e) {
- assertEquals(underlyingErrorDescription, e.getMessage());
- }
- }
-
- @Test
- public void testHeadIsReadOnly()
- {
- _underlyingOutput.setOutput("");
- assertTrue(_sslWrapper.head().isReadOnly());
- }
-
- @Test
- public void testOutputEncodesOnePacket()
- {
- _underlyingOutput.setOutput("a_");
-
- ByteBuffer outputBuffer = _sslWrapper.head();
-
- assertByteBufferContentEquals("<-A->".getBytes(StandardCharsets.UTF_8), outputBuffer);
- }
-
- @Test
- public void testOutputEncodesMultiplePackets()
- {
- _underlyingOutput.setOutput("a_b_c_");
-
- assertEquals("<-A-><-B-><-C->", getAllBytesFromTransport());
- }
-
- @Test
- public void testOutputEncodesMultiplePacketsOfVaryingSize()
- {
- _underlyingOutput.setOutput("z_a_b_");
-
- assertEquals("<><-A-><-B->", getAllBytesFromTransport());
- }
-
- @Test
- public void testClientConsumesEncodedOutputInMultipleChunks()
- {
- _underlyingOutput.setOutput("a_b_");
-
- {
- ByteBuffer buffer = _sslWrapper.head();
- String output = pourBufferToString(buffer, 2);
- assertEquals("<-", output);
- _sslWrapper.pop(buffer.position());
- }
-
- {
- ByteBuffer buffer = _sslWrapper.head();
- String output = pourBufferToString(buffer, 3);
- assertEquals("A->", output);
- _sslWrapper.pop(buffer.position());
- }
-
- assertEquals("<-B->", getAllBytesFromTransport());
- }
-
- @Test
- public void testNoOutputToEncode()
- {
- _underlyingOutput.setOutput("");
-
- assertFalse(_sslWrapper.head().hasRemaining());
- }
-
- private void putBytesIntoTransport(String encodedBytes)
- {
- ByteBuffer byteBuffer = ByteBuffer.wrap(encodedBytes.getBytes(StandardCharsets.UTF_8));
- while(byteBuffer.hasRemaining())
- {
- int numberPoured = pour(byteBuffer, _sslWrapper.tail());
- assertTrue("We should be able to pour some bytes into the input buffer",
- numberPoured > 0);
- _sslWrapper.process();
- }
- }
-
- private String getAllBytesFromTransport()
- {
- StringBuilder readBytes = new StringBuilder();
- while (true)
- {
- int pending = _sslWrapper.pending();
- if (pending > 0) {
- ByteBuffer buffer = _sslWrapper.head();
- readBytes.append(pourBufferToString(buffer));
- _sslWrapper.pop(pending);
- continue;
- } else {
- break;
- }
- }
-
- return readBytes.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslEngineFacadeFactoryTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslEngineFacadeFactoryTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslEngineFacadeFactoryTest.java
deleted file mode 100644
index 84ba8cb..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslEngineFacadeFactoryTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.net.URL;
-
-import org.junit.Test;
-
-public class SslEngineFacadeFactoryTest {
-
- private static final String PASSWORD = "unittest";
-
- @Test
- public void testCertifcateLoad() {
- String ipFile = resolveFilename("cert.pem.txt");
- SslEngineFacadeFactory factory = new SslEngineFacadeFactory();
-
- assertNotNull("Certificate was NULL", factory.readCertificate(ipFile));
- }
-
- @Test
- public void testLoadKey() {
- String keyFile = resolveFilename("key.pem.txt");
- SslEngineFacadeFactory factory = new SslEngineFacadeFactory();
-
- assertNotNull("Key was NULL", factory.readPrivateKey(keyFile, PASSWORD));
- }
-
- @Test
- public void testLoadUnencryptedPrivateKey(){
- String keyFile = resolveFilename("private-key-clear.pem.txt");
- SslEngineFacadeFactory factory = new SslEngineFacadeFactory();
-
- assertNotNull("Key was NULL", factory.readPrivateKey(keyFile, null));
- }
-
- @Test
- public void testLoadUnencryptedPKCS8PrivateKey(){
- String keyFile = resolveFilename("private-key-clear-pkcs8.pem.txt");
- SslEngineFacadeFactory factory = new SslEngineFacadeFactory();
-
- assertNotNull("Key was NULL", factory.readPrivateKey(keyFile, null));
- }
-
- private String resolveFilename(String testFilename) {
- URL resourceUri = this.getClass().getResource(testFilename);
-
- assertNotNull("Failed to load file: " + testFilename, resourceUri);
-
- String fName = resourceUri.getPath();
-
- return fName;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapperTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapperTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapperTest.java
deleted file mode 100644
index 3a14837..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapperTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import static org.apache.qpid.proton.engine.impl.TransportTestHelper.assertByteBufferContentEquals;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.engine.impl.TransportWrapper;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-public class SslHandshakeSniffingTransportWrapperTest
-{
- private static final byte[] EXAMPLE_SSL_V3_HANDSHAKE_BYTES = new byte[] {0x16, 0x03, 0x02, 0x00, 0x31};
- private static final byte[] EXAMPLE_SSL_V2_HANDSHAKE_BYTES = new byte[] {0x00, 0x00, 0x01, 0x03, 0x00};
-
- private SslTransportWrapper _secureTransportWrapper = mock(SslTransportWrapper.class);
- private TransportWrapper _plainTransportWrapper = mock(TransportWrapper.class);
- private SslTransportWrapper _sniffingWrapper = new SslHandshakeSniffingTransportWrapper(_secureTransportWrapper, _plainTransportWrapper);
-
- @Rule
- public ExpectedException _expectedException = ExpectedException.none();
-
- @Test
- public void testGetInputBufferGetOutputBufferWithNonSsl()
- {
- testInputAndOutput("INPUT".getBytes(), _plainTransportWrapper);
- }
-
- @Test
- public void testWithSSLv2()
- {
- testInputAndOutput(EXAMPLE_SSL_V2_HANDSHAKE_BYTES, _secureTransportWrapper);
- }
-
- @Test
- public void testWithSSLv3TLS()
- {
- testInputAndOutput(EXAMPLE_SSL_V3_HANDSHAKE_BYTES, _secureTransportWrapper);
- }
-
- private void testInputAndOutput(byte[] input, TransportWrapper transportThatShouldBeUsed)
- {
- byte[] output = "OUTPUT".getBytes();
-
- ByteBuffer underlyingInputBuffer = ByteBuffer.allocate(1024);
- ByteBuffer underlyingOutputBuffer = ByteBuffer.wrap(output);
-
- // set up underlying transport
- when(transportThatShouldBeUsed.tail()).thenReturn(underlyingInputBuffer);
- when(transportThatShouldBeUsed.head()).thenReturn(underlyingOutputBuffer);
-
- // do input and verify underlying calls were made
- ByteBuffer inputBuffer = _sniffingWrapper.tail();
- inputBuffer.put(input);
- _sniffingWrapper.process();
-
- verify(transportThatShouldBeUsed).tail();
- verify(transportThatShouldBeUsed).process();
-
- // check the wrapped input actually received the expected bytes
- underlyingInputBuffer.flip();
- assertByteBufferContentEquals(input, underlyingInputBuffer);
-
- // do output and check we get the correct transport's output
- ByteBuffer outputBuffer = _sniffingWrapper.head();
- verify(transportThatShouldBeUsed).head();
-
- assertByteBufferContentEquals(output, outputBuffer);
- int consumed = outputBuffer.position();
- _sniffingWrapper.pop(consumed);
- verify(transportThatShouldBeUsed).pop(consumed);
-
- verifyZeroInteractionsWithOtherTransport(transportThatShouldBeUsed);
- }
-
- @Test
- public void testTooFewBytesToMakeDetermination()
- {
- byte[] sourceBuffer = new byte[] {0x00};
-
- try
- {
- _sniffingWrapper.tail().put(sourceBuffer);
- _sniffingWrapper.close_tail();
-
- _expectedException.expect(TransportException.class);
- _sniffingWrapper.process();
- }
- finally
- {
- verifyZeroInteractions(_secureTransportWrapper, _plainTransportWrapper);
- }
- }
-
- @Test
- public void testGetSslAttributesWhenProtocolIsNotYetDetermined_returnNull()
- {
- assertEquals("Cipher name should be null", null, _sniffingWrapper.getCipherName());
- assertEquals("Protocol name should be null", null, _sniffingWrapper.getProtocolName());
- verifyZeroInteractions(_secureTransportWrapper, _plainTransportWrapper);
- }
-
- @Test
- public void testGetSslAttributesWhenUsingNonSsl_returnNull()
- {
- testGetSslAttributes("INPUT".getBytes(), _plainTransportWrapper, null, null);
- }
-
- /**
- * Tests {@link SslHandshakeSniffingTransportWrapper#getCipherName()}
- * and {@link SslHandshakeSniffingTransportWrapper#getProtocolName()}.
- */
- @Test
- public void testGetSslAttributesWhenUsingSsl()
- {
- String cipherName = "testCipherName";
- String protocolName = "testProtocolName";
- when(_secureTransportWrapper.getCipherName()).thenReturn(cipherName);
- when(_secureTransportWrapper.getProtocolName()).thenReturn(protocolName);
-
- testGetSslAttributes(EXAMPLE_SSL_V2_HANDSHAKE_BYTES, _secureTransportWrapper, cipherName, protocolName);
- }
-
- private void testGetSslAttributes(
- byte[] input, TransportWrapper transportThatShouldBeUsed,
- String expectedCipherName, String expectedProtocolName)
- {
- ByteBuffer underlyingInputBuffer = ByteBuffer.allocate(1024);
- when(transportThatShouldBeUsed.tail()).thenReturn(underlyingInputBuffer);
-
- _sniffingWrapper.tail().put(input);
- _sniffingWrapper.process();
-
- assertEquals(expectedCipherName, _sniffingWrapper.getCipherName());
- assertEquals(expectedProtocolName, _sniffingWrapper.getProtocolName());
-
- verifyZeroInteractionsWithOtherTransport(transportThatShouldBeUsed);
- }
-
- private void verifyZeroInteractionsWithOtherTransport(TransportWrapper transportThatShouldBeUsed)
- {
- final TransportWrapper transportThatShouldNotBeUsed;
- if(transportThatShouldBeUsed == _plainTransportWrapper)
- {
- transportThatShouldNotBeUsed = _secureTransportWrapper;
- }
- else
- {
- transportThatShouldNotBeUsed = _plainTransportWrapper;
- }
-
- verifyZeroInteractions(transportThatShouldNotBeUsed);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/message/impl/MessageImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/message/impl/MessageImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/message/impl/MessageImplTest.java
deleted file mode 100644
index 6070745..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/message/impl/MessageImplTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.message.impl;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.messaging.Data;
-import org.apache.qpid.proton.message.Message;
-import org.junit.Test;
-
-public class MessageImplTest
-{
- private static final long DATA_SECTION_ULONG_DESCRIPTOR = 0x0000000000000075L;
-
- @Test
- public void testEncodeOfMessageWithSmallDataBodyOnly()
- {
- doMessageEncodingWithDataBodySectionTestImpl(5);
- }
-
- @Test
- public void testEncodeOfMessageWithLargerDataBodyOnly()
- {
- doMessageEncodingWithDataBodySectionTestImpl(1024);
- }
-
- void doMessageEncodingWithDataBodySectionTestImpl(int bytesLength)
- {
- byte[] bytes = generateByteArray(bytesLength);
-
- byte[] expectedBytes = generateExpectedDataSectionBytes(bytes);
- byte[] encodedBytes = new byte[expectedBytes.length];
-
- Message msg = Message.Factory.create();
- msg.setBody(new Data(new Binary(bytes)));
-
- int encodedLength = msg.encode(encodedBytes, 0, encodedBytes.length);
-
- assertArrayEquals("Encoded bytes do not match expectation", expectedBytes, encodedBytes);
- assertEquals("Encoded length different than expected length", encodedLength, encodedBytes.length);
- }
-
- private byte[] generateByteArray(int bytesLength)
- {
- byte[] bytes = new byte[bytesLength];
- for(int i = 0; i < bytesLength; i++)
- {
- bytes [i] = (byte) (i % 10);
- }
-
- return bytes;
- }
-
- /*
- * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-data
- * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html
- *
- * ulong encodings:
- * <encoding code="0x80" category="fixed" width="8" label="64-bit unsigned integer in network byte order"/>
- * <encoding name="smallulong" code="0x53" category="fixed" width="1" label="unsigned long value in the range 0 to 255 inclusive"/>
- * <encoding name="ulong0" code="0x44" category="fixed" width="0" label="the ulong value 0"/>
- *
- * binary encodings:
- * <encoding name="vbin8" code="0xa0" category="variable" width="1" label="up to 2^8 - 1 octets of binary data"/>
- * <encoding name="vbin32" code="0xb0" category="variable" width="4" label="up to 2^32 - 1 octets of binary data"/>
- */
- byte[] generateExpectedDataSectionBytes(final byte[] payloadBytes)
- {
- int dataBytesLength = 1; // 0x00 for described-type constructor start
- dataBytesLength += 1; // smallulong encoding format for data section descriptor
- dataBytesLength += 1; // smallulong 8bit value
- dataBytesLength += 1; // vbin variable-width binary encoding format.
- if (payloadBytes.length > 255)
- {
- dataBytesLength += 4; // 32bit length field.
- }
- else
- {
- dataBytesLength += 1; // 8bit length field.
- }
- dataBytesLength += payloadBytes.length; // section payload length.
-
- ByteBuffer buffer = ByteBuffer.allocate(dataBytesLength);
-
- buffer.put((byte) 0x00); // 0x00 for described-type constructor start
- buffer.put((byte) 0x53); // smallulong encoding format for data section descriptor
- buffer.put((byte) DATA_SECTION_ULONG_DESCRIPTOR); // smallulong 8bit value
- if (payloadBytes.length > 255)
- {
- buffer.put((byte) 0xb0); // vbin32 variable-width binary encoding format.
- buffer.putInt(payloadBytes.length); // 32bit length field.
- }
- else
- {
- buffer.put((byte) 0xa0); // vbin8 variable-width binary encoding format.
- buffer.put((byte) payloadBytes.length); // 8bit length field.
- }
- buffer.put(payloadBytes); // The actual content of given length.
-
- assertEquals("Unexpected buffer position", dataBytesLength, buffer.position());
-
- return buffer.array();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/messenger/impl/AddressTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/messenger/impl/AddressTest.java b/proton-j/src/test/java/org/apache/qpid/proton/messenger/impl/AddressTest.java
deleted file mode 100644
index 77154b6..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/messenger/impl/AddressTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.proton.messenger.impl;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class AddressTest {
-
- @SuppressWarnings("deprecation")
- private void testParse(String url, String scheme, String user, String pass, String host, String port, String name)
- {
- Address address = new Address(url);
- assertEquals(scheme, address.getScheme());
- assertEquals(user, address.getUser());
- assertEquals(pass, address.getPass());
- assertEquals(host, address.getHost());
- assertEquals(port, address.getPort());
- assertEquals(url, address.toString());
- }
-
- @Test
- public void addressTests()
- {
- testParse("host", null, null, null, "host", null, null);
- testParse("host:423", null, null, null, "host", "423", null);
- testParse("user@host", null, "user", null, "host", null, null);
- testParse("user:1243^&^:pw@host:423", null, "user", "1243^&^:pw", "host", "423", null);
- testParse("user:1243^&^:pw@host:423/Foo.bar:90087", null, "user", "1243^&^:pw", "host", "423", "Foo.bar:90087");
- testParse("user:1243^&^:pw@host:423/Foo.bar:90087@somewhere", null, "user", "1243^&^:pw", "host", "423", "Foo.bar:90087@somewhere");
- testParse("[::1]", null, null, null, "::1", null, null);
- testParse("[::1]:amqp", null, null, null, "::1", "amqp", null);
- testParse("user@[::1]", null, "user", null, "::1", null, null);
- testParse("user@[::1]:amqp", null, "user", null, "::1", "amqp", null);
- testParse("user:1243^&^:pw@[::1]:amqp", null, "user", "1243^&^:pw", "::1", "amqp", null);
- testParse("user:1243^&^:pw@[::1]:amqp/Foo.bar:90087", null, "user", "1243^&^:pw", "::1", "amqp", "Foo.bar:90087");
- testParse("user:1243^&^:pw@[::1:amqp/Foo.bar:90087", null, "user", "1243^&^:pw", "[", ":1:amqp", "Foo.bar:90087");
- testParse("user:1243^&^:pw@::1]:amqp/Foo.bar:90087", null, "user", "1243^&^:pw", "", ":1]:amqp", "Foo.bar:90087");
- testParse("amqp://user@[::1]", "amqp", "user", null, "::1", null, null);
- testParse("amqp://user@[::1]:amqp", "amqp", "user", null, "::1", "amqp", null);
- testParse("amqp://user@[1234:52:0:1260:f2de:f1ff:fe59:8f87]:amqp", "amqp", "user", null, "1234:52:0:1260:f2de:f1ff:fe59:8f87", "amqp", null);
- testParse("amqp://user:1243^&^:pw@[::1]:amqp", "amqp", "user", "1243^&^:pw", "::1", "amqp", null);
- testParse("amqp://user:1243^&^:pw@[::1]:amqp/Foo.bar:90087", "amqp", "user", "1243^&^:pw", "::1", "amqp", "Foo.bar:90087");
- testParse("amqp://host", "amqp", null, null, "host", null, null);
- testParse("amqp://user@host", "amqp", "user", null, "host", null, null);
- testParse("amqp://user@host/path:%", "amqp", "user", null, "host", null, "path:%");
- testParse("amqp://user@host:5674/path:%", "amqp", "user", null, "host", "5674", "path:%");
- testParse("amqp://user@host/path:%", "amqp", "user", null, "host", null, "path:%");
- testParse("amqp://bigbird@host/queue@host", "amqp", "bigbird", null, "host", null, "queue@host");
- testParse("amqp://host/queue@host", "amqp", null, null, "host", null, "queue@host");
- testParse("amqp://host:9765/queue@host", "amqp", null, null, "host", "9765", "queue@host");
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java b/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java
deleted file mode 100644
index 387446e..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java
+++ /dev/null
@@ -1,692 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-import junit.framework.AssertionFailedError;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Event.Type;
-import org.apache.qpid.proton.engine.Handler;
-import org.apache.qpid.proton.engine.HandlerException;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.reactor.impl.AcceptorImpl;
-import org.apache.qpid.proton.reactor.impl.LeakTestReactor;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class ReactorTest {
-
- public ReactorFactory reactorFactory;
- private Reactor reactor;
-
- private static interface ReactorFactory {
- Reactor newReactor() throws IOException;
- }
-
- // Parameterize the tests, and run them once with a reactor obtained by calling
- // 'Proton.reactor()' and once with the LeakTestReactor.
- @Parameters
- public static Collection<ReactorFactory[]> data() throws IOException {
- ReactorFactory classicReactor = new ReactorFactory() {
- @Override public Reactor newReactor() throws IOException {
- return Proton.reactor();
- }
- };
- ReactorFactory newLeakDetection = new ReactorFactory() {
- @Override public Reactor newReactor() throws IOException {
- return new LeakTestReactor();
- }
- };
- return Arrays.asList(new ReactorFactory[][]{{classicReactor}, {newLeakDetection}});
- }
-
- public ReactorTest(ReactorFactory reactorFactory) {
- this.reactorFactory = reactorFactory;
- }
-
- @Before
- public void before() throws IOException {
- reactor = reactorFactory.newReactor();
- }
-
- private void checkForLeaks() {
- if (reactor instanceof LeakTestReactor) {
- ((LeakTestReactor)reactor).assertNoLeaks();
- }
- }
-
- @After
- public void after() {
- checkForLeaks();
- }
-
- /**
- * Tests that creating a reactor and running it:
- * <ul>
- * <li>Doesn't throw any exceptions.</li>
- * <li>Returns immediately from the run method (as there is no more work to do).</li>
- * </ul>
- * @throws IOException
- */
- @Test
- public void runEmpty() throws IOException {
- assertNotNull(reactor);
- reactor.run();
- reactor.free();
- }
-
- private static class TestHandler extends BaseHandler {
- private final ArrayList<Type> actual = new ArrayList<Type>();
-
- @Override
- public void onUnhandled(Event event) {
- assertNotNull(event.getReactor());
- actual.add(event.getType());
- }
-
- public void assertEvents(Type...expected) {
- assertArrayEquals(expected, actual.toArray());
- }
- }
-
- /**
- * Tests adding a handler to a reactor and running the reactor. The
- * expected behaviour is for the reactor to return, and a number of reactor-
- * related events to have been delivered to the handler.
- * @throws IOException
- */
- @Test
- public void handlerRun() throws IOException {
- Handler handler = reactor.getHandler();
- assertNotNull(handler);
- TestHandler testHandler = new TestHandler();
- handler.add(testHandler);
- reactor.run();
- reactor.free();
- testHandler.assertEvents(Type.REACTOR_INIT, Type.SELECTABLE_INIT, Type.SELECTABLE_UPDATED, Type.SELECTABLE_FINAL, Type.REACTOR_FINAL);
- }
-
- /**
- * Tests basic operation of the Reactor.connection method by creating a
- * connection from a reactor, then running the reactor. The expected behaviour
- * is for:
- * <ul>
- * <li>The reactor to end immediately.</li>
- * <li>The handler associated with the connection receives an init event.</li>
- * <li>The connection is one of the reactor's children.</li>
- * </ul>
- * @throws IOException
- */
- @Test
- public void connection() throws IOException {
- TestHandler connectionHandler = new TestHandler();
- Connection connection = reactor.connection(connectionHandler);
- assertNotNull(connection);
- assertTrue("connection should be one of the reactor's children", reactor.children().contains(connection));
- reactor.setConnectionHost(connection, "127.0.0.1", 5672);
- assertEquals("connection address configuration failed",
- reactor.getConnectionAddress(connection), "127.0.0.1:5672");
- TestHandler reactorHandler = new TestHandler();
- reactor.getHandler().add(reactorHandler);
- reactor.run();
- reactor.free();
- reactorHandler.assertEvents(Type.REACTOR_INIT, Type.SELECTABLE_INIT, Type.SELECTABLE_UPDATED, Type.SELECTABLE_FINAL, Type.REACTOR_FINAL);
- connectionHandler.assertEvents(Type.CONNECTION_INIT);
- }
-
- /**
- * Tests operation of the Reactor.acceptor method by creating an acceptor
- * which is immediately closed by the reactor. The expected behaviour is for:
- * <ul>
- * <li>The reactor to end immediately (as it has no more work to process).</li>
- * <li>The handler, associated with the acceptor, to receive no events.</li>
- * <li>For it's lifetime, the acceptor is one of the reactor's children.</li>
- * </ul>
- * @throws IOException
- */
- @Test
- public void acceptor() throws IOException {
- final Acceptor acceptor = reactor.acceptor("127.0.0.1", 0);
- assertNotNull(acceptor);
- assertTrue("acceptor should be one of the reactor's children", reactor.children().contains(acceptor));
- TestHandler acceptorHandler = new TestHandler();
- BaseHandler.setHandler(acceptor, acceptorHandler);
- reactor.getHandler().add(new BaseHandler() {
- @Override
- public void onReactorInit(Event event) {
- acceptor.close();
- }
- });
- reactor.run();
- reactor.free();
- acceptorHandler.assertEvents();
- assertFalse("acceptor should have been removed from the reactor's children", reactor.children().contains(acceptor));
- }
-
- private static class ServerHandler extends TestHandler {
- private Acceptor acceptor;
- public void setAcceptor(Acceptor acceptor) {
- this.acceptor = acceptor;
- }
- @Override
- public void onConnectionRemoteOpen(Event event) {
- super.onConnectionRemoteOpen(event);
- event.getConnection().open();
- }
- @Override
- public void onConnectionRemoteClose(Event event) {
- super.onConnectionRemoteClose(event);
- acceptor.close();
- event.getConnection().close();
- event.getConnection().free();
- }
- }
-
- /**
- * Tests end to end behaviour of the reactor by creating an acceptor and then
- * a connection (which connects to the port the acceptor is listening on).
- * As soon as the connection is established, both the acceptor and connection
- * are closed. The events generated by the acceptor and the connection are
- * compared to a set of expected events.
- * @throws IOException
- */
- @Test
- public void connect() throws IOException {
- ServerHandler sh = new ServerHandler();
- Acceptor acceptor = reactor.acceptor("127.0.0.1", 0, sh);
- final int listeningPort = ((AcceptorImpl)acceptor).getPortNumber();
- sh.setAcceptor(acceptor);
-
- class ClientHandler extends TestHandler {
- @Override
- public void onConnectionInit(Event event) {
- super.onConnectionInit(event);
- event.getReactor().setConnectionHost(event.getConnection(),
- "127.0.0.1",
- listeningPort);
- event.getConnection().open();
- }
- @Override
- public void onConnectionRemoteOpen(Event event) {
- super.onConnectionRemoteOpen(event);
- event.getConnection().close();
- }
- @Override
- public void onConnectionRemoteClose(Event event) {
- super.onConnectionRemoteClose(event);
- event.getConnection().free();
- }
- }
- ClientHandler ch = new ClientHandler();
- Connection connection = reactor.connection(ch);
-
- assertTrue("acceptor should be one of the reactor's children", reactor.children().contains(acceptor));
- assertTrue("connection should be one of the reactor's children", reactor.children().contains(connection));
-
- reactor.run();
- reactor.free();
-
- assertFalse("acceptor should have been removed from the reactor's children", reactor.children().contains(acceptor));
- assertFalse("connection should have been removed from the reactor's children", reactor.children().contains(connection));
- sh.assertEvents(Type.CONNECTION_INIT, Type.CONNECTION_BOUND,
- // XXX: proton-c generates a PN_TRANSPORT event here
- Type.CONNECTION_REMOTE_OPEN, Type.CONNECTION_LOCAL_OPEN,
- Type.TRANSPORT, Type.CONNECTION_REMOTE_CLOSE,
- Type.TRANSPORT_TAIL_CLOSED, Type.CONNECTION_LOCAL_CLOSE,
- Type.TRANSPORT, Type.TRANSPORT_HEAD_CLOSED,
- Type.TRANSPORT_CLOSED, Type.CONNECTION_UNBOUND,
- Type.CONNECTION_FINAL);
-
- ch.assertEvents(Type.CONNECTION_INIT, Type.CONNECTION_LOCAL_OPEN,
- Type.CONNECTION_BOUND,
- // XXX: proton-c generates two PN_TRANSPORT events here
- Type.CONNECTION_REMOTE_OPEN, Type.CONNECTION_LOCAL_CLOSE,
- Type.TRANSPORT, Type.TRANSPORT_HEAD_CLOSED,
- Type.CONNECTION_REMOTE_CLOSE, Type.TRANSPORT_TAIL_CLOSED,
- Type.TRANSPORT_CLOSED, Type.CONNECTION_UNBOUND,
- Type.CONNECTION_FINAL);
-
- }
-
- private String checkVhost(String vhost) throws IOException {
-
- class ServerVhostHandler extends ServerHandler {
- public String peerVhost;
-
- @Override
- public void onConnectionRemoteOpen(Event event) {
- super.onConnectionRemoteOpen(event);
- peerVhost = event.getConnection().getRemoteHostname();
- }
- }
-
- class ClientVhostHandler extends TestHandler {
- private int port;
- private String vhost;
-
- ClientVhostHandler(String vhost, int port) {
- this.port = port;
- this.vhost = vhost;
- }
-
- @Override
- public void onConnectionInit(Event event) {
- super.onConnectionInit(event);
- event.getReactor().setConnectionHost(event.getConnection(),
- "127.0.0.1", port);
- if (vhost != null) {
- event.getConnection().setHostname(vhost);
- }
- event.getConnection().open();
- }
- @Override
- public void onConnectionRemoteOpen(Event event) {
- super.onConnectionRemoteOpen(event);
- event.getConnection().close();
- }
- @Override
- public void onConnectionRemoteClose(Event event) {
- super.onConnectionRemoteClose(event);
- event.getConnection().free();
- }
- }
- ServerVhostHandler sh = new ServerVhostHandler();
- Acceptor acceptor = reactor.acceptor("127.0.0.1", 0, sh);
- final int listeningPort = ((AcceptorImpl)acceptor).getPortNumber();
- sh.setAcceptor(acceptor);
-
- ClientVhostHandler ch = new ClientVhostHandler(vhost, listeningPort);
- Connection connection = reactor.connection(ch);
-
- reactor.run();
- reactor.free();
- checkForLeaks();
-
- return sh.peerVhost;
- }
-
- /**
- * Tests the virtual host default configuration - should be set to host
- * used for the connection.
- * @throws IOException
- **/
- @Test
- public void checkVhostDefault() throws IOException {
- String vhost = checkVhost(null);
- assertEquals("The default virtual host is not correct",
- "127.0.0.1", vhost);
- }
-
- /**
- * Tests the virtual host override - should be set to connection's
- * hostname.
- * @throws IOException
- **/
- @Test
- public void checkVhostOverride() throws IOException {
- String vhost = checkVhost("my.vhost");
- assertEquals("The virtual host is not correct",
- "my.vhost", vhost);
- }
-
- /**
- * Tests eliminating the virtual host configuration - expects no vhost for
- * the connection.
- * @throws IOException
- **/
- @Test
- public void checkNoVhost() throws IOException {
- String vhost = checkVhost("");
- assertEquals("The virtual host is present",
- null, vhost);
- }
-
-
- private static class SinkHandler extends BaseHandler {
- protected int received = 0;
-
- @Override
- public void onDelivery(Event event) {
- Delivery dlv = event.getDelivery();
- if (!dlv.isPartial()) {
- dlv.settle();
- ++received;
- }
- }
- }
-
- private static class SourceHandler extends BaseHandler {
- private int remaining;
-
- protected SourceHandler(int count) {
- remaining = count;
- }
-
- @Override
- public void onConnectionInit(Event event) {
- Connection conn = event.getConnection();
- Session ssn = conn.session();
- Sender snd = ssn.sender("sender");
- conn.open();
- ssn.open();
- snd.open();
- }
-
- @Override
- public void onLinkFlow(Event event) {
- Sender link = (Sender)event.getLink();
- while (link.getCredit() > 0 && remaining > 0) {
- Delivery dlv = link.delivery(new byte[0]);
- assertNotNull(dlv);
- dlv.settle();
- link.advance();
- --remaining;
- }
-
- if (remaining == 0) {
- event.getConnection().close();
- }
- }
-
- @Override
- public void onConnectionRemoteClose(Event event) {
- event.getConnection().free();
- }
- }
-
- private void transfer(int count, int window) throws IOException {
- reactor = reactorFactory.newReactor();
- ServerHandler sh = new ServerHandler();
- Acceptor acceptor = reactor.acceptor("127.0.0.1", 0, sh);
- sh.setAcceptor(acceptor);
- sh.add(new Handshaker());
- // XXX: a window of 1 doesn't work unless the flowcontroller is
- // added after the thing that settles the delivery
- sh.add(new FlowController(window));
- SinkHandler snk = new SinkHandler();
- sh.add(snk);
-
- SourceHandler src = new SourceHandler(count);
- reactor.connectionToHost("127.0.0.1", ((AcceptorImpl)acceptor).getPortNumber(),
- src);
- reactor.run();
- reactor.free();
- assertEquals("Did not receive the expected number of messages", count, snk.received);
- checkForLeaks();
- }
-
- @Test
- public void transfer_0to64_2() throws IOException {
- for (int i = 0; i < 64; ++i) {
- transfer(i, 2);
- }
- }
-
- @Test
- public void transfer_1024_64() throws IOException {
- transfer(1024, 64);
- }
-
- @Test
- public void transfer_4096_1024() throws IOException {
- transfer(4*1024, 1024);
- }
-
- @Test
- public void schedule() throws IOException {
- TestHandler reactorHandler = new TestHandler();
- reactor.getHandler().add(reactorHandler);
- TestHandler taskHandler = new TestHandler();
- reactor.schedule(0, taskHandler);
- reactor.run();
- reactor.free();
- reactorHandler.assertEvents(Type.REACTOR_INIT, Type.SELECTABLE_INIT, Type.SELECTABLE_UPDATED, Type.REACTOR_QUIESCED, Type.SELECTABLE_UPDATED,
- Type.SELECTABLE_FINAL, Type.REACTOR_FINAL);
- taskHandler.assertEvents(Type.TIMER_TASK);
- }
-
- private class BarfException extends RuntimeException {
- private static final long serialVersionUID = -5891140258375562884L;
- }
-
- private class BarfOnSomethingHandler extends BaseHandler {
- protected final BarfException exception;
-
- protected BarfOnSomethingHandler(BarfException exception) {
- this.exception = exception;
- }
- }
-
- private class BarfOnReactorInit extends BarfOnSomethingHandler {
-
- protected BarfOnReactorInit(BarfException exception) {
- super(exception);
- }
-
- @Override
- public void onReactorInit(Event e) {
- throw exception;
- }
- }
-
- private class BarfOnReactorFinal extends BarfOnSomethingHandler {
-
- protected BarfOnReactorFinal(BarfException exception) {
- super(exception);
- }
-
- @Override
- public void onReactorFinal(Event event) {
- throw exception;
- }
- }
-
- private class BarfOnConnectionInit extends BarfOnSomethingHandler {
-
- protected BarfOnConnectionInit(BarfException exception) {
- super(exception);
- }
-
- @Override
- public void onConnectionInit(Event e) {
- throw exception;
- }
- }
-
- private class BarfOnSessionInit extends BarfOnSomethingHandler {
-
- protected BarfOnSessionInit(BarfException exception) {
- super(exception);
- }
-
- @Override
- public void onSessionInit(Event e) {
- throw exception;
- }
- }
-
- private class BarfOnLinkInit extends BarfOnSomethingHandler {
-
- protected BarfOnLinkInit(BarfException exception) {
- super(exception);
- }
-
- @Override
- public void onLinkInit(Event e) {
- throw exception;
- }
- }
-
- private class BarfOnTask extends BarfOnSomethingHandler {
-
- protected BarfOnTask(BarfException exception) {
- super(exception);
- }
-
- @Override
- public void onTimerTask(Event e) {
- throw exception;
- }
- }
-
- private void assertReactorRunBarfsOnHandler(Reactor reactor, BarfException expectedException, Handler expectedHandler) {
- try {
- reactor.run();
- throw new AssertionFailedError("Reactor.run() should have thrown an exception");
- } catch(HandlerException handlerException) {
- assertSame("Linked exception does not match expected exception", expectedException, handlerException.getCause());
- assertSame("Handler in exception does not match expected handler", expectedHandler, handlerException.getHandler());
- }
- }
-
- @Test
- public void barfInReactorFinal() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnReactorFinal(expectedBarf);
- reactor.getGlobalHandler().add(expectedHandler);
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void barfOnGlobalSet() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnReactorInit(expectedBarf);
- reactor.setGlobalHandler(expectedHandler);
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void barfOnGlobalAdd() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnReactorInit(expectedBarf);
- reactor.getGlobalHandler().add(expectedHandler);
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void barfOnReactorSet() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnReactorInit(expectedBarf);
- reactor.setHandler(expectedHandler);
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void barfOnReactorAdd() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnReactorInit(expectedBarf);
- reactor.getHandler().add(expectedHandler);
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void barfOnConnection() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnConnectionInit(expectedBarf);
- reactor.connection(expectedHandler);
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void barfOnSession() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnSessionInit(expectedBarf);
- reactor.connection(expectedHandler).session();
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void barfOnLink() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnLinkInit(expectedBarf);
- reactor.connection(expectedHandler).session().sender("barf");
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void barfOnSchedule() throws IOException {
- BarfException expectedBarf = new BarfException();
- Handler expectedHandler = new BarfOnTask(expectedBarf);
- reactor.schedule(0, expectedHandler);
- assertReactorRunBarfsOnHandler(reactor, expectedBarf, expectedHandler);
- reactor.free();
- }
-
- @Test
- public void connectionRefused() throws IOException {
- final ServerSocket serverSocket = new ServerSocket(0, 0);
-
- class ConnectionHandler extends TestHandler {
- @Override
- public void onConnectionInit(Event event) {
- super.onConnectionInit(event);
- Connection connection = event.getConnection();
- connection.open();
- try {
- serverSocket.close();
- } catch(IOException e) {
- AssertionFailedError afe = new AssertionFailedError();
- afe.initCause(e);
- throw afe;
- }
- }
- }
- TestHandler connectionHandler = new ConnectionHandler();
- reactor.connectionToHost("127.0.0.1", serverSocket.getLocalPort(), connectionHandler);
- reactor.run();
- reactor.free();
- serverSocket.close();
- connectionHandler.assertEvents(Type.CONNECTION_INIT, Type.CONNECTION_LOCAL_OPEN, Type.CONNECTION_BOUND, Type.TRANSPORT_ERROR, Type.TRANSPORT_TAIL_CLOSED,
- Type.TRANSPORT_HEAD_CLOSED, Type.TRANSPORT_CLOSED, Type.CONNECTION_UNBOUND, Type.TRANSPORT);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/reactor/impl/AcceptorImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/reactor/impl/AcceptorImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/reactor/impl/AcceptorImplTest.java
deleted file mode 100644
index 9ac0538..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/reactor/impl/AcceptorImplTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.io.IOException;
-import java.nio.channels.ServerSocketChannel;
-
-import org.apache.qpid.proton.reactor.ReactorChild;
-import org.apache.qpid.proton.reactor.Selectable.Callback;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-public class AcceptorImplTest {
-
- /**
- * Tests that if ServerSocketChannel.accept() throws an IOException the Acceptor will
- * call Selectable.error() on it's underlying selector.
- * @throws IOException
- */
- @Test
- public void acceptThrowsException() throws IOException {
- final Callback mockCallback = Mockito.mock(Callback.class);
- final SelectableImpl selectable = new SelectableImpl();
- selectable.onError(mockCallback);
- ReactorImpl mockReactor = Mockito.mock(ReactorImpl.class);
- class MockIO extends IOImpl {
- @Override
- public ServerSocketChannel serverSocketChannel() throws IOException {
- ServerSocketChannel result = Mockito.mock(ServerSocketChannel.class);
- Mockito.when(result.accept()).thenThrow(new IOException());
- return result;
- }
- }
- IO mockIO = new MockIO();
- Mockito.when(mockReactor.getIO()).thenReturn(mockIO);
- Mockito.when(mockReactor.selectable(Mockito.any(ReactorChild.class))).thenReturn(selectable);
- new AcceptorImpl(mockReactor, "host", 1234, null);
- selectable.readable();
- Mockito.verify(mockCallback).run(selectable);
- }
-
- /**
- * Tests that if ServerSocketChannel.accept() returns <code>null</code> the Acceptor will
- * throw a ReactorInternalException (because the acceptor's underlying selectable should
- * not have been marked as readable, if there is no connection to accept).
- * @throws IOException
- */
- @Test(expected=ReactorInternalException.class)
- public void acceptReturnsNull() throws IOException {
- final Callback mockCallback = Mockito.mock(Callback.class);
- final SelectableImpl selectable = new SelectableImpl();
- selectable.onError(mockCallback);
- ReactorImpl mockReactor = Mockito.mock(ReactorImpl.class);
- class MockIO extends IOImpl {
- @Override
- public ServerSocketChannel serverSocketChannel() throws IOException {
- ServerSocketChannel result = Mockito.mock(ServerSocketChannel.class);
- Mockito.when(result.accept()).thenReturn(null);
- return result;
- }
- }
- IO mockIO = new MockIO();
- Mockito.when(mockReactor.getIO()).thenReturn(mockIO);
- Mockito.when(mockReactor.selectable(Mockito.any(ReactorChild.class))).thenReturn(selectable);
- new AcceptorImpl(mockReactor, "host", 1234, null);
- selectable.readable();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[15/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
deleted file mode 100644
index fb1b06a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.transport.EmptyFrame;
-import org.apache.qpid.proton.amqp.transport.FrameBody;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.codec.WritableBuffer;
-import org.apache.qpid.proton.framing.TransportFrame;
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-/**
- * FrameWriter
- *
- */
-
-class FrameWriter
-{
-
- static final byte AMQP_FRAME_TYPE = 0;
- static final byte SASL_FRAME_TYPE = (byte) 1;
-
- private EncoderImpl _encoder;
- private ByteBuffer _bbuf;
- private WritableBuffer _buffer;
- private int _maxFrameSize;
- private byte _frameType;
- final private Ref<ProtocolTracer> _protocolTracer;
- private TransportImpl _transport;
-
- private int _frameStart = 0;
- private int _payloadStart;
- private int _performativeSize;
- private long _framesOutput = 0;
-
- FrameWriter(EncoderImpl encoder, int maxFrameSize, byte frameType,
- Ref<ProtocolTracer> protocolTracer, TransportImpl transport)
- {
- _encoder = encoder;
- _bbuf = ByteBuffer.allocate(1024);
- _buffer = new WritableBuffer.ByteBufferWrapper(_bbuf);
- _encoder.setByteBuffer(_buffer);
- _maxFrameSize = maxFrameSize;
- _frameType = frameType;
- _protocolTracer = protocolTracer;
- _transport = transport;
- }
-
- void setMaxFrameSize(int maxFrameSize)
- {
- _maxFrameSize = maxFrameSize;
- }
-
- private void grow()
- {
- ByteBuffer old = _bbuf;
- _bbuf = ByteBuffer.allocate(_bbuf.capacity() * 2);
- _buffer = new WritableBuffer.ByteBufferWrapper(_bbuf);
- old.flip();
- _bbuf.put(old);
- _encoder.setByteBuffer(_buffer);
- }
-
- void writeHeader(byte[] header)
- {
- _buffer.put(header, 0, header.length);
- }
-
- private void startFrame()
- {
- _frameStart = _buffer.position();
- }
-
- private void writePerformative(Object frameBody)
- {
- while (_buffer.remaining() < 8) {
- grow();
- }
-
- while (true)
- {
- try
- {
- _buffer.position(_frameStart + 8);
- if (frameBody != null) _encoder.writeObject(frameBody);
- break;
- }
- catch (BufferOverflowException e)
- {
- grow();
- }
- }
-
- _payloadStart = _buffer.position();
- _performativeSize = _payloadStart - _frameStart;
- }
-
- private void endFrame(int channel)
- {
- int frameSize = _buffer.position() - _frameStart;
- int limit = _buffer.position();
- _buffer.position(_frameStart);
- _buffer.putInt(frameSize);
- _buffer.put((byte) 2);
- _buffer.put(_frameType);
- _buffer.putShort((short) channel);
- _buffer.position(limit);
- }
-
- void writeFrame(int channel, Object frameBody, ByteBuffer payload,
- Runnable onPayloadTooLarge)
- {
- startFrame();
-
- writePerformative(frameBody);
-
- if(_maxFrameSize > 0 && payload != null && (payload.remaining() + _performativeSize) > _maxFrameSize)
- {
- if(onPayloadTooLarge != null)
- {
- onPayloadTooLarge.run();
- }
- writePerformative(frameBody);
- }
-
- int capacity;
- if (_maxFrameSize > 0) {
- capacity = _maxFrameSize - _performativeSize;
- } else {
- capacity = Integer.MAX_VALUE;
- }
- int payloadSize = Math.min(payload == null ? 0 : payload.remaining(), capacity);
-
- ProtocolTracer tracer = _protocolTracer == null ? null : _protocolTracer.get();
- if( tracer != null || _transport.isTraceFramesEnabled())
- {
- // XXX: this is a bit of a hack but it eliminates duplicate
- // code, further refactor will fix this
- if (_frameType == AMQP_FRAME_TYPE)
- {
- ByteBuffer originalPayload = null;
- if( payload!=null )
- {
- originalPayload = payload.duplicate();
- originalPayload.limit(payload.position() + payloadSize);
- }
-
- Binary payloadBin = Binary.create(originalPayload);
- FrameBody body = null;
- if (frameBody == null)
- {
- body = new EmptyFrame();
- }
- else
- {
- body = (FrameBody) frameBody;
- }
-
- TransportFrame frame = new TransportFrame(channel, body, payloadBin);
-
- _transport.log(TransportImpl.OUTGOING, frame);
-
- if(tracer != null)
- {
- tracer.sentFrame(frame);
- }
- }
- }
-
- if(payloadSize > 0)
- {
- while (_buffer.remaining() < payloadSize) {
- grow();
- }
-
- int oldLimit = payload.limit();
- payload.limit(payload.position() + payloadSize);
- _buffer.put(payload);
- payload.limit(oldLimit);
- }
-
- endFrame(channel);
-
- _framesOutput += 1;
- }
-
- void writeFrame(Object frameBody)
- {
- writeFrame(0, frameBody, null, null);
- }
-
- boolean isFull() {
- // XXX: this should probably be tunable
- return _bbuf.position() > 64*1024;
- }
-
- int readBytes(ByteBuffer dst)
- {
- ByteBuffer src = _bbuf.duplicate();
- src.flip();
-
- int size = Math.min(src.remaining(), dst.remaining());
- int limit = src.limit();
- src.limit(size);
- dst.put(src);
- src.limit(limit);
- _bbuf.rewind();
- _bbuf.put(src);
-
- return size;
- }
-
- long getFramesOutput()
- {
- return _framesOutput;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/HandshakeSniffingTransportWrapper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/HandshakeSniffingTransportWrapper.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/HandshakeSniffingTransportWrapper.java
deleted file mode 100644
index 6a5aac5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/HandshakeSniffingTransportWrapper.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.engine.impl.TransportWrapper;
-
-public abstract class HandshakeSniffingTransportWrapper<T1 extends TransportWrapper, T2 extends TransportWrapper>
- implements TransportWrapper
-{
-
- protected final T1 _wrapper1;
- protected final T2 _wrapper2;
-
- private boolean _tail_closed = false;
- private boolean _head_closed = false;
- protected TransportWrapper _selectedTransportWrapper;
-
- private final ByteBuffer _determinationBuffer;
-
- protected HandshakeSniffingTransportWrapper
- (T1 wrapper1,
- T2 wrapper2)
- {
- _wrapper1 = wrapper1;
- _wrapper2 = wrapper2;
- _determinationBuffer = ByteBuffer.allocate(bufferSize());
- }
-
- @Override
- public int capacity()
- {
- if (isDeterminationMade())
- {
- return _selectedTransportWrapper.capacity();
- }
- else
- {
- if (_tail_closed) { return Transport.END_OF_STREAM; }
- return _determinationBuffer.remaining();
- }
- }
-
- @Override
- public int position()
- {
- if (isDeterminationMade())
- {
- return _selectedTransportWrapper.position();
- }
- else
- {
- if (_tail_closed) { return Transport.END_OF_STREAM; }
- return _determinationBuffer.position();
- }
- }
-
- @Override
- public ByteBuffer tail()
- {
- if (isDeterminationMade())
- {
- return _selectedTransportWrapper.tail();
- }
- else
- {
- return _determinationBuffer;
- }
- }
-
- protected abstract int bufferSize();
-
- protected abstract void makeDetermination(byte[] bytes);
-
- @Override
- public void process() throws TransportException
- {
- if (isDeterminationMade())
- {
- _selectedTransportWrapper.process();
- }
- else if (_determinationBuffer.remaining() == 0)
- {
- _determinationBuffer.flip();
- byte[] bytesInput = new byte[_determinationBuffer.remaining()];
- _determinationBuffer.get(bytesInput);
- makeDetermination(bytesInput);
- _determinationBuffer.rewind();
-
- // TODO what if the selected transport has insufficient capacity?? Maybe use pour, and then try to finish pouring next time round.
- _selectedTransportWrapper.tail().put(_determinationBuffer);
- _selectedTransportWrapper.process();
- } else if (_tail_closed) {
- throw new TransportException("connection aborted");
- }
- }
-
- @Override
- public void close_tail()
- {
- try {
- if (isDeterminationMade())
- {
- _selectedTransportWrapper.close_tail();
- }
- } finally {
- _tail_closed = true;
- }
- }
-
- @Override
- public int pending()
- {
- if (_head_closed) { return Transport.END_OF_STREAM; }
-
- if (isDeterminationMade()) {
- return _selectedTransportWrapper.pending();
- } else {
- return 0;
- }
-
- }
-
- private static final ByteBuffer EMPTY = ByteBuffer.allocate(0);
-
- @Override
- public ByteBuffer head()
- {
- if (isDeterminationMade()) {
- return _selectedTransportWrapper.head();
- } else {
- return EMPTY;
- }
- }
-
- @Override
- public void pop(int bytes)
- {
- if (isDeterminationMade()) {
- _selectedTransportWrapper.pop(bytes);
- } else if (bytes > 0) {
- throw new IllegalStateException("no bytes have been read");
- }
- }
-
- @Override
- public void close_head()
- {
- if (isDeterminationMade()) {
- _selectedTransportWrapper.close_head();
- } else {
- _head_closed = true;
- }
- }
-
- protected boolean isDeterminationMade()
- {
- return _selectedTransportWrapper != null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java
deleted file mode 100644
index a67785e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java
+++ /dev/null
@@ -1,514 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.util.EnumSet;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.amqp.transport.Source;
-import org.apache.qpid.proton.amqp.transport.Target;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-
-public abstract class LinkImpl extends EndpointImpl implements Link
-{
-
- private final SessionImpl _session;
-
- DeliveryImpl _head;
- DeliveryImpl _tail;
- DeliveryImpl _current;
- private String _name;
- private Source _source;
- private Source _remoteSource;
- private Target _target;
- private Target _remoteTarget;
- private int _queued;
- private int _credit;
- private int _unsettled;
- private int _drained;
-
- private SenderSettleMode _senderSettleMode;
- private SenderSettleMode _remoteSenderSettleMode;
- private ReceiverSettleMode _receiverSettleMode;
- private ReceiverSettleMode _remoteReceiverSettleMode;
-
-
- private LinkNode<LinkImpl> _node;
- private boolean _drain;
- private boolean _detached;
- private Map<Symbol, Object> _properties;
- private Map<Symbol, Object> _remoteProperties;
- private Symbol[] _offeredCapabilities;
- private Symbol[] _remoteOfferedCapabilities;
- private Symbol[] _desiredCapabilities;
- private Symbol[] _remoteDesiredCapabilities;
-
- LinkImpl(SessionImpl session, String name)
- {
- _session = session;
- _session.incref();
- _name = name;
- ConnectionImpl conn = session.getConnectionImpl();
- _node = conn.addLinkEndpoint(this);
- conn.put(Event.Type.LINK_INIT, this);
- }
-
-
- @Override
- public String getName()
- {
- return _name;
- }
-
- @Override
- public DeliveryImpl delivery(byte[] tag)
- {
- return delivery(tag, 0, tag.length);
- }
-
- @Override
- public DeliveryImpl delivery(byte[] tag, int offset, int length)
- {
- if (offset != 0 || length != tag.length)
- {
- throw new IllegalArgumentException("At present delivery tag must be the whole byte array");
- }
- incrementQueued();
- try
- {
- DeliveryImpl delivery = new DeliveryImpl(tag, this, _tail);
- if (_tail == null)
- {
- _head = delivery;
- }
- _tail = delivery;
- if (_current == null)
- {
- _current = delivery;
- }
- getConnectionImpl().workUpdate(delivery);
- return delivery;
- }
- catch (RuntimeException e)
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- @Override
- void postFinal() {
- _session.getConnectionImpl().put(Event.Type.LINK_FINAL, this);
- _session.decref();
- }
-
- @Override
- void doFree()
- {
- DeliveryImpl dlv = _head;
- while (dlv != null) {
- dlv.free();
- dlv = dlv.next();
- }
-
- _session.getConnectionImpl().removeLinkEndpoint(_node);
- _node = null;
- }
-
- void modifyEndpoints() {
- modified();
- }
-
- public void remove(DeliveryImpl delivery)
- {
- if(_head == delivery)
- {
- _head = delivery.getLinkNext();
- }
- if(_tail == delivery)
- {
- _tail = delivery.getLinkPrevious();
- }
- if(_current == delivery)
- {
- // TODO - what???
- }
- }
-
- @Override
- public DeliveryImpl current()
- {
- return _current;
- }
-
- @Override
- public boolean advance()
- {
- if(_current != null )
- {
- DeliveryImpl oldCurrent = _current;
- _current = _current.getLinkNext();
- getConnectionImpl().workUpdate(oldCurrent);
-
- if(_current != null)
- {
- getConnectionImpl().workUpdate(_current);
- }
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- @Override
- protected ConnectionImpl getConnectionImpl()
- {
- return _session.getConnectionImpl();
- }
-
- @Override
- public SessionImpl getSession()
- {
- return _session;
- }
-
- @Override
- public Source getRemoteSource()
- {
- return _remoteSource;
- }
-
- void setRemoteSource(Source source)
- {
- _remoteSource = source;
- }
-
- @Override
- public Target getRemoteTarget()
- {
- return _remoteTarget;
- }
-
- void setRemoteTarget(Target target)
- {
- _remoteTarget = target;
- }
-
- @Override
- public Source getSource()
- {
- return _source;
- }
-
- @Override
- public void setSource(Source source)
- {
- // TODO - should be an error if local state is ACTIVE
- _source = source;
- }
-
- @Override
- public Target getTarget()
- {
- return _target;
- }
-
- @Override
- public void setTarget(Target target)
- {
- // TODO - should be an error if local state is ACTIVE
- _target = target;
- }
-
- @Override
- public Link next(EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
- {
- LinkNode.Query<LinkImpl> query = new EndpointImplQuery<LinkImpl>(local, remote);
-
- LinkNode<LinkImpl> linkNode = _node.next(query);
-
- return linkNode == null ? null : linkNode.getValue();
-
- }
-
- abstract TransportLink getTransportLink();
-
- @Override
- public int getCredit()
- {
- return _credit;
- }
-
- public void addCredit(int credit)
- {
- _credit+=credit;
- }
-
- public void setCredit(int credit)
- {
- _credit = credit;
- }
-
- boolean hasCredit()
- {
- return _credit > 0;
- }
-
- void incrementCredit()
- {
- _credit++;
- }
-
- void decrementCredit()
- {
- _credit--;
- }
-
- @Override
- public int getQueued()
- {
- return _queued;
- }
-
- void incrementQueued()
- {
- _queued++;
- }
-
- void decrementQueued()
- {
- _queued--;
- }
-
- @Override
- public int getUnsettled()
- {
- return _unsettled;
- }
-
- void incrementUnsettled()
- {
- _unsettled++;
- }
-
- void decrementUnsettled()
- {
- _unsettled--;
- }
-
- void setDrain(boolean drain)
- {
- _drain = drain;
- }
-
- @Override
- public boolean getDrain()
- {
- return _drain;
- }
-
- @Override
- public SenderSettleMode getSenderSettleMode()
- {
- return _senderSettleMode;
- }
-
- @Override
- public void setSenderSettleMode(SenderSettleMode senderSettleMode)
- {
- _senderSettleMode = senderSettleMode;
- }
-
- @Override
- public SenderSettleMode getRemoteSenderSettleMode()
- {
- return _remoteSenderSettleMode;
- }
-
- @Override
- public void setRemoteSenderSettleMode(SenderSettleMode remoteSenderSettleMode)
- {
- _remoteSenderSettleMode = remoteSenderSettleMode;
- }
-
- @Override
- public ReceiverSettleMode getReceiverSettleMode()
- {
- return _receiverSettleMode;
- }
-
- @Override
- public void setReceiverSettleMode(ReceiverSettleMode receiverSettleMode)
- {
- _receiverSettleMode = receiverSettleMode;
- }
-
- @Override
- public ReceiverSettleMode getRemoteReceiverSettleMode()
- {
- return _remoteReceiverSettleMode;
- }
-
- void setRemoteReceiverSettleMode(ReceiverSettleMode remoteReceiverSettleMode)
- {
- _remoteReceiverSettleMode = remoteReceiverSettleMode;
- }
-
- @Override
- public Map<Symbol, Object> getProperties()
- {
- return _properties;
- }
-
- @Override
- public void setProperties(Map<Symbol, Object> properties)
- {
- _properties = properties;
- }
-
- @Override
- public Map<Symbol, Object> getRemoteProperties()
- {
- return _remoteProperties;
- }
-
- void setRemoteProperties(Map<Symbol, Object> remoteProperties)
- {
- _remoteProperties = remoteProperties;
- }
-
- @Override
- public Symbol[] getDesiredCapabilities()
- {
- return _desiredCapabilities;
- }
-
- @Override
- public void setDesiredCapabilities(Symbol[] desiredCapabilities)
- {
- _desiredCapabilities = desiredCapabilities;
- }
-
- @Override
- public Symbol[] getRemoteDesiredCapabilities()
- {
- return _remoteDesiredCapabilities;
- }
-
- void setRemoteDesiredCapabilities(Symbol[] remoteDesiredCapabilities)
- {
- _remoteDesiredCapabilities = remoteDesiredCapabilities;
- }
-
- @Override
- public Symbol[] getOfferedCapabilities()
- {
- return _offeredCapabilities;
- }
-
- @Override
- public void setOfferedCapabilities(Symbol[] offeredCapabilities)
- {
- _offeredCapabilities = offeredCapabilities;
- }
-
- @Override
- public Symbol[] getRemoteOfferedCapabilities()
- {
- return _remoteOfferedCapabilities;
- }
-
- void setRemoteOfferedCapabilities(Symbol[] remoteOfferedCapabilities)
- {
- _remoteOfferedCapabilities = remoteOfferedCapabilities;
- }
-
- @Override
- public int drained()
- {
- int drained = 0;
-
- if (this instanceof SenderImpl) {
- if(getDrain() && hasCredit())
- {
- _drained = getCredit();
- setCredit(0);
- modified();
- drained = _drained;
- }
- } else {
- drained = _drained;
- _drained = 0;
- }
-
- return drained;
- }
-
- int getDrained()
- {
- return _drained;
- }
-
- void setDrained(int value)
- {
- _drained = value;
- }
-
- @Override
- public DeliveryImpl head()
- {
- return _head;
- }
-
- @Override
- void localOpen()
- {
- getConnectionImpl().put(Event.Type.LINK_LOCAL_OPEN, this);
- }
-
- @Override
- void localClose()
- {
- getConnectionImpl().put(Event.Type.LINK_LOCAL_CLOSE, this);
- }
-
- @Override
- public void detach()
- {
- _detached = true;
- getConnectionImpl().put(Event.Type.LINK_LOCAL_DETACH, this);
- modified();
- }
-
- public boolean detached()
- {
- return _detached;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkNode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkNode.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkNode.java
deleted file mode 100644
index e3a8f78..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkNode.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.apache.qpid.proton.engine.impl;
-/*
- *
- * 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.
- *
-*/
-
-
-class LinkNode<E>
-{
- public interface Query<T>
- {
- public boolean matches(LinkNode<T> node);
- }
-
-
- private E _value;
- private LinkNode<E> _prev;
- private LinkNode<E> _next;
-
- private LinkNode(E value)
- {
- _value = value;
- }
-
- public E getValue()
- {
- return _value;
- }
-
- public LinkNode<E> getPrev()
- {
- return _prev;
- }
-
- public LinkNode<E> getNext()
- {
- return _next;
- }
-
- public LinkNode<E> next(Query<E> query)
- {
- LinkNode<E> next = _next;
- while(next != null && !query.matches(next))
- {
- next = next.getNext();
- }
- return next;
- }
-
- public LinkNode<E> remove()
- {
- LinkNode<E> prev = _prev;
- LinkNode<E> next = _next;
- if(prev != null)
- {
- prev._next = next;
- }
- if(next != null)
- {
- next._prev = prev;
- }
- _next = _prev = null;
- return next;
- }
-
- public LinkNode<E> addAtTail(E value)
- {
- if(_next == null)
- {
- _next = new LinkNode<E>(value);
- _next._prev = this;
- return _next;
- }
- else
- {
- return _next.addAtTail(value);
- }
- }
-
- public static <T> LinkNode<T> newList(T value)
- {
- return new LinkNode<T>(value);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/PlainTransportWrapper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/PlainTransportWrapper.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/PlainTransportWrapper.java
deleted file mode 100644
index 62b75b3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/PlainTransportWrapper.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.TransportException;
-
-public class PlainTransportWrapper implements TransportWrapper
-{
- private final TransportOutput _outputProcessor;
- private final TransportInput _inputProcessor;
-
- public PlainTransportWrapper(TransportOutput outputProcessor,
- TransportInput inputProcessor)
- {
- _outputProcessor = outputProcessor;
- _inputProcessor = inputProcessor;
- }
-
- @Override
- public int capacity()
- {
- return _inputProcessor.capacity();
- }
-
- @Override
- public int position()
- {
- return _inputProcessor.position();
- }
-
- @Override
- public ByteBuffer tail()
- {
- return _inputProcessor.tail();
- }
-
- @Override
- public void process() throws TransportException
- {
- _inputProcessor.process();
- }
-
- @Override
- public void close_tail()
- {
- _inputProcessor.close_tail();
- }
-
- @Override
- public int pending()
- {
- return _outputProcessor.pending();
- }
-
- @Override
- public ByteBuffer head()
- {
- return _outputProcessor.head();
- }
-
- @Override
- public void pop(int bytes)
- {
- _outputProcessor.pop(bytes);
- }
-
- @Override
- public void close_head()
- {
- _outputProcessor.close_head();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ProtocolTracer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ProtocolTracer.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ProtocolTracer.java
deleted file mode 100644
index 92ad598..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ProtocolTracer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.framing.TransportFrame;
-
-/**
- * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
- */
-public interface ProtocolTracer
-{
- public void receivedFrame(TransportFrame transportFrame);
- public void sentFrame(TransportFrame transportFrame);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ReceiverImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ReceiverImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ReceiverImpl.java
deleted file mode 100644
index 6f86700..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ReceiverImpl.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.codec.WritableBuffer;
-import org.apache.qpid.proton.engine.Receiver;
-
-public class ReceiverImpl extends LinkImpl implements Receiver
-{
- private boolean _drainFlagMode = true;
-
- @Override
- public boolean advance()
- {
- DeliveryImpl current = current();
- if(current != null)
- {
- current.setDone();
- }
- final boolean advance = super.advance();
- if(advance)
- {
- decrementQueued();
- decrementCredit();
- getSession().incrementIncomingBytes(-current.pending());
- getSession().incrementIncomingDeliveries(-1);
- if (getSession().getTransportSession().getIncomingWindowSize().equals(UnsignedInteger.ZERO)) {
- modified();
- }
- }
- return advance;
- }
-
- private TransportReceiver _transportReceiver;
- private int _unsentCredits;
-
-
- ReceiverImpl(SessionImpl session, String name)
- {
- super(session, name);
- }
-
- @Override
- public void flow(final int credits)
- {
- addCredit(credits);
- _unsentCredits += credits;
- modified();
- if (!_drainFlagMode)
- {
- setDrain(false);
- _drainFlagMode = false;
- }
- }
-
- int clearUnsentCredits()
- {
- int credits = _unsentCredits;
- _unsentCredits = 0;
- return credits;
- }
-
- @Override
- public int recv(final byte[] bytes, int offset, int size)
- {
- if (_current == null) {
- throw new IllegalStateException("no current delivery");
- }
-
- int consumed = _current.recv(bytes, offset, size);
- if (consumed > 0) {
- getSession().incrementIncomingBytes(-consumed);
- if (getSession().getTransportSession().getIncomingWindowSize().equals(UnsignedInteger.ZERO)) {
- modified();
- }
- }
- return consumed;
- }
-
- @Override
- public int recv(final WritableBuffer buffer)
- {
- if (_current == null) {
- throw new IllegalStateException("no current delivery");
- }
-
- int consumed = _current.recv(buffer);
- if (consumed > 0) {
- getSession().incrementIncomingBytes(-consumed);
- if (getSession().getTransportSession().getIncomingWindowSize().equals(UnsignedInteger.ZERO)) {
- modified();
- }
- }
- return consumed;
- }
-
- @Override
- void doFree()
- {
- getSession().freeReceiver(this);
- super.doFree();
- }
-
- boolean hasIncoming()
- {
- return false; //TODO - Implement
- }
-
- void setTransportLink(TransportReceiver transportReceiver)
- {
- _transportReceiver = transportReceiver;
- }
-
- @Override
- TransportReceiver getTransportLink()
- {
- return _transportReceiver;
- }
-
- @Override
- public void drain(int credit)
- {
- setDrain(true);
- flow(credit);
- _drainFlagMode = false;
- }
-
- @Override
- public boolean draining()
- {
- return getDrain() && (getCredit() > getQueued());
- }
-
- @Override
- public void setDrain(boolean drain)
- {
- super.setDrain(drain);
- modified();
- _drainFlagMode = true;
- }
-
- @Override
- public int getRemoteCredit()
- {
- // Credit is only decremented once advance is called on a received message,
- // so we also need to consider the queued count.
- return getCredit() - getQueued();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/RecordImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/RecordImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/RecordImpl.java
deleted file mode 100644
index 85408cb..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/RecordImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.engine.Record;
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * RecordImpl
- *
- */
-
-public class RecordImpl implements Record
-{
-
- private Map<Object,Object> values = new HashMap<Object,Object>();
-
- public <T> void set(Object key, Class<T> klass, T value) {
- values.put(key, value);
- }
-
- public <T> T get(Object key, Class<T> klass) {
- return klass.cast(values.get(key));
- }
-
- public void clear() {
- values.clear();
- }
-
- void copy(RecordImpl src) {
- values.putAll(src.values);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java
deleted file mode 100644
index 01e3a35..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-
-/**
- * Ref
- *
- */
-
-class Ref<T>
-{
-
- T value;
-
- public Ref(T initial) {
- value = initial;
- }
-
- public T get() {
- return value;
- }
-
- public void set(T value) {
- this.value = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslFrameHandler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslFrameHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslFrameHandler.java
deleted file mode 100644
index efc12dd..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslFrameHandler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.security.SaslFrameBody;
-
-/**
- * Used by {@link SaslFrameParser} to handle the frames it parses
- */
-interface SaslFrameHandler
-{
- void handle(SaslFrameBody frameBody, Binary payload);
-
- boolean isDone();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslFrameParser.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslFrameParser.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslFrameParser.java
deleted file mode 100644
index 8becc72..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslFrameParser.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.security.SaslFrameBody;
-import org.apache.qpid.proton.codec.ByteBufferDecoder;
-import org.apache.qpid.proton.codec.DecodeException;
-import org.apache.qpid.proton.engine.TransportException;
-
-class SaslFrameParser
-{
- private SaslFrameHandler _sasl;
-
- enum State
- {
- SIZE_0,
- SIZE_1,
- SIZE_2,
- SIZE_3,
- PRE_PARSE,
- BUFFERING,
- PARSING,
- ERROR
- }
-
- private State _state = State.SIZE_0;
- private int _size;
-
- private ByteBuffer _buffer;
-
- private int _ignore = 8;
- private final ByteBufferDecoder _decoder;
-
-
- SaslFrameParser(SaslFrameHandler sasl, ByteBufferDecoder decoder)
- {
- _sasl = sasl;
- _decoder = decoder;
- }
-
- /**
- * Parse the provided SASL input and call my SASL frame handler with the result
- */
- public void input(ByteBuffer input) throws TransportException
- {
- TransportException frameParsingError = null;
- int size = _size;
- State state = _state;
- ByteBuffer oldIn = null;
-
- // Note that we simply skip over the header rather than parsing it.
- if(_ignore != 0)
- {
- int bytesToEat = Math.min(_ignore, input.remaining());
- input.position(input.position() + bytesToEat);
- _ignore -= bytesToEat;
- }
-
- while(input.hasRemaining() && state != State.ERROR && !_sasl.isDone())
- {
- switch(state)
- {
- case SIZE_0:
- if(input.remaining() >= 4)
- {
- size = input.getInt();
- state = State.PRE_PARSE;
- break;
- }
- else
- {
- size = (input.get() << 24) & 0xFF000000;
- if(!input.hasRemaining())
- {
- state = State.SIZE_1;
- break;
- }
- }
- case SIZE_1:
- size |= (input.get() << 16) & 0xFF0000;
- if(!input.hasRemaining())
- {
- state = State.SIZE_2;
- break;
- }
- case SIZE_2:
- size |= (input.get() << 8) & 0xFF00;
- if(!input.hasRemaining())
- {
- state = State.SIZE_3;
- break;
- }
- case SIZE_3:
- size |= input.get() & 0xFF;
- state = State.PRE_PARSE;
-
- case PRE_PARSE:
- if(size < 8)
- {
- frameParsingError = new TransportException("specified frame size %d smaller than minimum frame header "
- + "size %d",
- _size, 8);
- state = State.ERROR;
- break;
- }
-
- if(input.remaining() < size-4)
- {
- _buffer = ByteBuffer.allocate(size-4);
- _buffer.put(input);
- state = State.BUFFERING;
- break;
- }
- case BUFFERING:
- if(_buffer != null)
- {
- if(input.remaining() < _buffer.remaining())
- {
- _buffer.put(input);
- break;
- }
- else
- {
- ByteBuffer dup = input.duplicate();
- dup.limit(dup.position()+_buffer.remaining());
- input.position(input.position()+_buffer.remaining());
- _buffer.put(dup);
- oldIn = input;
- _buffer.flip();
- input = _buffer;
- state = State.PARSING;
- }
- }
-
- case PARSING:
-
- int dataOffset = (input.get() << 2) & 0x3FF;
-
- if(dataOffset < 8)
- {
- frameParsingError = new TransportException("specified frame data offset %d smaller than minimum frame header size %d", dataOffset, 8);
- state = State.ERROR;
- break;
- }
- else if(dataOffset > size)
- {
- frameParsingError = new TransportException("specified frame data offset %d larger than the frame size %d", dataOffset, _size);
- state = State.ERROR;
- break;
- }
-
- // type
-
- int type = input.get() & 0xFF;
- // SASL frame has no type-specific content in the frame header, so we skip next two bytes
- input.get();
- input.get();
-
- if(type != SaslImpl.SASL_FRAME_TYPE)
- {
- frameParsingError = new TransportException("unknown frame type: %d", type);
- state = State.ERROR;
- break;
- }
-
- if(dataOffset!=8)
- {
- input.position(input.position()+dataOffset-8);
- }
-
- // oldIn null iff not working on duplicated buffer
- if(oldIn == null)
- {
- oldIn = input;
- input = input.duplicate();
- final int endPos = input.position() + size - dataOffset;
- input.limit(endPos);
- oldIn.position(endPos);
-
- }
-
- try
- {
- _decoder.setByteBuffer(input);
- Object val = _decoder.readObject();
-
- Binary payload;
-
- if(input.hasRemaining())
- {
- byte[] payloadBytes = new byte[input.remaining()];
- input.get(payloadBytes);
- payload = new Binary(payloadBytes);
- }
- else
- {
- payload = null;
- }
-
- if(val instanceof SaslFrameBody)
- {
- SaslFrameBody frameBody = (SaslFrameBody) val;
- _sasl.handle(frameBody, payload);
-
- reset();
- input = oldIn;
- oldIn = null;
- _buffer = null;
- state = State.SIZE_0;
- }
- else
- {
- state = State.ERROR;
- frameParsingError = new TransportException("Unexpected frame type encountered."
- + " Found a %s which does not implement %s",
- val == null ? "null" : val.getClass(), SaslFrameBody.class);
- }
- }
- catch (DecodeException ex)
- {
- state = State.ERROR;
- frameParsingError = new TransportException(ex);
- }
- break;
- case ERROR:
- // do nothing
- }
-
- }
-
- _state = state;
- _size = size;
-
- if(_state == State.ERROR)
- {
- if(frameParsingError != null)
- {
- throw frameParsingError;
- }
- else
- {
- throw new TransportException("Unable to parse, probably because of a previous error");
- }
- }
- }
-
- private void reset()
- {
- _size = 0;
- _state = State.SIZE_0;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
deleted file mode 100644
index 56567fe..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-package org.apache.qpid.proton.engine.impl;
-
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.newWriteableBuffer;
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.pourAll;
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.pourBufferToArray;
-
-import java.nio.ByteBuffer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.security.SaslChallenge;
-import org.apache.qpid.proton.amqp.security.SaslCode;
-import org.apache.qpid.proton.amqp.security.SaslFrameBody;
-import org.apache.qpid.proton.amqp.security.SaslInit;
-import org.apache.qpid.proton.amqp.security.SaslMechanisms;
-import org.apache.qpid.proton.amqp.security.SaslResponse;
-import org.apache.qpid.proton.codec.AMQPDefinedTypes;
-import org.apache.qpid.proton.codec.DecoderImpl;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.engine.Sasl;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-
-public class SaslImpl implements Sasl, SaslFrameBody.SaslFrameBodyHandler<Void>, SaslFrameHandler, TransportLayer
-{
- private static final Logger _logger = Logger.getLogger(SaslImpl.class.getName());
-
- public static final byte SASL_FRAME_TYPE = (byte) 1;
-
- private final DecoderImpl _decoder = new DecoderImpl();
- private final EncoderImpl _encoder = new EncoderImpl(_decoder);
-
- private final TransportImpl _transport;
-
- private boolean _tail_closed = false;
- private final ByteBuffer _inputBuffer;
- private boolean _head_closed = false;
- private final ByteBuffer _outputBuffer;
- private final FrameWriter _frameWriter;
-
- private ByteBuffer _pending;
-
- private boolean _headerWritten;
- private Binary _challengeResponse;
- private SaslFrameParser _frameParser;
- private boolean _initReceived;
- private boolean _mechanismsSent;
- private boolean _initSent;
-
- enum Role { CLIENT, SERVER };
-
- private SaslOutcome _outcome = SaslOutcome.PN_SASL_NONE;
- private SaslState _state = SaslState.PN_SASL_IDLE;
-
- private String _hostname;
- private boolean _done;
- private Symbol[] _mechanisms;
-
- private Symbol _chosenMechanism;
-
- private Role _role;
- private boolean _allowSkip = true;
-
- /**
- * @param maxFrameSize the size of the input and output buffers
- * returned by {@link SaslTransportWrapper#getInputBuffer()} and
- * {@link SaslTransportWrapper#getOutputBuffer()}.
- */
- SaslImpl(TransportImpl transport, int maxFrameSize)
- {
- _transport = transport;
- _inputBuffer = newWriteableBuffer(maxFrameSize);
- _outputBuffer = newWriteableBuffer(maxFrameSize);
-
- AMQPDefinedTypes.registerAllTypes(_decoder,_encoder);
- _frameParser = new SaslFrameParser(this, _decoder);
- _frameWriter = new FrameWriter(_encoder, maxFrameSize, FrameWriter.SASL_FRAME_TYPE, null, _transport);
- }
-
- void fail() {
- if (_role == null || _role == Role.CLIENT) {
- _role = Role.CLIENT;
- _initSent = true;
- } else {
- _initReceived = true;
-
- }
- _done = true;
- _outcome = SaslOutcome.PN_SASL_SYS;
- }
-
- @Override
- public boolean isDone()
- {
- return _done && (_role==Role.CLIENT || _initReceived);
- }
-
- private void writeSaslOutput()
- {
- process();
- _frameWriter.readBytes(_outputBuffer);
-
- if(_logger.isLoggable(Level.FINER))
- {
- _logger.log(Level.FINER, "Finished writing SASL output. Output Buffer : " + _outputBuffer);
- }
- }
-
- private void process()
- {
- processHeader();
-
- if(_role == Role.SERVER)
- {
- if(!_mechanismsSent && _mechanisms != null)
- {
- SaslMechanisms mechanisms = new SaslMechanisms();
-
- mechanisms.setSaslServerMechanisms(_mechanisms);
- writeFrame(mechanisms);
- _mechanismsSent = true;
- _state = SaslState.PN_SASL_STEP;
- }
-
- if(getState() == SaslState.PN_SASL_STEP && getChallengeResponse() != null)
- {
- SaslChallenge challenge = new SaslChallenge();
- challenge.setChallenge(getChallengeResponse());
- writeFrame(challenge);
- setChallengeResponse(null);
- }
-
- if(_done)
- {
- org.apache.qpid.proton.amqp.security.SaslOutcome outcome =
- new org.apache.qpid.proton.amqp.security.SaslOutcome();
- outcome.setCode(SaslCode.values()[_outcome.getCode()]);
- writeFrame(outcome);
- }
- }
- else if(_role == Role.CLIENT)
- {
- if(getState() == SaslState.PN_SASL_IDLE && _chosenMechanism != null)
- {
- processInit();
- _state = SaslState.PN_SASL_STEP;
-
- //HACK: if we received an outcome before
- //we sent our init, change the state now
- if(_outcome != SaslOutcome.PN_SASL_NONE)
- {
- _state = classifyStateFromOutcome(_outcome);
- }
- }
-
- if(getState() == SaslState.PN_SASL_STEP && getChallengeResponse() != null)
- {
- processResponse();
- }
- }
- }
-
- private void writeFrame(SaslFrameBody frameBody)
- {
- _frameWriter.writeFrame(frameBody);
- }
-
- @Override
- final public int recv(byte[] bytes, int offset, int size)
- {
- if(_pending == null)
- {
- return -1;
- }
- final int written = pourBufferToArray(_pending, bytes, offset, size);
- if(!_pending.hasRemaining())
- {
- _pending = null;
- }
- return written;
- }
-
- @Override
- final public int send(byte[] bytes, int offset, int size)
- {
- byte[] data = new byte[size];
- System.arraycopy(bytes, offset, data, 0, size);
- setChallengeResponse(new Binary(data));
- return size;
- }
-
- final int processHeader()
- {
- if(!_headerWritten)
- {
- _frameWriter.writeHeader(AmqpHeader.SASL_HEADER);
-
- _headerWritten = true;
- return AmqpHeader.SASL_HEADER.length;
- }
- else
- {
- return 0;
- }
- }
-
- @Override
- public int pending()
- {
- return _pending == null ? 0 : _pending.remaining();
- }
-
- void setPending(ByteBuffer pending)
- {
- _pending = pending;
- }
-
- @Override
- public SaslState getState()
- {
- return _state;
- }
-
- final Binary getChallengeResponse()
- {
- return _challengeResponse;
- }
-
- final void setChallengeResponse(Binary challengeResponse)
- {
- _challengeResponse = challengeResponse;
- }
-
- @Override
- public void setMechanisms(String... mechanisms)
- {
- if(mechanisms != null)
- {
- _mechanisms = new Symbol[mechanisms.length];
- for(int i = 0; i < mechanisms.length; i++)
- {
- _mechanisms[i] = Symbol.valueOf(mechanisms[i]);
- }
- }
-
- if(_role == Role.CLIENT)
- {
- assert mechanisms != null;
- assert mechanisms.length == 1;
-
- _chosenMechanism = Symbol.valueOf(mechanisms[0]);
- }
- }
-
- @Override
- public String[] getRemoteMechanisms()
- {
- if(_role == Role.SERVER)
- {
- return _chosenMechanism == null ? new String[0] : new String[] { _chosenMechanism.toString() };
- }
- else if(_role == Role.CLIENT)
- {
- if(_mechanisms == null)
- {
- return new String[0];
- }
- else
- {
- String[] remoteMechanisms = new String[_mechanisms.length];
- for(int i = 0; i < _mechanisms.length; i++)
- {
- remoteMechanisms[i] = _mechanisms[i].toString();
- }
- return remoteMechanisms;
- }
- }
- else
- {
- throw new IllegalStateException();
- }
- }
-
- public void setMechanism(Symbol mechanism)
- {
- _chosenMechanism = mechanism;
- }
-
- public Symbol getChosenMechanism()
- {
- return _chosenMechanism;
- }
-
- public void setResponse(Binary initialResponse)
- {
- setPending(initialResponse.asByteBuffer());
- }
-
- @Override
- public void handle(SaslFrameBody frameBody, Binary payload)
- {
- frameBody.invoke(this, payload, null);
- }
-
- @Override
- public void handleInit(SaslInit saslInit, Binary payload, Void context)
- {
- if(_role == null)
- {
- server();
- }
- checkRole(Role.SERVER);
- _hostname = saslInit.getHostname();
- _chosenMechanism = saslInit.getMechanism();
- _initReceived = true;
- if(saslInit.getInitialResponse() != null)
- {
- setPending(saslInit.getInitialResponse().asByteBuffer());
- }
- }
-
- @Override
- public void handleResponse(SaslResponse saslResponse, Binary payload, Void context)
- {
- checkRole(Role.SERVER);
- setPending(saslResponse.getResponse() == null ? null : saslResponse.getResponse().asByteBuffer());
- }
-
- @Override
- public void done(SaslOutcome outcome)
- {
- checkRole(Role.SERVER);
- _outcome = outcome;
- _done = true;
- _state = classifyStateFromOutcome(outcome);
- _logger.fine("SASL negotiation done: " + this);
- }
-
- private void checkRole(Role role)
- {
- if(role != _role)
- {
- throw new IllegalStateException("Role is " + _role + " but should be " + role);
- }
- }
-
- @Override
- public void handleMechanisms(SaslMechanisms saslMechanisms, Binary payload, Void context)
- {
- if(_role == null)
- {
- client();
- }
- checkRole(Role.CLIENT);
- _mechanisms = saslMechanisms.getSaslServerMechanisms();
- }
-
- @Override
- public void handleChallenge(SaslChallenge saslChallenge, Binary payload, Void context)
- {
- checkRole(Role.CLIENT);
- setPending(saslChallenge.getChallenge() == null ? null : saslChallenge.getChallenge().asByteBuffer());
- }
-
- @Override
- public void handleOutcome(org.apache.qpid.proton.amqp.security.SaslOutcome saslOutcome,
- Binary payload,
- Void context)
- {
- checkRole(Role.CLIENT);
- for(SaslOutcome outcome : SaslOutcome.values())
- {
- if(outcome.getCode() == saslOutcome.getCode().ordinal())
- {
- _outcome = outcome;
- if (_state != SaslState.PN_SASL_IDLE)
- {
- _state = classifyStateFromOutcome(outcome);
- }
- break;
- }
- }
- _done = true;
-
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine("Handled outcome: " + this);
- }
- }
-
- private SaslState classifyStateFromOutcome(SaslOutcome outcome)
- {
- return outcome == SaslOutcome.PN_SASL_OK ? SaslState.PN_SASL_PASS : SaslState.PN_SASL_FAIL;
- }
-
- private void processResponse()
- {
- SaslResponse response = new SaslResponse();
- response.setResponse(getChallengeResponse());
- setChallengeResponse(null);
- writeFrame(response);
- }
-
- private void processInit()
- {
- SaslInit init = new SaslInit();
- init.setHostname(_hostname);
- init.setMechanism(_chosenMechanism);
- if(getChallengeResponse() != null)
- {
- init.setInitialResponse(getChallengeResponse());
- setChallengeResponse(null);
- }
- _initSent = true;
- writeFrame(init);
- }
-
- @Override
- public void plain(String username, String password)
- {
- client();
- _chosenMechanism = Symbol.valueOf("PLAIN");
- byte[] usernameBytes = username.getBytes();
- byte[] passwordBytes = password.getBytes();
- byte[] data = new byte[usernameBytes.length+passwordBytes.length+2];
- System.arraycopy(usernameBytes, 0, data, 1, usernameBytes.length);
- System.arraycopy(passwordBytes, 0, data, 2+usernameBytes.length, passwordBytes.length);
-
- setChallengeResponse(new Binary(data));
- }
-
- @Override
- public SaslOutcome getOutcome()
- {
- return _outcome;
- }
-
- @Override
- public void client()
- {
- _role = Role.CLIENT;
- if(_mechanisms != null)
- {
- assert _mechanisms.length == 1;
-
- _chosenMechanism = _mechanisms[0];
- }
- }
-
- @Override
- public void server()
- {
- _role = Role.SERVER;
- }
-
- @Override
- public void allowSkip(boolean allowSkip)
- {
- _allowSkip = allowSkip;
- }
-
- public TransportWrapper wrap(final TransportInput input, final TransportOutput output)
- {
- return new SaslSniffer(new SaslTransportWrapper(input, output),
- new PlainTransportWrapper(output, input)) {
- protected boolean isDeterminationMade() {
- if (_role == Role.SERVER && _allowSkip) {
- return super.isDeterminationMade();
- } else {
- _selectedTransportWrapper = _wrapper1;
- return true;
- }
- }
- };
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder
- .append("SaslImpl [_outcome=").append(_outcome)
- .append(", state=").append(_state)
- .append(", done=").append(_done)
- .append(", role=").append(_role)
- .append("]");
- return builder.toString();
- }
-
- private class SaslTransportWrapper implements TransportWrapper
- {
- private final TransportInput _underlyingInput;
- private final TransportOutput _underlyingOutput;
- private boolean _outputComplete;
- private final ByteBuffer _head;
-
- private SaslTransportWrapper(TransportInput input, TransportOutput output)
- {
- _underlyingInput = input;
- _underlyingOutput = output;
- _head = _outputBuffer.asReadOnlyBuffer();
- _head.limit(0);
- }
-
- private void fillOutputBuffer()
- {
- if(isOutputInSaslMode())
- {
- SaslImpl.this.writeSaslOutput();
- if(_done)
- {
- _outputComplete = true;
- }
- }
- }
-
- /**
- * TODO rationalise this method with respect to the other similar checks of _role/_initReceived etc
- * @see SaslImpl#isDone()
- */
- private boolean isInputInSaslMode()
- {
- return _role == null || (_role == Role.CLIENT && !_done) ||(_role == Role.SERVER && (!_initReceived || !_done));
- }
-
- private boolean isOutputInSaslMode()
- {
- return _role == null || (_role == Role.CLIENT && (!_done || !_initSent)) || (_role == Role.SERVER && !_outputComplete);
- }
-
- @Override
- public int capacity()
- {
- if (_tail_closed) return Transport.END_OF_STREAM;
- if (isInputInSaslMode())
- {
- return _inputBuffer.remaining();
- }
- else
- {
- return _underlyingInput.capacity();
- }
- }
-
- @Override
- public int position()
- {
- if (_tail_closed) return Transport.END_OF_STREAM;
- if (isInputInSaslMode())
- {
- return _inputBuffer.position();
- }
- else
- {
- return _underlyingInput.position();
- }
- }
-
- @Override
- public ByteBuffer tail()
- {
- if (!isInputInSaslMode())
- {
- return _underlyingInput.tail();
- }
-
- return _inputBuffer;
- }
-
- @Override
- public void process() throws TransportException
- {
- _inputBuffer.flip();
-
- try
- {
- reallyProcessInput();
- }
- finally
- {
- _inputBuffer.compact();
- }
- }
-
- @Override
- public void close_tail()
- {
- _tail_closed = true;
- if (isInputInSaslMode()) {
- _head_closed = true;
- _underlyingInput.close_tail();
- } else {
- _underlyingInput.close_tail();
- }
- }
-
- private void reallyProcessInput() throws TransportException
- {
- if(isInputInSaslMode())
- {
- if(_logger.isLoggable(Level.FINER))
- {
- _logger.log(Level.FINER, SaslImpl.this + " about to call input.");
- }
-
- _frameParser.input(_inputBuffer);
- }
-
- if(!isInputInSaslMode())
- {
- if(_logger.isLoggable(Level.FINER))
- {
- _logger.log(Level.FINER, SaslImpl.this + " about to call plain input");
- }
-
- if (_inputBuffer.hasRemaining())
- {
- int bytes = pourAll(_inputBuffer, _underlyingInput);
- if (bytes == Transport.END_OF_STREAM)
- {
- _tail_closed = true;
- }
-
- _underlyingInput.process();
- }
- else
- {
- _underlyingInput.process();
- }
- }
- }
-
- @Override
- public int pending()
- {
- if (isOutputInSaslMode() || _outputBuffer.position() != 0)
- {
- fillOutputBuffer();
- _head.limit(_outputBuffer.position());
-
- if (_head_closed && _outputBuffer.position() == 0)
- {
- return Transport.END_OF_STREAM;
- }
- else
- {
- return _outputBuffer.position();
- }
- }
- else
- {
- return _underlyingOutput.pending();
- }
- }
-
- @Override
- public ByteBuffer head()
- {
- if (isOutputInSaslMode() || _outputBuffer.position() != 0)
- {
- pending();
- return _head;
- }
- else
- {
- return _underlyingOutput.head();
- }
- }
-
- @Override
- public void pop(int bytes)
- {
- if (isOutputInSaslMode() || _outputBuffer.position() != 0)
- {
- _outputBuffer.flip();
- _outputBuffer.position(bytes);
- _outputBuffer.compact();
- _head.position(0);
- _head.limit(_outputBuffer.position());
- }
- else
- {
- _underlyingOutput.pop(bytes);
- }
- }
-
- @Override
- public void close_head()
- {
- _underlyingOutput.close_head();
- }
- }
-
- @Override
- public String getHostname()
- {
- if(_role != null)
- {
- checkRole(Role.SERVER);
- }
-
- return _hostname;
- }
-
- @Override
- public void setRemoteHostname(String hostname)
- {
- if(_role != null)
- {
- checkRole(Role.CLIENT);
- }
-
- _hostname = hostname;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslSniffer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslSniffer.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslSniffer.java
deleted file mode 100644
index 2d92496..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslSniffer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-
-/**
- * SaslSniffer
- *
- */
-
-class SaslSniffer extends HandshakeSniffingTransportWrapper<TransportWrapper, TransportWrapper>
-{
-
- SaslSniffer(TransportWrapper sasl, TransportWrapper other) {
- super(sasl, other);
- }
-
- protected int bufferSize() { return AmqpHeader.SASL_HEADER.length; }
-
- protected void makeDetermination(byte[] bytes) {
- if (bytes.length < bufferSize()) {
- throw new IllegalArgumentException("insufficient bytes");
- }
-
- for (int i = 0; i < AmqpHeader.SASL_HEADER.length; i++) {
- if (bytes[i] != AmqpHeader.SASL_HEADER[i]) {
- _selectedTransportWrapper = _wrapper2;
- return;
- }
- }
-
- _selectedTransportWrapper = _wrapper1;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SenderImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SenderImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SenderImpl.java
deleted file mode 100644
index f418655..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SenderImpl.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.codec.ReadableBuffer;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Sender;
-
-public class SenderImpl extends LinkImpl implements Sender
-{
- private int _offered;
- private TransportSender _transportLink;
-
- SenderImpl(SessionImpl session, String name)
- {
- super(session, name);
- }
-
- @Override
- public void offer(final int credits)
- {
- _offered = credits;
- }
-
- @Override
- public int send(final byte[] bytes, int offset, int length)
- {
- if (getLocalState() == EndpointState.CLOSED)
- {
- throw new IllegalStateException("send not allowed after the sender is closed.");
- }
- DeliveryImpl current = current();
- if (current == null || current.getLink() != this)
- {
- throw new IllegalArgumentException();//TODO.
- }
- int sent = current.send(bytes, offset, length);
- if (sent > 0) {
- getSession().incrementOutgoingBytes(sent);
- }
- return sent;
- }
-
- @Override
- public int send(final ReadableBuffer buffer)
- {
- if (getLocalState() == EndpointState.CLOSED)
- {
- throw new IllegalStateException("send not allowed after the sender is closed.");
- }
- DeliveryImpl current = current();
- if (current == null || current.getLink() != this)
- {
- throw new IllegalArgumentException();
- }
- int sent = current.send(buffer);
- if (sent > 0) {
- getSession().incrementOutgoingBytes(sent);
- }
- return sent;
- }
-
- @Override
- public void abort()
- {
- //TODO.
- }
-
- @Override
- void doFree()
- {
- getSession().freeSender(this);
- super.doFree();
- }
-
- @Override
- public boolean advance()
- {
- DeliveryImpl delivery = current();
- if (delivery != null) {
- delivery.setComplete();
- }
-
- boolean advance = super.advance();
- if(advance && _offered > 0)
- {
- _offered--;
- }
- if(advance)
- {
- decrementCredit();
- delivery.addToTransportWorkList();
- getSession().incrementOutgoingDeliveries(1);
- }
-
- return advance;
- }
-
- boolean hasOfferedCredits()
- {
- return _offered > 0;
- }
-
- @Override
- TransportSender getTransportLink()
- {
- return _transportLink;
- }
-
- void setTransportLink(TransportSender transportLink)
- {
- _transportLink = transportLink;
- }
-
-
- @Override
- public void setCredit(int credit)
- {
- super.setCredit(credit);
- /* while(getQueued()>0 && getCredit()>0)
- {
- advance();
- }*/
- }
-
- @Override
- public int getRemoteCredit()
- {
- // Credit is decremented as soon as advance is called on a send,
- // so we need only consider the credit count, not the queued count.
- return getCredit();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[17/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/EndpointState.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/EndpointState.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/EndpointState.java
deleted file mode 100644
index c11da6c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/EndpointState.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.qpid.proton.engine;
-/*
- *
- * 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.
- *
-*/
-
-
-/**
- * Represents the state of a communication endpoint.
- */
-public enum EndpointState
-{
- UNINITIALIZED,
- ACTIVE,
- CLOSED;
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Engine.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Engine.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Engine.java
deleted file mode 100644
index 3bd46ce..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Engine.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-/**
- * Engine
- *
- */
-
-public final class Engine
-{
-
- private Engine()
- {
- }
-
- public static Collector collector()
- {
- return Collector.Factory.create();
- }
-
- public static Connection connection()
- {
- return Connection.Factory.create();
- }
-
- public static Transport transport()
- {
- return Transport.Factory.create();
- }
-
- public static SslDomain sslDomain()
- {
- return SslDomain.Factory.create();
- }
-
- public static SslPeerDetails sslPeerDetails(String hostname, int port)
- {
- return SslPeerDetails.Factory.create(hostname, port);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java
deleted file mode 100644
index 5930d2c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Selectable;
-import org.apache.qpid.proton.reactor.Task;
-
-
-/**
- * Event
- *
- */
-
-public interface Event extends Extendable
-{
- /**
- * Event types built into the library.
- */
- public enum Type implements EventType {
- REACTOR_INIT,
- REACTOR_QUIESCED,
- REACTOR_FINAL,
-
- TIMER_TASK,
-
- CONNECTION_INIT,
- CONNECTION_BOUND,
- CONNECTION_UNBOUND,
- CONNECTION_LOCAL_OPEN,
- CONNECTION_REMOTE_OPEN,
- CONNECTION_LOCAL_CLOSE,
- CONNECTION_REMOTE_CLOSE,
- CONNECTION_FINAL,
-
- SESSION_INIT,
- SESSION_LOCAL_OPEN,
- SESSION_REMOTE_OPEN,
- SESSION_LOCAL_CLOSE,
- SESSION_REMOTE_CLOSE,
- SESSION_FINAL,
-
- LINK_INIT,
- LINK_LOCAL_OPEN,
- LINK_REMOTE_OPEN,
- LINK_LOCAL_DETACH,
- LINK_REMOTE_DETACH,
- LINK_LOCAL_CLOSE,
- LINK_REMOTE_CLOSE,
- LINK_FLOW,
- LINK_FINAL,
-
- DELIVERY,
-
- TRANSPORT,
- TRANSPORT_ERROR,
- TRANSPORT_HEAD_CLOSED,
- TRANSPORT_TAIL_CLOSED,
- TRANSPORT_CLOSED,
-
- SELECTABLE_INIT,
- SELECTABLE_UPDATED,
- SELECTABLE_READABLE,
- SELECTABLE_WRITABLE,
- SELECTABLE_EXPIRED,
- SELECTABLE_ERROR,
- SELECTABLE_FINAL,
-
- /**
- * This value must never be used to generate an event, it's only used as
- * a guard when casting custom EventTypes to core {@link Type} via
- * {@link Event#getType()}.
- */
- NON_CORE_EVENT {
- @Override
- public boolean isValid() { return false; }
- };
-
- @Override
- public boolean isValid() {
- return true;
- }
- }
-
- /**
- * @return type of the event. The event type can be defined outside of the
- * proton library.
- */
- EventType getEventType();
-
- /**
- * A concrete event type of core events.
- *
- * @return type of the event for core events. For events generated by
- * extensions a {@link Type#NON_CORE_EVENT} will be returned
- */
- Type getType();
-
- Object getContext();
-
- /**
- * The {@link Handler} at the root of the handler tree.
- * <p>
- * Set by the {@link Reactor} before dispatching the event.
- * <p>
- * @see #redispatch(EventType, Handler)
- * @return The root handler
- */
- Handler getRootHandler();
-
- void dispatch(Handler handler) throws HandlerException;
-
- /**
- * Synchronously redispatch the current event as a new {@link EventType} on the provided handler and it's children.
- * <p>
- * Note: the <code>redispatch()</code> will complete before children of the current handler have had the current event dispatched, see {@link #delegate()}.
- *
- *
- * @param as_type Type of event to dispatch
- * @param handler The handler where to start the dispatch. Use {@link #getRootHandler()} to redispatch the new event to all handlers in the tree.
- * @throws HandlerException A wrapper exception of any unhandled exception thrown by <code>handler</code>
- */
- void redispatch(EventType as_type, Handler handler) throws HandlerException;
-
- /**
- * dispatch the event to all children of the handler. A handler can call
- * this method explicitly to be able to do more processing after all child
- * handlers have already processed the event. If handler does not invoke
- * this method it is invoked implicitly by {@link #dispatch(Handler)}
- *
- * @throws HandlerException
- */
- void delegate() throws HandlerException;
-
- Connection getConnection();
-
- Session getSession();
-
- Link getLink();
-
- Sender getSender();
-
- Receiver getReceiver();
-
- Delivery getDelivery();
-
- Transport getTransport();
-
- Reactor getReactor();
-
- Selectable getSelectable();
-
- Task getTask();
-
- Event copy();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/EventType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/EventType.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/EventType.java
deleted file mode 100644
index 68ec6e4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/EventType.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-/**
- * Entry point for external libraries to add event types. Event types should be
- * <code>final static</code> fields. EventType instances are compared by
- * reference.
- * <p>
- * Event types are best described by an <code>enum</code> that implements the
- * {@link EventType} interface, see {@link Event.Type}.
- *
- */
-public interface EventType {
-
- /**
- * @return false if this particular EventType instance does not represent a
- * real event type but a guard value, example: extra enum value for
- * switch statements, see {@link Event.Type#NON_CORE_EVENT}
- */
- public boolean isValid();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Extendable.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Extendable.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Extendable.java
deleted file mode 100644
index 14b9b2e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Extendable.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-
-/**
- * Extendable
- *
- */
-
-public interface Extendable
-{
-
- Record attachments();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java
deleted file mode 100644
index d2eee03..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-/**
- * A typesafe convenience class for associating additional data with {@link Extendable} classes.
- * <p>
- * An instance of <code>ExtendableAccessor</code> uses itself as the key in the {@link Extendable#attachments()}
- * so it's best instantiated as a static final member.
- * <pre><code>
- * class Foo extends BaseHandler {
- * private static ExtendableAccessor<Link, Bar> LINK_BAR = new ExtendableAccessor<>(Bar.class);
- * void onLinkRemoteOpen(Event e) {
- * Bar bar = LINK_BAR.get(e.getLink());
- * if (bar == null) {
- * bar = new Bar();
- * LINK_BAR.set(e.getLink(), bar);
- * }
- * }
- * }
- * </code></pre>
- *
- * @param <E> An {@link Extendable} type where the data is to be stored
- * @param <T> The type of the data to be stored
- */
-public final class ExtendableAccessor<E extends Extendable, T> {
- private final Class<T> klass;
- public ExtendableAccessor(Class<T> klass) {
- this.klass = klass;
- }
-
- public T get(E e) {
- return e.attachments().get(this, klass);
- }
-
- public void set(E e, T value) {
- e.attachments().set(this, klass, value);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Handler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Handler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Handler.java
deleted file mode 100644
index 3a8e5ae..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Handler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import java.util.Iterator;
-
-
-/**
- * Handler
- *
- */
-
-public interface Handler
-{
- /**
- * Handle the event in this instance. This is the second half of
- * {@link Event#dispatch(Handler)}. The method must invoke a concrete onXxx
- * method for the given event, or invoke it's {@link #onUnhandled(Event)}
- * method if the {@link EventType} of the event is not recognized by the
- * handler.
- * <p>
- * <b>Note:</b> The handler is not supposed to invoke the
- * {@link #handle(Event)} method on it's {@link #children()}, that is the
- * responsibility of the {@link Event#dispatch(Handler)}
- *
- * @see BaseHandler
- * @param e
- * The event to handle
- */
- void handle(Event e);
-
- void onUnhandled(Event e);
-
- void add(Handler child);
-
- Iterator<Handler> children();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/HandlerException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/HandlerException.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/HandlerException.java
deleted file mode 100644
index ca18d7c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/HandlerException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine;
-
-
-public class HandlerException extends RuntimeException {
-
- private static final long serialVersionUID = 5300211824119834005L;
-
- private final Handler handler;
-
- public HandlerException(Handler handler, Throwable cause) {
- super(cause);
- this.handler = handler;
- }
-
- public Handler getHandler() {
- return handler;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java
deleted file mode 100644
index 248c687..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import java.util.EnumSet;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.amqp.transport.Source;
-import org.apache.qpid.proton.amqp.transport.Target;
-
-/**
- * Link
- *
- * The settlement mode defaults are:
- *
- * Sender settle mode - {@link SenderSettleMode#MIXED}.
- * Receiver settle mode - {@link ReceiverSettleMode#FIRST}
- *
- * TODO describe the application's responsibility to honour settlement.
- */
-public interface Link extends Endpoint
-{
-
- /**
- * Returns the name of the link
- *
- * @return the link name
- */
- String getName();
-
- /**
- * Create a delivery object based on the specified tag and adds it to the
- * this link's delivery list and its connection work list.
- *
- * TODO to clarify - this adds the delivery to the connection list. It is not yet
- * clear why this is done or if it is useful for the application to be able to discover
- * newly created deliveries from the {@link Connection#getWorkHead()}.
- *
- * @param tag a tag for the delivery
- * @return a new Delivery object
- */
- public Delivery delivery(byte[] tag);
-
- /**
- * Create a delivery object based on the specified tag. This form
- * of the method is intended to allow the tag to be formed from a
- * subsequence of the byte array passed in. This might allow more
- * optimisation options in future but at present is not
- * implemented.
- *
- * @param tag a tag for the delivery
- * @param offset (currently ignored and must be 0)
- * @param length (currently ignored and must be the length of the <code>tag</code> array
- * @return a Delivery object
- */
- public Delivery delivery(byte[] tag, int offset, int length);
-
- /**
- * Returns the head delivery on the link.
- */
- Delivery head();
-
- /**
- * Returns the current delivery
- */
- Delivery current();
-
- /**
- * Attempts to advance the current delivery. Advances it to the next delivery if one exists, else null.
- *
- * The behaviour of this method is different for senders and receivers.
- *
- * @return true if it can advance, false if it cannot
- *
- * TODO document the meaning of the return value more fully. Currently Senderimpl only returns false if there is no current delivery
- */
- boolean advance();
-
-
- Source getSource();
- Target getTarget();
-
- /**
- * Sets the source for this link.
- *
- * The initiator of the link must always provide a Source.
- *
- * An application responding to the creation of the link should perform an application
- * specific lookup on the {@link #getRemoteSource()} to determine an actual Source. If it
- * failed to determine an actual source, it should set null, and then go on to {@link #close()}
- * the link.
- *
- * @see "AMQP Spec 1.0 section 2.6.3"
- */
- void setSource(Source address);
-
- /**
- * Expected to be used in a similar manner to {@link #setSource(Source)}
- */
- void setTarget(Target address);
-
- /**
- * @see #setSource(Source)
- */
- Source getRemoteSource();
-
- /**
- * @see #setTarget(Target)
- */
- Target getRemoteTarget();
-
- public Link next(EnumSet<EndpointState> local, EnumSet<EndpointState> remote);
-
- /**
- * Gets the credit balance for a link.
- *
- * Note that a sending link may still be used to send deliveries even if
- * link credit is/reaches zero, however those deliveries will end up being
- * {@link #getQueued() queued} by the link until enough credit is obtained
- * from the receiver to send them over the wire. In this case the balance
- * reported will go negative.
- *
- * @return the credit balance for the link
- */
- public int getCredit();
-
- /**
- * Gets the number of queued messages for a link.
- *
- * Links may queue deliveries for a number of reasons, for example there may be insufficient
- * {@link #getCredit() credit} to send them to the receiver, they may not have yet had a chance
- * to be written to the wire, or the receiving application has simply not yet processed them.
- *
- * @return the queued message count for the link
- */
- public int getQueued();
-
- public int getUnsettled();
-
- public Session getSession();
-
- SenderSettleMode getSenderSettleMode();
-
- /**
- * Sets the sender settle mode.
- *
- * Should only be called during link set-up, i.e. before calling {@link #open()}.
- *
- * If this endpoint is the initiator of the link, this method can be used to set a value other than
- * the default.
- *
- * If this endpoint is not the initiator, this method should be used to set a local value. According
- * to the AMQP spec, the application may choose to accept the sender's suggestion
- * (accessed by calling {@link #getRemoteSenderSettleMode()}) or choose another value. The value
- * has no effect on Proton, but may be useful to the application at a later point.
- *
- * In order to be AMQP compliant the application is responsible for honouring the settlement mode. See {@link Link}.
- */
- void setSenderSettleMode(SenderSettleMode senderSettleMode);
-
- /**
- * @see #setSenderSettleMode(SenderSettleMode)
- */
- SenderSettleMode getRemoteSenderSettleMode();
-
- ReceiverSettleMode getReceiverSettleMode();
-
- /**
- * Sets the receiver settle mode.
- *
- * Used in analogous way to {@link #setSenderSettleMode(SenderSettleMode)}
- */
- void setReceiverSettleMode(ReceiverSettleMode receiverSettleMode);
-
- /**
- * @see #setReceiverSettleMode(ReceiverSettleMode)
- */
- ReceiverSettleMode getRemoteReceiverSettleMode();
-
- /**
- * TODO should this be part of the interface?
- */
- @Deprecated
- void setRemoteSenderSettleMode(SenderSettleMode remoteSenderSettleMode);
-
- /**
- * Gets the local link properties.
- *
- * @see #setProperties(Map)
- */
- Map<Symbol, Object> getProperties();
-
- /**
- * Sets the local link properties, to be conveyed to the peer via the Attach frame when
- * attaching the link to the session.
- *
- * Must be called during link setup, i.e. before calling the {@link #open()} method.
- */
- void setProperties(Map<Symbol, Object> properties);
-
- /**
- * Gets the remote link properties, as conveyed from the peer via the Attach frame
- * when attaching the link to the session.
- *
- * @return the properties Map conveyed by the peer, or null if there was none.
- */
- Map<Symbol, Object> getRemoteProperties();
-
- public int drained();
-
- /**
- * Returns a [locally generated] view of credit at the remote peer by considering the
- * current link {@link #getCredit() credit} count as well as the effect of
- * any locally {@link #getQueued() queued} messages.
- *
- * @return view of effective remote credit
- */
- public int getRemoteCredit();
-
- public boolean getDrain();
-
- public void detach();
- public boolean detached();
-
- /**
- * Sets the local link offered capabilities, to be conveyed to the peer via the Attach frame
- * when attaching the link to the session.
- *
- * Must be called during link setup, i.e. before calling the {@link #open()} method.
- *
- * @param offeredCapabilities
- * the offered capabilities array to send, or null for none.
- */
- public void setOfferedCapabilities(Symbol[] offeredCapabilities);
-
- /**
- * Gets the local link offered capabilities.
- *
- * @return the offered capabilities array, or null if none was set.
- *
- * @see #setOfferedCapabilities(Symbol[])
- */
- Symbol[] getOfferedCapabilities();
-
- /**
- * Gets the remote link offered capabilities, as conveyed from the peer via the Attach frame
- * when attaching the link to the session.
- *
- * @return the offered capabilities array conveyed by the peer, or null if there was none.
- */
- Symbol[] getRemoteOfferedCapabilities();
-
- /**
- * Sets the local link desired capabilities, to be conveyed to the peer via the Attach frame
- * when attaching the link to the session.
- *
- * Must be called during link setup, i.e. before calling the {@link #open()} method.
- *
- * @param desiredCapabilities
- * the desired capabilities array to send, or null for none.
- */
- public void setDesiredCapabilities(Symbol[] desiredCapabilities);
-
- /**
- * Gets the local link desired capabilities.
- *
- * @return the desired capabilities array, or null if none was set.
- *
- * @see #setDesiredCapabilities(Symbol[])
- */
- Symbol[] getDesiredCapabilities();
-
- /**
- * Gets the remote link desired capabilities, as conveyed from the peer via the Attach frame
- * when attaching the link to the session.
- *
- * @return the desired capabilities array conveyed by the peer, or null if there was none.
- */
- Symbol[] getRemoteDesiredCapabilities();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJConnection.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJConnection.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJConnection.java
deleted file mode 100644
index bf44a3c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJConnection.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.Connection;
-
-/**
- * Extends {@link Connection} with functionality that is specific to proton-j
- */
-public interface ProtonJConnection extends Connection, ProtonJEndpoint
-{
- void setLocalContainerId(String localContainerId);
-
- @Override
- ProtonJSession session();
-
- int getMaxChannels();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJEndpoint.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJEndpoint.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJEndpoint.java
deleted file mode 100644
index accc7e3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJEndpoint.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.Endpoint;
-
-public interface ProtonJEndpoint extends Endpoint
-{
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSession.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSession.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSession.java
deleted file mode 100644
index f939d93..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSession.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-
-/**
- * Extends {@link Session} with functionality that is specific to proton-j
- */
-public interface ProtonJSession extends Session, ProtonJEndpoint
-{
- Sender sender(String name);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSslDomain.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSslDomain.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSslDomain.java
deleted file mode 100644
index e1960fc..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSslDomain.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.SslDomain;
-
-/**
- * Extends {@link SslDomain} with functionality that is specific to proton-j
- */
-public interface ProtonJSslDomain extends SslDomain
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSslPeerDetails.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSslPeerDetails.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSslPeerDetails.java
deleted file mode 100644
index ea5aae8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJSslPeerDetails.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.SslPeerDetails;
-
-/**
- * Extends {@link SslPeerDetails} with functionality specific to proton-j
- */
-public interface ProtonJSslPeerDetails extends SslPeerDetails
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJTransport.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJTransport.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJTransport.java
deleted file mode 100644
index 8bd24b3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/ProtonJTransport.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.impl.ProtocolTracer;
-
-/**
- * Extends {@link Transport} with functionality that is specific to proton-j
- */
-public interface ProtonJTransport extends Transport
-{
- void setProtocolTracer(ProtocolTracer protocolTracer);
-
- ProtocolTracer getProtocolTracer();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Receiver.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Receiver.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Receiver.java
deleted file mode 100644
index f9d718f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Receiver.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.codec.WritableBuffer;
-
-/**
- * Receiver
- *
- */
-public interface Receiver extends Link
-{
-
- /**
- * Adds the specified number of credits.
- *
- * The number of link credits initialises to zero. It is the application's responsibility to call
- * this method to allow the receiver to receive {@code credits} more deliveries.
- */
- public void flow(int credits);
-
- /**
- * Receive message data for the current delivery.
- *
- * If the caller takes all the bytes the Receiver currently has for this delivery then it is removed from
- * the Connection's work list.
- *
- * Before considering a delivery to be complete, the caller should examine {@link Delivery#isPartial()}. If
- * the delivery is partial, the caller should call {@link #recv(byte[], int, int)} again to receive
- * the additional bytes once the Delivery appears again on the Connection work-list.
- *
- * TODO might the flags other than IO_WORK in DeliveryImpl also prevent the work list being pruned?
- * e.g. what if a slow JMS consumer receives a disposition frame containing state=RELEASED? This is not IO_WORK.
- *
- * @param bytes the destination array where the message data is written
- * @param offset index in the array to start writing data at
- * @param size the maximum number of bytes to write
- *
- * @return number of bytes written. -1 if there are no more bytes for the current delivery.
- *
- * @see #current()
- */
- public int recv(byte[] bytes, int offset, int size);
-
- /**
- * Receive message data for the current delivery.
- *
- * @param buffer the buffer to write the message data.
- *
- * @return number of bytes written. -1 if there are no more bytes for the current delivery.
- */
- public int recv(WritableBuffer buffer);
-
- public void drain(int credit);
-
- /**
- * {@inheritDoc}
- *
- * TODO document what this method conceptually does and when you should use it.
- */
- @Override
- public boolean advance();
-
- public boolean draining();
-
- public void setDrain(boolean drain);
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Record.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Record.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Record.java
deleted file mode 100644
index e97948d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Record.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-
-/**
- * Record
- *
- */
-
-public interface Record
-{
-
- <T> T get(Object key, Class<T> klass);
- <T> void set(Object key, Class<T> klass, T value);
- void clear();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/RecordAccessor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/RecordAccessor.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/RecordAccessor.java
deleted file mode 100644
index 4896b21..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/RecordAccessor.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-public interface RecordAccessor<T> {
- public T get(Record r);
- public void set(Record r, T value);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
deleted file mode 100644
index 08929e8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package org.apache.qpid.proton.engine;
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-public interface Sasl
-{
- public enum SaslState
- {
- /** Pending configuration by application */
- PN_SASL_CONF,
- /** Pending SASL Init */
- PN_SASL_IDLE,
- /** negotiation in progress */
- PN_SASL_STEP,
- /** negotiation completed successfully */
- PN_SASL_PASS,
- /** negotiation failed */
- PN_SASL_FAIL
- }
-
- public enum SaslOutcome
- {
- /** negotiation not completed */
- PN_SASL_NONE((byte)-1),
- /** authentication succeeded */
- PN_SASL_OK((byte)0),
- /** failed due to bad credentials */
- PN_SASL_AUTH((byte)1),
- /** failed due to a system error */
- PN_SASL_SYS((byte)2),
- /** failed due to unrecoverable error */
- PN_SASL_PERM((byte)3),
- PN_SASL_TEMP((byte)4),
- PN_SASL_SKIPPED((byte)5);
-
- private final byte _code;
-
- /** failed due to transient error */
-
- SaslOutcome(byte code)
- {
- _code = code;
- }
-
- public byte getCode()
- {
- return _code;
- }
- }
-
- public static SaslOutcome PN_SASL_NONE = SaslOutcome.PN_SASL_NONE;
- public static SaslOutcome PN_SASL_OK = SaslOutcome.PN_SASL_OK;
- public static SaslOutcome PN_SASL_AUTH = SaslOutcome.PN_SASL_AUTH;
- public static SaslOutcome PN_SASL_SYS = SaslOutcome.PN_SASL_SYS;
- public static SaslOutcome PN_SASL_PERM = SaslOutcome.PN_SASL_PERM;
- public static SaslOutcome PN_SASL_TEMP = SaslOutcome.PN_SASL_TEMP;
- public static SaslOutcome PN_SASL_SKIPPED = SaslOutcome.PN_SASL_SKIPPED;
-
- /**
- * Access the current state of the layer.
- *
- * @return The state of the sasl layer.
- */
- SaslState getState();
-
- /**
- * Set the acceptable SASL mechanisms for the layer.
- *
- * @param mechanisms a list of acceptable SASL mechanisms
- */
- void setMechanisms(String... mechanisms);
-
- /**
- * Retrieve the list of SASL mechanisms provided by the remote.
- *
- * @return the SASL mechanisms advertised by the remote
- */
- String[] getRemoteMechanisms();
-
- /**
- * Set the remote hostname to indicate the host being connected to when
- * sending a SaslInit to the server.
- */
- void setRemoteHostname(String hostname);
-
- /**
- * Retrieve the hostname indicated by the client when sending its SaslInit.
- *
- * @return the hostname indicated by the remote client, or null if none specified.
- */
- String getHostname();
-
- /**
- * Determine the size of the bytes available via recv().
- *
- * Returns the size in bytes available via recv().
- *
- * @return The number of bytes available, zero if no available data.
- */
- int pending();
-
- /**
- * Read challenge/response data sent from the peer.
- *
- * Use pending to determine the size of the data.
- *
- * @param bytes written with up to size bytes of inbound data.
- * @param offset the offset in the array to begin writing at
- * @param size maximum number of bytes that bytes can accept.
- * @return The number of bytes written to bytes, or an error code if {@literal < 0}.
- */
- int recv(byte[] bytes, int offset, int size);
-
- /**
- * Send challenge or response data to the peer.
- *
- * @param bytes The challenge/response data.
- * @param offset the point within the array at which the data starts at
- * @param size The number of data octets in bytes.
- * @return The number of octets read from bytes, or an error code if {@literal < 0}
- */
- int send(byte[] bytes, int offset, int size);
-
-
- /**
- * Set the outcome of SASL negotiation
- *
- * Used by the server to set the result of the negotiation process.
- *
- * @param outcome the outcome of the SASL negotiation
- */
- void done(SaslOutcome outcome);
-
-
- /**
- * Configure the SASL layer to use the "PLAIN" mechanism.
- *
- * A utility function to configure a simple client SASL layer using
- * PLAIN authentication.
- *
- * @param username credential for the PLAIN authentication
- * mechanism
- * @param password credential for the PLAIN authentication
- * mechanism
- */
- void plain(String username, String password);
-
- /**
- * Retrieve the outcome of SASL negotiation.
- */
- SaslOutcome getOutcome();
-
- void client();
- void server();
-
- /**
- * Set whether servers may accept incoming connections
- * that skip the SASL layer negotiation.
- */
- void allowSkip(boolean allowSkip);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java
deleted file mode 100644
index 159d5c3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.codec.ReadableBuffer;
-
-/**
- * Sender
- *
- */
-public interface Sender extends Link
-{
-
- /**
- * indicates pending deliveries
- *
- * @param credits the number of pending deliveries
- */
- //TODO is this absolute or cumulative?
- public void offer(int credits);
-
- /**
- * Sends some data for the current delivery. The application may call this method multiple
- * times for the same delivery.
- *
- * @param bytes the byte array containing the data to be sent.
- * @param offset the offset into the given array to start reading.
- * @param length the number of bytes to read from the given byte array.
- *
- * @return the number of bytes accepted
- *
- * TODO Proton-j current copies all the bytes it has been given so the return value will always be
- * length. Should this be changed? How does Proton-c behave? What should the application do if
- * the number of bytes accepted is smaller than length.
- */
- public int send(byte[] bytes, int offset, int length);
-
- /**
- * Sends some data for the current delivery. The application may call this method multiple
- * times for the same delivery.
- *
- * @param buffer the buffer to read the data from.
- *
- * @return the number of bytes read from the provided buffer.
- */
- public int send(ReadableBuffer buffer);
-
- /**
- * Abort the current delivery.
- *
- * Note "pn_link_abort" is commented out in the .h
- */
- public void abort();
-
- /**
- * {@inheritDoc}
- *
- * Informs the sender that all the bytes of the current {@link Delivery} have been written.
- * The application must call this method in order for the delivery to be considered complete.
- *
- * @see #send(byte[], int, int)
- *
- * TODO fully state the rules regarding when you have to call this method, what happens if you don't call it
- * before creating another delivery etc.
- */
- @Override
- public boolean advance();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Session.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Session.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Session.java
deleted file mode 100644
index 1a28c26..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Session.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import java.util.EnumSet;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-
-/**
- * Session
- *
- * Note that session level flow control is handled internally by Proton.
- */
-public interface Session extends Endpoint
-{
- /**
- * Returns a newly created sender endpoint
- */
- public Sender sender(String name);
-
- /**
- * Returns a newly created receiver endpoint
- */
- public Receiver receiver(String name);
-
- public Session next(EnumSet<EndpointState> local, EnumSet<EndpointState> remote);
-
- public Connection getConnection();
-
- public int getIncomingCapacity();
-
- public void setIncomingCapacity(int bytes);
-
- public int getIncomingBytes();
-
- public int getOutgoingBytes();
-
- public long getOutgoingWindow();
-
- /**
- * Sets the outgoing window size.
- *
- * @param outgoingWindowSize the outgoing window size
- */
- public void setOutgoingWindow(long outgoingWindowSize);
-
- /**
- * Sets the local session properties, to be conveyed to the peer via the Begin frame when
- * attaching the session to the session.
- *
- * Must be called during session setup, i.e. before calling the {@link #open()} method.
- *
- * @param properties
- * the properties map to send, or null for none.
- */
- void setProperties(Map<Symbol, Object> properties);
-
- /**
- * Gets the local session properties.
- *
- * @return the properties map, or null if none was set.
- *
- * @see #setProperties(Map)
- */
- Map<Symbol, Object> getProperties();
-
- /**
- * Gets the remote session properties, as conveyed from the peer via the Begin frame
- * when opening the session.
- *
- * @return the properties Map conveyed by the peer, or null if there was none.
- */
- Map<Symbol, Object> getRemoteProperties();
-
- /**
- * Sets the local session offered capabilities, to be conveyed to the peer via the Begin frame
- * when opening the session.
- *
- * Must be called during session setup, i.e. before calling the {@link #open()} method.
- *
- * @param offeredCapabilities
- * the offered capabilities array to send, or null for none.
- */
- public void setOfferedCapabilities(Symbol[] offeredCapabilities);
-
- /**
- * Gets the local session offered capabilities.
- *
- * @return the offered capabilities array, or null if none was set.
- *
- * @see #setOfferedCapabilities(Symbol[])
- */
- Symbol[] getOfferedCapabilities();
-
- /**
- * Gets the remote session offered capabilities, as conveyed from the peer via the Begin frame
- * when opening the session.
- *
- * @return the offered capabilities array conveyed by the peer, or null if there was none.
- */
- Symbol[] getRemoteOfferedCapabilities();
-
- /**
- * Sets the local session desired capabilities, to be conveyed to the peer via the Begin frame
- * when opening the session.
- *
- * Must be called during session setup, i.e. before calling the {@link #open()} method.
- *
- * @param desiredCapabilities
- * the desired capabilities array to send, or null for none.
- */
- public void setDesiredCapabilities(Symbol[] desiredCapabilities);
-
- /**
- * Gets the local session desired capabilities.
- *
- * @return the desired capabilities array, or null if none was set.
- *
- * @see #setDesiredCapabilities(Symbol[])
- */
- Symbol[] getDesiredCapabilities();
-
- /**
- * Gets the remote session desired capabilities, as conveyed from the peer via the Begin frame
- * when opening the session.
- *
- * @return the desired capabilities array conveyed by the peer, or null if there was none.
- */
- Symbol[] getRemoteDesiredCapabilities();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Ssl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Ssl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Ssl.java
deleted file mode 100644
index 8d3bab7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Ssl.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-/**
- * I represent the details of a particular SSL session.
- */
-public interface Ssl
-{
- /**
- * Get the name of the Cipher that is currently in use.
- *
- * Gets a text description of the cipher that is currently active, or returns null if SSL
- * is not active (no cipher). Note that the cipher in use may change over time due to
- * renegotiation or other changes to the SSL state.
- *
- * @return the name of the cipher in use, or null if none
- */
- String getCipherName();
-
- /**
- * Get the name of the SSL protocol that is currently in use.
- *
- * Gets a text description of the SSL protocol that is currently active, or null if SSL
- * is not active. Note that the protocol may change over time due to renegotiation.
- *
- * @return the name of the protocol in use, or null if none
- */
- String getProtocolName();
-
- void setPeerHostname(String hostname);
-
- String getPeerHostname();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java
deleted file mode 100644
index 24b101c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.impl.ssl.SslDomainImpl;
-
-/**
- * I store the details used to create SSL sessions.
- */
-public interface SslDomain
-{
-
- public static final class Factory
- {
- public static SslDomain create() {
- return new SslDomainImpl();
- }
- }
-
- /**
- * Determines whether the endpoint acts as a client or server.
- */
- public enum Mode
- {
- /** Local connection endpoint is an SSL client */
- CLIENT,
-
- /** Local connection endpoint is an SSL server */
- SERVER
- }
-
- /**
- * Determines the level of peer validation.
- *
- * {@link #ANONYMOUS_PEER} is configured by default.
- */
- public enum VerifyMode
- {
- /**
- * will only connect to those peers that provide a valid identifying certificate signed
- * by a trusted CA and are using an authenticated cipher
- */
- VERIFY_PEER,
- VERIFY_PEER_NAME,
- /**
- * does not require a valid certificate, and permits use of ciphers that
- * do not provide authentication
- */
- ANONYMOUS_PEER,
- }
-
- /**
- * Initialize the ssl domain object.
- *
- * An SSL object be either an SSL server or an SSL client. It cannot be both. Those
- * transports that will be used to accept incoming connection requests must be configured
- * as an SSL server. Those transports that will be used to initiate outbound connections
- * must be configured as an SSL client.
- *
- */
- void init(Mode mode);
-
- Mode getMode();
-
- /**
- * Set the certificate that identifies the local node to the remote.
- *
- * This certificate establishes the identity for the local node. It will be sent to the
- * remote if the remote needs to verify the identity of this node. This may be used for
- * both SSL servers and SSL clients (if client authentication is required by the server).
- *
- * @param certificateFile path to file/database containing the identifying
- * certificate.
- * @param privateKeyFile path to file/database containing the private key used to
- * sign the certificate
- * @param password the password used to sign the key, else null if key is not
- * protected.
- */
- void setCredentials(String certificateFile, String privateKeyFile, String password);
-
- String getPrivateKeyFile();
-
- String getPrivateKeyPassword();
-
- String getCertificateFile();
-
- /**
- * Configure the set of trusted CA certificates used by this node to verify peers.
- *
- * If the local SSL client/server needs to verify the identity of the remote, it must
- * validate the signature of the remote's certificate. This function sets the database of
- * trusted CAs that will be used to verify the signature of the remote's certificate.
- *
- * @param certificateDb database of trusted CAs, used to authenticate the peer.
- */
- void setTrustedCaDb(String certificateDb);
-
- String getTrustedCaDb();
-
- /**
- * Configure the level of verification used on the peer certificate.
- *
- * This method controls how the peer's certificate is validated, if at all. By default,
- * neither servers nor clients attempt to verify their peers ({@link VerifyMode#ANONYMOUS_PEER}).
- * Once certificates and trusted CAs are configured, peer verification can be enabled.
- *
- * In order to verify a peer, a trusted CA must be configured. See
- * {@link #setTrustedCaDb(String)}.
- *
- * NOTE: Servers must provide their own certificate when verifying a peer. See
- * {@link #setCredentials(String, String, String)}).
- *
- * @param mode the level of validation to apply to the peer
- */
- void setPeerAuthentication(VerifyMode mode);
-
- VerifyMode getPeerAuthentication();
-
- /**
- * Permit a server to accept connection requests from non-SSL clients.
- *
- * This configures the server to "sniff" the incoming client data stream, and dynamically
- * determine whether SSL/TLS is being used. This option is disabled by default: only
- * clients using SSL/TLS are accepted.
- */
- void allowUnsecuredClient(boolean allowUnsecured);
-
- boolean allowUnsecuredClient();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/SslPeerDetails.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/SslPeerDetails.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/SslPeerDetails.java
deleted file mode 100644
index 5b318fe..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/SslPeerDetails.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.impl.ssl.SslPeerDetailsImpl;
-
-/**
- * The details of the remote peer involved in an SSL session.
- *
- * Used when creating an SSL session to hint that the underlying SSL implementation
- * should attempt to resume a previous session if one exists for the same peer details,
- * e.g. using session identifiers (http://tools.ietf.org/html/rfc5246) or session tickets
- * (http://tools.ietf.org/html/rfc5077).
- */
-public interface SslPeerDetails
-{
-
- public static final class Factory
- {
- public static SslPeerDetails create(String hostname, int port) {
- return new SslPeerDetailsImpl(hostname, port);
- }
- }
-
- String getHostname();
- int getPort();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java
deleted file mode 100644
index 5d8b79d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.engine.impl.TransportImpl;
-
-
-/**
- * <p>
- * Operates on the entities in the associated {@link Connection}
- * by accepting and producing binary AMQP output, potentially
- * layered within SASL and/or SSL.
- * </p>
- * <p>
- * After a connection is bound with {@link #bind(Connection)}, the methods for accepting and producing
- * output are typically repeatedly called. See the specific methods for details of their legal usage.
- * </p>
- * <p>
- * <strong>Processing the input data received from another AMQP container.</strong>
- * </p>
- * <ol>
- * <li>{@link #getInputBuffer()} </li>
- * <li>Write data into input buffer</li>
- * <li>{@link #processInput()}</li>
- * <li>Check the result, e.g. by calling {@link TransportResult#checkIsOk()}</li>
- * </ol>
- * <p>
- * <strong>Getting the output data to send to another AMQP container:</strong>
- * </p>
- * <ol>
- * <li>{@link #getOutputBuffer()} </li>
- * <li>Read output from output buffer</li>
- * <li>{@link #outputConsumed()}</li>
- * </ol>
- *
- * <p>The following methods on the byte buffers returned by {@link #getInputBuffer()} and {@link #getOutputBuffer()}
- * must not be called:
- * </p>
- * <ol>
- * <li> {@link ByteBuffer#clear()} </li>
- * <li> {@link ByteBuffer#compact()} </li>
- * <li> {@link ByteBuffer#flip()} </li>
- * <li> {@link ByteBuffer#mark()} </li>
- * </ol>
- */
-public interface Transport extends Endpoint
-{
-
- public static final class Factory
- {
- public static Transport create() {
- return new TransportImpl();
- }
- }
-
- public static final int TRACE_OFF = 0;
- public static final int TRACE_RAW = 1;
- public static final int TRACE_FRM = 2;
- public static final int TRACE_DRV = 4;
-
- public static final int DEFAULT_MAX_FRAME_SIZE = -1;
-
- /** the lower bound for the agreed maximum frame size (in bytes). */
- public int MIN_MAX_FRAME_SIZE = 512;
- public int SESSION_WINDOW = 16*1024;
- public int END_OF_STREAM = -1;
-
- public void trace(int levels);
-
- public void bind(Connection connection);
- public void unbind();
-
- public int capacity();
- public ByteBuffer tail();
- public void process() throws TransportException;
- public void close_tail();
-
-
- public int pending();
- public ByteBuffer head();
- public void pop(int bytes);
- public void close_head();
-
- public boolean isClosed();
-
- /**
- * Processes the provided input.
- *
- * @param bytes input bytes for consumption
- * @param offset the offset within bytes where input begins
- * @param size the number of bytes available for input
- *
- * @return the number of bytes consumed
- * @throws TransportException if the input is invalid, if the transport is already in an error state,
- * or if the input is empty (unless the remote connection is already closed)
- * @deprecated use {@link #getInputBuffer()} and {@link #processInput()} instead.
- */
- @Deprecated
- public int input(byte[] bytes, int offset, int size);
-
- /**
- * Get a buffer that can be used to write input data into the transport.
- * Once the client has finished putting into the input buffer, {@link #processInput()}
- * must be called.
- *
- * Successive calls to this method are not guaranteed to return the same object.
- * Once {@link #processInput()} is called the buffer must not be used.
- *
- * @throws TransportException if the transport is already in an invalid state
- */
- ByteBuffer getInputBuffer();
-
- /**
- * Tell the transport to process the data written to the input buffer.
- *
- * If the returned result indicates failure, the transport will not accept any more input.
- * Specifically, any subsequent {@link #processInput()} calls on this object will
- * throw an exception.
- *
- * @return the result of processing the data, which indicates success or failure.
- * @see #getInputBuffer()
- */
- TransportResult processInput();
-
- /**
- * Has the transport produce up to size bytes placing the result
- * into dest beginning at position offset.
- *
- * @param dest array for output bytes
- * @param offset the offset within bytes where output begins
- * @param size the maximum number of bytes to be output
- *
- * @return the number of bytes written
- * @deprecated use {@link #getOutputBuffer()} and {@link #outputConsumed()} instead
- */
- @Deprecated
- public int output(byte[] dest, int offset, int size);
-
- /**
- * Get a read-only byte buffer containing the transport's pending output.
- * Once the client has finished getting from the output buffer, {@link #outputConsumed()}
- * must be called.
- *
- * Successive calls to this method are not guaranteed to return the same object.
- * Once {@link #outputConsumed()} is called the buffer must not be used.
- *
- * If the transport's state changes AFTER calling this method, this will not be
- * reflected in the output buffer.
- */
- ByteBuffer getOutputBuffer();
-
- /**
- * Informs the transport that the output buffer returned by {@link #getOutputBuffer()}
- * is finished with, allowing implementation-dependent steps to be performed such as
- * reclaiming buffer space.
- */
- void outputConsumed();
-
- /**
- * Signal the transport to expect SASL frames used to establish a SASL layer prior to
- * performing the AMQP protocol version negotiation. This must first be performed before
- * the transport is used for processing. Subsequent invocations will return the same
- * {@link Sasl} object.
- *
- * @throws IllegalStateException if transport processing has already begun prior to initial invocation
- */
- Sasl sasl() throws IllegalStateException;
-
- /**
- * Wrap this transport's output and input to apply SSL encryption and decryption respectively.
- *
- * This method is expected to be called at most once. A subsequent invocation will return the same
- * {@link Ssl} object, regardless of the parameters supplied.
- *
- * @param sslDomain the SSL settings to use
- * @param sslPeerDetails may be null, in which case SSL session resume will not be attempted
- * @return an {@link Ssl} object representing the SSL session.
- */
- Ssl ssl(SslDomain sslDomain, SslPeerDetails sslPeerDetails);
-
- /**
- * As per {@link #ssl(SslDomain, SslPeerDetails)} but no attempt is made to resume a previous SSL session.
- */
- Ssl ssl(SslDomain sslDomain);
-
-
- /**
- * Get the maximum frame size for the transport
- *
- * @return the maximum frame size
- */
- int getMaxFrameSize();
-
- void setMaxFrameSize(int size);
-
- int getRemoteMaxFrameSize();
-
- /**
- * Gets the local channel-max value to be advertised to the remote peer
- *
- * @return the local channel-max value
- * @see #setChannelMax(int)
- */
- int getChannelMax();
-
- /**
- * Set the local value of channel-max, to be advertised to the peer on the
- * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-open">
- * Open frame</a> emitted by the transport.
- *
- * The remote peers advertised channel-max can be observed using {@link #getRemoteChannelMax()}.
- *
- * @param channelMax the local channel-max to advertise to the peer, in range [0 - 2^16).
- * @throws IllegalArgumentException if the value supplied is outside range [0 - 2^16).
- */
- void setChannelMax(int channelMax);
-
- /**
- * Gets the remote value of channel-max, as advertised by the peer on its
- * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-open">
- * Open frame</a>.
- *
- * The local peers advertised channel-max can be observed using {@link #getChannelMax()}.
- *
- * @return the remote channel-max value
- */
- int getRemoteChannelMax();
-
- ErrorCondition getCondition();
-
- /**
- *
- * @param timeout local idle timeout in milliseconds
- */
- void setIdleTimeout(int timeout);
- /**
- *
- * @return local idle timeout in milliseconds
- */
- int getIdleTimeout();
- /**
- *
- * @return remote idle timeout in milliseconds
- */
- int getRemoteIdleTimeout();
-
- long tick(long now);
-
- long getFramesInput();
-
- long getFramesOutput();
-
- /**
- * Configure whether a synthetic Flow event should be emitted when messages are sent,
- * reflecting a change in the credit level on the link that may prompt other action.
- *
- * Defaults to true.
- *
- * @param emitFlowEventOnSend true if a flow event should be emitted, false otherwise
- */
- void setEmitFlowEventOnSend(boolean emitFlowEventOnSend);
-
- boolean isEmitFlowEventOnSend();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportException.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportException.java
deleted file mode 100644
index c4955b4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportException.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine;
-
-import java.util.IllegalFormatException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.ProtonException;
-
-public class TransportException extends ProtonException
-{
-
- private static final Logger LOGGER = Logger.getLogger(TransportException.class.getName());
-
- public TransportException()
- {
- }
-
- public TransportException(String message)
- {
- super(message);
- }
-
- public TransportException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public TransportException(Throwable cause)
- {
- super(cause);
- }
-
- private static String format(String format, Object ... args)
- {
- try
- {
- return String.format(format, args);
- }
- catch(IllegalFormatException e)
- {
- LOGGER.log(Level.SEVERE, "Formating error in string " + format, e);
- return format;
- }
- }
-
- public TransportException(String format, Object ... args)
- {
- this(format(format, args));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportResult.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportResult.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportResult.java
deleted file mode 100644
index a484ce7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/TransportResult.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-public interface TransportResult
-{
- enum Status
- {
- OK,
- ERROR
- }
-
- Status getStatus();
-
- String getErrorDescription();
-
- Exception getException();
-
- /**
- * @throws TransportException if the result's state is not ok.
- */
- void checkIsOk();
-
- boolean isOk();
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[10/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/ReactorChild.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/ReactorChild.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/ReactorChild.java
deleted file mode 100644
index 146ee09..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/ReactorChild.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-/**
- * Interface used to identify classes that can be a child of a reactor.
- */
-public interface ReactorChild {
-
- /** Frees any resources associated with this child. */
- void free();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java
deleted file mode 100644
index e91a0ee..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-import java.nio.channels.SelectableChannel;
-
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Extendable;
-
-/**
- * An entity that can be multiplexed using a {@link Selector}.
- * <p>
- * Every selectable is associated with exactly one {@link SelectableChannel}.
- * Selectables may be interested in three kinds of events: read events, write
- * events, and timer events. A selectable will express its interest in these
- * events through the {@link #isReading()}, {@link #isWriting()}, and
- * {@link #getDeadline()} methods.
- * <p>
- * When a read, write, or timer event occurs, the selectable must be notified by
- * calling {@link #readable()}, {@link #writeable()}, or {@link #expired()} as
- * appropriate.
- *
- * Once a selectable reaches a terminal state (see {@link #isTerminal()}, it
- * will never be interested in events of any kind. When this occurs it should be
- * removed from the Selector and discarded using {@link #free()}.
- */
-public interface Selectable extends ReactorChild, Extendable {
-
- /**
- * A callback that can be passed to the various "on" methods of the
- * selectable - to allow code to be run when the selectable becomes ready
- * for the associated operation.
- */
- interface Callback {
- void run(Selectable selectable);
- }
-
- /**
- * @return <code>true</code> if the selectable is interested in receiving
- * notification (via the {@link #readable()} method that indicate
- * that the associated {@link SelectableChannel} has data ready
- * to be read from it.
- */
- boolean isReading();
-
- /**
- * @return <code>true</code> if the selectable is interested in receiving
- * notifications (via the {@link #writeable()} method that indicate
- * that the associated {@link SelectableChannel} is ready to be
- * written to.
- */
- boolean isWriting();
-
- /**
- * @return a deadline after which this selectable can expect to receive
- * a notification (via the {@link #expired()} method that indicates
- * that the deadline has past. The deadline is expressed in the
- * same format as {@link System#currentTimeMillis()}. Returning
- * a deadline of zero (or a negative number) indicates that the
- * selectable does not wish to be notified of expiry.
- */
- long getDeadline();
-
- /**
- * Sets the value that will be returned by {@link #isReading()}.
- * @param reading
- */
- void setReading(boolean reading);
-
- /**
- * Sets the value that will be returned by {@link #isWriting()}.
- * @param writing
- */
- void setWriting(boolean writing);
-
- /**
- * Sets the value that will be returned by {@link #getDeadline()}.
- * @param deadline
- */
- void setDeadline(long deadline);
-
- /**
- * Registers a callback that will be run when the selectable becomes ready
- * for reading.
- * @param runnable the callback to register. Any previously registered
- * callback will be replaced.
- */
- void onReadable(Callback runnable);
-
- /**
- * Registers a callback that will be run when the selectable becomes ready
- * for writing.
- * @param runnable the callback to register. Any previously registered
- * callback will be replaced.
- */
- void onWritable(Callback runnable);
-
- /**
- * Registers a callback that will be run when the selectable expires.
- * @param runnable the callback to register. Any previously registered
- * callback will be replaced.
- */
- void onExpired(Callback runnable);
-
- /**
- * Registers a callback that will be run when the selectable is notified of
- * an error.
- * @param runnable the callback to register. Any previously registered
- * callback will be replaced.
- */
- void onError(Callback runnable);
-
- /**
- * Registers a callback that will be run when the selectable is notified
- * that it has been released.
- * @param runnable the callback to register. Any previously registered
- * callback will be replaced.
- */
- void onRelease(Callback runnable);
-
- /**
- * Registers a callback that will be run when the selectable is notified
- * that it has been free'd.
- * @param runnable the callback to register. Any previously registered
- * callback will be replaced.
- */
- void onFree(Callback runnable);
-
- /**
- * Notify the selectable that the underlying {@link SelectableChannel} is
- * ready for a read operation.
- */
- void readable();
-
- /**
- * Notify the selectable that the underlying {@link SelectableChannel} is
- * ready for a write operation.
- */
- void writeable();
-
- /** Notify the selectable that it has expired. */
- void expired();
-
- /** Notify the selectable that an error has occurred. */
- void error();
-
- /** Notify the selectable that it has been released. */
- void release();
-
- /** Notify the selectable that it has been free'd. */
- @Override
- void free();
-
- /**
- * Associates a {@link SelectableChannel} with this selector.
- * @param channel
- */
- void setChannel(SelectableChannel channel); // This is the equivalent to pn_selectable_set_fd(...)
-
- /** @return the {@link SelectableChannel} associated with this selector. */
- SelectableChannel getChannel(); // This is the equivalent to pn_selectable_get_fd(...)
-
- /**
- * Check if a selectable is registered. This can be used for tracking
- * whether a given selectable has been registerd with an external event
- * loop.
- * <p>
- * <em>Note:</em> the reactor code, currently, does not use this flag.
- * @return <code>true</code>if the selectable is registered.
- */
- boolean isRegistered(); // XXX: unused in C reactor code
-
- /**
- * Set the registered flag for a selectable.
- * <p>
- * <em>Note:</em> the reactor code, currently, does not use this flag.
- * @param registered the value returned by {@link #isRegistered()}
- */
- void setRegistered(boolean registered); // XXX: unused in C reactor code
-
- /**
- * Configure a selectable with a set of callbacks that emit readable,
- * writable, and expired events into the supplied collector.
- * @param collector
- */
- void setCollector(final Collector collector);
-
- /** @return the reactor to which this selectable is a child. */
- Reactor getReactor() ;
-
- /**
- * Terminates the selectable. Once a selectable reaches a terminal state
- * it will never be interested in events of any kind.
- */
- public void terminate() ;
-
- /**
- * @return <code>true</code> if the selectable has reached a terminal state.
- */
- boolean isTerminal();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selector.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selector.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selector.java
deleted file mode 100644
index 4228a8d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selector.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-/**
- * A multiplexor of instances of {@link Selectable}.
- * <p>
- * Many instances of <code>Selectable</code> can be added to a selector, and
- * the {@link #select(long)} method used to block the calling thread until
- * one of the <code>Selectables</code> becomes read to perform an operation.
- * <p>
- * This class is not thread safe, so only one thread should be manipulating the
- * contents of the selector, or running the {@link #select(long)} method at
- * any given time.
- */
-public interface Selector {
-
- /**
- * Adds a selectable to the selector.
- * @param selectable
- * @throws IOException
- */
- void add(Selectable selectable) throws IOException;
-
- /**
- * Updates the selector to reflect any changes interest by the specified
- * selectable. This is achieved by calling the
- * {@link Selectable#isReading()} and {@link Selectable#isWriting()}
- * methods.
- * @param selectable
- */
- void update(Selectable selectable);
-
- /**
- * Removes a selectable from the selector.
- * @param selectable
- */
- void remove(Selectable selectable);
-
- /**
- * Waits for the specified timeout period for one or more selectables to
- * become ready for an operation. Selectables that become ready are
- * returned by the {@link #readable()}, {@link #writeable()},
- * {@link #expired()}, or {@link #error()} methods.
- *
- * @param timeout the maximum number of milliseconds to block the calling
- * thread waiting for a selectable to become ready for an
- * operation. The value zero is interpreted as check but
- * don't block.
- * @throws IOException
- */
- void select(long timeout) throws IOException;
-
- /**
- * @return the selectables that have become readable since the last call
- * to {@link #select(long)}. Calling <code>select</code> clears
- * any previous values in this set before adding new values
- * corresponding to those selectables that have become readable.
- */
- Iterator<Selectable> readable();
-
- /**
- * @return the selectables that have become writable since the last call
- * to {@link #select(long)}. Calling <code>select</code> clears
- * any previous values in this set before adding new values
- * corresponding to those selectables that have become writable.
- */
- Iterator<Selectable> writeable();
-
- /**
- * @return the selectables that have expired since the last call
- * to {@link #select(long)}. Calling <code>select</code> clears
- * any previous values in this set before adding new values
- * corresponding to those selectables that have now expired.
- */
- Iterator<Selectable> expired();
-
- /**
- * @return the selectables that have encountered an error since the last
- * call to {@link #select(long)}. Calling <code>select</code>
- * clears any previous values in this set before adding new values
- * corresponding to those selectables that have encountered an
- * error.
- */
- Iterator<Selectable> error() ;
-
- /** Frees the resources used by this selector. */
- void free();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java
deleted file mode 100644
index 7fb5964..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor;
-
-import org.apache.qpid.proton.engine.Event.Type;
-import org.apache.qpid.proton.engine.Extendable;
-import org.apache.qpid.proton.engine.Handler;
-
-/**
- * Represents work scheduled with a {@link Reactor} for execution at
- * some point in the future.
- * <p>
- * Tasks are created using the {@link Reactor#schedule(int, Handler)}
- * method.
- */
-public interface Task extends Extendable {
-
- /**
- * @return the deadline at which the handler associated with the scheduled
- * task should be delivered a {@link Type#TIMER_TASK} event.
- */
- long deadline();
-
- /** @return the reactor that created this task. */
- Reactor getReactor();
-
- /**
- * Cancel the execution of this task. No-op if invoked after the task was already executed.
- */
- void cancel();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java
deleted file mode 100644
index c5abbd8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Handler;
-import org.apache.qpid.proton.engine.Record;
-import org.apache.qpid.proton.engine.Sasl;
-import org.apache.qpid.proton.engine.Sasl.SaslOutcome;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.impl.RecordImpl;
-import org.apache.qpid.proton.reactor.Acceptor;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.impl.ReactorImpl;
-import org.apache.qpid.proton.reactor.Selectable;
-import org.apache.qpid.proton.reactor.Selectable.Callback;
-import org.apache.qpid.proton.messenger.impl.Address;
-
-@SuppressWarnings("deprecation")
-public class AcceptorImpl implements Acceptor {
-
- private Record attachments = new RecordImpl();
- private final SelectableImpl sel;
- protected static final String CONNECTION_ACCEPTOR_KEY = "pn_reactor_connection_acceptor";
-
- private class AcceptorReadable implements Callback {
- @Override
- public void run(Selectable selectable) {
- Reactor reactor = selectable.getReactor();
- try {
- SocketChannel socketChannel = ((ServerSocketChannel)selectable.getChannel()).accept();
- if (socketChannel == null) {
- throw new ReactorInternalException("Selectable readable, but no socket to accept");
- }
- Handler handler = BaseHandler.getHandler(AcceptorImpl.this);
- if (handler == null) {
- handler = reactor.getHandler();
- }
- Connection conn = reactor.connection(handler);
- Record conn_recs = conn.attachments();
- conn_recs.set(CONNECTION_ACCEPTOR_KEY, Acceptor.class, AcceptorImpl.this);
- InetSocketAddress peerAddr = (InetSocketAddress)socketChannel.getRemoteAddress();
- if (peerAddr != null) {
- Address addr = new Address();
- addr.setHost(peerAddr.getHostString());
- addr.setPort(Integer.toString(peerAddr.getPort()));
- conn_recs.set(ReactorImpl.CONNECTION_PEER_ADDRESS_KEY, Address.class, addr);
- }
- Transport trans = Proton.transport();
- Sasl sasl = trans.sasl();
- sasl.server();
- sasl.setMechanisms("ANONYMOUS");
- sasl.done(SaslOutcome.PN_SASL_OK);
- trans.bind(conn);
- IOHandler.selectableTransport(reactor, socketChannel.socket(), trans);
- } catch(IOException ioException) {
- sel.error();
- }
- }
- }
-
- private static class AcceptorFree implements Callback {
- @Override
- public void run(Selectable selectable) {
- try {
- if (selectable.getChannel() != null) {
- selectable.getChannel().close();
- }
- } catch(IOException ioException) {
- // Ignore - as we can't make the channel any more closed...
- }
- }
- }
-
- protected AcceptorImpl(Reactor reactor, String host, int port, Handler handler) throws IOException {
- ServerSocketChannel ssc = ((ReactorImpl)reactor).getIO().serverSocketChannel();
- ssc.bind(new InetSocketAddress(host, port));
- sel = ((ReactorImpl)reactor).selectable(this);
- sel.setChannel(ssc);
- sel.onReadable(new AcceptorReadable());
- sel.onFree(new AcceptorFree());
- sel.setReactor(reactor);
- BaseHandler.setHandler(this, handler);
- sel.setReading(true);
- reactor.update(sel);
- }
-
- @Override
- public void close() {
- if (!sel.isTerminal()) {
- Reactor reactor = sel.getReactor();
- try {
- sel.getChannel().close();
- } catch(IOException ioException) {
- // Ignore.
- }
- sel.setChannel(null);
- sel.terminate();
- reactor.update(sel);
- }
- }
-
- // Used for unit tests, where acceptor is bound to an ephemeral port
- public int getPortNumber() throws IOException {
- ServerSocketChannel ssc = (ServerSocketChannel)sel.getChannel();
- return ((InetSocketAddress)ssc.getLocalAddress()).getPort();
- }
-
- @Override
- public void free() {
- sel.free();
- }
-
- @Override
- public Record attachments() {
- return attachments;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IO.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IO.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IO.java
deleted file mode 100644
index 1028ae8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IO.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.io.IOException;
-import java.nio.channels.Pipe;
-import java.nio.channels.Selector;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-// Java equivalent to pn_io.
-// This is, currently, in the reactor.impl package because it is not
-// used elsewhere in the proton-j codebase. Instead it is present to
-// facilitate mocking of various Java I/O related resources so that
-// the unit tests can check for leaks.
-public interface IO {
-
- Pipe pipe() throws IOException;
-
- Selector selector() throws IOException;
-
- ServerSocketChannel serverSocketChannel() throws IOException;
-
- SocketChannel socketChannel() throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
deleted file mode 100644
index 2dd7e1a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.nio.channels.Channel;
-import java.nio.channels.SocketChannel;
-import java.util.Iterator;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Sasl;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.impl.TransportImpl;
-import org.apache.qpid.proton.engine.Record;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Selectable;
-import org.apache.qpid.proton.reactor.Selectable.Callback;
-import org.apache.qpid.proton.reactor.Selector;
-import org.apache.qpid.proton.reactor.Acceptor;
-import org.apache.qpid.proton.reactor.impl.AcceptorImpl;
-import org.apache.qpid.proton.messenger.impl.Address;
-
-@SuppressWarnings("deprecation")
-public class IOHandler extends BaseHandler {
-
- // pni_handle_quiesced from connection.c
- private void handleQuiesced(Reactor reactor, Selector selector) throws IOException {
- // check if we are still quiesced, other handlers of
- // PN_REACTOR_QUIESCED could have produced more events to process
- if (!reactor.quiesced()) return;
- selector.select(reactor.getTimeout());
- reactor.mark();
- Iterator<Selectable> selectables = selector.readable();
- while(selectables.hasNext()) {
- selectables.next().readable();
- }
- selectables = selector.writeable();
- while(selectables.hasNext()) {
- selectables.next().writeable();
- }
- selectables = selector.expired();
- while(selectables.hasNext()) {
- selectables.next().expired();
- }
- selectables = selector.error();
- while(selectables.hasNext()) {
- selectables.next().error();
- }
- reactor.yield();
- }
-
- // pni_handle_open(...) from connection.c
- private void handleOpen(Reactor reactor, Event event) {
- Connection connection = event.getConnection();
- if (connection.getRemoteState() != EndpointState.UNINITIALIZED) {
- return;
- }
- // Outgoing Reactor connections set the virtual host automatically using the
- // following rules:
- String vhost = connection.getHostname();
- if (vhost == null) {
- // setHostname never called, use the host from the connection's
- // socket address as the default virtual host:
- String conAddr = reactor.getConnectionAddress(connection);
- if (conAddr != null) {
- Address addr = new Address(conAddr);
- connection.setHostname(addr.getHost());
- }
- } else if (vhost.isEmpty()) {
- // setHostname called explictly with a null string. This allows
- // the application to completely avoid sending a virtual host
- // name
- connection.setHostname(null);
- } else {
- // setHostname set by application - use it.
- }
- Transport transport = Proton.transport();
- Sasl sasl = transport.sasl();
- sasl.client();
- sasl.setMechanisms("ANONYMOUS");
- transport.bind(connection);
- }
-
- // pni_handle_bound(...) from connection.c
- // If this connection is an outgoing connection - not an incoming
- // connection created by the Acceptor - create a socket connection to
- // the peer address.
- private void handleBound(Reactor reactor, Event event) {
- Connection connection = event.getConnection();
- Record conn_recs = connection.attachments();
- if (conn_recs.get(AcceptorImpl.CONNECTION_ACCEPTOR_KEY, Acceptor.class) != null) {
- // Connection was created via the Acceptor, so the socket already
- // exists
- return;
- }
- String url = reactor.getConnectionAddress(connection);
- String hostname = connection.getHostname();
- int port = 5672;
-
- if (url != null) {
- Address address = new Address(url);
- hostname = address.getHost();
- try {
- port = Integer.parseInt(address.getImpliedPort());
- } catch(NumberFormatException nfe) {
- throw new IllegalArgumentException("Not a valid host: " + url, nfe);
- }
- } else if (hostname != null && !hostname.equals("")) {
- // Backward compatibility with old code that illegally overloaded
- // the connection's hostname
- int colonIndex = hostname.indexOf(':');
- if (colonIndex >= 0) {
- try {
- port = Integer.parseInt(hostname.substring(colonIndex+1));
- } catch(NumberFormatException nfe) {
- throw new IllegalArgumentException("Not a valid host: " + hostname, nfe);
- }
- hostname = hostname.substring(0, colonIndex);
- }
- } else {
- throw new IllegalStateException("No address provided for Connection");
- }
-
- Transport transport = event.getConnection().getTransport();
- Socket socket = null; // In this case, 'null' is the proton-j equivalent of PN_INVALID_SOCKET
- try {
- SocketChannel socketChannel = ((ReactorImpl)reactor).getIO().socketChannel();
- socketChannel.configureBlocking(false);
- socketChannel.connect(new InetSocketAddress(hostname, port));
- socket = socketChannel.socket();
- } catch(Exception exception) {
- ErrorCondition condition = new ErrorCondition();
- condition.setCondition(Symbol.getSymbol("proton:io"));
- condition.setDescription(exception.getMessage());
- transport.setCondition(condition);
- transport.close_tail();
- transport.close_head();
- transport.pop(Math.max(0, transport.pending())); // Force generation of TRANSPORT_HEAD_CLOSE (not in C code)
- }
- selectableTransport(reactor, socket, transport);
- }
-
- // pni_connection_capacity from connection.c
- private static int capacity(Selectable selectable) {
- Transport transport = ((SelectableImpl)selectable).getTransport();
- int capacity = transport.capacity();
- if (capacity < 0) {
- if (transport.isClosed()) {
- selectable.terminate();
- }
- }
- return capacity;
- }
-
- // pni_connection_pending from connection.c
- private static int pending(Selectable selectable) {
- Transport transport = ((SelectableImpl)selectable).getTransport();
- int pending = transport.pending();
- if (pending < 0) {
- if (transport.isClosed()) {
- selectable.terminate();
- }
- }
- return pending;
- }
-
- // pni_connection_deadline from connection.c
- private static long deadline(SelectableImpl selectable) {
- Reactor reactor = selectable.getReactor();
- Transport transport = selectable.getTransport();
- long deadline = transport.tick(reactor.now());
- return deadline;
- }
-
- // pni_connection_update from connection.c
- private static void update(Selectable selectable) {
- SelectableImpl selectableImpl = (SelectableImpl)selectable;
- int c = capacity(selectableImpl);
- int p = pending(selectableImpl);
- selectable.setReading(c > 0);
- selectable.setWriting(p > 0);
- selectable.setDeadline(deadline(selectableImpl));
- }
-
- // pni_connection_readable from connection.c
- private static Callback connectionReadable = new Callback() {
- @Override
- public void run(Selectable selectable) {
- Reactor reactor = selectable.getReactor();
- Transport transport = ((SelectableImpl)selectable).getTransport();
- int capacity = transport.capacity();
- if (capacity > 0) {
- SocketChannel socketChannel = (SocketChannel)selectable.getChannel();
- try {
- int n = socketChannel.read(transport.tail());
- if (n == -1) {
- transport.close_tail();
- } else {
- transport.process();
- }
- } catch (IOException e) {
- ErrorCondition condition = new ErrorCondition();
- condition.setCondition(Symbol.getSymbol("proton:io"));
- condition.setDescription(e.getMessage());
- transport.setCondition(condition);
- transport.close_tail();
- }
- }
- // (Comment from C code:) occasionally transport events aren't
- // generated when expected, so the following hack ensures we
- // always update the selector
- update(selectable);
- reactor.update(selectable);
- }
- };
-
- // pni_connection_writable from connection.c
- private static Callback connectionWritable = new Callback() {
- @Override
- public void run(Selectable selectable) {
- Reactor reactor = selectable.getReactor();
- Transport transport = ((SelectableImpl)selectable).getTransport();
- int pending = transport.pending();
- if (pending > 0) {
- SocketChannel channel = (SocketChannel)selectable.getChannel();
- try {
- int n = channel.write(transport.head());
- if (n < 0) {
- transport.close_head();
- } else {
- transport.pop(n);
- }
- } catch(IOException ioException) {
- ErrorCondition condition = new ErrorCondition();
- condition.setCondition(Symbol.getSymbol("proton:io"));
- condition.setDescription(ioException.getMessage());
- transport.setCondition(condition);
- transport.close_head();
- }
- }
-
- int newPending = transport.pending();
- if (newPending != pending) {
- update(selectable);
- reactor.update(selectable);
- }
- }
- };
-
- // pni_connection_error from connection.c
- private static Callback connectionError = new Callback() {
- @Override
- public void run(Selectable selectable) {
- Reactor reactor = selectable.getReactor();
- selectable.terminate();
- reactor.update(selectable);
- }
- };
-
- // pni_connection_expired from connection.c
- private static Callback connectionExpired = new Callback() {
- @Override
- public void run(Selectable selectable) {
- Reactor reactor = selectable.getReactor();
- Transport transport = ((SelectableImpl)selectable).getTransport();
- long deadline = transport.tick(reactor.now());
- selectable.setDeadline(deadline);
- int c = capacity(selectable);
- int p = pending(selectable);
- selectable.setReading(c > 0);
- selectable.setWriting(p > 0);
- reactor.update(selectable);
- }
- };
-
- private static Callback connectionFree = new Callback() {
- @Override
- public void run(Selectable selectable) {
- Channel channel = selectable.getChannel();
- if (channel != null) {
- try {
- channel.close();
- } catch(IOException ioException) {
- // Ignore
- }
- }
- }
- };
-
- // pn_reactor_selectable_transport
- // Note the socket argument can, validly be 'null' this is the equivalent of proton-c's PN_INVALID_SOCKET
- protected static Selectable selectableTransport(Reactor reactor, Socket socket, Transport transport) {
- Selectable selectable = reactor.selectable();
- selectable.setChannel(socket != null ? socket.getChannel() : null);
- selectable.onReadable(connectionReadable);
- selectable.onWritable(connectionWritable);
- selectable.onError(connectionError);
- selectable.onExpired(connectionExpired);
- selectable.onFree(connectionFree);
- ((SelectableImpl)selectable).setTransport(transport);
- ((TransportImpl)transport).setSelectable(selectable);
- ((TransportImpl)transport).setReactor(reactor);
- update(selectable);
- reactor.update(selectable);
- return selectable;
- }
-
- private void handleTransport(Reactor reactor, Event event) {
- TransportImpl transport = (TransportImpl)event.getTransport();
- Selectable selectable = transport.getSelectable();
- if (selectable != null && !selectable.isTerminal()) {
- update(selectable);
- reactor.update(selectable);
- }
- }
-
- @Override
- public void onUnhandled(Event event) {
- try {
- ReactorImpl reactor = (ReactorImpl)event.getReactor();
- Selector selector = reactor.getSelector();
- if (selector == null) {
- selector = new SelectorImpl(reactor.getIO());
- reactor.setSelector(selector);
- }
-
- Selectable selectable;
- switch(event.getType()) {
- case SELECTABLE_INIT:
- selectable = event.getSelectable();
- selector.add(selectable);
- break;
- case SELECTABLE_UPDATED:
- selectable = event.getSelectable();
- selector.update(selectable);
- break;
- case SELECTABLE_FINAL:
- selectable = event.getSelectable();
- selector.remove(selectable);
- selectable.release();
- break;
- case CONNECTION_LOCAL_OPEN:
- handleOpen(reactor, event);
- break;
- case CONNECTION_BOUND:
- handleBound(reactor, event);
- break;
- case TRANSPORT:
- handleTransport(reactor, event);
- break;
- case TRANSPORT_CLOSED:
- event.getTransport().unbind();
- break;
- case REACTOR_QUIESCED:
- handleQuiesced(reactor, selector);
- break;
- default:
- break;
- }
- } catch(IOException ioException) {
- // XXX: Might not be the right exception type, but at least the exception isn't being swallowed
- throw new ReactorInternalException(ioException);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOImpl.java
deleted file mode 100644
index 6376b16..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOImpl.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.io.IOException;
-import java.nio.channels.Pipe;
-import java.nio.channels.Selector;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-public class IOImpl implements IO {
-
- @Override
- public Pipe pipe() throws IOException {
- return Pipe.open();
- }
-
- @Override
- public Selector selector() throws IOException {
- return Selector.open();
- }
-
- @Override
- public ServerSocketChannel serverSocketChannel() throws IOException {
- return ServerSocketChannel.open();
- }
-
- @Override
- public SocketChannel socketChannel() throws IOException {
- return SocketChannel.open();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java
deleted file mode 100644
index 30c8df9..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java
+++ /dev/null
@@ -1,485 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.Pipe;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Event.Type;
-import org.apache.qpid.proton.engine.EventType;
-import org.apache.qpid.proton.engine.Extendable;
-import org.apache.qpid.proton.engine.ExtendableAccessor;
-import org.apache.qpid.proton.engine.Handler;
-import org.apache.qpid.proton.engine.HandlerException;
-import org.apache.qpid.proton.engine.Record;
-import org.apache.qpid.proton.engine.impl.CollectorImpl;
-import org.apache.qpid.proton.engine.impl.ConnectionImpl;
-import org.apache.qpid.proton.engine.impl.RecordImpl;
-import org.apache.qpid.proton.reactor.Acceptor;
-import org.apache.qpid.proton.reactor.impl.AcceptorImpl;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.ReactorChild;
-import org.apache.qpid.proton.reactor.Selectable;
-import org.apache.qpid.proton.reactor.Selectable.Callback;
-import org.apache.qpid.proton.reactor.Selector;
-import org.apache.qpid.proton.reactor.Task;
-import org.apache.qpid.proton.messenger.impl.Address;
-
-@SuppressWarnings("deprecation")
-public class ReactorImpl implements Reactor, Extendable {
- public static final ExtendableAccessor<Event, Handler> ROOT = new ExtendableAccessor<>(Handler.class);
-
- private CollectorImpl collector;
- private long now;
- private long timeout;
- private Handler global;
- private Handler handler;
- private Set<ReactorChild> children;
- private int selectables;
- private boolean yield;
- private boolean stop;
- private Selectable selectable;
- private EventType previous;
- private Timer timer;
- private final Pipe wakeup;
- private Selector selector;
- private Record attachments;
- private final IO io;
- protected static final String CONNECTION_PEER_ADDRESS_KEY = "pn_reactor_connection_peer_address";
-
- @Override
- public long mark() {
- now = System.currentTimeMillis();
- return now;
- }
-
- @Override
- public long now() {
- return now;
- }
-
- protected ReactorImpl(IO io) throws IOException {
- collector = (CollectorImpl)Proton.collector();
- global = new IOHandler();
- handler = new BaseHandler();
- children = new HashSet<ReactorChild>();
- selectables = 0;
- timer = new Timer(collector);
- this.io = io;
- wakeup = this.io.pipe();
- mark();
- attachments = new RecordImpl();
- }
-
- public ReactorImpl() throws IOException {
- this(new IOImpl());
- }
-
- @Override
- public void free() {
- if (wakeup.source().isOpen()) {
- try {
- wakeup.source().close();
- } catch(IOException e) {
- // Ignore.
- }
- }
- if (wakeup.sink().isOpen()) {
- try {
- wakeup.sink().close();
- } catch(IOException e) {
- // Ignore
- }
- }
-
- if (selector != null) {
- selector.free();
- }
-
- for (ReactorChild child : children) {
- child.free();
- }
- }
-
- @Override
- public Record attachments() {
- return attachments;
- }
-
- @Override
- public long getTimeout() {
- return timeout;
- }
-
- @Override
- public void setTimeout(long timeout) {
- this.timeout = timeout;
- }
-
- @Override
- public Handler getGlobalHandler() {
- return global;
- }
-
- @Override
- public void setGlobalHandler(Handler handler) {
- global = handler;
- }
-
- @Override
- public Handler getHandler() {
- return handler;
- }
-
- @Override
- public void setHandler(Handler handler) {
- this.handler = handler;
- }
-
- @Override
- public Set<ReactorChild> children() {
- return children;
- }
-
- @Override
- public Collector collector() {
- return collector;
- }
-
- private class ReleaseCallback implements Callback {
- private final ReactorImpl reactor;
- private final ReactorChild child;
- public ReleaseCallback(ReactorImpl reactor, ReactorChild child) {
- this.reactor = reactor;
- this.child = child;
- }
- @Override
- public void run(Selectable selectable) {
- if (reactor.children.remove(child)) {
- --reactor.selectables;
- child.free();
- }
- }
- }
-
- @Override
- public Selectable selectable() {
- return selectable(null);
- }
-
- public SelectableImpl selectable(ReactorChild child) {
- SelectableImpl result = new SelectableImpl();
- result.setCollector(collector);
- collector.put(Type.SELECTABLE_INIT, result);
- result.setReactor(this);
- children.add(child == null ? result : child);
- result.onRelease(new ReleaseCallback(this, child == null ? result : child));
- ++selectables;
- return result;
- }
-
- @Override
- public void update(Selectable selectable) {
- SelectableImpl selectableImpl = (SelectableImpl)selectable;
- if (!selectableImpl.isTerminated()) {
- if (selectableImpl.isTerminal()) {
- selectableImpl.terminated();
- collector.put(Type.SELECTABLE_FINAL, selectable);
- } else {
- collector.put(Type.SELECTABLE_UPDATED, selectable);
- }
- }
- }
-
- // pn_event_handler
- private Handler eventHandler(Event event) {
- Handler result;
- if (event.getLink() != null) {
- result = BaseHandler.getHandler(event.getLink());
- if (result != null) return result;
- }
- if (event.getSession() != null) {
- result = BaseHandler.getHandler(event.getSession());
- if (result != null) return result;
- }
- if (event.getConnection() != null) {
- result = BaseHandler.getHandler(event.getConnection());
- if (result != null) return result;
- }
-
- if (event.getTask() != null) {
- result = BaseHandler.getHandler(event.getTask());
- if (result != null) return result;
- }
-
- if (event.getSelectable() != null) {
- result = BaseHandler.getHandler(event.getSelectable());
- if (result != null) return result;
- }
-
- return handler;
- }
-
-
- @Override
- public void yield() {
- yield = true;
- }
-
- @Override
- public boolean quiesced() {
- Event event = collector.peek();
- if (event == null) return true;
- if (collector.more()) return false;
- return event.getEventType() == Type.REACTOR_QUIESCED;
- }
-
- @Override
- public boolean process() throws HandlerException {
- mark();
- EventType previous = null;
- while (true) {
- Event event = collector.peek();
- if (event != null) {
- if (yield) {
- yield = false;
- return true;
- }
- Handler handler = eventHandler(event);
- dispatch(event, handler);
- dispatch(event, global);
-
- if (event.getEventType() == Type.CONNECTION_FINAL) {
- children.remove(event.getConnection());
- }
- this.previous = event.getEventType();
- previous = this.previous;
- collector.pop();
-
- } else {
- if (!stop && more()) {
- if (previous != Type.REACTOR_QUIESCED && this.previous != Type.REACTOR_FINAL) {
- collector.put(Type.REACTOR_QUIESCED, this);
- } else {
- return true;
- }
- } else {
- if (selectable != null) {
- selectable.terminate();
- update(selectable);
- selectable = null;
- } else {
- collector.put(Type.REACTOR_FINAL, this);
- return false;
- }
- }
- }
- }
- }
-
- private void dispatch(Event event, Handler handler) {
- ROOT.set(event, handler);
- event.dispatch(handler);
- }
-
- @Override
- public void wakeup() {
- try {
- wakeup.sink().write(ByteBuffer.allocate(1));
- } catch(ClosedChannelException channelClosedException) {
- // Ignore - pipe already closed by reactor being shutdown.
- } catch(IOException ioException) {
- throw new ReactorInternalException(ioException);
- }
- }
-
- @Override
- public void start() {
- collector.put(Type.REACTOR_INIT, this);
- selectable = timerSelectable();
- }
-
- @Override
- public void stop() throws HandlerException {
- stop = true;
- }
-
- private boolean more() {
- return timer.tasks() > 0 || selectables > 1;
- }
-
- @Override
- public void run() throws HandlerException {
- setTimeout(3141);
- start();
- while(process()) {}
- stop();
- process();
- collector = null;
- }
-
- // pn_reactor_schedule from reactor.c
- @Override
- public Task schedule(int delay, Handler handler) {
- Task task = timer.schedule(now + delay);
- ((TaskImpl)task).setReactor(this);
- BaseHandler.setHandler(task, handler);
- if (selectable != null) {
- selectable.setDeadline(timer.deadline());
- update(selectable);
- }
- return task;
- }
-
- private void expireSelectable(Selectable selectable) {
- ReactorImpl reactor = (ReactorImpl) selectable.getReactor();
- reactor.timer.tick(reactor.now);
- selectable.setDeadline(reactor.timer.deadline());
- reactor.update(selectable);
- }
-
- private class TimerReadable implements Callback {
-
- @Override
- public void run(Selectable selectable) {
- try {
- wakeup.source().read(ByteBuffer.allocate(64));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- expireSelectable(selectable);
- }
-
- }
-
- private class TimerExpired implements Callback {
- @Override
- public void run(Selectable selectable) {
- expireSelectable(selectable);
- }
- }
-
-
- // pni_timer_finalize from reactor.c
- private static class TimerFree implements Callback {
- @Override
- public void run(Selectable selectable) {
- try {
- selectable.getChannel().close();
- } catch(IOException ioException) {
- // Ignore
- }
- }
- }
-
- private Selectable timerSelectable() {
- Selectable sel = selectable();
- sel.setChannel(wakeup.source());
- sel.onReadable(new TimerReadable());
- sel.onExpired(new TimerExpired());
- sel.onFree(new TimerFree());
- sel.setReading(true);
- sel.setDeadline(timer.deadline());
- update(sel);
- return sel;
- }
-
- protected Selector getSelector() {
- return selector;
- }
-
- protected void setSelector(Selector selector) {
- this.selector = selector;
- }
-
- // pn_reactor_connection from connection.c
- @Override
- public Connection connection(Handler handler) {
- Connection connection = Proton.connection();
- BaseHandler.setHandler(connection, handler);
- connection.collect(collector);
- children.add(connection);
- ((ConnectionImpl)connection).setReactor(this);
- return connection;
- }
-
- @Override
- public Connection connectionToHost(String host, int port, Handler handler) {
- Connection connection = connection(handler);
- setConnectionHost(connection, host, port);
- return connection;
- }
-
- @Override
- public String getConnectionAddress(Connection connection) {
- Record r = connection.attachments();
- Address addr = r.get(CONNECTION_PEER_ADDRESS_KEY, Address.class);
- if (addr != null) {
- StringBuilder sb = new StringBuilder(addr.getHost());
- if (addr.getPort() != null)
- sb.append(":" + addr.getPort());
- return sb.toString();
- }
- return null;
- }
-
- @Override
- public void setConnectionHost(Connection connection,
- String host, int port) {
- Record r = connection.attachments();
- // cannot set the address on an incoming connection
- if (r.get(AcceptorImpl.CONNECTION_ACCEPTOR_KEY, Acceptor.class) == null) {
- Address addr = new Address();
- addr.setHost(host);
- if (port == 0) {
- port = 5672;
- }
- addr.setPort(Integer.toString(port));
- r.set(CONNECTION_PEER_ADDRESS_KEY, Address.class, addr);
- } else {
- throw new IllegalStateException("Cannot set the host address on an incoming Connection");
- }
- }
-
- @Override
- public Acceptor acceptor(String host, int port) throws IOException {
- return this.acceptor(host, port, null);
- }
-
- @Override
- public Acceptor acceptor(String host, int port, Handler handler) throws IOException {
- return new AcceptorImpl(this, host, port, handler);
- }
-
- public IO getIO() {
- return io;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorInternalException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorInternalException.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorInternalException.java
deleted file mode 100644
index 6dde424..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorInternalException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-/**
- * Thrown by the reactor when it encounters an internal error condition.
- * This is analogous to an assertion failure in the proton-c reactor
- * implementation.
- */
-class ReactorInternalException extends RuntimeException {
-
- private static final long serialVersionUID = 8979674526584642454L;
-
- protected ReactorInternalException(String msg) {
- super(msg);
- }
-
- protected ReactorInternalException(Throwable cause) {
- super(cause);
- }
-
- protected ReactorInternalException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java
deleted file mode 100644
index df4e6cc..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.nio.channels.SelectableChannel;
-
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Event.Type;
-import org.apache.qpid.proton.engine.Record;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.impl.CollectorImpl;
-import org.apache.qpid.proton.engine.impl.RecordImpl;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Selectable;
-
-public class SelectableImpl implements Selectable {
-
- private Callback readable;
- private Callback writable;
- private Callback error;
- private Callback expire;
- private Callback release;
- private Callback free;
-
- private boolean reading = false;
- private boolean writing = false;
- private long deadline = 0;
- private SelectableChannel channel;
- private Record attachments = new RecordImpl();
- private boolean registered;
- private Reactor reactor;
- private Transport transport;
- private boolean terminal;
- private boolean terminated;
-
- @Override
- public boolean isReading() {
- return reading;
- }
-
- @Override
- public boolean isWriting() {
- return writing;
- }
-
- @Override
- public long getDeadline() {
- return deadline;
- }
-
- @Override
- public void setReading(boolean reading) {
- this.reading = reading;
- }
-
- @Override
- public void setWriting(boolean writing) {
- this.writing = writing;
- }
-
- @Override
- public void setDeadline(long deadline) {
- this.deadline = deadline;
- }
-
- @Override
- public void onReadable(Callback runnable) {
- this.readable = runnable;
- }
-
- @Override
- public void onWritable(Callback runnable) {
- this.writable = runnable;
- }
-
- @Override
- public void onExpired(Callback runnable) {
- this.expire = runnable;
- }
-
- @Override
- public void onError(Callback runnable) {
- this.error = runnable;
- }
-
- @Override
- public void onRelease(Callback runnable) {
- this.release = runnable;
- }
-
- @Override
- public void onFree(Callback runnable) {
- this.free = runnable;
- }
-
- @Override
- public void readable() {
- if (readable != null) {
- readable.run(this);
- }
- }
-
- @Override
- public void writeable() {
- if (writable != null) {
- writable.run(this);
- }
- }
-
- @Override
- public void expired() {
- if (expire != null) {
- expire.run(this);
- }
- }
-
- @Override
- public void error() {
- if (error != null) {
- error.run(this);
- }
- }
-
- @Override
- public void release() {
- if (release != null) {
- release.run(this);
- }
- }
-
- @Override
- public void free() {
- if (free != null) {
- free.run(this);
- }
- }
-
- @Override
- public void setChannel(SelectableChannel channel) {
- this.channel = channel;
- }
-
- @Override
- public SelectableChannel getChannel() {
- return channel;
- }
-
- @Override
- public boolean isRegistered() {
- return registered;
- }
-
- @Override
- public void setRegistered(boolean registered) {
- this.registered = registered;
- }
-
- @Override
- public void setCollector(final Collector collector) {
- final CollectorImpl collectorImpl = (CollectorImpl)collector;
-
- onReadable(new Callback() {
- @Override
- public void run(Selectable selectable) {
- collectorImpl.put(Type.SELECTABLE_READABLE, selectable);
- }
- });
- onWritable(new Callback() {
- @Override
- public void run(Selectable selectable) {
- collectorImpl.put(Type.SELECTABLE_WRITABLE, selectable);
- }
- });
- onExpired(new Callback() {
- @Override
- public void run(Selectable selectable) {
- collectorImpl.put(Type.SELECTABLE_EXPIRED, selectable);
- }
- });
- onError(new Callback() {
- @Override
- public void run(Selectable selectable) {
- collectorImpl.put(Type.SELECTABLE_ERROR, selectable);
- }
- });
- }
-
- @Override
- public Reactor getReactor() {
- return reactor;
- }
-
- @Override
- public void terminate() {
- terminal = true;
- }
-
- @Override
- public boolean isTerminal() {
- return terminal;
- }
-
- protected Transport getTransport() {
- return transport;
- }
-
- protected void setTransport(Transport transport) {
- this.transport = transport;
- }
-
- protected void setReactor(Reactor reactor) {
- this.reactor = reactor;
- }
-
- @Override
- public Record attachments() {
- return attachments;
- }
-
- public boolean isTerminated() {
- return terminated;
- }
-
- public void terminated() {
- terminated = true;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectorImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectorImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectorImpl.java
deleted file mode 100644
index b4efb39..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectorImpl.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.io.IOException;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.reactor.Selectable;
-import org.apache.qpid.proton.reactor.Selector;
-
-class SelectorImpl implements Selector {
-
- private final java.nio.channels.Selector selector;
- private final HashSet<Selectable> selectables = new HashSet<Selectable>();
- private final HashSet<Selectable> readable = new HashSet<Selectable>();
- private final HashSet<Selectable> writeable = new HashSet<Selectable>();
- private final HashSet<Selectable> expired = new HashSet<Selectable>();
- private final HashSet<Selectable> error = new HashSet<Selectable>();
-
- protected SelectorImpl(IO io) throws IOException {
- selector = io.selector();
- }
-
- @Override
- public void add(Selectable selectable) throws IOException {
- // Selectable can be 'null' - if this is the case it can only ever receive expiry events.
- if (selectable.getChannel() != null) {
- selectable.getChannel().configureBlocking(false);
- SelectionKey key = selectable.getChannel().register(selector, 0);
- key.attach(selectable);
- }
- selectables.add(selectable);
- update(selectable);
- }
-
- @Override
- public void update(Selectable selectable) {
- if (selectable.getChannel() != null) {
- int interestedOps = 0;
- if (selectable.getChannel() instanceof SocketChannel &&
- ((SocketChannel)selectable.getChannel()).isConnectionPending()) {
- interestedOps |= SelectionKey.OP_CONNECT;
- } else {
- if (selectable.isReading()) {
- if (selectable.getChannel() instanceof ServerSocketChannel) {
- interestedOps |= SelectionKey.OP_ACCEPT;
- } else {
- interestedOps |= SelectionKey.OP_READ;
- }
- }
- if (selectable.isWriting()) interestedOps |= SelectionKey.OP_WRITE;
- }
- SelectionKey key = selectable.getChannel().keyFor(selector);
- key.interestOps(interestedOps);
- }
- }
-
- @Override
- public void remove(Selectable selectable) {
- if (selectable.getChannel() != null) {
- SelectionKey key = selectable.getChannel().keyFor(selector);
- if (key != null) {
- key.cancel();
- key.attach(null);
- }
- }
- selectables.remove(selectable);
- }
-
- @Override
- public void select(long timeout) throws IOException {
-
- long now = System.currentTimeMillis();
- if (timeout > 0) {
- long deadline = 0;
- // XXX: Note: this differs from the C code which requires a call to update() to make deadline changes take affect
- for (Selectable selectable : selectables) {
- long d = selectable.getDeadline();
- if (d > 0) {
- deadline = (deadline == 0) ? d : Math.min(deadline, d);
- }
- }
-
- if (deadline > 0) {
- long delta = deadline - now;
- if (delta < 0) {
- timeout = 0;
- } else if (delta < timeout) {
- timeout = delta;
- }
- }
- }
-
- error.clear();
-
- long awoken = 0;
- if (timeout > 0) {
- long remainingTimeout = timeout;
- while(remainingTimeout > 0) {
- selector.select(remainingTimeout);
- awoken = System.currentTimeMillis();
-
- for (Iterator<SelectionKey> iterator = selector.selectedKeys().iterator(); iterator.hasNext();) {
- SelectionKey key = iterator.next();
- if (key.isConnectable()) {
- try {
- ((SocketChannel)key.channel()).finishConnect();
- update((Selectable)key.attachment());
- } catch(IOException ioException) {
- SelectableImpl selectable = (SelectableImpl)key.attachment();
- ErrorCondition condition = new ErrorCondition();
- condition.setCondition(Symbol.getSymbol("proton:io"));
- condition.setDescription(ioException.getMessage());
- Transport transport = selectable.getTransport();
- if (transport != null) {
- transport.setCondition(condition);
- transport.close_tail();
- transport.close_head();
- transport.pop(Math.max(0, transport.pending())); // Force generation of TRANSPORT_HEAD_CLOSE (not in C code)
- }
- error.add(selectable);
- }
- iterator.remove();
- }
- }
- if (!selector.selectedKeys().isEmpty()) {
- break;
- }
- remainingTimeout = remainingTimeout - (awoken - now);
- }
- } else {
- selector.selectNow();
- awoken = System.currentTimeMillis();
- }
-
- readable.clear();
- writeable.clear();
- expired.clear();
- for (SelectionKey key : selector.selectedKeys()) {
- Selectable selectable = (Selectable)key.attachment();
- if (key.isReadable()) readable.add(selectable);
- if (key.isAcceptable()) readable.add(selectable);
- if (key.isWritable()) writeable.add(selectable);
- }
- selector.selectedKeys().clear();
- // XXX: Note: this is different to the C code which evaluates expiry at the point the selectable is iterated over.
- for (Selectable selectable : selectables) {
- long deadline = selectable.getDeadline();
- if (deadline > 0 && awoken >= deadline) {
- expired.add(selectable);
- }
- }
- }
-
- @Override
- public Iterator<Selectable> readable() {
- return readable.iterator();
- }
-
- @Override
- public Iterator<Selectable> writeable() {
- return writeable.iterator();
- }
-
- @Override
- public Iterator<Selectable> expired() {
- return expired.iterator();
- }
-
- @Override
- public Iterator<Selectable> error() {
- return error.iterator();
- }
-
- @Override
- public void free() {
- try {
- selector.close();
- } catch(IOException ioException) {
- // Ignore
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java
deleted file mode 100644
index 11bb6b8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.qpid.proton.engine.Record;
-import org.apache.qpid.proton.engine.impl.RecordImpl;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Task;
-
-public class TaskImpl implements Task, Comparable<TaskImpl> {
- private final long deadline;
- private final int counter;
- private boolean cancelled = false;
- private final AtomicInteger count = new AtomicInteger();
- private Record attachments = new RecordImpl();
- private Reactor reactor;
-
- public TaskImpl(long deadline) {
- this.deadline = deadline;
- this.counter = count.getAndIncrement();
- }
-
- @Override
- public int compareTo(TaskImpl other) {
- int result;
- if (deadline < other.deadline) {
- result = -1;
- } else if (deadline > other.deadline) {
- result = 1;
- } else {
- result = counter - other.counter;
- }
- return result;
- }
-
- @Override
- public long deadline() {
- return deadline;
- }
-
- public boolean isCancelled() {
- return cancelled;
- }
-
- @Override
- public void cancel() {
- cancelled = true;
- }
-
- public void setReactor(Reactor reactor) {
- this.reactor = reactor;
- }
-
- @Override
- public Reactor getReactor() {
- return reactor;
- }
-
- @Override
- public Record attachments() {
- return attachments;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/Timer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/Timer.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/Timer.java
deleted file mode 100644
index b8df19d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/Timer.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.util.PriorityQueue;
-
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Event.Type;
-import org.apache.qpid.proton.engine.impl.CollectorImpl;
-import org.apache.qpid.proton.reactor.Task;
-
-public class Timer {
-
- private CollectorImpl collector;
- private PriorityQueue<TaskImpl> tasks = new PriorityQueue<TaskImpl>();
-
- public Timer(Collector collector) {
- this.collector = (CollectorImpl)collector;
- }
-
- Task schedule(long deadline) {
- TaskImpl task = new TaskImpl(deadline);
- tasks.add(task);
- return task;
- }
-
- long deadline() {
- flushCancelled();
- if (tasks.size() > 0) {
- Task task = tasks.peek();
- return task.deadline();
- } else {
- return 0;
- }
- }
-
- private void flushCancelled() {
- while (!tasks.isEmpty()) {
- TaskImpl task = tasks.peek();
- if (task.isCancelled())
- tasks.poll();
- else
- break;
- }
- }
-
- void tick(long now) {
- while(!tasks.isEmpty()) {
- TaskImpl task = tasks.peek();
- if (now >= task.deadline()) {
- tasks.poll();
- if (!task.isCancelled())
- collector.put(Type.TIMER_TASK, task);
- } else {
- break;
- }
- }
- }
-
- int tasks() {
- flushCancelled();
- return tasks.size();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.codec.DataFactory
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.codec.DataFactory b/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.codec.DataFactory
deleted file mode 100644
index 46a716b..0000000
--- a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.codec.DataFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.qpid.proton.codec.impl.DataFactoryImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.driver.DriverFactory
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.driver.DriverFactory b/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.driver.DriverFactory
deleted file mode 100644
index 00e7a60..0000000
--- a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.driver.DriverFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.qpid.proton.driver.impl.DriverFactoryImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory b/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory
deleted file mode 100644
index 33f9865..0000000
--- a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.qpid.proton.engine.impl.EngineFactoryImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.message.MessageFactory
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.message.MessageFactory b/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.message.MessageFactory
deleted file mode 100644
index 99eb726..0000000
--- a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.message.MessageFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.qpid.proton.message.impl.MessageFactoryImpl
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.messenger.MessengerFactory
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.messenger.MessengerFactory b/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.messenger.MessengerFactory
deleted file mode 100644
index d0beeb4..0000000
--- a/proton-j/src/main/resources/META-INF/services/org.apache.qpid.proton.messenger.MessengerFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.qpid.proton.messenger.impl.MessengerFactoryImpl
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[02/34] qpid-proton git commit: PROTON-1325: Repair broken fix for
python "buffer" type.
Posted by ac...@apache.org.
PROTON-1325: Repair broken fix for python "buffer" type.
Commit 05deba72edebd0cf1e7bf148ba7e99ab2fb62bfe was incorrect and did not
address the bug, this commit does.
Add an automatic mapping from a python buffer or memoryview object to the AMQP binary type.
In the other direction, AMQP "binary" maps to the python "bytes" or "str" type, as before.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e2357e2c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e2357e2c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e2357e2c
Branch: refs/heads/go1
Commit: e2357e2cc8af94cf038d31936f19fea2e46a323b
Parents: 440131e
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Jan 5 10:06:28 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Jan 5 16:33:04 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/python/proton/__init__.py | 21 +++++++----
tests/python/proton_tests/codec.py | 44 ++++++++++++++----------
2 files changed, 39 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e2357e2c/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index d3f6922..cfac01e 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -1840,7 +1840,15 @@ class Data:
@type b: binary
@param b: a binary value
"""
- self._check(pn_data_put_binary(self._data, bytes(b)))
+ self._check(pn_data_put_binary(self._data, b))
+
+ def put_memoryview(self, mv):
+ """Put a python memoryview object as an AMQP binary value"""
+ self.put_binary(mv.tobytes())
+
+ def put_buffer(self, buff):
+ """Put a python buffer object as an AMQP binary value"""
+ self.put_binary(bytes(buff))
def put_string(self, s):
"""
@@ -2236,12 +2244,11 @@ class Data:
# we need to add an explicit int since it is a different type
if int not in put_mappings:
put_mappings[int] = put_int
- # For python 3.x use 'memoryview', for <=2.5 use 'buffer'. Python >=2.6 has both.
- if getattr(__builtins__, 'memoryview', None):
- put_mappings[memoryview] = put_binary
- if getattr(__builtins__, 'buffer', None):
- put_mappings[buffer] = put_binary
-
+ # Python >=3.0 has 'memoryview', <=2.5 has 'buffer', >=2.6 has both.
+ try: put_mappings[memoryview] = put_memoryview
+ except NameError: pass
+ try: put_mappings[buffer] = put_buffer
+ except NameError: pass
get_mappings = {
NULL: lambda s: None,
BOOL: get_bool,
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e2357e2c/tests/python/proton_tests/codec.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/codec.py b/tests/python/proton_tests/codec.py
index 4d3d906..49a57e0 100644
--- a/tests/python/proton_tests/codec.py
+++ b/tests/python/proton_tests/codec.py
@@ -357,25 +357,31 @@ class DataTest(Test):
copy = data.get_object()
assert copy == obj, (copy, obj)
- if getattr(__builtins__, 'buffer', None):
- def testBuffer(self):
- self.data.put_object(buffer("foo"))
- data = Data()
- data.decode(self.data.encode())
- data.rewind()
- assert data.next()
- assert data.type() == Data.BINARY
- assert data.get_object() == "foo"
-
- if getattr(__builtins__, 'memoryview', None):
- def testBuffer(self):
- self.data.put_object(memoryview("foo"))
- data = Data()
- data.decode(self.data.encode())
- data.rewind()
- assert data.next()
- assert data.type() == Data.BINARY
- assert data.get_object() == "foo"
+ def testBuffer(self):
+ try:
+ self.data.put_object(buffer(str2bin("foo")))
+ except NameError:
+ # python >= 3.0 does not have `buffer`
+ return
+ data = Data()
+ data.decode(self.data.encode())
+ data.rewind()
+ assert data.next()
+ assert data.type() == Data.BINARY
+ assert data.get_object() == str2bin("foo")
+
+ def testMemoryView(self):
+ try:
+ self.data.put_object(memoryview(str2bin("foo")))
+ except NameError:
+ # python <= 2.6 does not have `memoryview`
+ return
+ data = Data()
+ data.decode(self.data.encode())
+ data.rewind()
+ assert data.next()
+ assert data.type() == Data.BINARY
+ assert data.get_object() == str2bin("foo")
def testLookup(self):
obj = {symbol("key"): str2unicode("value"),
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[12/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java
deleted file mode 100644
index de99351..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.ProtonUnsupportedOperationException;
-import org.apache.qpid.proton.engine.Ssl;
-import org.apache.qpid.proton.engine.SslDomain;
-import org.apache.qpid.proton.engine.SslPeerDetails;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.engine.impl.PlainTransportWrapper;
-import org.apache.qpid.proton.engine.impl.TransportInput;
-import org.apache.qpid.proton.engine.impl.TransportLayer;
-import org.apache.qpid.proton.engine.impl.TransportOutput;
-import org.apache.qpid.proton.engine.impl.TransportWrapper;
-
-public class SslImpl implements Ssl, TransportLayer
-{
- private SslTransportWrapper _unsecureClientAwareTransportWrapper;
-
- private final SslDomain _domain;
- private final ProtonSslEngineProvider _protonSslEngineProvider;
-
- private final SslPeerDetails _peerDetails;
- private TransportException _initException;
-
- /**
- * @param domain must implement {@link org.apache.qpid.proton.engine.impl.ssl.ProtonSslEngineProvider}. This is not possible
- * enforce at the API level because {@link org.apache.qpid.proton.engine.impl.ssl.ProtonSslEngineProvider} is not part of the
- * public Proton API.
- */
- public SslImpl(SslDomain domain, SslPeerDetails peerDetails)
- {
- _domain = domain;
- _protonSslEngineProvider = (ProtonSslEngineProvider)domain;
- _peerDetails = peerDetails;
- }
-
- public TransportWrapper wrap(TransportInput inputProcessor, TransportOutput outputProcessor)
- {
- if (_unsecureClientAwareTransportWrapper != null)
- {
- throw new IllegalStateException("Transport already wrapped");
- }
-
- _unsecureClientAwareTransportWrapper = new UnsecureClientAwareTransportWrapper(inputProcessor, outputProcessor);
- return _unsecureClientAwareTransportWrapper;
- }
-
- @Override
- public String getCipherName()
- {
- if(_unsecureClientAwareTransportWrapper == null)
- {
- throw new IllegalStateException("Transport wrapper is uninitialised");
- }
-
- return _unsecureClientAwareTransportWrapper.getCipherName();
- }
-
- @Override
- public String getProtocolName()
- {
- if(_unsecureClientAwareTransportWrapper == null)
- {
- throw new IllegalStateException("Transport wrapper is uninitialised");
- }
-
- return _unsecureClientAwareTransportWrapper.getProtocolName();
- }
-
- private class UnsecureClientAwareTransportWrapper implements SslTransportWrapper
- {
- private final TransportInput _inputProcessor;
- private final TransportOutput _outputProcessor;
- private SslTransportWrapper _transportWrapper;
-
- private UnsecureClientAwareTransportWrapper(TransportInput inputProcessor,
- TransportOutput outputProcessor)
- {
- _inputProcessor = inputProcessor;
- _outputProcessor = outputProcessor;
- }
-
- @Override
- public int capacity()
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- return _transportWrapper.capacity();
- } else {
- return Transport.END_OF_STREAM;
- }
- }
-
- @Override
- public int position()
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- return _transportWrapper.position();
- } else {
- return Transport.END_OF_STREAM;
- }
- }
-
- @Override
- public ByteBuffer tail()
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- return _transportWrapper.tail();
- } else {
- return null;
- }
- }
-
-
- @Override
- public void process() throws TransportException
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- _transportWrapper.process();
- } else {
- throw new TransportException(_initException);
- }
- }
-
- @Override
- public void close_tail()
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- _transportWrapper.close_tail();
- }
- }
-
- @Override
- public int pending()
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- return _transportWrapper.pending();
- } else {
- throw new TransportException(_initException);
- }
- }
-
- @Override
- public ByteBuffer head()
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- return _transportWrapper.head();
- } else {
- return null;
- }
- }
-
- @Override
- public void pop(int bytes)
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- _transportWrapper.pop(bytes);
- }
- }
-
- @Override
- public void close_head()
- {
- initTransportWrapperOnFirstIO();
- if (_initException == null) {
- _transportWrapper.close_head();
- }
- }
-
- @Override
- public String getCipherName()
- {
- if (_transportWrapper == null)
- {
- return null;
- }
- else
- {
- return _transportWrapper.getCipherName();
- }
- }
-
- @Override
- public String getProtocolName()
- {
- if(_transportWrapper == null)
- {
- return null;
- }
- else
- {
- return _transportWrapper.getProtocolName();
- }
- }
-
- private void initTransportWrapperOnFirstIO()
- {
- try {
- if (_initException == null && _transportWrapper == null)
- {
- SslTransportWrapper sslTransportWrapper = new SimpleSslTransportWrapper
- (_protonSslEngineProvider.createSslEngine(_peerDetails),
- _inputProcessor, _outputProcessor);
-
- if (_domain.allowUnsecuredClient() && _domain.getMode() == SslDomain.Mode.SERVER)
- {
- TransportWrapper plainTransportWrapper = new PlainTransportWrapper
- (_outputProcessor, _inputProcessor);
- _transportWrapper = new SslHandshakeSniffingTransportWrapper
- (sslTransportWrapper, plainTransportWrapper);
- }
- else
- {
- _transportWrapper = sslTransportWrapper;
- }
- }
- } catch (TransportException e) {
- _initException = e;
- }
- }
- }
-
- /**
- * {@inheritDoc}
- * @throws ProtonUnsupportedOperationException
- */
- @Override
- public void setPeerHostname(String hostname)
- {
- throw new ProtonUnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- * @throws ProtonUnsupportedOperationException
- */
- @Override
- public String getPeerHostname()
- {
- throw new ProtonUnsupportedOperationException();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java
deleted file mode 100644
index cbd9755..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import org.apache.qpid.proton.engine.ProtonJSslPeerDetails;
-
-
-public class SslPeerDetailsImpl implements ProtonJSslPeerDetails
-{
- private final String _hostname;
- private final int _port;
-
- /**
- * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
- * Client code outside this module should use {@link org.apache.qpid.proton.engine.SslPeerDetails.Factory#create(String, int)} instead.
- */
- @Deprecated public SslPeerDetailsImpl(String hostname, int port)
- {
- _hostname = hostname;
- _port = port;
- }
-
- @Override
- public String getHostname()
- {
- return _hostname;
- }
-
- @Override
- public int getPort()
- {
- return _port;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslTransportWrapper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslTransportWrapper.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslTransportWrapper.java
deleted file mode 100644
index 8b1f133..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslTransportWrapper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import org.apache.qpid.proton.engine.impl.TransportWrapper;
-
-public interface SslTransportWrapper extends TransportWrapper
-{
- String getCipherName();
- String getProtocolName();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/framing/TransportFrame.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/framing/TransportFrame.java b/proton-j/src/main/java/org/apache/qpid/proton/framing/TransportFrame.java
deleted file mode 100644
index 624ac56..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/framing/TransportFrame.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.framing;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.transport.FrameBody;
-
-public class TransportFrame
-{
- private final int _channel;
- private final FrameBody _body;
- private final Binary _payload;
-
-
- public TransportFrame(final int channel,
- final FrameBody body,
- final Binary payload)
- {
- _payload = payload;
- _body = body;
- _channel = channel;
- }
-
- public int getChannel()
- {
- return _channel;
- }
-
- public FrameBody getBody()
- {
- return _body;
- }
-
- public Binary getPayload()
- {
- return _payload;
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("TransportFrame{ _channel=").append(_channel).append(", _body=").append(_body).append("}");
- return builder.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/logging/LoggingProtocolTracer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/logging/LoggingProtocolTracer.java b/proton-j/src/main/java/org/apache/qpid/proton/logging/LoggingProtocolTracer.java
deleted file mode 100644
index 7624b0b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/logging/LoggingProtocolTracer.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.logging;
-
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.engine.impl.ProtocolTracer;
-import org.apache.qpid.proton.framing.TransportFrame;
-
-public class LoggingProtocolTracer implements ProtocolTracer
-{
- private static final String LOGGER_NAME_STEM = LoggingProtocolTracer.class.getName();
-
- private static final Logger RECEIVED_LOGGER = Logger.getLogger(LOGGER_NAME_STEM + ".received");
- private static final Logger SENT_LOGGER = Logger.getLogger(LOGGER_NAME_STEM + ".sent");
-
- private String _logMessagePrefix;
-
- public LoggingProtocolTracer()
- {
- this("Transport");
- }
-
- public LoggingProtocolTracer(String logMessagePrefix)
- {
- _logMessagePrefix = logMessagePrefix;
- }
-
- @Override
- public void receivedFrame(TransportFrame transportFrame)
- {
- RECEIVED_LOGGER.finer(_logMessagePrefix + " received frame: " + transportFrame);
- }
-
- @Override
- public void sentFrame(TransportFrame transportFrame)
- {
- SENT_LOGGER.finer(_logMessagePrefix + " writing frame: " + transportFrame);
- }
-
- public void setLogMessagePrefix(String logMessagePrefix)
- {
- _logMessagePrefix = logMessagePrefix;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/logging/ProtonLoggerFactory.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/logging/ProtonLoggerFactory.java b/proton-j/src/main/java/org/apache/qpid/proton/logging/ProtonLoggerFactory.java
deleted file mode 100644
index 890873a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/logging/ProtonLoggerFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.logging;
-
-import java.util.logging.Logger;
-
-/**
- * Thin convenience wrapper around {@link Logger}
- */
-public class ProtonLoggerFactory
-{
- /**
- * Returns a logger named using the fully qualified name of the supplied class.
- */
- public static Logger getLogger(Class<?> clazz)
- {
- return Logger.getLogger(clazz.getName());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java b/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java
deleted file mode 100644
index 41945fa..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.message;
-
-import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
-import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations;
-import org.apache.qpid.proton.amqp.messaging.Footer;
-import org.apache.qpid.proton.amqp.messaging.Header;
-import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
-import org.apache.qpid.proton.amqp.messaging.Properties;
-import org.apache.qpid.proton.amqp.messaging.Section;
-
-import org.apache.qpid.proton.message.impl.MessageImpl;
-
-/**
- * Represents a Message within Proton.
- *
- * Create instances of Message using {@link Message.Factory}.
- *
- */
-public interface Message
-{
-
- public static final class Factory
- {
- public static Message create() {
- return new MessageImpl();
- }
-
- public static Message create(Header header,
- DeliveryAnnotations deliveryAnnotations,
- MessageAnnotations messageAnnotations,
- Properties properties,
- ApplicationProperties applicationProperties,
- Section body,
- Footer footer) {
- return new MessageImpl(header, deliveryAnnotations,
- messageAnnotations, properties,
- applicationProperties, body, footer);
- }
- }
-
-
- short DEFAULT_PRIORITY = 4;
-
- boolean isDurable();
-
- long getDeliveryCount();
-
- short getPriority();
-
- boolean isFirstAcquirer();
-
- long getTtl();
-
- void setDurable(boolean durable);
-
- void setTtl(long ttl);
-
- void setDeliveryCount(long deliveryCount);
-
- void setFirstAcquirer(boolean firstAcquirer);
-
- void setPriority(short priority);
-
- Object getMessageId();
-
- long getGroupSequence();
-
- String getReplyToGroupId();
-
-
- long getCreationTime();
-
- String getAddress();
-
- byte[] getUserId();
-
- String getReplyTo();
-
- String getGroupId();
-
- String getContentType();
-
- long getExpiryTime();
-
- Object getCorrelationId();
-
- String getContentEncoding();
-
- String getSubject();
-
- void setGroupSequence(long groupSequence);
-
- void setUserId(byte[] userId);
-
- void setCreationTime(long creationTime);
-
- void setSubject(String subject);
-
- void setGroupId(String groupId);
-
- void setAddress(String to);
-
- void setExpiryTime(long absoluteExpiryTime);
-
- void setReplyToGroupId(String replyToGroupId);
-
- void setContentEncoding(String contentEncoding);
-
- void setContentType(String contentType);
-
- void setReplyTo(String replyTo);
-
- void setCorrelationId(Object correlationId);
-
- void setMessageId(Object messageId);
-
- Header getHeader();
-
- DeliveryAnnotations getDeliveryAnnotations();
-
- MessageAnnotations getMessageAnnotations();
-
- Properties getProperties();
-
- ApplicationProperties getApplicationProperties();
-
- Section getBody();
-
- Footer getFooter();
-
- void setHeader(Header header);
-
- void setDeliveryAnnotations(DeliveryAnnotations deliveryAnnotations);
-
- void setMessageAnnotations(MessageAnnotations messageAnnotations);
-
- void setProperties(Properties properties);
-
- void setApplicationProperties(ApplicationProperties applicationProperties);
-
- void setBody(Section body);
-
- void setFooter(Footer footer);
-
- /**
- * TODO describe what happens if the data does not represent a complete message.
- * Currently this appears to leave the message in an unknown state.
- */
- int decode(byte[] data, int offset, int length);
-
- /**
- * Encodes up to {@code length} bytes of the message into the provided byte array,
- * starting at position {@code offset}.
- *
- * TODO describe what happens if length is smaller than the encoded form, Currently
- * Proton-J throws an exception. What does Proton-C do?
- *
- * @return the number of bytes written to the byte array
- */
- int encode(byte[] data, int offset, int length);
-
- void clear();
-
- MessageError getError();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/message/MessageError.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message/MessageError.java b/proton-j/src/main/java/org/apache/qpid/proton/message/MessageError.java
deleted file mode 100644
index 1b8e0af..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/message/MessageError.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.message;
-
-public enum MessageError
-{
- OK
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/message/ProtonJMessage.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message/ProtonJMessage.java b/proton-j/src/main/java/org/apache/qpid/proton/message/ProtonJMessage.java
deleted file mode 100644
index b22ef2a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/message/ProtonJMessage.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.message;
-
-import org.apache.qpid.proton.codec.WritableBuffer;
-import org.apache.qpid.proton.message.Message;
-
-public interface ProtonJMessage extends Message
-{
-
- int encode2(byte[] data, int offset, int length);
-
- int encode(WritableBuffer buffer);
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
deleted file mode 100644
index df6373f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
+++ /dev/null
@@ -1,784 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-package org.apache.qpid.proton.message.impl;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.messaging.*;
-import org.apache.qpid.proton.codec.*;
-import org.apache.qpid.proton.message.*;
-
-public class MessageImpl implements ProtonJMessage
-{
- private Header _header;
- private DeliveryAnnotations _deliveryAnnotations;
- private MessageAnnotations _messageAnnotations;
- private Properties _properties;
- private ApplicationProperties _applicationProperties;
- private Section _body;
- private Footer _footer;
-
- private static class EncoderDecoderPair {
- DecoderImpl decoder = new DecoderImpl();
- EncoderImpl encoder = new EncoderImpl(decoder);
- {
- AMQPDefinedTypes.registerAllTypes(decoder, encoder);
- }
- }
-
- private static final ThreadLocal<EncoderDecoderPair> tlsCodec = new ThreadLocal<EncoderDecoderPair>() {
- @Override protected EncoderDecoderPair initialValue() {
- return new EncoderDecoderPair();
- }
- };
-
- /**
- * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
- * Client code outside this module should use {@link Message.Factory#create()} instead
- */
- @Deprecated public MessageImpl()
- {
- }
-
- /**
- * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
- * Client code outside this module should instead use
- * {@link Message.Factory#create(Header, DeliveryAnnotations, MessageAnnotations, Properties, ApplicationProperties, Section, Footer)}
- */
- @Deprecated public MessageImpl(Header header, DeliveryAnnotations deliveryAnnotations, MessageAnnotations messageAnnotations,
- Properties properties, ApplicationProperties applicationProperties, Section body, Footer footer)
- {
- _header = header;
- _deliveryAnnotations = deliveryAnnotations;
- _messageAnnotations = messageAnnotations;
- _properties = properties;
- _applicationProperties = applicationProperties;
- _body = body;
- _footer = footer;
- }
-
- @Override
- public boolean isDurable()
- {
- return (_header == null || _header.getDurable() == null) ? false : _header.getDurable();
- }
-
-
- @Override
- public long getDeliveryCount()
- {
- return (_header == null || _header.getDeliveryCount() == null) ? 0l : _header.getDeliveryCount().longValue();
- }
-
-
- @Override
- public short getPriority()
- {
- return (_header == null || _header.getPriority() == null)
- ? DEFAULT_PRIORITY
- : _header.getPriority().shortValue();
- }
-
- @Override
- public boolean isFirstAcquirer()
- {
- return (_header == null || _header.getFirstAcquirer() == null) ? false : _header.getFirstAcquirer();
- }
-
- @Override
- public long getTtl()
- {
- return (_header == null || _header.getTtl() == null) ? 0l : _header.getTtl().longValue();
- }
-
- @Override
- public void setDurable(boolean durable)
- {
- if (_header == null)
- {
- if (durable)
- {
- _header = new Header();
- }
- else
- {
- return;
- }
- }
- _header.setDurable(durable);
- }
-
- @Override
- public void setTtl(long ttl)
- {
-
- if (_header == null)
- {
- if (ttl != 0l)
- {
- _header = new Header();
- }
- else
- {
- return;
- }
- }
- _header.setTtl(UnsignedInteger.valueOf(ttl));
- }
-
- @Override
- public void setDeliveryCount(long deliveryCount)
- {
- if (_header == null)
- {
- if (deliveryCount == 0l)
- {
- return;
- }
- _header = new Header();
- }
- _header.setDeliveryCount(UnsignedInteger.valueOf(deliveryCount));
- }
-
-
- @Override
- public void setFirstAcquirer(boolean firstAcquirer)
- {
-
- if (_header == null)
- {
- if (!firstAcquirer)
- {
- return;
- }
- _header = new Header();
- }
- _header.setFirstAcquirer(firstAcquirer);
- }
-
- @Override
- public void setPriority(short priority)
- {
-
- if (_header == null)
- {
- if (priority == DEFAULT_PRIORITY)
- {
- return;
- }
- _header = new Header();
- }
- _header.setPriority(UnsignedByte.valueOf((byte) priority));
- }
-
- @Override
- public Object getMessageId()
- {
- return _properties == null ? null : _properties.getMessageId();
- }
-
- @Override
- public long getGroupSequence()
- {
- return (_properties == null || _properties.getGroupSequence() == null) ? 0l : _properties.getGroupSequence().intValue();
- }
-
- @Override
- public String getReplyToGroupId()
- {
- return _properties == null ? null : _properties.getReplyToGroupId();
- }
-
- @Override
- public long getCreationTime()
- {
- return (_properties == null || _properties.getCreationTime() == null) ? 0l : _properties.getCreationTime().getTime();
- }
-
- @Override
- public String getAddress()
- {
- return _properties == null ? null : _properties.getTo();
- }
-
- @Override
- public byte[] getUserId()
- {
- if(_properties == null || _properties.getUserId() == null)
- {
- return null;
- }
- else
- {
- final Binary userId = _properties.getUserId();
- byte[] id = new byte[userId.getLength()];
- System.arraycopy(userId.getArray(),userId.getArrayOffset(),id,0,userId.getLength());
- return id;
- }
-
- }
-
- @Override
- public String getReplyTo()
- {
- return _properties == null ? null : _properties.getReplyTo();
- }
-
- @Override
- public String getGroupId()
- {
- return _properties == null ? null : _properties.getGroupId();
- }
-
- @Override
- public String getContentType()
- {
- return (_properties == null || _properties.getContentType() == null) ? null : _properties.getContentType().toString();
- }
-
- @Override
- public long getExpiryTime()
- {
- return (_properties == null || _properties.getAbsoluteExpiryTime() == null) ? 0l : _properties.getAbsoluteExpiryTime().getTime();
- }
-
- @Override
- public Object getCorrelationId()
- {
- return (_properties == null) ? null : _properties.getCorrelationId();
- }
-
- @Override
- public String getContentEncoding()
- {
- return (_properties == null || _properties.getContentEncoding() == null) ? null : _properties.getContentEncoding().toString();
- }
-
- @Override
- public String getSubject()
- {
- return _properties == null ? null : _properties.getSubject();
- }
-
- @Override
- public void setGroupSequence(long groupSequence)
- {
- if(_properties == null)
- {
- if(groupSequence == 0l)
- {
- return;
- }
- else
- {
- _properties = new Properties();
- }
- }
- _properties.setGroupSequence(UnsignedInteger.valueOf((int) groupSequence));
- }
-
- @Override
- public void setUserId(byte[] userId)
- {
- if(userId == null)
- {
- if(_properties != null)
- {
- _properties.setUserId(null);
- }
-
- }
- else
- {
- if(_properties == null)
- {
- _properties = new Properties();
- }
- byte[] id = new byte[userId.length];
- System.arraycopy(userId, 0, id,0, userId.length);
- _properties.setUserId(new Binary(id));
- }
- }
-
- @Override
- public void setCreationTime(long creationTime)
- {
- if(_properties == null)
- {
- if(creationTime == 0l)
- {
- return;
- }
- _properties = new Properties();
-
- }
- _properties.setCreationTime(new Date(creationTime));
- }
-
- @Override
- public void setSubject(String subject)
- {
- if(_properties == null)
- {
- if(subject == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setSubject(subject);
- }
-
- @Override
- public void setGroupId(String groupId)
- {
- if(_properties == null)
- {
- if(groupId == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setGroupId(groupId);
- }
-
- @Override
- public void setAddress(String to)
- {
- if(_properties == null)
- {
- if(to == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setTo(to);
- }
-
- @Override
- public void setExpiryTime(long absoluteExpiryTime)
- {
- if(_properties == null)
- {
- if(absoluteExpiryTime == 0l)
- {
- return;
- }
- _properties = new Properties();
-
- }
- _properties.setAbsoluteExpiryTime(new Date(absoluteExpiryTime));
- }
-
- @Override
- public void setReplyToGroupId(String replyToGroupId)
- {
- if(_properties == null)
- {
- if(replyToGroupId == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setReplyToGroupId(replyToGroupId);
- }
-
- @Override
- public void setContentEncoding(String contentEncoding)
- {
- if(_properties == null)
- {
- if(contentEncoding == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setContentEncoding(Symbol.valueOf(contentEncoding));
- }
-
- @Override
- public void setContentType(String contentType)
- {
- if(_properties == null)
- {
- if(contentType == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setContentType(Symbol.valueOf(contentType));
- }
-
- @Override
- public void setReplyTo(String replyTo)
- {
-
- if(_properties == null)
- {
- if(replyTo == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setReplyTo(replyTo);
- }
-
- @Override
- public void setCorrelationId(Object correlationId)
- {
-
- if(_properties == null)
- {
- if(correlationId == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setCorrelationId(correlationId);
- }
-
- @Override
- public void setMessageId(Object messageId)
- {
-
- if(_properties == null)
- {
- if(messageId == null)
- {
- return;
- }
- _properties = new Properties();
- }
- _properties.setMessageId(messageId);
- }
-
-
- @Override
- public Header getHeader()
- {
- return _header;
- }
-
- @Override
- public DeliveryAnnotations getDeliveryAnnotations()
- {
- return _deliveryAnnotations;
- }
-
- @Override
- public MessageAnnotations getMessageAnnotations()
- {
- return _messageAnnotations;
- }
-
- @Override
- public Properties getProperties()
- {
- return _properties;
- }
-
- @Override
- public ApplicationProperties getApplicationProperties()
- {
- return _applicationProperties;
- }
-
- @Override
- public Section getBody()
- {
- return _body;
- }
-
- @Override
- public Footer getFooter()
- {
- return _footer;
- }
-
- @Override
- public void setHeader(Header header)
- {
- _header = header;
- }
-
- @Override
- public void setDeliveryAnnotations(DeliveryAnnotations deliveryAnnotations)
- {
- _deliveryAnnotations = deliveryAnnotations;
- }
-
- @Override
- public void setMessageAnnotations(MessageAnnotations messageAnnotations)
- {
- _messageAnnotations = messageAnnotations;
- }
-
- @Override
- public void setProperties(Properties properties)
- {
- _properties = properties;
- }
-
- @Override
- public void setApplicationProperties(ApplicationProperties applicationProperties)
- {
- _applicationProperties = applicationProperties;
- }
-
- @Override
- public void setBody(Section body)
- {
- _body = body;
- }
-
- @Override
- public void setFooter(Footer footer)
- {
- _footer = footer;
- }
-
- @Override
- public int decode(byte[] data, int offset, int length)
- {
- final ByteBuffer buffer = ByteBuffer.wrap(data, offset, length);
- decode(buffer);
-
- return length-buffer.remaining();
- }
-
- public void decode(ByteBuffer buffer)
- {
- DecoderImpl decoder = tlsCodec.get().decoder;
- decoder.setByteBuffer(buffer);
-
- _header = null;
- _deliveryAnnotations = null;
- _messageAnnotations = null;
- _properties = null;
- _applicationProperties = null;
- _body = null;
- _footer = null;
- Section section = null;
-
- if(buffer.hasRemaining())
- {
- section = (Section) decoder.readObject();
- }
- if(section instanceof Header)
- {
- _header = (Header) section;
- if(buffer.hasRemaining())
- {
- section = (Section) decoder.readObject();
- }
- else
- {
- section = null;
- }
-
- }
- if(section instanceof DeliveryAnnotations)
- {
- _deliveryAnnotations = (DeliveryAnnotations) section;
-
- if(buffer.hasRemaining())
- {
- section = (Section) decoder.readObject();
- }
- else
- {
- section = null;
- }
-
- }
- if(section instanceof MessageAnnotations)
- {
- _messageAnnotations = (MessageAnnotations) section;
-
- if(buffer.hasRemaining())
- {
- section = (Section) decoder.readObject();
- }
- else
- {
- section = null;
- }
-
- }
- if(section instanceof Properties)
- {
- _properties = (Properties) section;
-
- if(buffer.hasRemaining())
- {
- section = (Section) decoder.readObject();
- }
- else
- {
- section = null;
- }
-
- }
- if(section instanceof ApplicationProperties)
- {
- _applicationProperties = (ApplicationProperties) section;
-
- if(buffer.hasRemaining())
- {
- section = (Section) decoder.readObject();
- }
- else
- {
- section = null;
- }
-
- }
- if(section != null && !(section instanceof Footer))
- {
- _body = section;
-
- if(buffer.hasRemaining())
- {
- section = (Section) decoder.readObject();
- }
- else
- {
- section = null;
- }
-
- }
- if(section instanceof Footer)
- {
- _footer = (Footer) section;
-
- }
-
- decoder.setByteBuffer(null);
- }
-
- @Override
- public int encode(byte[] data, int offset, int length)
- {
- ByteBuffer buffer = ByteBuffer.wrap(data, offset, length);
- return encode(new WritableBuffer.ByteBufferWrapper(buffer));
- }
-
- @Override
- public int encode2(byte[] data, int offset, int length)
- {
- ByteBuffer buffer = ByteBuffer.wrap(data, offset, length);
- WritableBuffer.ByteBufferWrapper first = new WritableBuffer.ByteBufferWrapper(buffer);
- DroppingWritableBuffer second = new DroppingWritableBuffer();
- CompositeWritableBuffer composite = new CompositeWritableBuffer(first, second);
- int start = composite.position();
- encode(composite);
- return composite.position() - start;
- }
-
- @Override
- public int encode(WritableBuffer buffer)
- {
- int length = buffer.remaining();
- EncoderImpl encoder = tlsCodec.get().encoder;
- encoder.setByteBuffer(buffer);
-
- if(getHeader() != null)
- {
- encoder.writeObject(getHeader());
- }
- if(getDeliveryAnnotations() != null)
- {
- encoder.writeObject(getDeliveryAnnotations());
- }
- if(getMessageAnnotations() != null)
- {
- encoder.writeObject(getMessageAnnotations());
- }
- if(getProperties() != null)
- {
- encoder.writeObject(getProperties());
- }
- if(getApplicationProperties() != null)
- {
- encoder.writeObject(getApplicationProperties());
- }
- if(getBody() != null)
- {
- encoder.writeObject(getBody());
- }
- if(getFooter() != null)
- {
- encoder.writeObject(getFooter());
- }
- encoder.setByteBuffer((WritableBuffer)null);
-
- return length - buffer.remaining();
- }
-
- @Override
- public void clear()
- {
- _body = null;
- }
-
- @Override
- public MessageError getError()
- {
- return MessageError.OK;
- }
-
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append("Message{");
- if (_header != null) {
- sb.append("header=");
- sb.append(_header);
- }
- if (_properties != null) {
- sb.append("properties=");
- sb.append(_properties);
- }
- if (_messageAnnotations != null) {
- sb.append("message_annotations=");
- sb.append(_messageAnnotations);
- }
- if (_body != null) {
- sb.append("body=");
- sb.append(_body);
- }
- sb.append("}");
- return sb.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/Messenger.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/Messenger.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/Messenger.java
deleted file mode 100644
index bd19259..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/Messenger.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.messenger;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.TimeoutException;
-import org.apache.qpid.proton.message.Message;
-import org.apache.qpid.proton.messenger.impl.MessengerImpl;
-
-/**
- *
- * Messenger defines a high level interface for sending and receiving
- * messages. Every Messenger contains a single logical queue of
- * incoming messages and a single logical queue of outgoing
- * messages. These messages in these queues may be destined for, or
- * originate from, a variety of addresses.
- *
- * <h3>Address Syntax</h3>
- *
- * An address has the following form:
- *
- * [ amqp[s]:// ] [user[:password]@] domain [/[name]]
- *
- * Where domain can be one of:
- *
- * host | host:port | ip | ip:port | name
- *
- * The following are valid examples of addresses:
- *
- * - example.org
- * - example.org:1234
- * - amqp://example.org
- * - amqps://example.org
- * - example.org/incoming
- * - amqps://example.org/outgoing
- * - amqps://fred:trustno1@example.org
- * - 127.0.0.1:1234
- * - amqps://127.0.0.1:1234
- *
- * <h3>Sending & Receiving Messages</h3>
- *
- * The Messenger interface works in conjuction with the Message
- * class. The Message class is a mutable holder of message content.
- * The put method will encode the content in a given Message object
- * into the outgoing message queue leaving that Message object free
- * to be modified or discarded without having any impact on the
- * content in the outgoing queue.
- *
- * Similarly, the get method will decode the content in the incoming
- * message queue into the supplied Message object.
- *
- * @deprecated Messenger will be removed from upcoming proton-j releases.
-*/
-@Deprecated
-public interface Messenger
-{
-
- /**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
- @Deprecated
- public static final class Factory
- {
- public static Messenger create() {
- return new MessengerImpl();
- }
-
- public static Messenger create(String name) {
- return new MessengerImpl(name);
- }
- }
-
- /**
- * Flag for use with reject(), accept() and settle() methods.
- */
- static final int CUMULATIVE = 0x01;
-
- /**
- * Places the content contained in the message onto the outgoing
- * queue of the Messenger. This method will never block. The
- * send call may be used to block until the messages are
- * sent. Either a send() or a recv() call is neceesary at present
- * to cause the messages to actually be sent out.
- */
- void put(Message message) throws MessengerException;
-
- /**
- * Blocks until the outgoing queue is empty and, in the event that
- * an outgoing window has been set, until the messages in that
- * window have been received by the target to which they were
- * sent, or the operation times out. The timeout property
- * controls how long a Messenger will block before timing out.
- */
- void send() throws TimeoutException;
-
- void send(int n) throws TimeoutException;
-
- /**
- * Subscribes the Messenger to messages originating from the
- * specified source. The source is an address as specified in the
- * Messenger introduction with the following addition. If the
- * domain portion of the address begins with the '~' character,
- * the Messenger will interpret the domain as host/port, bind
- * to it, and listen for incoming messages. For example
- * "~0.0.0.0", "amqp://~0.0.0.0" will bind to any local interface
- * and listen for incoming messages.
- */
- void subscribe(String source) throws MessengerException;
- /**
- * Receives an arbitrary number of messages into the
- * incoming queue of the Messenger. This method will block until
- * at least one message is available or the operation times out.
- */
- void recv() throws TimeoutException;
- /**
- * Receives up to the specified number of messages into the
- * incoming queue of the Messenger. This method will block until
- * at least one message is available or the operation times out.
- */
- void recv(int count) throws TimeoutException;
- /**
- * Returns the capacity of the incoming message queue of
- * messenger. Note this count does not include those messages
- * already available on the incoming queue (see
- * incoming()). Rather it returns the number of incoming queue
- * entries available for receiving messages
- */
- int receiving();
- /**
- * Returns the message from the head of the incoming message
- * queue.
- */
- Message get();
-
- /**
- * Transitions the Messenger to an active state. A Messenger is
- * initially created in an inactive state. When inactive, a
- * Messenger will not send or receive messages from its internal
- * queues. A Messenger must be started before calling send() or
- * recv().
- */
- void start() throws IOException;
- /**
- * Transitions the Messenger to an inactive state. An inactive
- * Messenger will not send or receive messages from its internal
- * queues. A Messenger should be stopped before being discarded to
- * ensure a clean shutdown handshake occurs on any internally managed
- * connections.
- */
- void stop();
-
- boolean stopped();
-
- /** Sends or receives any outstanding messages queued for a
- * messenger. If timeout is zero, no blocking is done. A timeout
- * of -1 blocks forever, otherwise timeout is the maximum time (in
- * millisecs) to block. Returns True if work was performed.
- */
- boolean work(long timeout) throws TimeoutException;
-
- void interrupt();
-
- void setTimeout(long timeInMillis);
- long getTimeout();
-
- boolean isBlocking();
- void setBlocking(boolean b);
-
- /**
- * Returns a count of the messages currently on the outgoing queue
- * (i.e. those that have been put() but not yet actually sent
- * out).
- */
- int outgoing();
- /**
- * Returns a count of the messages available on the incoming
- * queue.
- */
- int incoming();
-
- int getIncomingWindow();
- void setIncomingWindow(int window);
-
- int getOutgoingWindow();
- void setOutgoingWindow(int window);
-
- /**
- * Returns a token which can be used to accept or reject the
- * message returned in the previous get() call.
- */
- Tracker incomingTracker();
- /**
- * Returns a token which can be used to track the status of the
- * message of the previous put() call.
- */
- Tracker outgoingTracker();
-
- /**
- * Rejects messages retrieved from the incoming message queue. The
- * tracker object for a message is obtained through a call to
- * incomingTracker() following a get(). If the flags argument
- * contains CUMULATIVE, then all message up to the one identified
- * by the tracker will be rejected.
- */
- void reject(Tracker tracker, int flags);
- /**
- * Accepts messages retrieved from the incoming message queue. The
- * tracker object for a message is obtained through a call to
- * incomingTracker() following a get(). If the flags argument
- * contains CUMULATIVE, then all message up to the one identified
- * by the tracker will be accepted.
- */
- void accept(Tracker tracker, int flags);
- void settle(Tracker tracker, int flags);
-
- /**
- * Gets the last known remote state of the delivery associated
- * with the given tracker.
- */
- Status getStatus(Tracker tracker);
-
- void route(String pattern, String address);
-
- void rewrite(String pattern, String address);
-
- /**
- * Set the path to the certificate file.
- */
- void setCertificate(String certificate);
-
- /**
- * Get the path to the certificate file.
- */
- String getCertificate();
-
- /**
- * Set the path to private key file.
- */
- void setPrivateKey(String privateKey);
-
- /**
- * Get the path to the private key file.
- */
- String getPrivateKey();
-
- /**
- * Set the password for private key file.
- */
- void setPassword(String password);
-
- /**
- * Get the password for the priate key file.
- */
- String getPassword();
-
- /**
- * Set the path to the trusted certificate database.
- */
- void setTrustedCertificates(String trusted);
-
- /**
- * Get the path to the trusted certificate database.
- */
- String getTrustedCertificates();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/MessengerException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/MessengerException.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/MessengerException.java
deleted file mode 100644
index c6f3570..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/MessengerException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.messenger;
-
-import org.apache.qpid.proton.ProtonException;
-
-/**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public class MessengerException extends ProtonException
-{
- public MessengerException()
- {
- }
-
- public MessengerException(String message)
- {
- super(message);
- }
-
- public MessengerException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public MessengerException(Throwable cause)
- {
- super(cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/Status.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/Status.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/Status.java
deleted file mode 100644
index ae7ca95..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/Status.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.messenger;
-
-/**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public enum Status
-{
- UNKNOWN,
- PENDING,
- ACCEPTED,
- REJECTED,
- RELEASED,
- MODIFIED,
- ABORTED,
- SETTLED
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/Tracker.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/Tracker.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/Tracker.java
deleted file mode 100644
index 974b1b6..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/Tracker.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.messenger;
-
-/**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public interface Tracker { }
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Address.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Address.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Address.java
deleted file mode 100644
index 27b0d39..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/Address.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.messenger.impl;
-
-
-/**
- * Address
- *
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-public class Address
-{
-
- private String _address;
- private boolean _passive;
- private String _scheme;
- private String _user;
- private String _pass;
- private String _host;
- private String _port;
- private String _name;
-
- public void clear()
- {
- _passive = false;
- _scheme = null;
- _user = null;
- _pass = null;
- _host = null;
- _port = null;
- _name = null;
- }
-
- /**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
- public Address()
- {
- clear();
- }
-
- /**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
- public Address(String address)
- {
- clear();
- int start = 0;
- int schemeEnd = address.indexOf("://", start);
- if (schemeEnd >= 0) {
- _scheme = address.substring(start, schemeEnd);
- start = schemeEnd + 3;
- }
-
- String uphp;
- int slash = address.indexOf("/", start);
- if (slash >= 0) {
- uphp = address.substring(start, slash);
- _name = address.substring(slash + 1);
- } else {
- uphp = address.substring(start);
- }
-
- String hp;
- int at = uphp.indexOf('@');
- if (at >= 0) {
- String up = uphp.substring(0, at);
- hp = uphp.substring(at + 1);
-
- int colon = up.indexOf(':');
- if (colon >= 0) {
- _user = up.substring(0, colon);
- _pass = up.substring(colon + 1);
- } else {
- _user = up;
- }
- } else {
- hp = uphp;
- }
-
- if (hp.startsWith("[")) {
- int close = hp.indexOf(']');
- if (close >= 0) {
- _host = hp.substring(1, close);
- if (hp.substring(close + 1).startsWith(":")) {
- _port = hp.substring(close + 2);
- }
- }
- }
-
- if (_host == null) {
- int colon = hp.indexOf(':');
- if (colon >= 0) {
- _host = hp.substring(0, colon);
- _port = hp.substring(colon + 1);
- } else {
- _host = hp;
- }
- }
-
- if (_host.startsWith("~")) {
- _host = _host.substring(1);
- _passive = true;
- }
- }
-
- public String toString()
- {
- String str = new String();
- if (_scheme != null) str += _scheme + "://";
- if (_user != null) str += _user;
- if (_pass != null) str += ":" + _pass;
- if (_user != null || _pass != null) str += "@";
- if (_host != null) {
- if (_host.contains(":")) str += "[" + _host + "]";
- else str += _host;
- }
- if (_port != null) str += ":" + _port;
- if (_name != null) str += "/" + _name;
- return str;
- }
-
- public boolean isPassive()
- {
- return _passive;
- }
-
- public String getScheme()
- {
- return _scheme;
- }
-
- public String getUser()
- {
- return _user;
- }
-
- public String getPass()
- {
- return _pass;
- }
-
- public String getHost()
- {
- return _host;
- }
-
- public String getPort()
- {
- return _port;
- }
-
- public String getImpliedPort()
- {
- if (_port == null) {
- return getDefaultPort();
- } else {
- return getPort();
- }
- }
-
- public String getDefaultPort()
- {
- if ("amqps".equals(_scheme)) return "5671";
- else return "5672";
- }
-
- public String getName()
- {
- return _name;
- }
-
- public void setScheme(String scheme)
- {
- _scheme= scheme;
- }
-
- public void setUser(String user)
- {
- _user= user;
- }
-
- public void setPass(String pass)
- {
- _pass= pass;
- }
-
- public void setHost(String host)
- {
- _host= host;
- }
-
- public void setPort(String port)
- {
- _port= port;
- }
-
- public void setName(String name)
- {
- _name= name;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[21/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataDecoder.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataDecoder.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataDecoder.java
deleted file mode 100644
index 71199bb..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataDecoder.java
+++ /dev/null
@@ -1,1074 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.Date;
-import java.util.UUID;
-
-import org.apache.qpid.proton.amqp.*;
-import org.apache.qpid.proton.codec.Data;
-
-class DataDecoder
-{
-
- private static final Charset ASCII = Charset.forName("US-ASCII");
- private static final Charset UTF_8 = Charset.forName("UTF-8");
-
- private static final TypeConstructor[] _constructors = new TypeConstructor[256];
-
- static
- {
-
- _constructors[0x00] = new DescribedTypeConstructor();
-
- _constructors[0x40] = new NullConstructor();
- _constructors[0x41] = new TrueConstructor();
- _constructors[0x42] = new FalseConstructor();
- _constructors[0x43] = new UInt0Constructor();
- _constructors[0x44] = new ULong0Constructor();
- _constructors[0x45] = new EmptyListConstructor();
-
- _constructors[0x50] = new UByteConstructor();
- _constructors[0x51] = new ByteConstructor();
- _constructors[0x52] = new SmallUIntConstructor();
- _constructors[0x53] = new SmallULongConstructor();
- _constructors[0x54] = new SmallIntConstructor();
- _constructors[0x55] = new SmallLongConstructor();
- _constructors[0x56] = new BooleanConstructor();
-
- _constructors[0x60] = new UShortConstructor();
- _constructors[0x61] = new ShortConstructor();
-
- _constructors[0x70] = new UIntConstructor();
- _constructors[0x71] = new IntConstructor();
- _constructors[0x72] = new FloatConstructor();
- _constructors[0x73] = new CharConstructor();
- _constructors[0x74] = new Decimal32Constructor();
-
- _constructors[0x80] = new ULongConstructor();
- _constructors[0x81] = new LongConstructor();
- _constructors[0x82] = new DoubleConstructor();
- _constructors[0x83] = new TimestampConstructor();
- _constructors[0x84] = new Decimal64Constructor();
-
- _constructors[0x94] = new Decimal128Constructor();
- _constructors[0x98] = new UUIDConstructor();
-
- _constructors[0xa0] = new SmallBinaryConstructor();
- _constructors[0xa1] = new SmallStringConstructor();
- _constructors[0xa3] = new SmallSymbolConstructor();
-
- _constructors[0xb0] = new BinaryConstructor();
- _constructors[0xb1] = new StringConstructor();
- _constructors[0xb3] = new SymbolConstructor();
-
- _constructors[0xc0] = new SmallListConstructor();
- _constructors[0xc1] = new SmallMapConstructor();
-
-
- _constructors[0xd0] = new ListConstructor();
- _constructors[0xd1] = new MapConstructor();
-
- _constructors[0xe0] = new SmallArrayConstructor();
- _constructors[0xf0] = new ArrayConstructor();
-
- }
-
- private interface TypeConstructor
- {
- Data.DataType getType();
-
- int size(ByteBuffer b);
-
- void parse(ByteBuffer b, Data data);
- }
-
-
- static int decode(ByteBuffer b, Data data)
- {
- if(b.hasRemaining())
- {
- int position = b.position();
- TypeConstructor c = readConstructor(b);
- final int size = c.size(b);
- if(b.remaining() >= size)
- {
- c.parse(b, data);
- return 1+size;
- }
- else
- {
- b.position(position);
- return -4;
- }
- }
- return 0;
- }
-
- private static TypeConstructor readConstructor(ByteBuffer b)
- {
- int index = b.get() & 0xff;
- TypeConstructor tc = _constructors[index];
- if(tc == null)
- {
- throw new IllegalArgumentException("No constructor for type " + index);
- }
- return tc;
- }
-
-
- private static class NullConstructor implements TypeConstructor
- {
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.NULL;
- }
-
- @Override
- public int size(ByteBuffer b)
- {
- return 0;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putNull();
- }
- }
-
- private static class TrueConstructor implements TypeConstructor
- {
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.BOOL;
- }
-
- @Override
- public int size(ByteBuffer b)
- {
- return 0;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putBoolean(true);
- }
- }
-
-
- private static class FalseConstructor implements TypeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.BOOL;
- }
-
- @Override
- public int size(ByteBuffer b)
- {
- return 0;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putBoolean(false);
- }
- }
-
- private static class UInt0Constructor implements TypeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.UINT;
- }
-
- @Override
- public int size(ByteBuffer b)
- {
- return 0;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUnsignedInteger(UnsignedInteger.ZERO);
- }
- }
-
- private static class ULong0Constructor implements TypeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.ULONG;
- }
-
- @Override
- public int size(ByteBuffer b)
- {
- return 0;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUnsignedLong(UnsignedLong.ZERO);
- }
- }
-
-
- private static class EmptyListConstructor implements TypeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.LIST;
- }
-
- @Override
- public int size(ByteBuffer b)
- {
- return 0;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putList();
- }
- }
-
-
- private static abstract class Fixed0SizeConstructor implements TypeConstructor
- {
- @Override
- public final int size(ByteBuffer b)
- {
- return 0;
- }
- }
-
- private static abstract class Fixed1SizeConstructor implements TypeConstructor
- {
- @Override
- public int size(ByteBuffer b)
- {
- return 1;
- }
- }
-
- private static abstract class Fixed2SizeConstructor implements TypeConstructor
- {
- @Override
- public int size(ByteBuffer b)
- {
- return 2;
- }
- }
-
- private static abstract class Fixed4SizeConstructor implements TypeConstructor
- {
- @Override
- public int size(ByteBuffer b)
- {
- return 4;
- }
- }
-
- private static abstract class Fixed8SizeConstructor implements TypeConstructor
- {
- @Override
- public int size(ByteBuffer b)
- {
- return 8;
- }
- }
-
- private static abstract class Fixed16SizeConstructor implements TypeConstructor
- {
- @Override
- public int size(ByteBuffer b)
- {
- return 16;
- }
- }
-
- private static class UByteConstructor extends Fixed1SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.UBYTE;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUnsignedByte(UnsignedByte.valueOf(b.get()));
- }
- }
-
- private static class ByteConstructor extends Fixed1SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.BYTE;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putByte(b.get());
- }
- }
-
- private static class SmallUIntConstructor extends Fixed1SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.UINT;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUnsignedInteger(UnsignedInteger.valueOf(((int) b.get()) & 0xff));
- }
- }
-
- private static class SmallIntConstructor extends Fixed1SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.INT;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putInt(b.get());
- }
- }
-
- private static class SmallULongConstructor extends Fixed1SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.ULONG;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUnsignedLong(UnsignedLong.valueOf(((int) b.get()) & 0xff));
- }
- }
-
- private static class SmallLongConstructor extends Fixed1SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.LONG;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putLong(b.get());
- }
- }
-
- private static class BooleanConstructor extends Fixed1SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.BOOL;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int i = b.get();
- if(i != 0 && i != 1)
- {
- throw new IllegalArgumentException("Illegal value " + i + " for boolean");
- }
- data.putBoolean(i == 1);
- }
- }
-
- private static class UShortConstructor extends Fixed2SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.USHORT;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUnsignedShort(UnsignedShort.valueOf(b.getShort()));
- }
- }
-
- private static class ShortConstructor extends Fixed2SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.SHORT;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putShort(b.getShort());
- }
- }
-
- private static class UIntConstructor extends Fixed4SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.UINT;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUnsignedInteger(UnsignedInteger.valueOf(b.getInt()));
- }
- }
-
- private static class IntConstructor extends Fixed4SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.INT;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putInt(b.getInt());
- }
- }
-
- private static class FloatConstructor extends Fixed4SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.FLOAT;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putFloat(b.getFloat());
- }
- }
-
- private static class CharConstructor extends Fixed4SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.CHAR;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putChar(b.getInt());
- }
- }
-
- private static class Decimal32Constructor extends Fixed4SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.DECIMAL32;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putDecimal32(new Decimal32(b.getInt()));
- }
- }
-
- private static class ULongConstructor extends Fixed8SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.ULONG;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUnsignedLong(UnsignedLong.valueOf(b.getLong()));
- }
- }
-
- private static class LongConstructor extends Fixed8SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.LONG;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putLong(b.getLong());
- }
- }
-
- private static class DoubleConstructor extends Fixed8SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.DOUBLE;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putDouble(b.getDouble());
- }
- }
-
- private static class TimestampConstructor extends Fixed8SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.TIMESTAMP;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putTimestamp(new Date(b.getLong()));
- }
- }
-
- private static class Decimal64Constructor extends Fixed8SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.DECIMAL64;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putDecimal64(new Decimal64(b.getLong()));
- }
- }
-
- private static class Decimal128Constructor extends Fixed16SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.DECIMAL128;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putDecimal128(new Decimal128(b.getLong(), b.getLong()));
- }
- }
-
- private static class UUIDConstructor extends Fixed16SizeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.UUID;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putUUID(new UUID(b.getLong(), b.getLong()));
- }
- }
-
- private static abstract class SmallVariableConstructor implements TypeConstructor
- {
-
- @Override
- public int size(ByteBuffer b)
- {
- int position = b.position();
- if(b.hasRemaining())
- {
- int size = b.get() & 0xff;
- b.position(position);
-
- return size+1;
- }
- else
- {
- return 1;
- }
- }
-
- }
-
- private static abstract class VariableConstructor implements TypeConstructor
- {
-
- @Override
- public int size(ByteBuffer b)
- {
- int position = b.position();
- if(b.remaining()>=4)
- {
- int size = b.getInt();
- b.position(position);
-
- return size+4;
- }
- else
- {
- return 4;
- }
- }
-
- }
-
-
- private static class SmallBinaryConstructor extends SmallVariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.BINARY;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.get() & 0xff;
- byte[] bytes = new byte[size];
- b.get(bytes);
- data.putBinary(bytes);
- }
- }
-
- private static class SmallSymbolConstructor extends SmallVariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.SYMBOL;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.get() & 0xff;
- byte[] bytes = new byte[size];
- b.get(bytes);
- data.putSymbol(Symbol.valueOf(new String(bytes, ASCII)));
- }
- }
-
-
- private static class SmallStringConstructor extends SmallVariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.STRING;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.get() & 0xff;
- byte[] bytes = new byte[size];
- b.get(bytes);
- data.putString(new String(bytes, UTF_8));
- }
- }
-
- private static class BinaryConstructor extends VariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.BINARY;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.getInt();
- byte[] bytes = new byte[size];
- b.get(bytes);
- data.putBinary(bytes);
- }
- }
-
- private static class SymbolConstructor extends VariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.SYMBOL;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.getInt();
- byte[] bytes = new byte[size];
- b.get(bytes);
- data.putSymbol(Symbol.valueOf(new String(bytes, ASCII)));
- }
- }
-
-
- private static class StringConstructor extends VariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.STRING;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.getInt();
- byte[] bytes = new byte[size];
- b.get(bytes);
- data.putString(new String(bytes, UTF_8));
- }
- }
-
-
- private static class SmallListConstructor extends SmallVariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.LIST;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.get() & 0xff;
- ByteBuffer buf = b.slice();
- buf.limit(size);
- b.position(b.position()+size);
- int count = buf.get() & 0xff;
- data.putList();
- parseChildren(data, buf, count);
- }
- }
-
-
- private static class SmallMapConstructor extends SmallVariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.MAP;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.get() & 0xff;
- ByteBuffer buf = b.slice();
- buf.limit(size);
- b.position(b.position()+size);
- int count = buf.get() & 0xff;
- data.putMap();
- parseChildren(data, buf, count);
- }
- }
-
-
- private static class ListConstructor extends VariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.LIST;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.getInt();
- ByteBuffer buf = b.slice();
- buf.limit(size);
- b.position(b.position()+size);
- int count = buf.getInt();
- data.putList();
- parseChildren(data, buf, count);
- }
- }
-
-
- private static class MapConstructor extends VariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.MAP;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- int size = b.getInt();
- ByteBuffer buf = b.slice();
- buf.limit(size);
- b.position(b.position()+size);
- int count = buf.getInt();
- data.putMap();
- parseChildren(data, buf, count);
- }
- }
-
-
- private static void parseChildren(Data data, ByteBuffer buf, int count)
- {
- data.enter();
- for(int i = 0; i < count; i++)
- {
- TypeConstructor c = readConstructor(buf);
- final int size = c.size(buf);
- final int remaining = buf.remaining();
- if(size <= remaining)
- {
- c.parse(buf, data);
- }
- else
- {
- throw new IllegalArgumentException("Malformed data");
- }
-
- }
- data.exit();
- }
-
- private static class DescribedTypeConstructor implements TypeConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.DESCRIBED;
- }
-
- @Override
- public int size(ByteBuffer b)
- {
- ByteBuffer buf = b.slice();
- if(buf.hasRemaining())
- {
- TypeConstructor c = readConstructor(buf);
- int size = c.size(buf);
- if(buf.remaining()>size)
- {
- buf.position(size + 1);
- c = readConstructor(buf);
- return size + 2 + c.size(buf);
- }
- else
- {
- return size + 2;
- }
- }
- else
- {
- return 1;
- }
-
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
- data.putDescribed();
- data.enter();
- TypeConstructor c = readConstructor(b);
- c.parse(b, data);
- c = readConstructor(b);
- c.parse(b, data);
- data.exit();
- }
- }
-
- private static class SmallArrayConstructor extends SmallVariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.ARRAY;
- }
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
-
- int size = b.get() & 0xff;
- ByteBuffer buf = b.slice();
- buf.limit(size);
- b.position(b.position()+size);
- int count = buf.get() & 0xff;
- parseArray(data, buf, count);
- }
-
- }
-
- private static class ArrayConstructor extends VariableConstructor
- {
-
- @Override
- public Data.DataType getType()
- {
- return Data.DataType.ARRAY;
- }
-
-
- @Override
- public void parse(ByteBuffer b, Data data)
- {
-
- int size = b.getInt();
- ByteBuffer buf = b.slice();
- buf.limit(size);
- b.position(b.position()+size);
- int count = buf.getInt();
- parseArray(data, buf, count);
- }
- }
-
- private static void parseArray(Data data, ByteBuffer buf, int count)
- {
- byte type = buf.get();
- boolean isDescribed = type == (byte)0x00;
- int descriptorPosition = buf.position();
- if(isDescribed)
- {
- TypeConstructor descriptorTc = readConstructor(buf);
- buf.position(buf.position()+descriptorTc.size(buf));
- type = buf.get();
- if(type == (byte)0x00)
- {
- throw new IllegalArgumentException("Malformed array data");
- }
-
- }
- TypeConstructor tc = _constructors[type&0xff];
-
- data.putArray(isDescribed, tc.getType());
- data.enter();
- if(isDescribed)
- {
- int position = buf.position();
- buf.position(descriptorPosition);
- TypeConstructor descriptorTc = readConstructor(buf);
- descriptorTc.parse(buf,data);
- buf.position(position);
- }
- for(int i = 0; i<count; i++)
- {
- tc.parse(buf,data);
- }
-
- data.exit();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java
deleted file mode 100644
index 5f430ba..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java
+++ /dev/null
@@ -1,928 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import org.apache.qpid.proton.ProtonUnsupportedOperationException;
-import org.apache.qpid.proton.amqp.*;
-import org.apache.qpid.proton.codec.Data;
-
-
-public class DataImpl implements Data
-{
-
- private Element _first;
- private Element _current;
- private Element _parent;
-
-
- public DataImpl()
- {
- }
-
- @Override
- public void free()
- {
- _first = null;
- _current = null;
-
- }
-
- @Override
- public void clear()
- {
- _first=null;
- _current=null;
- _parent=null;
- }
-
- @Override
- public long size()
- {
- return _first == null ? 0 : _first.size();
- }
-
- @Override
- public void rewind()
- {
- _current = null;
- _parent = null;
- }
-
- @Override
- public DataType next()
- {
- Element next = _current == null ? (_parent == null ? _first : _parent.child()) : _current.next();
-
- if(next != null)
- {
- _current = next;
- }
- return next == null ? null : next.getDataType();
- }
-
- @Override
- public DataType prev()
- {
- Element prev = _current == null ? null : _current.prev();
-
- _current = prev;
- return prev == null ? null : prev.getDataType();
- }
-
- @Override
- public boolean enter()
- {
- if(_current != null && _current.canEnter())
- {
-
- _parent = _current;
- _current = null;
- return true;
- }
- return false;
- }
-
- @Override
- public boolean exit()
- {
- if(_parent != null)
- {
- Element parent = _parent;
- _current = parent;
- _parent = _current.parent();
- return true;
-
- }
- return false;
- }
-
- @Override
- public boolean lookup(String name)
- {
- // TODO
- throw new ProtonUnsupportedOperationException();
-
- }
-
- @Override
- public DataType type()
- {
- return _current == null ? null : _current.getDataType();
- }
-
- @Override
- public long encodedSize()
- {
- int size = 0;
- Element elt = _first;
- while(elt != null)
- {
- size += elt.size();
- elt = elt.next();
- }
- return size;
- }
-
- @Override
- public Binary encode()
- {
- byte[] data = new byte[(int)encodedSize()];
- ByteBuffer buf = ByteBuffer.wrap(data);
- encode(buf);
-
- return new Binary(data);
- }
-
- @Override
- public long encode(ByteBuffer buf)
- {
- Element elt = _first;
- int size = 0;
- while(elt != null )
- {
- final int eltSize = elt.size();
- if(eltSize <= buf.remaining())
- {
- size += elt.encode(buf);
- }
- else
- {
- size+= eltSize;
- }
- elt = elt.next();
- }
- return size;
- }
-
- @Override
- public long decode(ByteBuffer buf)
- {
- return DataDecoder.decode(buf, this);
- }
-
-
- private void putElement(Element element)
- {
- if(_first == null)
- {
- _first = element;
- }
- else
- {
- if(_current == null)
- {
- if (_parent == null) {
- _first = _first.replaceWith(element);
- element = _first;
- } else {
- element = _parent.addChild(element);
- }
- }
- else
- {
- if(_parent!=null)
- {
- element = _parent.checkChild(element);
- }
- _current.setNext(element);
- }
- }
-
- _current = element;
- }
-
- @Override
- public void putList()
- {
- putElement(new ListElement(_parent, _current));
- }
-
- @Override
- public void putMap()
- {
- putElement(new MapElement(_parent, _current));
- }
-
- @Override
- public void putArray(boolean described, DataType type)
- {
- putElement(new ArrayElement(_parent, _current, described, type));
-
- }
-
- @Override
- public void putDescribed()
- {
- putElement(new DescribedTypeElement(_parent, _current));
- }
-
- @Override
- public void putNull()
- {
- putElement(new NullElement(_parent, _current));
-
- }
-
- @Override
- public void putBoolean(boolean b)
- {
- putElement(new BooleanElement(_parent, _current, b));
- }
-
- @Override
- public void putUnsignedByte(UnsignedByte ub)
- {
- putElement(new UnsignedByteElement(_parent, _current, ub));
-
- }
-
- @Override
- public void putByte(byte b)
- {
- putElement(new ByteElement(_parent, _current, b));
- }
-
- @Override
- public void putUnsignedShort(UnsignedShort us)
- {
- putElement(new UnsignedShortElement(_parent, _current, us));
-
- }
-
- @Override
- public void putShort(short s)
- {
- putElement(new ShortElement(_parent, _current, s));
- }
-
- @Override
- public void putUnsignedInteger(UnsignedInteger ui)
- {
- putElement(new UnsignedIntegerElement(_parent, _current, ui));
- }
-
- @Override
- public void putInt(int i)
- {
- putElement(new IntegerElement(_parent, _current, i));
- }
-
- @Override
- public void putChar(int c)
- {
- putElement(new CharElement(_parent, _current, c));
- }
-
- @Override
- public void putUnsignedLong(UnsignedLong ul)
- {
- putElement(new UnsignedLongElement(_parent, _current, ul));
- }
-
- @Override
- public void putLong(long l)
- {
- putElement(new LongElement(_parent, _current, l));
- }
-
- @Override
- public void putTimestamp(Date t)
- {
- putElement(new TimestampElement(_parent,_current,t));
- }
-
- @Override
- public void putFloat(float f)
- {
- putElement(new FloatElement(_parent,_current,f));
- }
-
- @Override
- public void putDouble(double d)
- {
- putElement(new DoubleElement(_parent,_current,d));
- }
-
- @Override
- public void putDecimal32(Decimal32 d)
- {
- putElement(new Decimal32Element(_parent,_current,d));
- }
-
- @Override
- public void putDecimal64(Decimal64 d)
- {
- putElement(new Decimal64Element(_parent,_current,d));
- }
-
- @Override
- public void putDecimal128(Decimal128 d)
- {
- putElement(new Decimal128Element(_parent,_current,d));
- }
-
- @Override
- public void putUUID(UUID u)
- {
- putElement(new UUIDElement(_parent,_current,u));
- }
-
- @Override
- public void putBinary(Binary bytes)
- {
- putElement(new BinaryElement(_parent, _current, bytes));
- }
-
- @Override
- public void putBinary(byte[] bytes)
- {
- putBinary(new Binary(bytes));
- }
-
- @Override
- public void putString(String string)
- {
- putElement(new StringElement(_parent,_current,string));
- }
-
- @Override
- public void putSymbol(Symbol symbol)
- {
- putElement(new SymbolElement(_parent,_current,symbol));
- }
-
- @Override
- public void putObject(Object o)
- {
- if(o == null)
- {
- putNull();
- }
- else if(o instanceof Boolean)
- {
- putBoolean((Boolean) o);
- }
- else if(o instanceof UnsignedByte)
- {
- putUnsignedByte((UnsignedByte)o);
- }
- else if(o instanceof Byte)
- {
- putByte((Byte)o);
- }
- else if(o instanceof UnsignedShort)
- {
- putUnsignedShort((UnsignedShort)o);
- }
- else if(o instanceof Short)
- {
- putShort((Short)o);
- }
- else if(o instanceof UnsignedInteger)
- {
- putUnsignedInteger((UnsignedInteger)o);
- }
- else if(o instanceof Integer)
- {
- putInt((Integer)o);
- }
- else if(o instanceof Character)
- {
- putChar((Character)o);
- }
- else if(o instanceof UnsignedLong)
- {
- putUnsignedLong((UnsignedLong)o);
- }
- else if(o instanceof Long)
- {
- putLong((Long)o);
- }
- else if(o instanceof Date)
- {
- putTimestamp((Date)o);
- }
- else if(o instanceof Float)
- {
- putFloat((Float)o);
- }
- else if(o instanceof Double)
- {
- putDouble((Double)o);
- }
- else if(o instanceof Decimal32)
- {
- putDecimal32((Decimal32)o);
- }
- else if(o instanceof Decimal64)
- {
- putDecimal64((Decimal64)o);
- }
- else if(o instanceof Decimal128)
- {
- putDecimal128((Decimal128)o);
- }
- else if(o instanceof UUID)
- {
- putUUID((UUID)o);
- }
- else if(o instanceof Binary)
- {
- putBinary((Binary)o);
- }
- else if(o instanceof String)
- {
- putString((String)o);
- }
- else if(o instanceof Symbol)
- {
- putSymbol((Symbol)o);
- }
- else if(o instanceof DescribedType)
- {
- putDescribedType((DescribedType)o);
- }
- else if(o instanceof Symbol[])
- {
- putArray(false, Data.DataType.SYMBOL);
- enter();
- for(Symbol s : (Symbol[]) o)
- {
- putSymbol(s);
- }
- exit();
- }
- else if(o instanceof Object[])
- {
- putJavaArray((Object[]) o);
- }
- else if(o instanceof List)
- {
- putJavaList((List)o);
- }
- else if(o instanceof Map)
- {
- putJavaMap((Map)o);
- }
- else
- {
- throw new IllegalArgumentException("Unknown type " + o.getClass().getSimpleName());
- }
- }
-
- @Override
- public void putJavaMap(Map<Object, Object> map)
- {
- putMap();
- enter();
- for(Map.Entry<Object, Object> entry : map.entrySet())
- {
- putObject(entry.getKey());
- putObject(entry.getValue());
- }
- exit();
-
- }
-
- @Override
- public void putJavaList(List<Object> list)
- {
- putList();
- enter();
- for(Object o : list)
- {
- putObject(o);
- }
- exit();
- }
-
- @Override
- public void putJavaArray(Object[] array)
- {
- // TODO
- throw new ProtonUnsupportedOperationException();
- }
-
- @Override
- public void putDescribedType(DescribedType dt)
- {
- putElement(new DescribedTypeElement(_parent,_current));
- enter();
- putObject(dt.getDescriptor());
- putObject(dt.getDescribed());
- exit();
- }
-
- @Override
- public long getList()
- {
- if(_current instanceof ListElement)
- {
- return ((ListElement)_current).count();
- }
- throw new IllegalStateException("Current value not list");
- }
-
- @Override
- public long getMap()
- {
- if(_current instanceof MapElement)
- {
- return ((MapElement)_current).count();
- }
- throw new IllegalStateException("Current value not map");
- }
-
- @Override
- public long getArray()
- {
- if(_current instanceof ArrayElement)
- {
- return ((ArrayElement)_current).count();
- }
- throw new IllegalStateException("Current value not array");
- }
-
- @Override
- public boolean isArrayDescribed()
- {
- if(_current instanceof ArrayElement)
- {
- return ((ArrayElement)_current).isDescribed();
- }
- throw new IllegalStateException("Current value not array");
- }
-
- @Override
- public DataType getArrayType()
- {
- if(_current instanceof ArrayElement)
- {
- return ((ArrayElement)_current).getArrayDataType();
- }
- throw new IllegalStateException("Current value not array");
- }
-
- @Override
- public boolean isDescribed()
- {
- return _current != null && _current.getDataType() == DataType.DESCRIBED;
- }
-
- @Override
- public boolean isNull()
- {
- return _current != null && _current.getDataType() == DataType.NULL;
- }
-
- @Override
- public boolean getBoolean()
- {
- if(_current instanceof BooleanElement)
- {
- return ((BooleanElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not boolean");
- }
-
- @Override
- public UnsignedByte getUnsignedByte()
- {
-
- if(_current instanceof UnsignedByteElement)
- {
- return ((UnsignedByteElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not unsigned byte");
- }
-
- @Override
- public byte getByte()
- {
- if(_current instanceof ByteElement)
- {
- return ((ByteElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not byte");
- }
-
- @Override
- public UnsignedShort getUnsignedShort()
- {
- if(_current instanceof UnsignedShortElement)
- {
- return ((UnsignedShortElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not unsigned short");
- }
-
- @Override
- public short getShort()
- {
- if(_current instanceof ShortElement)
- {
- return ((ShortElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not short");
- }
-
- @Override
- public UnsignedInteger getUnsignedInteger()
- {
- if(_current instanceof UnsignedIntegerElement)
- {
- return ((UnsignedIntegerElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not unsigned integer");
- }
-
- @Override
- public int getInt()
- {
- if(_current instanceof IntegerElement)
- {
- return ((IntegerElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not integer");
- }
-
- @Override
- public int getChar()
- {
- if(_current instanceof CharElement)
- {
- return ((CharElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not char");
- }
-
- @Override
- public UnsignedLong getUnsignedLong()
- {
- if(_current instanceof UnsignedLongElement)
- {
- return ((UnsignedLongElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not unsigned long");
- }
-
- @Override
- public long getLong()
- {
- if(_current instanceof LongElement)
- {
- return ((LongElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not long");
- }
-
- @Override
- public Date getTimestamp()
- {
- if(_current instanceof TimestampElement)
- {
- return ((TimestampElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not timestamp");
- }
-
- @Override
- public float getFloat()
- {
- if(_current instanceof FloatElement)
- {
- return ((FloatElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not float");
- }
-
- @Override
- public double getDouble()
- {
- if(_current instanceof DoubleElement)
- {
- return ((DoubleElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not double");
- }
-
- @Override
- public Decimal32 getDecimal32()
- {
- if(_current instanceof Decimal32Element)
- {
- return ((Decimal32Element)_current).getValue();
- }
- throw new IllegalStateException("Current value not decimal32");
- }
-
- @Override
- public Decimal64 getDecimal64()
- {
- if(_current instanceof Decimal64Element)
- {
- return ((Decimal64Element)_current).getValue();
- }
- throw new IllegalStateException("Current value not decimal32");
- }
-
- @Override
- public Decimal128 getDecimal128()
- {
- if(_current instanceof Decimal128Element)
- {
- return ((Decimal128Element)_current).getValue();
- }
- throw new IllegalStateException("Current value not decimal32");
- }
-
- @Override
- public UUID getUUID()
- {
- if(_current instanceof UUIDElement)
- {
- return ((UUIDElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not uuid");
- }
-
- @Override
- public Binary getBinary()
- {
- if(_current instanceof BinaryElement)
- {
- return ((BinaryElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not binary");
- }
-
- @Override
- public String getString()
- {
- if (_current instanceof StringElement)
- {
- return ((StringElement) _current).getValue();
- }
- throw new IllegalStateException("Current value not string");
- }
-
- @Override
- public Symbol getSymbol()
- {
- if(_current instanceof SymbolElement)
- {
- return ((SymbolElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not symbol");
- }
-
- @Override
- public Object getObject()
- {
- return _current == null ? null : _current.getValue();
- }
-
- @Override
- public Map<Object, Object> getJavaMap()
- {
- if(_current instanceof MapElement)
- {
- return ((MapElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not map");
- }
-
- @Override
- public List<Object> getJavaList()
- {
- if(_current instanceof ListElement)
- {
- return ((ListElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not list");
- }
-
- @Override
- public Object[] getJavaArray()
- {
- if(_current instanceof ArrayElement)
- {
- return ((ArrayElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not array");
- }
-
- @Override
- public DescribedType getDescribedType()
- {
- if(_current instanceof DescribedTypeElement)
- {
- return ((DescribedTypeElement)_current).getValue();
- }
- throw new IllegalStateException("Current value not described type");
- }
-
- @Override
- public void copy(Data src)
- {
- // TODO
-
- throw new ProtonUnsupportedOperationException();
- }
-
- @Override
- public void append(Data src)
- {
- // TODO
-
- throw new ProtonUnsupportedOperationException();
- }
-
- @Override
- public void appendn(Data src, int limit)
- {
- // TODO
-
- throw new ProtonUnsupportedOperationException();
- }
-
- @Override
- public void narrow()
- {
- // TODO
-
- throw new ProtonUnsupportedOperationException();
- }
-
- @Override
- public void widen()
- {
- // TODO
-
- throw new ProtonUnsupportedOperationException();
- }
-
-
- @Override
- public String format()
- {
- StringBuilder sb = new StringBuilder();
- Element el = _first;
- boolean first = true;
- while (el != null) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- el.render(sb);
- el = el.next();
- }
-
- return sb.toString();
- }
-
- private void render(StringBuilder sb, Element el)
- {
- if (el == null) return;
- sb.append(" ").append(el).append("\n");
- if (el.canEnter()) {
- render(sb, el.child());
- }
- render(sb, el.next());
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- render(sb, _first);
- return String.format("Data[current=%h, parent=%h]{%n%s}",
- System.identityHashCode(_current),
- System.identityHashCode(_parent),
- sb);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal128Element.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal128Element.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal128Element.java
deleted file mode 100644
index 433c10b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal128Element.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.Decimal128;
-import org.apache.qpid.proton.codec.Data;
-
-class Decimal128Element extends AtomicElement<Decimal128>
-{
-
- private final Decimal128 _value;
-
- Decimal128Element(Element parent, Element prev, Decimal128 d)
- {
- super(parent, prev);
- _value = d;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 16 : 17;
- }
-
- @Override
- public Decimal128 getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.DECIMAL128;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(b.remaining()>=size)
- {
- if(size == 17)
- {
- b.put((byte)0x94);
- }
- b.putLong(_value.getMostSignificantBits());
- b.putLong(_value.getLeastSignificantBits());
- return size;
- }
- else
- {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal32Element.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal32Element.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal32Element.java
deleted file mode 100644
index 4859a78..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal32Element.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.Decimal32;
-import org.apache.qpid.proton.codec.Data;
-
-class Decimal32Element extends AtomicElement<Decimal32>
-{
-
- private final Decimal32 _value;
-
- Decimal32Element(Element parent, Element prev, Decimal32 d)
- {
- super(parent, prev);
- _value = d;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 4 : 5;
- }
-
- @Override
- public Decimal32 getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.DECIMAL32;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(b.remaining()>=size)
- {
- if(size == 5)
- {
- b.put((byte)0x74);
- }
- b.putInt(_value.getBits());
- return size;
- }
- else
- {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal64Element.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal64Element.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal64Element.java
deleted file mode 100644
index cd8ce45..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Decimal64Element.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.Decimal64;
-import org.apache.qpid.proton.codec.Data;
-
-class Decimal64Element extends AtomicElement<Decimal64>
-{
-
- private final Decimal64 _value;
-
- Decimal64Element(Element parent, Element prev, Decimal64 d)
- {
- super(parent, prev);
- _value = d;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 8 : 9;
- }
-
- @Override
- public Decimal64 getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.DECIMAL64;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(b.remaining()>=size)
- {
- if(size == 9)
- {
- b.put((byte)0x84);
- }
- b.putLong(_value.getBits());
- return size;
- }
- else
- {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeElement.java
deleted file mode 100644
index 432cd21..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeElement.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.util.AbstractSequentialList;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.codec.Data;
-
-class DescribedTypeElement extends AbstractElement<DescribedType>
-{
- private Element _first;
-
- DescribedTypeElement(Element parent, Element prev)
- {
- super(parent, prev);
- }
-
-
-
-
- @Override
- public int size()
- {
- int count = 0;
- int size = 0;
- Element elt = _first;
- while(elt != null)
- {
- count++;
- size += elt.size();
- elt = elt.next();
- }
-
- if(isElementOfArray())
- {
- throw new IllegalArgumentException("Cannot add described type members to an array");
- }
- else if(count > 2)
- {
- throw new IllegalArgumentException("Too many elements in described type");
- }
- else if(count == 0)
- {
- size = 3;
- }
- else if(count == 1)
- {
- size += 2;
- }
- else
- {
- size+=1;
- }
-
- return size;
- }
-
- @Override
- public DescribedType getValue()
- {
- final Object descriptor = _first == null ? null : _first.getValue();
- Element second = _first == null ? null : _first.next();
- final Object described = second == null ? null : second.getValue();
- return new DescribedTypeImpl(descriptor,described);
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.DESCRIBED;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int encodedSize = size();
-
- if(encodedSize > b.remaining())
- {
- return 0;
- }
- else
- {
- b.put((byte) 0);
- if(_first == null)
- {
- b.put((byte)0x40);
- b.put((byte)0x40);
- }
- else
- {
- _first.encode(b);
- if(_first.next() == null)
- {
- b.put((byte)0x40);
- }
- else
- {
- _first.next().encode(b);
- }
- }
- }
- return encodedSize;
- }
-
- @Override
- public boolean canEnter()
- {
- return true;
- }
-
- @Override
- public Element child()
- {
- return _first;
- }
-
- @Override
- public void setChild(Element elt)
- {
- _first = elt;
- }
-
- @Override
- public Element checkChild(Element element)
- {
- if(element.prev() != _first)
- {
- throw new IllegalArgumentException("Described Type may only have two elements");
- }
- return element;
-
- }
-
- @Override
- public Element addChild(Element element)
- {
- _first = element;
- return element;
- }
-
- @Override
- String startSymbol() {
- return "(";
- }
-
- @Override
- String stopSymbol() {
- return ")";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeImpl.java
deleted file mode 100644
index a16595a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import org.apache.qpid.proton.amqp.DescribedType;
-
-class DescribedTypeImpl implements DescribedType
-{
- private final Object _descriptor;
- private final Object _described;
-
- public DescribedTypeImpl(final Object descriptor, final Object described)
- {
- _descriptor = descriptor;
- _described = described;
- }
-
- @Override
- public Object getDescriptor()
- {
- return _descriptor;
- }
-
- @Override
- public Object getDescribed()
- {
- return _described;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || ! (o instanceof DescribedType))
- {
- return false;
- }
-
- DescribedType that = (DescribedType) o;
-
- if (_described != null ? !_described.equals(that.getDescribed()) : that.getDescribed() != null)
- {
- return false;
- }
- if (_descriptor != null ? !_descriptor.equals(that.getDescriptor()) : that.getDescriptor() != null)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = _descriptor != null ? _descriptor.hashCode() : 0;
- result = 31 * result + (_described != null ? _described.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "{" + _descriptor +
- ": " + _described +
- '}';
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DoubleElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DoubleElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DoubleElement.java
deleted file mode 100644
index b4c56bc..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DoubleElement.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class DoubleElement extends AtomicElement<Double>
-{
-
- private final double _value;
-
- DoubleElement(Element parent, Element prev, double d)
- {
- super(parent, prev);
- _value = d;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 8 : 9;
- }
-
- @Override
- public Double getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.DOUBLE;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(b.remaining()>=size)
- {
- if(size == 9)
- {
- b.put((byte)0x82);
- }
- b.putDouble(_value);
- return size;
- }
- else
- {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Element.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Element.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Element.java
deleted file mode 100644
index 492008d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/Element.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-interface Element<T>
-{
- int size();
- T getValue();
- Data.DataType getDataType();
- int encode(ByteBuffer b);
- Element next();
- Element prev();
- Element child();
- Element parent();
-
- void setNext(Element elt);
- void setPrev(Element elt);
- void setParent(Element elt);
- void setChild(Element elt);
-
- Element replaceWith(Element elt);
-
- Element addChild(Element element);
- Element checkChild(Element element);
-
- boolean canEnter();
-
- void render(StringBuilder sb);
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/FloatElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/FloatElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/FloatElement.java
deleted file mode 100644
index d8c13c2..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/FloatElement.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class FloatElement extends AtomicElement<Float>
-{
-
- private final float _value;
-
- FloatElement(Element parent, Element prev, float f)
- {
- super(parent, prev);
- _value = f;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 4 : 5;
- }
-
- @Override
- public Float getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.FLOAT;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(b.remaining()>=size)
- {
- if(size == 5)
- {
- b.put((byte)0x72);
- }
- b.putFloat(_value);
- return size;
- }
- else
- {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/IntegerElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/IntegerElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/IntegerElement.java
deleted file mode 100644
index 8e4f435..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/IntegerElement.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class IntegerElement extends AtomicElement<Integer>
-{
-
- private final int _value;
-
- IntegerElement(Element parent, Element prev, int i)
- {
- super(parent, prev);
- _value = i;
- }
-
- @Override
- public int size()
- {
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(-128 <= _value && _value <= 127)
- {
- return 1;
- }
- else
- {
- parent.setConstructorType(ArrayElement.LARGE);
- return 4;
- }
- }
- else
- {
- return 4;
- }
- }
- else
- {
- return (-128 <= _value && _value <= 127) ? 2 : 5;
- }
-
- }
-
- @Override
- public Integer getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.INT;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(size <= b.remaining())
- {
- switch(size)
- {
- case 2:
- b.put((byte)0x54);
- case 1:
- b.put((byte)_value);
- break;
-
- case 5:
- b.put((byte)0x71);
- case 4:
- b.putInt(_value);
-
- }
-
- return size;
- }
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ListElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ListElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ListElement.java
deleted file mode 100644
index 6b2dde1..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ListElement.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import org.apache.qpid.proton.codec.Data;
-
-class ListElement extends AbstractElement<List<Object>>
-{
- private Element _first;
-
- ListElement(Element parent, Element prev)
- {
- super(parent, prev);
- }
-
- public int count()
- {
- int count = 0;
- Element elt = _first;
- while(elt != null)
- {
- count++;
- elt = elt.next();
- }
- return count;
- }
-
-
- @Override
- public int size()
- {
- int count = 0;
- int size = 0;
- Element elt = _first;
- while(elt != null)
- {
- count++;
- size += elt.size();
- elt = elt.next();
- }
- if(isElementOfArray())
- {
- ArrayElement parent = (ArrayElement) parent();
- if(parent.constructorType() == ArrayElement.TINY)
- {
- if(count != 0)
- {
- parent.setConstructorType(ArrayElement.ConstructorType.SMALL);
- size += 2;
- }
- }
- else if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(count > 255 || size > 254)
- {
- parent.setConstructorType(ArrayElement.ConstructorType.LARGE);
- size += 8;
- }
- else
- {
- size += 2;
- }
- }
- size += 8;
-
- }
- else
- {
- if(count == 0)
- {
- size = 1;
- }
- else if(count <= 255 && size <= 254)
- {
- size += 3;
- }
- else
- {
- size+=9;
- }
- }
-
- return size;
- }
-
- @Override
- public List<Object> getValue()
- {
- List<Object> list = new ArrayList<Object>();
- Element elt = _first;
- while(elt != null)
- {
- list.add(elt.getValue());
- elt = elt.next();
- }
-
- return Collections.unmodifiableList(list);
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.LIST;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int encodedSize = size();
-
- int count = 0;
- int size = 0;
- Element elt = _first;
- while(elt != null)
- {
- count++;
- size += elt.size();
- elt = elt.next();
- }
-
- if(encodedSize > b.remaining())
- {
- return 0;
- }
- else
- {
- if(isElementOfArray())
- {
- switch(((ArrayElement)parent()).constructorType())
- {
- case TINY:
- break;
- case SMALL:
- b.put((byte)(size+1));
- b.put((byte)count);
- break;
- case LARGE:
- b.putInt((size+4));
- b.putInt(count);
- }
- }
- else
- {
- if(count == 0)
- {
- b.put((byte)0x45);
- }
- else if(size <= 254 && count <=255)
- {
- b.put((byte)0xc0);
- b.put((byte)(size+1));
- b.put((byte)count);
- }
- else
- {
- b.put((byte)0xd0);
- b.putInt((size+4));
- b.putInt(count);
- }
-
- }
-
- elt = _first;
- while(elt != null)
- {
- elt.encode(b);
- elt = elt.next();
- }
-
- return encodedSize;
- }
- }
-
- @Override
- public boolean canEnter()
- {
- return true;
- }
-
- @Override
- public Element child()
- {
- return _first;
- }
-
- @Override
- public void setChild(Element elt)
- {
- _first = elt;
- }
-
- @Override
- public Element checkChild(Element element)
- {
- return element;
- }
-
- @Override
- public Element addChild(Element element)
- {
- _first = element;
- return element;
- }
-
- @Override
- String startSymbol() {
- return "[";
- }
-
- @Override
- String stopSymbol() {
- return "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/LongElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/LongElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/LongElement.java
deleted file mode 100644
index e2e832d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/LongElement.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class LongElement extends AtomicElement<Long>
-{
-
- private final long _value;
-
- LongElement(Element parent, Element prev, long l)
- {
- super(parent, prev);
- _value = l;
- }
-
- @Override
- public int size()
- {
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(-128l <= _value && _value <= 127l)
- {
- return 1;
- }
- else
- {
- parent.setConstructorType(ArrayElement.LARGE);
- }
- }
-
- return 8;
-
- }
- else
- {
- return (-128l <= _value && _value <= 127l) ? 2 : 9;
- }
-
- }
-
- @Override
- public Long getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.LONG;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(size > b.remaining())
- {
- return 0;
- }
- switch(size)
- {
- case 2:
- b.put((byte)0x55);
- case 1:
- b.put((byte)_value);
- break;
- case 9:
- b.put((byte)0x81);
- case 8:
- b.putLong(_value);
-
- }
- return size;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/MapElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/MapElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/MapElement.java
deleted file mode 100644
index 710e9f0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/MapElement.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import org.apache.qpid.proton.codec.Data;
-
-class MapElement extends AbstractElement<Map<Object,Object>>
-{
- private Element _first;
-
- MapElement(Element parent, Element prev)
- {
- super(parent, prev);
- }
-
-
- public int count()
- {
- int count = 0;
- Element elt = _first;
- while(elt != null)
- {
- count++;
- elt = elt.next();
- }
- return count;
- }
-
- @Override
- public int size()
- {
- int count = 0;
- int size = 0;
- Element elt = _first;
- while(elt != null)
- {
- count++;
- size += elt.size();
- elt = elt.next();
- }
- if(isElementOfArray())
- {
- ArrayElement parent = (ArrayElement) parent();
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(count > 255 || size > 254)
- {
- parent.setConstructorType(ArrayElement.ConstructorType.LARGE);
- size += 8;
- }
- else
- {
- size += 2;
- }
- }
- size += 8;
-
- }
- else
- {
- if(count <= 255 && size <= 254)
- {
- size += 3;
- }
- else
- {
- size+=9;
- }
- }
-
- return size;
- }
-
- @Override
- public Map<Object,Object> getValue()
- {
- LinkedHashMap<Object,Object> map = new LinkedHashMap<Object,Object>();
- Element elt = _first;
- while(elt != null)
- {
- Object key = elt.getValue();
- Object value;
- elt = elt.next();
- if(elt != null)
- {
- value = elt.getValue();
- elt = elt.next();
- }
- else
- {
- value = null;
- }
- map.put(key,value);
- }
-
- return Collections.unmodifiableMap(map);
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.MAP;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int encodedSize = size();
-
- int count = 0;
- int size = 0;
- Element elt = _first;
- while(elt != null)
- {
- count++;
- size += elt.size();
- elt = elt.next();
- }
-
- if(encodedSize > b.remaining())
- {
- return 0;
- }
- else
- {
- if(isElementOfArray())
- {
- switch(((ArrayElement)parent()).constructorType())
- {
- case SMALL:
- b.put((byte)(size+1));
- b.put((byte)count);
- break;
- case LARGE:
- b.putInt((size+4));
- b.putInt(count);
- }
- }
- else
- {
- if(size <= 254 && count <=255)
- {
- b.put((byte)0xc1);
- b.put((byte)(size+1));
- b.put((byte)count);
- }
- else
- {
- b.put((byte)0xd1);
- b.putInt((size+4));
- b.putInt(count);
- }
-
- }
-
- elt = _first;
- while(elt != null)
- {
- elt.encode(b);
- elt = elt.next();
- }
-
- return encodedSize;
- }
- }
-
- @Override
- public boolean canEnter()
- {
- return true;
- }
-
- @Override
- public Element child()
- {
- return _first;
- }
-
- @Override
- public void setChild(Element elt)
- {
- _first = elt;
- }
-
- @Override
- public Element checkChild(Element element)
- {
- return element;
- }
-
- @Override
- public Element addChild(Element element)
- {
- _first = element;
- return element;
- }
-
- @Override
- String startSymbol() {
- return "{";
- }
-
- @Override
- String stopSymbol() {
- return "}";
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[23/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/EncodeException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/EncodeException.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/EncodeException.java
deleted file mode 100644
index 5aa28bc..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/EncodeException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec;
-
-public class EncodeException extends RuntimeException
-{
- public EncodeException()
- {
- }
-
- public EncodeException(String message)
- {
- super(message);
- }
-
- public EncodeException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public EncodeException(Throwable cause)
- {
- super(cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/Encoder.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/Encoder.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/Encoder.java
deleted file mode 100644
index a0ab5b8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/Encoder.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Decimal128;
-import org.apache.qpid.proton.amqp.Decimal32;
-import org.apache.qpid.proton.amqp.Decimal64;
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-public interface Encoder
-{
- void writeNull();
-
- void writeBoolean(boolean bool);
-
- void writeBoolean(Boolean bool);
-
- void writeUnsignedByte(UnsignedByte ubyte);
-
- void writeUnsignedShort(UnsignedShort ushort);
-
- void writeUnsignedInteger(UnsignedInteger ushort);
-
- void writeUnsignedLong(UnsignedLong ulong);
-
- void writeByte(byte b);
-
- void writeByte(Byte b);
-
- void writeShort(short s);
-
- void writeShort(Short s);
-
- void writeInteger(int i);
-
- void writeInteger(Integer i);
-
- void writeLong(long l);
-
- void writeLong(Long l);
-
- void writeFloat(float f);
-
- void writeFloat(Float f);
-
- void writeDouble(double d);
-
- void writeDouble(Double d);
-
- void writeDecimal32(Decimal32 d);
-
- void writeDecimal64(Decimal64 d);
-
- void writeDecimal128(Decimal128 d);
-
- void writeCharacter(char c);
-
- void writeCharacter(Character c);
-
- void writeTimestamp(long d);
- void writeTimestamp(Date d);
-
- void writeUUID(UUID uuid);
-
- void writeBinary(Binary b);
-
- void writeString(String s);
-
- void writeSymbol(Symbol s);
-
- void writeList(List l);
-
- void writeMap(Map m);
-
- void writeDescribedType(DescribedType d);
-
- void writeArray(boolean[] a);
- void writeArray(byte[] a);
- void writeArray(short[] a);
- void writeArray(int[] a);
- void writeArray(long[] a);
- void writeArray(float[] a);
- void writeArray(double[] a);
- void writeArray(char[] a);
- void writeArray(Object[] a);
-
- void writeObject(Object o);
-
- <V> void register(AMQPType<V> type);
-
- AMQPType getType(Object element);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java
deleted file mode 100644
index 97e1005..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java
+++ /dev/null
@@ -1,817 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Decimal128;
-import org.apache.qpid.proton.amqp.Decimal32;
-import org.apache.qpid.proton.amqp.Decimal64;
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-public final class EncoderImpl implements ByteBufferEncoder
-{
- private static final byte DESCRIBED_TYPE_OP = (byte)0;
-
-
- private WritableBuffer _buffer;
-
- private final Map<Class, AMQPType> _typeRegistry = new HashMap<Class, AMQPType>();
- private Map<Object, AMQPType> _describedDescriptorRegistry = new HashMap<Object, AMQPType>();
- private Map<Class, AMQPType> _describedTypesClassRegistry = new HashMap<Class, AMQPType>();
-
- private final NullType _nullType;
- private final BooleanType _booleanType;
- private final ByteType _byteType;
- private final UnsignedByteType _unsignedByteType;
- private final ShortType _shortType;
- private final UnsignedShortType _unsignedShortType;
- private final IntegerType _integerType;
- private final UnsignedIntegerType _unsignedIntegerType;
- private final LongType _longType;
- private final UnsignedLongType _unsignedLongType;
- private final BigIntegerType _bigIntegerType;
-
- private final CharacterType _characterType;
- private final FloatType _floatType;
- private final DoubleType _doubleType;
- private final TimestampType _timestampType;
- private final UUIDType _uuidType;
-
- private final Decimal32Type _decimal32Type;
- private final Decimal64Type _decimal64Type;
- private final Decimal128Type _decimal128Type;
-
- private final BinaryType _binaryType;
- private final SymbolType _symbolType;
- private final StringType _stringType;
-
- private final ListType _listType;
- private final MapType _mapType;
-
- private final ArrayType _arrayType;
-
- EncoderImpl(ByteBuffer buffer, DecoderImpl decoder)
- {
- this(decoder);
- setByteBuffer(buffer);
- }
-
- public EncoderImpl(DecoderImpl decoder)
- {
-
- _nullType = new NullType(this, decoder);
- _booleanType = new BooleanType(this, decoder);
- _byteType = new ByteType(this, decoder);
- _unsignedByteType = new UnsignedByteType(this, decoder);
- _shortType = new ShortType(this, decoder);
- _unsignedShortType = new UnsignedShortType(this, decoder);
- _integerType = new IntegerType(this, decoder);
- _unsignedIntegerType = new UnsignedIntegerType(this, decoder);
- _longType = new LongType(this, decoder);
- _unsignedLongType = new UnsignedLongType(this, decoder);
- _bigIntegerType = new BigIntegerType(this, decoder);
-
- _characterType = new CharacterType(this, decoder);
- _floatType = new FloatType(this, decoder);
- _doubleType = new DoubleType(this, decoder);
- _timestampType = new TimestampType(this, decoder);
- _uuidType = new UUIDType(this, decoder);
-
- _decimal32Type = new Decimal32Type(this, decoder);
- _decimal64Type = new Decimal64Type(this, decoder);
- _decimal128Type = new Decimal128Type(this, decoder);
-
-
- _binaryType = new BinaryType(this, decoder);
- _symbolType = new SymbolType(this, decoder);
- _stringType = new StringType(this, decoder);
-
- _listType = new ListType(this, decoder);
- _mapType = new MapType(this, decoder);
-
- _arrayType = new ArrayType(this,
- decoder,
- _booleanType,
- _byteType,
- _shortType,
- _integerType,
- _longType,
- _floatType,
- _doubleType,
- _characterType);
-
-
- }
-
- public void setByteBuffer(final ByteBuffer buf)
- {
- _buffer = new WritableBuffer.ByteBufferWrapper(buf);
- }
-
- public void setByteBuffer(final WritableBuffer buf)
- {
- _buffer = buf;
- }
-
-
- @Override
- public AMQPType getType(final Object element)
- {
- if(element instanceof DescribedType)
- {
- AMQPType amqpType;
-
- Object descriptor = ((DescribedType)element).getDescriptor();
- amqpType = _describedDescriptorRegistry.get(descriptor);
- if(amqpType == null)
- {
- amqpType = new DynamicDescribedType(this, descriptor);
- _describedDescriptorRegistry.put(descriptor, amqpType);
- }
- return amqpType;
-
- }
- else
- {
- return getTypeFromClass(element == null ? Void.class : element.getClass());
- }
- }
-
- public AMQPType getTypeFromClass(final Class clazz)
- {
- AMQPType amqpType = _typeRegistry.get(clazz);
- if(amqpType == null)
- {
-
- if(clazz.isArray())
- {
- amqpType = _arrayType;
- }
- else
- {
- if(List.class.isAssignableFrom(clazz))
- {
- amqpType = _listType;
- }
- else if(Map.class.isAssignableFrom(clazz))
- {
- amqpType = _mapType;
- }
- else if(DescribedType.class.isAssignableFrom(clazz))
- {
- amqpType = _describedTypesClassRegistry.get(clazz);
- }
- }
- _typeRegistry.put(clazz, amqpType);
- }
- return amqpType;
- }
-
- @Override
- public <V> void register(AMQPType<V> type)
- {
- register(type.getTypeClass(), type);
- }
-
- <T> void register(Class<T> clazz, AMQPType<T> type)
- {
- _typeRegistry.put(clazz, type);
- }
-
- public void registerDescribedType(Class clazz, Object descriptor)
- {
- AMQPType type = _describedDescriptorRegistry.get(descriptor);
- if(type == null)
- {
- type = new DynamicDescribedType(this, descriptor);
- _describedDescriptorRegistry.put(descriptor, type);
- }
- _describedTypesClassRegistry.put(clazz, type);
- }
-
- public void writeNull()
- {
- _nullType.write();
- }
-
- public void writeBoolean(final boolean bool)
- {
- _booleanType.writeValue(bool);
- }
-
- public void writeBoolean(final Boolean bool)
- {
- if(bool == null)
- {
- writeNull();
- }
- else
- {
- _booleanType.write(bool);
- }
- }
-
- public void writeUnsignedByte(final UnsignedByte ubyte)
- {
- if(ubyte == null)
- {
- writeNull();
- }
- else
- {
- _unsignedByteType.write(ubyte);
- }
- }
-
- public void writeUnsignedShort(final UnsignedShort ushort)
- {
- if(ushort == null)
- {
- writeNull();
- }
- else
- {
- _unsignedShortType.write(ushort);
- }
- }
-
- public void writeUnsignedInteger(final UnsignedInteger uint)
- {
- if(uint == null)
- {
- writeNull();
- }
- else
- {
- _unsignedIntegerType.write(uint);
- }
- }
-
- public void writeUnsignedLong(final UnsignedLong ulong)
- {
- if(ulong == null)
- {
- writeNull();
- }
- else
- {
- _unsignedLongType.write(ulong);
- }
- }
-
- public void writeByte(final byte b)
- {
- _byteType.write(b);
- }
-
- public void writeByte(final Byte b)
- {
- if(b == null)
- {
- writeNull();
- }
- else
- {
- writeByte(b.byteValue());
- }
- }
-
- public void writeShort(final short s)
- {
- _shortType.write(s);
- }
-
- public void writeShort(final Short s)
- {
- if(s == null)
- {
- writeNull();
- }
- else
- {
- writeShort(s.shortValue());
- }
- }
-
- public void writeInteger(final int i)
- {
- _integerType.write(i);
- }
-
- public void writeInteger(final Integer i)
- {
- if(i == null)
- {
- writeNull();
- }
- else
- {
- writeInteger(i.intValue());
- }
- }
-
- public void writeLong(final long l)
- {
- _longType.write(l);
- }
-
- public void writeLong(final Long l)
- {
-
- if(l == null)
- {
- writeNull();
- }
- else
- {
- writeLong(l.longValue());
- }
- }
-
- public void writeFloat(final float f)
- {
- _floatType.write(f);
- }
-
- public void writeFloat(final Float f)
- {
- if(f == null)
- {
- writeNull();
- }
- else
- {
- writeFloat(f.floatValue());
- }
- }
-
- public void writeDouble(final double d)
- {
- _doubleType.write(d);
- }
-
- public void writeDouble(final Double d)
- {
- if(d == null)
- {
- writeNull();
- }
- else
- {
- writeDouble(d.doubleValue());
- }
- }
-
- public void writeDecimal32(final Decimal32 d)
- {
- if(d == null)
- {
- writeNull();
- }
- else
- {
- _decimal32Type.write(d);
- }
- }
-
- public void writeDecimal64(final Decimal64 d)
- {
- if(d == null)
- {
- writeNull();
- }
- else
- {
- _decimal64Type.write(d);
- }
- }
-
- public void writeDecimal128(final Decimal128 d)
- {
- if(d == null)
- {
- writeNull();
- }
- else
- {
- _decimal128Type.write(d);
- }
- }
-
- public void writeCharacter(final char c)
- {
- // TODO - java character may be half of a pair, should probably throw exception then
- _characterType.write(c);
- }
-
- public void writeCharacter(final Character c)
- {
- if(c == null)
- {
- writeNull();
- }
- else
- {
- writeCharacter(c.charValue());
- }
- }
-
- public void writeTimestamp(final long d)
- {
- _timestampType.write(d);
- }
-
- public void writeTimestamp(final Date d)
- {
- if(d == null)
- {
- writeNull();
- }
- else
- {
- writeTimestamp(d.getTime());
- }
- }
-
- public void writeUUID(final UUID uuid)
- {
- if(uuid == null)
- {
- writeNull();
- }
- else
- {
- _uuidType.write(uuid);
- }
-
- }
-
- public void writeBinary(final Binary b)
- {
- if(b == null)
- {
- writeNull();
- }
- else
- {
- _binaryType.write(b);
- }
- }
-
- public void writeString(final String s)
- {
- if(s == null)
- {
- writeNull();
- }
- else
- {
- _stringType.write(s);
- }
- }
-
- public void writeSymbol(final Symbol s)
- {
- if(s == null)
- {
- writeNull();
- }
- else
- {
- _symbolType.write(s);
- }
-
- }
-
- public void writeList(final List l)
- {
- if(l == null)
- {
- writeNull();
- }
- else
- {
- _listType.write(l);
- }
- }
-
- public void writeMap(final Map m)
- {
-
- if(m == null)
- {
- writeNull();
- }
- else
- {
- _mapType.write(m);
- }
- }
-
- public void writeDescribedType(final DescribedType d)
- {
- if(d == null)
- {
- writeNull();
- }
- else
- {
- _buffer.put(DESCRIBED_TYPE_OP);
- writeObject(d.getDescriptor());
- writeObject(d.getDescribed());
- }
- }
-
- public void writeArray(final boolean[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeArray(final byte[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeArray(final short[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeArray(final int[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeArray(final long[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeArray(final float[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeArray(final double[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeArray(final char[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeArray(final Object[] a)
- {
- if(a == null)
- {
- writeNull();
- }
- else
- {
- _arrayType.write(a);
- }
- }
-
- public void writeObject(final Object o)
- {
- AMQPType type = _typeRegistry.get(o == null ? Void.class : o.getClass());
-
- if(type == null)
- {
- if(o.getClass().isArray())
- {
- Class<?> componentType = o.getClass().getComponentType();
- if(componentType.isPrimitive())
- {
- if(componentType == Boolean.TYPE)
- {
- writeArray((boolean[])o);
- }
- else if(componentType == Byte.TYPE)
- {
- writeArray((byte[])o);
- }
- else if(componentType == Short.TYPE)
- {
- writeArray((short[])o);
- }
- else if(componentType == Integer.TYPE)
- {
- writeArray((int[])o);
- }
- else if(componentType == Long.TYPE)
- {
- writeArray((long[])o);
- }
- else if(componentType == Float.TYPE)
- {
- writeArray((float[])o);
- }
- else if(componentType == Double.TYPE)
- {
- writeArray((double[])o);
- }
- else if(componentType == Character.TYPE)
- {
- writeArray((char[])o);
- }
- else
- {
- throw new IllegalArgumentException("Cannot write arrays of type " + componentType.getName());
- }
- }
- else
- {
- writeArray((Object[]) o);
- }
- }
- else if(o instanceof List)
- {
- writeList((List)o);
- }
- else if(o instanceof Map)
- {
- writeMap((Map)o);
- }
- else if(o instanceof DescribedType)
- {
- writeDescribedType((DescribedType)o);
- }
- else
- {
- throw new IllegalArgumentException("Do not know how to write Objects of class " + o.getClass()
- .getName());
-
- }
- }
- else
- {
- type.write(o);
- }
- }
-
- public void writeRaw(final byte b)
- {
- _buffer.put(b);
- }
-
- void writeRaw(final short s)
- {
- _buffer.putShort(s);
- }
-
- void writeRaw(final int i)
- {
- _buffer.putInt(i);
- }
-
- void writeRaw(final long l)
- {
- _buffer.putLong(l);
- }
-
- void writeRaw(final float f)
- {
- _buffer.putFloat(f);
- }
-
- void writeRaw(final double d)
- {
- _buffer.putDouble(d);
- }
-
- void writeRaw(byte[] src, int offset, int length)
- {
- _buffer.put(src, offset, length);
- }
-
- void writeRaw(String string)
- {
- final int length = string.length();
- int c;
-
- for (int i = 0; i < length; i++)
- {
- c = string.charAt(i);
- if ((c & 0xFF80) == 0) /* U+0000..U+007F */
- {
- _buffer.put((byte) c);
- }
- else if ((c & 0xF800) == 0) /* U+0080..U+07FF */
- {
- _buffer.put((byte)(0xC0 | ((c >> 6) & 0x1F)));
- _buffer.put((byte)(0x80 | (c & 0x3F)));
- }
- else if ((c & 0xD800) != 0xD800 || (c > 0xDBFF)) /* U+0800..U+FFFF - excluding surrogate pairs */
- {
- _buffer.put((byte)(0xE0 | ((c >> 12) & 0x0F)));
- _buffer.put((byte)(0x80 | ((c >> 6) & 0x3F)));
- _buffer.put((byte)(0x80 | (c & 0x3F)));
- }
- else
- {
- int low;
-
- if((++i == length) || ((low = string.charAt(i)) & 0xDC00) != 0xDC00)
- {
- throw new IllegalArgumentException("String contains invalid Unicode code points");
- }
-
- c = 0x010000 + ((c & 0x03FF) << 10) + (low & 0x03FF);
-
- _buffer.put((byte)(0xF0 | ((c >> 18) & 0x07)));
- _buffer.put((byte)(0x80 | ((c >> 12) & 0x3F)));
- _buffer.put((byte)(0x80 | ((c >> 6) & 0x3F)));
- _buffer.put((byte)(0x80 | (c & 0x3F)));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/EncodingCodes.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/EncodingCodes.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/EncodingCodes.java
deleted file mode 100644
index ec55a90..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/EncodingCodes.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-public interface EncodingCodes
-{
- public static final byte DESCRIBED_TYPE_INDICATOR = (byte) 0x00;
-
- public static final byte NULL = (byte) 0x40;
-
- public static final byte BOOLEAN = (byte) 0x56;
- public static final byte BOOLEAN_TRUE = (byte) 0x41;
- public static final byte BOOLEAN_FALSE = (byte) 0x42;
-
- public static final byte UBYTE = (byte) 0x50;
-
- public static final byte USHORT = (byte) 0x60;
-
- public static final byte UINT = (byte) 0x70;
- public static final byte SMALLUINT = (byte) 0x52;
- public static final byte UINT0 = (byte) 0x43;
-
- public static final byte ULONG = (byte) 0x80;
- public static final byte SMALLULONG = (byte) 0x53;
- public static final byte ULONG0 = (byte) 0x44;
-
- public static final byte BYTE = (byte) 0x51;
-
- public static final byte SHORT = (byte) 0x61;
-
- public static final byte INT = (byte) 0x71;
- public static final byte SMALLINT = (byte) 0x54;
-
- public static final byte LONG = (byte) 0x81;
- public static final byte SMALLLONG = (byte) 0x55;
-
- public static final byte FLOAT = (byte) 0x72;
-
- public static final byte DOUBLE = (byte) 0x82;
-
- public static final byte DECIMAL32 = (byte) 0x74;
-
- public static final byte DECIMAL64 = (byte) 0x84;
-
- public static final byte DECIMAL128 = (byte) 0x94;
-
- public static final byte CHAR = (byte) 0x73;
-
- public static final byte TIMESTAMP = (byte) 0x83;
-
- public static final byte UUID = (byte) 0x98;
-
- public static final byte VBIN8 = (byte) 0xa0;
- public static final byte VBIN32 = (byte) 0xb0;
-
- public static final byte STR8 = (byte) 0xa1;
- public static final byte STR32 = (byte) 0xb1;
-
- public static final byte SYM8 = (byte) 0xa3;
- public static final byte SYM32 = (byte) 0xb3;
-
- public static final byte LIST0 = (byte) 0x45;
- public static final byte LIST8 = (byte) 0xc0;
- public static final byte LIST32 = (byte) 0xd0;
-
- public static final byte MAP8 = (byte) 0xc1;
- public static final byte MAP32 = (byte) 0xd1;
-
- public static final byte ARRAY8 = (byte) 0xe0;
- public static final byte ARRAY32 = (byte) 0xf0;
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/FixedSizePrimitiveTypeEncoding.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/FixedSizePrimitiveTypeEncoding.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/FixedSizePrimitiveTypeEncoding.java
deleted file mode 100644
index 2762064..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/FixedSizePrimitiveTypeEncoding.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-abstract class FixedSizePrimitiveTypeEncoding<T> extends AbstractPrimitiveTypeEncoding<T>
-{
-
- FixedSizePrimitiveTypeEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- public final boolean isFixedSizeVal()
- {
- return true;
- }
-
- public final int getValueSize(final T val)
- {
- return getFixedSize();
- }
-
- protected abstract int getFixedSize();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/FloatType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/FloatType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/FloatType.java
deleted file mode 100644
index f00af4e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/FloatType.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class FloatType extends AbstractPrimitiveType<Float>
-{
- private FloatEncoding _floatEncoding;
-
- FloatType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _floatEncoding = new FloatEncoding(encoder, decoder);
- encoder.register(Float.class, this);
- decoder.register(this);
- }
-
- public Class<Float> getTypeClass()
- {
- return Float.class;
- }
-
- public FloatEncoding getEncoding(final Float val)
- {
- return _floatEncoding;
- }
-
-
- public FloatEncoding getCanonicalEncoding()
- {
- return _floatEncoding;
- }
-
- public Collection<FloatEncoding> getAllEncodings()
- {
- return Collections.singleton(_floatEncoding);
- }
-
- public void write(float f)
- {
- _floatEncoding.write(f);
- }
-
- public class FloatEncoding extends FixedSizePrimitiveTypeEncoding<Float>
- {
-
- public FloatEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 4;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.FLOAT;
- }
-
- public FloatType getType()
- {
- return FloatType.this;
- }
-
- public void writeValue(final Float val)
- {
- getEncoder().writeRaw(val.floatValue());
- }
-
- public void writeValue(final float val)
- {
- getEncoder().writeRaw(val);
- }
-
-
- public void write(final float f)
- {
- writeConstructor();
- getEncoder().writeRaw(f);
-
- }
-
- public boolean encodesSuperset(final TypeEncoding<Float> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Float readValue()
- {
- return readPrimitiveValue();
- }
-
- public float readPrimitiveValue()
- {
- return getDecoder().readRawFloat();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/FloatingSizePrimitiveTypeEncoding.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/FloatingSizePrimitiveTypeEncoding.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/FloatingSizePrimitiveTypeEncoding.java
deleted file mode 100644
index eb6969d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/FloatingSizePrimitiveTypeEncoding.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-abstract class FloatingSizePrimitiveTypeEncoding<T> extends AbstractPrimitiveTypeEncoding<T>
-{
-
- FloatingSizePrimitiveTypeEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- public final boolean isFixedSizeVal()
- {
- return false;
- }
-
- abstract int getSizeBytes();
-
- public void writeValue(final T val)
- {
- writeSize(val);
- writeEncodedValue(val);
- }
-
- protected abstract void writeEncodedValue(final T val);
-
- protected abstract void writeSize(final T val);
-
- public int getValueSize(final T val)
- {
- return getSizeBytes() + getEncodedValueSize(val);
- }
-
- protected abstract int getEncodedValueSize(final T val);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/IntegerType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/IntegerType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/IntegerType.java
deleted file mode 100644
index a4fd0f5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/IntegerType.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public class IntegerType extends AbstractPrimitiveType<Integer>
-{
-
- public static interface IntegerEncoding extends PrimitiveTypeEncoding<Integer>
- {
- void write(int i);
- void writeValue(int i);
- int readPrimitiveValue();
- }
-
- private IntegerEncoding _integerEncoding;
- private IntegerEncoding _smallIntegerEncoding;
-
- IntegerType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _integerEncoding = new AllIntegerEncoding(encoder, decoder);
- _smallIntegerEncoding = new SmallIntegerEncoding(encoder, decoder);
- encoder.register(Integer.class, this);
- decoder.register(this);
- }
-
- public Class<Integer> getTypeClass()
- {
- return Integer.class;
- }
-
- public IntegerEncoding getEncoding(final Integer val)
- {
- return getEncoding(val.intValue());
- }
-
- public IntegerEncoding getEncoding(final int i)
- {
-
- return (i >= -128 && i <= 127) ? _smallIntegerEncoding : _integerEncoding;
- }
-
-
- public IntegerEncoding getCanonicalEncoding()
- {
- return _integerEncoding;
- }
-
- public Collection<IntegerEncoding> getAllEncodings()
- {
- return Arrays.asList(_integerEncoding, _smallIntegerEncoding);
- }
-
- public void write(int i)
- {
- if(i >= -128 && i <= 127)
- {
- _smallIntegerEncoding.write(i);
- }
- else
- {
- _integerEncoding.write(i);
- }
- }
-
- private class AllIntegerEncoding extends FixedSizePrimitiveTypeEncoding<Integer> implements IntegerEncoding
- {
-
- public AllIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 4;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.INT;
- }
-
- public IntegerType getType()
- {
- return IntegerType.this;
- }
-
- public void writeValue(final Integer val)
- {
- getEncoder().writeRaw(val.intValue());
- }
-
- public void write(final int i)
- {
- writeConstructor();
- getEncoder().writeRaw(i);
-
- }
-
- public void writeValue(final int i)
- {
- getEncoder().writeRaw(i);
- }
-
- public int readPrimitiveValue()
- {
- return getDecoder().readRawInt();
- }
-
- public boolean encodesSuperset(final TypeEncoding<Integer> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Integer readValue()
- {
- return readPrimitiveValue();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-
- private class SmallIntegerEncoding extends FixedSizePrimitiveTypeEncoding<Integer> implements IntegerEncoding
- {
- public SmallIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SMALLINT;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
- public void write(final int i)
- {
- writeConstructor();
- getEncoder().writeRaw((byte)i);
- }
-
- public void writeValue(final int i)
- {
- getEncoder().writeRaw((byte)i);
- }
-
- public int readPrimitiveValue()
- {
- return getDecoder().readRawByte();
- }
-
- public IntegerType getType()
- {
- return IntegerType.this;
- }
-
- public void writeValue(final Integer val)
- {
- getEncoder().writeRaw((byte)val.intValue());
- }
-
- public boolean encodesSuperset(final TypeEncoding<Integer> encoder)
- {
- return encoder == this;
- }
-
- public Integer readValue()
- {
- return readPrimitiveValue();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/LargeFloatingSizePrimitiveTypeEncoding.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/LargeFloatingSizePrimitiveTypeEncoding.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/LargeFloatingSizePrimitiveTypeEncoding.java
deleted file mode 100644
index e6be002..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/LargeFloatingSizePrimitiveTypeEncoding.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-abstract class LargeFloatingSizePrimitiveTypeEncoding<T> extends FloatingSizePrimitiveTypeEncoding<T>
-{
-
- LargeFloatingSizePrimitiveTypeEncoding(final EncoderImpl encoder, DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public int getSizeBytes()
- {
- return 4;
- }
-
- @Override
- protected void writeSize(final T val)
- {
- getEncoder().writeRaw(getEncodedValueSize(val));
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java
deleted file mode 100644
index 185373f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-public class ListType extends AbstractPrimitiveType<List>
-{
- private final ListEncoding _listEncoding;
- private final ListEncoding _shortListEncoding;
- private final ListEncoding _zeroListEncoding;
- private EncoderImpl _encoder;
-
- private static interface ListEncoding extends PrimitiveTypeEncoding<List>
- {
- void setValue(List value, int length);
- }
-
- ListType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _encoder = encoder;
- _listEncoding = new AllListEncoding(encoder, decoder);
- _shortListEncoding = new ShortListEncoding(encoder, decoder);
- _zeroListEncoding = new ZeroListEncoding(encoder, decoder);
- encoder.register(List.class, this);
- decoder.register(this);
- }
-
- public Class<List> getTypeClass()
- {
- return List.class;
- }
-
- public ListEncoding getEncoding(final List val)
- {
-
- int calculatedSize = calculateSize(val, _encoder);
- ListEncoding encoding = val.isEmpty()
- ? _zeroListEncoding
- : (val.size() > 255 || calculatedSize >= 254)
- ? _listEncoding
- : _shortListEncoding;
-
- encoding.setValue(val, calculatedSize);
- return encoding;
- }
-
- private static int calculateSize(final List val, EncoderImpl encoder)
- {
- int len = 0;
- final int count = val.size();
-
- for(int i = 0; i < count; i++)
- {
- Object element = val.get(i);
- AMQPType type = encoder.getType(element);
- if(type == null)
- {
- throw new IllegalArgumentException("No encoding defined for type: " + element.getClass());
- }
- TypeEncoding elementEncoding = type.getEncoding(element);
- len += elementEncoding.getConstructorSize()+elementEncoding.getValueSize(element);
- }
- return len;
- }
-
-
- public ListEncoding getCanonicalEncoding()
- {
- return _listEncoding;
- }
-
- public Collection<ListEncoding> getAllEncodings()
- {
- return Arrays.asList(_zeroListEncoding, _shortListEncoding, _listEncoding);
- }
-
- private class AllListEncoding
- extends LargeFloatingSizePrimitiveTypeEncoding<List>
- implements ListEncoding
- {
-
- private List _value;
- private int _length;
-
- public AllListEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final List val)
- {
- getEncoder().writeRaw(val.size());
-
- final int count = val.size();
-
- for(int i = 0; i < count; i++)
- {
- Object element = val.get(i);
- TypeEncoding elementEncoding = getEncoder().getType(element).getEncoding(element);
- elementEncoding.writeConstructor();
- elementEncoding.writeValue(element);
- }
- }
-
- @Override
- protected int getEncodedValueSize(final List val)
- {
- return 4 + ((val == _value) ? _length : calculateSize(val, getEncoder()));
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.LIST32;
- }
-
- public ListType getType()
- {
- return ListType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<List> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public List readValue()
- {
- DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- // todo - limit the decoder with size
- int count = decoder.readRawInt();
- // Ensure we do not allocate an array of size greater then the available data, otherwise there is a risk for an OOM error
- if (count > decoder.getByteBufferRemaining()) {
- throw new IllegalArgumentException("List element count "+count+" is specified to be greater than the amount of data available ("+
- decoder.getByteBufferRemaining()+")");
- }
- List list = new ArrayList(count);
- for(int i = 0; i < count; i++)
- {
- list.add(decoder.readObject());
- }
- return list;
- }
-
- public void setValue(final List value, final int length)
- {
- _value = value;
- _length = length;
- }
- }
-
- private class ShortListEncoding
- extends SmallFloatingSizePrimitiveTypeEncoding<List>
- implements ListEncoding
- {
-
- private List _value;
- private int _length;
-
- public ShortListEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final List val)
- {
- getEncoder().writeRaw((byte)val.size());
-
- final int count = val.size();
-
- for(int i = 0; i < count; i++)
- {
- Object element = val.get(i);
- TypeEncoding elementEncoding = getEncoder().getType(element).getEncoding(element);
- elementEncoding.writeConstructor();
- elementEncoding.writeValue(element);
- }
- }
-
- @Override
- protected int getEncodedValueSize(final List val)
- {
- return 1 + ((val == _value) ? _length : calculateSize(val, getEncoder()));
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.LIST8;
- }
-
- public ListType getType()
- {
- return ListType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<List> encoder)
- {
- return encoder == this;
- }
-
- public List readValue()
- {
-
- DecoderImpl decoder = getDecoder();
- int size = ((int)decoder.readRawByte()) & 0xff;
- // todo - limit the decoder with size
- int count = ((int)decoder.readRawByte()) & 0xff;
- List list = new ArrayList(count);
- for(int i = 0; i < count; i++)
- {
- list.add(decoder.readObject());
- }
- return list;
- }
-
- public void setValue(final List value, final int length)
- {
- _value = value;
- _length = length;
- }
- }
-
-
- private class ZeroListEncoding
- extends FixedSizePrimitiveTypeEncoding<List>
- implements ListEncoding
- {
- public ZeroListEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.LIST0;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 0;
- }
-
-
- public ListType getType()
- {
- return ListType.this;
- }
-
- public void setValue(List value, int length)
- {
- }
-
- public void writeValue(final List val)
- {
- }
-
- public boolean encodesSuperset(final TypeEncoding<List> encoder)
- {
- return encoder == this;
- }
-
- public List readValue()
- {
- return Collections.EMPTY_LIST;
- }
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/LongType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/LongType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/LongType.java
deleted file mode 100644
index 47532df..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/LongType.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public class LongType extends AbstractPrimitiveType<Long>
-{
-
- public static interface LongEncoding extends PrimitiveTypeEncoding<Long>
- {
- void write(long l);
- void writeValue(long l);
- public long readPrimitiveValue();
- }
-
- private LongEncoding _longEncoding;
- private LongEncoding _smallLongEncoding;
-
- LongType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _longEncoding = new AllLongEncoding(encoder, decoder);
- _smallLongEncoding = new SmallLongEncoding(encoder, decoder);
- encoder.register(Long.class, this);
- decoder.register(this);
- }
-
- public Class<Long> getTypeClass()
- {
- return Long.class;
- }
-
- public LongEncoding getEncoding(final Long val)
- {
- return getEncoding(val.longValue());
- }
-
- public LongEncoding getEncoding(final long l)
- {
- return (l >= -128l && l <= 127l) ? _smallLongEncoding : _longEncoding;
- }
-
-
- public LongEncoding getCanonicalEncoding()
- {
- return _longEncoding;
- }
-
- public Collection<LongEncoding> getAllEncodings()
- {
- return Arrays.asList(_smallLongEncoding, _longEncoding);
- }
-
- public void write(long l)
- {
- if(l >= -128l && l <= 127l)
- {
- _smallLongEncoding.write(l);
- }
- else
- {
- _longEncoding.write(l);
- }
- }
-
- private class AllLongEncoding extends FixedSizePrimitiveTypeEncoding<Long> implements LongEncoding
- {
-
- public AllLongEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 8;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.LONG;
- }
-
- public LongType getType()
- {
- return LongType.this;
- }
-
- public void writeValue(final Long val)
- {
- getEncoder().writeRaw(val.longValue());
- }
-
- public void write(final long l)
- {
- writeConstructor();
- getEncoder().writeRaw(l);
-
- }
-
- public void writeValue(final long l)
- {
- getEncoder().writeRaw(l);
- }
-
- public boolean encodesSuperset(final TypeEncoding<Long> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Long readValue()
- {
- return readPrimitiveValue();
- }
-
- public long readPrimitiveValue()
- {
- return getDecoder().readRawLong();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-
- private class SmallLongEncoding extends FixedSizePrimitiveTypeEncoding<Long> implements LongEncoding
- {
- public SmallLongEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SMALLLONG;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
- public void write(final long l)
- {
- writeConstructor();
- getEncoder().writeRaw((byte)l);
- }
-
- public void writeValue(final long l)
- {
- getEncoder().writeRaw((byte)l);
- }
-
- public long readPrimitiveValue()
- {
- return (long) getDecoder().readRawByte();
- }
-
- public LongType getType()
- {
- return LongType.this;
- }
-
- public void writeValue(final Long val)
- {
- getEncoder().writeRaw((byte)val.longValue());
- }
-
- public boolean encodesSuperset(final TypeEncoding<Long> encoder)
- {
- return encoder == this;
- }
-
- public Long readValue()
- {
- return readPrimitiveValue();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/MapType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/MapType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/MapType.java
deleted file mode 100644
index 5c8a7c7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/MapType.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.*;
-
-public class MapType extends AbstractPrimitiveType<Map>
-{
- private final MapEncoding _mapEncoding;
- private final MapEncoding _shortMapEncoding;
- private EncoderImpl _encoder;
-
- private static interface MapEncoding extends PrimitiveTypeEncoding<Map>
- {
- void setValue(Map value, int length);
- }
-
- MapType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _encoder = encoder;
- _mapEncoding = new AllMapEncoding(encoder, decoder);
- _shortMapEncoding = new ShortMapEncoding(encoder, decoder);
- encoder.register(Map.class, this);
- decoder.register(this);
- }
-
- public Class<Map> getTypeClass()
- {
- return Map.class;
- }
-
- public MapEncoding getEncoding(final Map val)
- {
-
- int calculatedSize = calculateSize(val, _encoder);
- MapEncoding encoding = (val.size() > 127 || calculatedSize >= 254)
- ? _mapEncoding
- : _shortMapEncoding;
-
- encoding.setValue(val, calculatedSize);
- return encoding;
- }
-
- private static int calculateSize(final Map val, EncoderImpl encoder)
- {
- int len = 0;
- Iterator<Map.Entry> iter = val.entrySet().iterator();
-
- while(iter.hasNext())
- {
- Map.Entry element = iter.next();
- TypeEncoding elementEncoding = encoder.getType(element.getKey()).getEncoding(element.getKey());
- len += elementEncoding.getConstructorSize()+elementEncoding.getValueSize(element.getKey());
- elementEncoding = encoder.getType(element.getValue()).getEncoding(element.getValue());
- len += elementEncoding.getConstructorSize()+elementEncoding.getValueSize(element.getValue());
-
- }
- return len;
- }
-
-
- public MapEncoding getCanonicalEncoding()
- {
- return _mapEncoding;
- }
-
- public Collection<MapEncoding> getAllEncodings()
- {
- return Arrays.asList(_shortMapEncoding, _mapEncoding);
- }
-
- private class AllMapEncoding
- extends LargeFloatingSizePrimitiveTypeEncoding<Map>
- implements MapEncoding
- {
-
- private Map _value;
- private int _length;
-
- public AllMapEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final Map val)
- {
- getEncoder().writeRaw(2 * val.size());
-
-
- Iterator<Map.Entry> iter = val.entrySet().iterator();
-
- while(iter.hasNext())
- {
- Map.Entry element = iter.next();
- TypeEncoding elementEncoding = getEncoder().getType(element.getKey()).getEncoding(element.getKey());
- elementEncoding.writeConstructor();
- elementEncoding.writeValue(element.getKey());
- elementEncoding = getEncoder().getType(element.getValue()).getEncoding(element.getValue());
- elementEncoding.writeConstructor();
- elementEncoding.writeValue(element.getValue());
- }
- }
-
- @Override
- protected int getEncodedValueSize(final Map val)
- {
- return 4 + ((val == _value) ? _length : calculateSize(val, getEncoder()));
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.MAP32;
- }
-
- public MapType getType()
- {
- return MapType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Map> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Map readValue()
- {
-
- DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- // todo - limit the decoder with size
- int count = decoder.readRawInt();
- if (count > decoder.getByteBufferRemaining()) {
- throw new IllegalArgumentException("Map element count "+count+" is specified to be greater than the amount of data available ("+
- decoder.getByteBufferRemaining()+")");
- }
- Map map = new LinkedHashMap(count);
- for(int i = 0; i < count; i++)
- {
- Object key = decoder.readObject();
- i++;
- Object value = decoder.readObject();
- map.put(key, value);
- }
- return map;
- }
-
- public void setValue(final Map value, final int length)
- {
- _value = value;
- _length = length;
- }
- }
-
- private class ShortMapEncoding
- extends SmallFloatingSizePrimitiveTypeEncoding<Map>
- implements MapEncoding
- {
-
- private Map _value;
- private int _length;
-
- public ShortMapEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final Map val)
- {
- getEncoder().writeRaw((byte)(2*val.size()));
-
-
- Iterator<Map.Entry> iter = val.entrySet().iterator();
-
- while(iter.hasNext())
- {
- Map.Entry element = iter.next();
- TypeEncoding elementEncoding = getEncoder().getType(element.getKey()).getEncoding(element.getKey());
- elementEncoding.writeConstructor();
- elementEncoding.writeValue(element.getKey());
- elementEncoding = getEncoder().getType(element.getValue()).getEncoding(element.getValue());
- elementEncoding.writeConstructor();
- elementEncoding.writeValue(element.getValue());
- }
- }
-
- @Override
- protected int getEncodedValueSize(final Map val)
- {
- return 1 + ((val == _value) ? _length : calculateSize(val, getEncoder()));
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.MAP8;
- }
-
- public MapType getType()
- {
- return MapType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Map> encoder)
- {
- return encoder == this;
- }
-
- public Map readValue()
- {
- DecoderImpl decoder = getDecoder();
- int size = ((int)decoder.readRawByte()) & 0xff;
- // todo - limit the decoder with size
- int count = ((int)decoder.readRawByte()) & 0xff;
-
- Map map = new LinkedHashMap(count);
- for(int i = 0; i < count; i++)
- {
- Object key = decoder.readObject();
- i++;
- Object value = decoder.readObject();
- map.put(key, value);
- }
- return map;
- }
-
- public void setValue(final Map value, final int length)
- {
- _value = value;
- _length = length;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/NullType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/NullType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/NullType.java
deleted file mode 100644
index 5449f9b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/NullType.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public final class NullType extends AbstractPrimitiveType<Void>
-{
- private NullEncoding _nullEncoding;
-
- NullType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _nullEncoding = new NullEncoding(encoder, decoder);
- encoder.register(Void.class, this);
- decoder.register(this);
- }
-
- public Class<Void> getTypeClass()
- {
- return Void.class;
- }
-
- public NullEncoding getEncoding(final Void val)
- {
- return _nullEncoding;
- }
-
-
- public NullEncoding getCanonicalEncoding()
- {
- return _nullEncoding;
- }
-
- public Collection<NullEncoding> getAllEncodings()
- {
- return Collections.singleton(_nullEncoding);
- }
-
- public void write()
- {
- _nullEncoding.write();
- }
-
- private class NullEncoding extends FixedSizePrimitiveTypeEncoding<Void>
- {
-
- public NullEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 0;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.NULL;
- }
-
- public NullType getType()
- {
- return NullType.this;
- }
-
- public void writeValue(final Void val)
- {
- }
-
- public void writeValue()
- {
- }
-
- public boolean encodesSuperset(final TypeEncoding<Void> encoding)
- {
- return encoding == this;
- }
-
- public Void readValue()
- {
- return null;
- }
-
- public void write()
- {
- writeConstructor();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/PrimitiveType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/PrimitiveType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/PrimitiveType.java
deleted file mode 100644
index 25fb9c6..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/PrimitiveType.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-
-public interface PrimitiveType<V> extends AMQPType<V>
-{
-
- PrimitiveTypeEncoding<V> getEncoding(V val);
-
- PrimitiveTypeEncoding<V> getCanonicalEncoding();
-
- Collection<? extends PrimitiveTypeEncoding<V>> getAllEncodings();
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/PrimitiveTypeEncoding.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/PrimitiveTypeEncoding.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/PrimitiveTypeEncoding.java
deleted file mode 100644
index ee0e04a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/PrimitiveTypeEncoding.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-public interface PrimitiveTypeEncoding<T> extends TypeEncoding<T>, TypeConstructor<T>
-{
- PrimitiveType<T> getType();
-
- byte getEncodingCode();
-
- void writeConstructor();
-
- int getConstructorSize();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/ReadableBuffer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ReadableBuffer.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ReadableBuffer.java
deleted file mode 100644
index 1360d76..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ReadableBuffer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.codec;
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-
-/**
- * Interface to abstract a buffer, similar to {@link WritableBuffer}
- */
-public interface ReadableBuffer {
-
- void put(ReadableBuffer other);
-
- byte get();
-
- int getInt();
-
- long getLong();
-
- short getShort();
-
- float getFloat();
-
- double getDouble();
-
- ReadableBuffer get(final byte[] data, final int offset, final int length);
-
- ReadableBuffer get(final byte[] data);
-
- ReadableBuffer position(int position);
-
- ReadableBuffer slice();
-
- ReadableBuffer flip();
-
- ReadableBuffer limit(int limit);
-
- int limit();
-
- int remaining();
-
- int position();
-
- boolean hasRemaining();
-
- ReadableBuffer duplicate();
-
- ByteBuffer byteBuffer();
-
- String readUTF8();
-
- final class ByteBufferReader implements ReadableBuffer {
-
- private static final Charset Charset_UTF8 = Charset.forName("UTF-8");
-
- private ByteBuffer buffer;
-
- public static ByteBufferReader allocate(int size) {
- ByteBuffer allocated = ByteBuffer.allocate(size);
- return new ByteBufferReader(allocated);
- }
-
- public ByteBufferReader(ByteBuffer buffer) {
- this.buffer = buffer;
- }
-
- @Override
- public byte get() {
- return buffer.get();
- }
-
- @Override
- public int getInt() {
- return buffer.getInt();
- }
-
- @Override
- public long getLong() {
- return buffer.getLong();
- }
-
- @Override
- public short getShort() {
- return buffer.getShort();
- }
-
- @Override
- public float getFloat() {
- return buffer.getFloat();
- }
-
- @Override
- public double getDouble() {
- return buffer.getDouble();
- }
-
- @Override
- public int limit() {
- return buffer.limit();
- }
-
- @Override
- public ReadableBuffer get(byte[] data, int offset, int length) {
- buffer.get(data, offset, length);
- return this;
- }
-
- @Override
- public ReadableBuffer get(byte[] data) {
- buffer.get(data);
- return this;
- }
-
- @Override
- public ReadableBuffer flip() {
- buffer.flip();
- return this;
- }
-
- @Override
- public ReadableBuffer position(int position) {
- buffer.position(position);
- return this;
- }
-
- @Override
- public ReadableBuffer slice() {
- return new ByteBufferReader(buffer.slice());
- }
-
- @Override
- public ReadableBuffer limit(int limit) {
- buffer.limit(limit);
- return this;
- }
-
- @Override
- public int remaining() {
- return buffer.remaining();
- }
-
- @Override
- public int position() {
- return buffer.position();
- }
-
- @Override
- public boolean hasRemaining() {
- return buffer.hasRemaining();
- }
-
- @Override
- public ReadableBuffer duplicate() {
- return new ByteBufferReader(buffer.duplicate());
- }
-
- @Override
- public ByteBuffer byteBuffer() {
- return buffer;
- }
-
- @Override
- public String readUTF8() {
- CharBuffer charBuf = Charset_UTF8.decode(buffer);
- return charBuf.toString();
- }
-
- @Override
- public void put(ReadableBuffer other) {
- this.buffer.put(other.byteBuffer());
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/ShortType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ShortType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ShortType.java
deleted file mode 100644
index 7dfe035..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ShortType.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class ShortType extends AbstractPrimitiveType<Short>
-{
- private ShortEncoding _shortEncoding;
-
- ShortType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _shortEncoding = new ShortEncoding(encoder, decoder);
- encoder.register(Short.class, this);
- decoder.register(this);
- }
-
- public Class<Short> getTypeClass()
- {
- return Short.class;
- }
-
- public ShortEncoding getEncoding(final Short val)
- {
- return _shortEncoding;
- }
-
- public void write(short s)
- {
- _shortEncoding.write(s);
- }
-
- public ShortEncoding getCanonicalEncoding()
- {
- return _shortEncoding;
- }
-
- public Collection<ShortEncoding> getAllEncodings()
- {
- return Collections.singleton(_shortEncoding);
- }
-
- public class ShortEncoding extends FixedSizePrimitiveTypeEncoding<Short>
- {
-
- public ShortEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 2;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SHORT;
- }
-
- public ShortType getType()
- {
- return ShortType.this;
- }
-
- public void writeValue(final Short val)
- {
- getEncoder().writeRaw(val);
- }
-
- public void writeValue(final short val)
- {
- getEncoder().writeRaw(val);
- }
-
-
- public void write(final short s)
- {
- writeConstructor();
- getEncoder().writeRaw(s);
- }
-
- public boolean encodesSuperset(final TypeEncoding<Short> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Short readValue()
- {
- return readPrimitiveValue();
- }
-
- public short readPrimitiveValue()
- {
- return getDecoder().readRawShort();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/SmallFloatingSizePrimitiveTypeEncoding.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/SmallFloatingSizePrimitiveTypeEncoding.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/SmallFloatingSizePrimitiveTypeEncoding.java
deleted file mode 100644
index 75e405a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/SmallFloatingSizePrimitiveTypeEncoding.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-abstract class SmallFloatingSizePrimitiveTypeEncoding<T> extends FloatingSizePrimitiveTypeEncoding<T>
-{
-
- SmallFloatingSizePrimitiveTypeEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public int getSizeBytes()
- {
- return 1;
- }
-
- @Override
- protected void writeSize(final T val)
- {
- getEncoder().writeRaw((byte)getEncodedValueSize(val));
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[14/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java
deleted file mode 100644
index c7b796d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.ProtonJSession;
-import org.apache.qpid.proton.engine.Session;
-
-public class SessionImpl extends EndpointImpl implements ProtonJSession
-{
- private final ConnectionImpl _connection;
-
- private Map<String, SenderImpl> _senders = new LinkedHashMap<String, SenderImpl>();
- private Map<String, ReceiverImpl> _receivers = new LinkedHashMap<String, ReceiverImpl>();
- private List<LinkImpl> _oldLinksToFree = new ArrayList<LinkImpl>();
- private TransportSession _transportSession;
- private int _incomingCapacity = 1024*1024;
- private int _incomingBytes = 0;
- private int _outgoingBytes = 0;
- private int _incomingDeliveries = 0;
- private int _outgoingDeliveries = 0;
- private long _outgoingWindow = Integer.MAX_VALUE;
- private Map<Symbol, Object> _properties;
- private Map<Symbol, Object> _remoteProperties;
- private Symbol[] _offeredCapabilities;
- private Symbol[] _remoteOfferedCapabilities;
- private Symbol[] _desiredCapabilities;
- private Symbol[] _remoteDesiredCapabilities;
-
- private LinkNode<SessionImpl> _node;
-
-
- SessionImpl(ConnectionImpl connection)
- {
- _connection = connection;
- _connection.incref();
- _node = _connection.addSessionEndpoint(this);
- _connection.put(Event.Type.SESSION_INIT, this);
- }
-
- @Override
- public SenderImpl sender(String name)
- {
- SenderImpl sender = _senders.get(name);
- if(sender == null)
- {
- sender = new SenderImpl(this, name);
- _senders.put(name, sender);
- }
- else
- {
- if(sender.getLocalState() == EndpointState.CLOSED
- && sender.getRemoteState() == EndpointState.CLOSED)
- {
- _oldLinksToFree.add(sender);
-
- sender = new SenderImpl(this, name);
- _senders.put(name, sender);
- }
- }
- return sender;
- }
-
- @Override
- public ReceiverImpl receiver(String name)
- {
- ReceiverImpl receiver = _receivers.get(name);
- if(receiver == null)
- {
- receiver = new ReceiverImpl(this, name);
- _receivers.put(name, receiver);
- }
- else
- {
- if(receiver.getLocalState() == EndpointState.CLOSED
- && receiver.getRemoteState() == EndpointState.CLOSED)
- {
- _oldLinksToFree.add(receiver);
-
- receiver = new ReceiverImpl(this, name);
- _receivers.put(name, receiver);
- }
- }
- return receiver;
- }
-
- @Override
- public Session next(EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
- {
- LinkNode.Query<SessionImpl> query = new EndpointImplQuery<SessionImpl>(local, remote);
-
- LinkNode<SessionImpl> sessionNode = _node.next(query);
-
- return sessionNode == null ? null : sessionNode.getValue();
- }
-
- @Override
- protected ConnectionImpl getConnectionImpl()
- {
- return _connection;
- }
-
- @Override
- public ConnectionImpl getConnection()
- {
- return getConnectionImpl();
- }
-
- @Override
- void postFinal() {
- _connection.put(Event.Type.SESSION_FINAL, this);
- _connection.decref();
- }
-
- @Override
- void doFree() {
- _connection.freeSession(this);
- _connection.removeSessionEndpoint(_node);
- _node = null;
-
- List<SenderImpl> senders = new ArrayList<SenderImpl>(_senders.values());
- for(SenderImpl sender : senders) {
- sender.free();
- }
- _senders.clear();
-
- List<ReceiverImpl> receivers = new ArrayList<ReceiverImpl>(_receivers.values());
- for(ReceiverImpl receiver : receivers) {
- receiver.free();
- }
- _receivers.clear();
-
- List<LinkImpl> links = new ArrayList<LinkImpl>(_oldLinksToFree);
- for(LinkImpl link : links) {
- link.free();
- }
- }
-
- void modifyEndpoints() {
- for (SenderImpl snd : _senders.values()) {
- snd.modifyEndpoints();
- }
-
- for (ReceiverImpl rcv : _receivers.values()) {
- rcv.modifyEndpoints();
- }
- modified();
- }
-
- TransportSession getTransportSession()
- {
- return _transportSession;
- }
-
- void setTransportSession(TransportSession transportSession)
- {
- _transportSession = transportSession;
- }
-
- void setNode(LinkNode<SessionImpl> node)
- {
- _node = node;
- }
-
- void freeSender(SenderImpl sender)
- {
- String name = sender.getName();
- SenderImpl existing = _senders.get(name);
- if (sender.equals(existing))
- {
- _senders.remove(name);
- }
- else
- {
- _oldLinksToFree.remove(sender);
- }
- }
-
- void freeReceiver(ReceiverImpl receiver)
- {
- String name = receiver.getName();
- ReceiverImpl existing = _receivers.get(name);
- if (receiver.equals(existing))
- {
- _receivers.remove(name);
- }
- else
- {
- _oldLinksToFree.remove(receiver);
- }
- }
-
- @Override
- public int getIncomingCapacity()
- {
- return _incomingCapacity;
- }
-
- @Override
- public void setIncomingCapacity(int capacity)
- {
- _incomingCapacity = capacity;
- }
-
- @Override
- public int getIncomingBytes()
- {
- return _incomingBytes;
- }
-
- void incrementIncomingBytes(int delta)
- {
- _incomingBytes += delta;
- }
-
- @Override
- public int getOutgoingBytes()
- {
- return _outgoingBytes;
- }
-
- void incrementOutgoingBytes(int delta)
- {
- _outgoingBytes += delta;
- }
-
- void incrementIncomingDeliveries(int delta)
- {
- _incomingDeliveries += delta;
- }
-
- int getOutgoingDeliveries()
- {
- return _outgoingDeliveries;
- }
-
- void incrementOutgoingDeliveries(int delta)
- {
- _outgoingDeliveries += delta;
- }
-
- @Override
- void localOpen()
- {
- getConnectionImpl().put(Event.Type.SESSION_LOCAL_OPEN, this);
- }
-
- @Override
- void localClose()
- {
- getConnectionImpl().put(Event.Type.SESSION_LOCAL_CLOSE, this);
- }
-
- @Override
- public void setOutgoingWindow(long outgoingWindow) {
- if(outgoingWindow < 0 || outgoingWindow > 0xFFFFFFFFL)
- {
- throw new IllegalArgumentException("Value '" + outgoingWindow + "' must be in the"
- + " range [0 - 2^32-1]");
- }
-
- _outgoingWindow = outgoingWindow;
- }
-
- @Override
- public long getOutgoingWindow()
- {
- return _outgoingWindow;
- }
-
- @Override
- public Map<Symbol, Object> getProperties()
- {
- return _properties;
- }
-
- @Override
- public void setProperties(Map<Symbol, Object> properties)
- {
- _properties = properties;
- }
-
- @Override
- public Map<Symbol, Object> getRemoteProperties()
- {
- return _remoteProperties;
- }
-
- void setRemoteProperties(Map<Symbol, Object> remoteProperties)
- {
- _remoteProperties = remoteProperties;
- }
-
- @Override
- public Symbol[] getDesiredCapabilities()
- {
- return _desiredCapabilities;
- }
-
- @Override
- public void setDesiredCapabilities(Symbol[] desiredCapabilities)
- {
- _desiredCapabilities = desiredCapabilities;
- }
-
- @Override
- public Symbol[] getRemoteDesiredCapabilities()
- {
- return _remoteDesiredCapabilities;
- }
-
- void setRemoteDesiredCapabilities(Symbol[] remoteDesiredCapabilities)
- {
- _remoteDesiredCapabilities = remoteDesiredCapabilities;
- }
-
- @Override
- public Symbol[] getOfferedCapabilities()
- {
- return _offeredCapabilities;
- }
-
- @Override
- public void setOfferedCapabilities(Symbol[] offeredCapabilities)
- {
- _offeredCapabilities = offeredCapabilities;
- }
-
- @Override
- public Symbol[] getRemoteOfferedCapabilities()
- {
- return _remoteOfferedCapabilities;
- }
-
- void setRemoteOfferedCapabilities(Symbol[] remoteOfferedCapabilities)
- {
- _remoteOfferedCapabilities = remoteOfferedCapabilities;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/StringUtils.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/StringUtils.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/StringUtils.java
deleted file mode 100644
index f80cca3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/StringUtils.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-public class StringUtils
-{
- /**
- * Converts the Binary to a quoted string.
- *
- * @param bin the Binary to convert
- * @param stringLength the maximum length of stringified content (excluding the quotes, and truncated indicator)
- * @param appendIfTruncated appends "...(truncated)" if not all of the payload is present in the string
- * @return the converted string
- */
- public static String toQuotedString(final Binary bin,final int stringLength,final boolean appendIfTruncated)
- {
- if(bin == null)
- {
- return "\"\"";
- }
-
- final byte[] binData = bin.getArray();
- final int binLength = bin.getLength();
- final int offset = bin.getArrayOffset();
-
- StringBuilder str = new StringBuilder();
- str.append("\"");
-
- int size = 0;
- boolean truncated = false;
- for (int i = 0; i < binLength; i++)
- {
- byte c = binData[offset + i];
-
- if (c > 31 && c < 127 && c != '\\')
- {
- if (size + 1 <= stringLength)
- {
- size += 1;
- str.append((char) c);
- }
- else
- {
- truncated = true;
- break;
- }
- }
- else
- {
- if (size + 4 <= stringLength)
- {
- size += 4;
- str.append(String.format("\\x%02x", c));
- }
- else
- {
- truncated = true;
- break;
- }
- }
- }
-
- str.append("\"");
-
- if (truncated && appendIfTruncated)
- {
- str.append("...(truncated)");
- }
-
- return str.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportDelivery.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportDelivery.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportDelivery.java
deleted file mode 100644
index 3e6cada..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportDelivery.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-public class TransportDelivery
-{
- private UnsignedInteger _deliveryId;
- private DeliveryImpl _delivery;
- private TransportLink _transportLink;
- private int _sessionSize = 1;
-
- TransportDelivery(UnsignedInteger currentDeliveryId, DeliveryImpl delivery, TransportLink transportLink)
- {
- _deliveryId = currentDeliveryId;
- _delivery = delivery;
- _transportLink = transportLink;
- }
-
- public UnsignedInteger getDeliveryId()
- {
- return _deliveryId;
- }
-
- public TransportLink getTransportLink()
- {
- return _transportLink;
- }
-
- void incrementSessionSize()
- {
- _sessionSize++;
- }
-
- int getSessionSize()
- {
- return _sessionSize;
- }
-
- void settled()
- {
- _transportLink.settled(this);
- _delivery.updateWork();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
deleted file mode 100644
index 42126b0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ /dev/null
@@ -1,1732 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.pourArrayToBuffer;
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.pourBufferToArray;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-import org.apache.qpid.proton.amqp.transport.Attach;
-import org.apache.qpid.proton.amqp.transport.Begin;
-import org.apache.qpid.proton.amqp.transport.Close;
-import org.apache.qpid.proton.amqp.transport.ConnectionError;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-import org.apache.qpid.proton.amqp.transport.Detach;
-import org.apache.qpid.proton.amqp.transport.Disposition;
-import org.apache.qpid.proton.amqp.transport.End;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.amqp.transport.Flow;
-import org.apache.qpid.proton.amqp.transport.FrameBody;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.amqp.transport.Role;
-import org.apache.qpid.proton.amqp.transport.Transfer;
-import org.apache.qpid.proton.codec.AMQPDefinedTypes;
-import org.apache.qpid.proton.codec.DecoderImpl;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.ProtonJTransport;
-import org.apache.qpid.proton.engine.Sasl;
-import org.apache.qpid.proton.engine.Ssl;
-import org.apache.qpid.proton.engine.SslDomain;
-import org.apache.qpid.proton.engine.SslPeerDetails;
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.engine.TransportResult;
-import org.apache.qpid.proton.engine.TransportResultFactory;
-import org.apache.qpid.proton.engine.impl.ssl.SslImpl;
-import org.apache.qpid.proton.framing.TransportFrame;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Selectable;
-
-public class TransportImpl extends EndpointImpl
- implements ProtonJTransport, FrameBody.FrameBodyHandler<Integer>,
- FrameHandler, TransportOutputWriter, TransportInternal
-{
- static final int BUFFER_RELEASE_THRESHOLD = Integer.getInteger("proton.transport_buffer_release_threshold", 2 * 1024 * 1024);
- private static final int CHANNEL_MAX_LIMIT = 65535;
-
- private static final boolean getBooleanEnv(String name)
- {
- String value = System.getenv(name);
- return "true".equalsIgnoreCase(value) ||
- "1".equals(value) ||
- "yes".equalsIgnoreCase(value);
- }
-
- private static final boolean FRM_ENABLED = getBooleanEnv("PN_TRACE_FRM");
- private static final int TRACE_FRAME_PAYLOAD_LENGTH = Integer.getInteger("proton.trace_frame_payload_length", 1024);
-
- // trace levels
- private int _levels = (FRM_ENABLED ? TRACE_FRM : 0);
-
- private FrameParser _frameParser;
-
- private ConnectionImpl _connectionEndpoint;
-
- private boolean _isOpenSent;
- private boolean _isCloseSent;
-
- private boolean _headerWritten;
- private Map<Integer, TransportSession> _remoteSessions = new HashMap<Integer, TransportSession>();
- private Map<Integer, TransportSession> _localSessions = new HashMap<Integer, TransportSession>();
-
- private TransportInput _inputProcessor;
- private TransportOutput _outputProcessor;
-
- private DecoderImpl _decoder = new DecoderImpl();
- private EncoderImpl _encoder = new EncoderImpl(_decoder);
-
- private int _maxFrameSize = DEFAULT_MAX_FRAME_SIZE;
- private int _remoteMaxFrameSize = 512;
- private int _channelMax = CHANNEL_MAX_LIMIT;
- private int _remoteChannelMax = CHANNEL_MAX_LIMIT;
-
- private final FrameWriter _frameWriter;
-
- private boolean _closeReceived;
- private Open _open;
- private SaslImpl _sasl;
- private SslImpl _ssl;
- private final Ref<ProtocolTracer> _protocolTracer = new Ref(null);
-
- private TransportResult _lastTransportResult = TransportResultFactory.ok();
-
- private boolean _init;
- private boolean _processingStarted;
- private boolean _emitFlowEventOnSend = true;
-
- private FrameHandler _frameHandler = this;
- private boolean _head_closed = false;
- private ErrorCondition _condition = null;
-
- private boolean postedHeadClosed = false;
- private boolean postedTailClosed = false;
- private boolean postedTransportError = false;
-
- private int _localIdleTimeout = 0;
- private int _remoteIdleTimeout = 0;
- private long _bytesInput = 0;
- private long _bytesOutput = 0;
- private long _localIdleDeadline = 0;
- private long _lastBytesInput = 0;
- private long _lastBytesOutput = 0;
- private long _remoteIdleDeadline = 0;
-
- private Selectable _selectable;
- private Reactor _reactor;
-
- private List<TransportLayer> _additionalTransportLayers;
-
- /**
- * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
- * Client code outside this module should use {@link org.apache.qpid.proton.engine.Transport.Factory#create()} instead
- */
- @Deprecated public TransportImpl()
- {
- this(DEFAULT_MAX_FRAME_SIZE);
- }
-
-
- /**
- * Creates a transport with the given maximum frame size.
- * Note that the maximumFrameSize also determines the size of the output buffer.
- */
- TransportImpl(int maxFrameSize)
- {
- AMQPDefinedTypes.registerAllTypes(_decoder, _encoder);
-
- _maxFrameSize = maxFrameSize;
- _frameWriter = new FrameWriter(_encoder, _remoteMaxFrameSize,
- FrameWriter.AMQP_FRAME_TYPE,
- _protocolTracer,
- this);
- }
-
- private void init()
- {
- if(!_init)
- {
- _init = true;
- _frameParser = new FrameParser(_frameHandler , _decoder, _maxFrameSize);
- _inputProcessor = _frameParser;
- _outputProcessor = new TransportOutputAdaptor(this, _maxFrameSize);
- }
- }
-
- @Override
- public void trace(int levels) {
- _levels = levels;
- }
-
- @Override
- public int getMaxFrameSize()
- {
- return _maxFrameSize;
- }
-
- @Override
- public int getRemoteMaxFrameSize()
- {
- return _remoteMaxFrameSize;
- }
-
- @Override
- public void setMaxFrameSize(int maxFrameSize)
- {
- if(_init)
- {
- throw new IllegalStateException("Cannot set max frame size after transport has been initialised");
- }
- _maxFrameSize = maxFrameSize;
- }
-
- @Override
- public int getChannelMax()
- {
- return _channelMax;
- }
-
- @Override
- public void setChannelMax(int channelMax)
- {
- if(_isOpenSent)
- {
- throw new IllegalArgumentException("Cannot change channel max after open frame has been sent");
- }
-
- if(channelMax < 0 || channelMax >= (1<<16))
- {
- throw new NumberFormatException("Value \""+channelMax+"\" lies outside the range [0-" + (1<<16) +").");
- }
-
- _channelMax = channelMax;
- }
-
- @Override
- public int getRemoteChannelMax()
- {
- return _remoteChannelMax;
- }
-
- @Override
- public ErrorCondition getCondition()
- {
- return _condition;
- }
-
- @Override
- public void bind(Connection conn)
- {
- // TODO - check if already bound
-
- _connectionEndpoint = (ConnectionImpl) conn;
- put(Event.Type.CONNECTION_BOUND, conn);
- _connectionEndpoint.setTransport(this);
- _connectionEndpoint.incref();
-
- if(getRemoteState() != EndpointState.UNINITIALIZED)
- {
- _connectionEndpoint.handleOpen(_open);
- if(getRemoteState() == EndpointState.CLOSED)
- {
- _connectionEndpoint.setRemoteState(EndpointState.CLOSED);
- }
-
- _frameParser.flush();
- }
- }
-
- @Override
- public void unbind()
- {
- for (TransportSession ts: _localSessions.values()) {
- ts.unbind();
- }
- for (TransportSession ts: _remoteSessions.values()) {
- ts.unbind();
- }
-
- put(Event.Type.CONNECTION_UNBOUND, _connectionEndpoint);
-
- _connectionEndpoint.modifyEndpoints();
- _connectionEndpoint.setTransport(null);
- _connectionEndpoint.decref();
- }
-
- @Override
- public int input(byte[] bytes, int offset, int length)
- {
- oldApiCheckStateBeforeInput(length).checkIsOk();
-
- ByteBuffer inputBuffer = getInputBuffer();
- int numberOfBytesConsumed = pourArrayToBuffer(bytes, offset, length, inputBuffer);
- processInput().checkIsOk();
- return numberOfBytesConsumed;
- }
-
- /**
- * This method is public as it is used by Python layer.
- * @see org.apache.qpid.proton.engine.Transport#input(byte[], int, int)
- */
- public TransportResult oldApiCheckStateBeforeInput(int inputLength)
- {
- _lastTransportResult.checkIsOk();
- if(inputLength == 0)
- {
- if(_connectionEndpoint == null || _connectionEndpoint.getRemoteState() != EndpointState.CLOSED)
- {
- return TransportResultFactory.error(new TransportException("Unexpected EOS when remote connection not closed: connection aborted"));
- }
- }
- return TransportResultFactory.ok();
- }
-
- //==================================================================================================================
- // Process model state to generate output
-
- @Override
- public int output(byte[] bytes, final int offset, final int size)
- {
- ByteBuffer outputBuffer = getOutputBuffer();
- int numberOfBytesOutput = pourBufferToArray(outputBuffer, bytes, offset, size);
- outputConsumed();
- return numberOfBytesOutput;
- }
-
- @Override
- public boolean writeInto(ByteBuffer outputBuffer)
- {
- processHeader();
- processOpen();
- processBegin();
- processAttach();
- processReceiverFlow();
- // we process transport work twice intentionally, the first
- // pass may end up settling deliveries that the second pass
- // can clean up
- processTransportWork();
- processTransportWork();
- processSenderFlow();
- processDetach();
- processEnd();
- processClose();
-
- _frameWriter.readBytes(outputBuffer);
-
- return _isCloseSent || _head_closed;
- }
-
- @Override
- public Sasl sasl()
- {
- if(_sasl == null)
- {
- if(_processingStarted)
- {
- throw new IllegalStateException("Sasl can't be initiated after transport has started processing");
- }
-
- init();
- _sasl = new SaslImpl(this, _remoteMaxFrameSize);
- TransportWrapper transportWrapper = _sasl.wrap(_inputProcessor, _outputProcessor);
- _inputProcessor = transportWrapper;
- _outputProcessor = transportWrapper;
- }
- return _sasl;
-
- }
-
- /**
- * {@inheritDoc}
- *
- * <p>Note that sslDomain must implement {@link org.apache.qpid.proton.engine.impl.ssl.ProtonSslEngineProvider}.
- * This is not possible enforce at the API level because {@link org.apache.qpid.proton.engine.impl.ssl.ProtonSslEngineProvider} is not part of the
- * public Proton API.</p>
- */
- @Override
- public Ssl ssl(SslDomain sslDomain, SslPeerDetails sslPeerDetails)
- {
- if (_ssl == null)
- {
- init();
- _ssl = new SslImpl(sslDomain, sslPeerDetails);
- TransportWrapper transportWrapper = _ssl.wrap(_inputProcessor, _outputProcessor);
- _inputProcessor = transportWrapper;
- _outputProcessor = transportWrapper;
- }
- return _ssl;
- }
-
- @Override
- public Ssl ssl(SslDomain sslDomain)
- {
- return ssl(sslDomain, null);
- }
-
- private void processDetach()
- {
- if(_connectionEndpoint != null && _isOpenSent)
- {
- EndpointImpl endpoint = _connectionEndpoint.getTransportHead();
- while(endpoint != null)
- {
-
- if(endpoint instanceof LinkImpl)
- {
- LinkImpl link = (LinkImpl) endpoint;
- TransportLink<?> transportLink = getTransportState(link);
- SessionImpl session = link.getSession();
- TransportSession transportSession = getTransportState(session);
-
- if(((link.getLocalState() == EndpointState.CLOSED) || link.detached())
- && transportLink.isLocalHandleSet()
- && transportSession.isLocalChannelSet()
- && !_isCloseSent)
- {
- if((link instanceof SenderImpl)
- && link.getQueued() > 0
- && !transportLink.detachReceived()
- && !transportSession.endReceived()
- && !_closeReceived) {
- endpoint = endpoint.transportNext();
- continue;
- }
-
- UnsignedInteger localHandle = transportLink.getLocalHandle();
- transportLink.clearLocalHandle();
- transportSession.freeLocalHandle(localHandle);
-
-
- Detach detach = new Detach();
- detach.setHandle(localHandle);
- detach.setClosed(!link.detached());
-
- ErrorCondition localError = link.getCondition();
- if( localError.getCondition() !=null )
- {
- detach.setError(localError);
- }
-
-
- writeFrame(transportSession.getLocalChannel(), detach, null, null);
- }
-
- endpoint.clearModified();
-
- }
- endpoint = endpoint.transportNext();
- }
- }
- }
-
- private void writeFlow(TransportSession ssn, TransportLink link)
- {
- Flow flow = new Flow();
- flow.setNextIncomingId(ssn.getNextIncomingId());
- flow.setNextOutgoingId(ssn.getNextOutgoingId());
- ssn.updateIncomingWindow();
- flow.setIncomingWindow(ssn.getIncomingWindowSize());
- flow.setOutgoingWindow(ssn.getOutgoingWindowSize());
- if (link != null) {
- flow.setHandle(link.getLocalHandle());
- flow.setDeliveryCount(link.getDeliveryCount());
- flow.setLinkCredit(link.getLinkCredit());
- flow.setDrain(link.getLink().getDrain());
- }
- writeFrame(ssn.getLocalChannel(), flow, null, null);
- }
-
- private void processSenderFlow()
- {
- if(_connectionEndpoint != null && _isOpenSent && !_isCloseSent)
- {
- EndpointImpl endpoint = _connectionEndpoint.getTransportHead();
- while(endpoint != null)
- {
-
- if(endpoint instanceof SenderImpl)
- {
- SenderImpl sender = (SenderImpl) endpoint;
- if(sender.getDrain() && sender.getDrained() > 0)
- {
- TransportSender transportLink = sender.getTransportLink();
- TransportSession transportSession = sender.getSession().getTransportSession();
- UnsignedInteger credits = transportLink.getLinkCredit();
- transportLink.setLinkCredit(UnsignedInteger.ZERO);
- transportLink.setDeliveryCount(transportLink.getDeliveryCount().add(credits));
- sender.setDrained(0);
-
- writeFlow(transportSession, transportLink);
- }
-
- }
-
- endpoint = endpoint.transportNext();
- }
- }
- }
-
- private void processTransportWork()
- {
- if(_connectionEndpoint != null && _isOpenSent && !_isCloseSent)
- {
- DeliveryImpl delivery = _connectionEndpoint.getTransportWorkHead();
- while(delivery != null)
- {
- LinkImpl link = delivery.getLink();
- if (link instanceof SenderImpl) {
- if (processTransportWorkSender(delivery, (SenderImpl) link)) {
- delivery = delivery.clearTransportWork();
- } else {
- delivery = delivery.getTransportWorkNext();
- }
- } else {
- if (processTransportWorkReceiver(delivery, (ReceiverImpl) link)) {
- delivery = delivery.clearTransportWork();
- } else {
- delivery = delivery.getTransportWorkNext();
- }
- }
- }
- }
- }
-
- private boolean processTransportWorkSender(DeliveryImpl delivery,
- SenderImpl snd)
- {
- TransportSender tpLink = snd.getTransportLink();
- SessionImpl session = snd.getSession();
- TransportSession tpSession = session.getTransportSession();
-
- boolean wasDone = delivery.isDone();
-
- if(!delivery.isDone() &&
- (delivery.getDataLength() > 0 || delivery != snd.current()) &&
- tpSession.hasOutgoingCredit() && tpLink.hasCredit() &&
- tpSession.isLocalChannelSet() &&
- tpLink.getLocalHandle() != null && !_frameWriter.isFull())
- {
- DeliveryImpl inProgress = tpLink.getInProgressDelivery();
- if(inProgress != null){
- // There is an existing Delivery awaiting completion. Check it
- // is the same Delivery object given and return if not, as we
- // can't interleave Transfer frames for deliveries on a link.
- if(inProgress != delivery) {
- return false;
- }
- }
-
- UnsignedInteger deliveryId = tpSession.getOutgoingDeliveryId();
- TransportDelivery tpDelivery = new TransportDelivery(deliveryId, delivery, tpLink);
- delivery.setTransportDelivery(tpDelivery);
-
- final Transfer transfer = new Transfer();
- transfer.setDeliveryId(deliveryId);
- transfer.setDeliveryTag(new Binary(delivery.getTag()));
- transfer.setHandle(tpLink.getLocalHandle());
-
- if(delivery.getLocalState() != null)
- {
- transfer.setState(delivery.getLocalState());
- }
-
- if(delivery.isSettled())
- {
- transfer.setSettled(Boolean.TRUE);
- }
- else
- {
- tpSession.addUnsettledOutgoing(deliveryId, delivery);
- }
-
- if(snd.current() == delivery)
- {
- transfer.setMore(true);
- }
-
- int messageFormat = delivery.getMessageFormat();
- if(messageFormat == DeliveryImpl.DEFAULT_MESSAGE_FORMAT) {
- transfer.setMessageFormat(UnsignedInteger.ZERO);
- } else {
- transfer.setMessageFormat(UnsignedInteger.valueOf(messageFormat));
- }
-
- ByteBuffer payload = delivery.getData() == null ? null :
- ByteBuffer.wrap(delivery.getData(), delivery.getDataOffset(),
- delivery.getDataLength());
-
- writeFrame(tpSession.getLocalChannel(), transfer, payload,
- new PartialTransfer(transfer));
- tpSession.incrementOutgoingId();
- tpSession.decrementRemoteIncomingWindow();
-
- if(payload == null || !payload.hasRemaining())
- {
- session.incrementOutgoingBytes(-delivery.pending());
- delivery.setData(null);
- delivery.setDataLength(0);
-
- if (!transfer.getMore()) {
- // Clear the in-progress delivery marker
- tpLink.setInProgressDelivery(null);
-
- delivery.setDone();
- tpLink.setDeliveryCount(tpLink.getDeliveryCount().add(UnsignedInteger.ONE));
- tpLink.setLinkCredit(tpLink.getLinkCredit().subtract(UnsignedInteger.ONE));
- tpSession.incrementOutgoingDeliveryId();
- session.incrementOutgoingDeliveries(-1);
- snd.decrementQueued();
- }
- }
- else
- {
- int delta = delivery.getDataLength() - payload.remaining();
- delivery.setDataOffset(delivery.getDataOffset() + delta);
- delivery.setDataLength(payload.remaining());
- session.incrementOutgoingBytes(-delta);
-
- // Remember the delivery we are still processing
- // the body transfer frames for
- tpLink.setInProgressDelivery(delivery);
- }
-
- if (_emitFlowEventOnSend && snd.getLocalState() != EndpointState.CLOSED) {
- getConnectionImpl().put(Event.Type.LINK_FLOW, snd);
- }
- }
-
- if(wasDone && delivery.getLocalState() != null)
- {
- TransportDelivery tpDelivery = delivery.getTransportDelivery();
- Disposition disposition = new Disposition();
- disposition.setFirst(tpDelivery.getDeliveryId());
- disposition.setLast(tpDelivery.getDeliveryId());
- disposition.setRole(Role.SENDER);
- disposition.setSettled(delivery.isSettled());
- if(delivery.isSettled())
- {
- tpDelivery.settled();
- }
- disposition.setState(delivery.getLocalState());
-
- writeFrame(tpSession.getLocalChannel(), disposition, null,
- null);
- }
-
- return !delivery.isBuffered();
- }
-
- private boolean processTransportWorkReceiver(DeliveryImpl delivery,
- ReceiverImpl rcv)
- {
- TransportDelivery tpDelivery = delivery.getTransportDelivery();
- SessionImpl session = rcv.getSession();
- TransportSession tpSession = session.getTransportSession();
-
- if (tpSession.isLocalChannelSet())
- {
- boolean settled = delivery.isSettled();
- DeliveryState localState = delivery.getLocalState();
-
- Disposition disposition = new Disposition();
- disposition.setFirst(tpDelivery.getDeliveryId());
- disposition.setLast(tpDelivery.getDeliveryId());
- disposition.setRole(Role.RECEIVER);
- disposition.setSettled(settled);
- disposition.setState(localState);
-
- if(localState == null && settled) {
- disposition.setState(delivery.getDefaultDeliveryState());
- }
-
- writeFrame(tpSession.getLocalChannel(), disposition, null, null);
- if (settled)
- {
- tpDelivery.settled();
- }
- return true;
- }
-
- return false;
- }
-
- private void processReceiverFlow()
- {
- if(_connectionEndpoint != null && _isOpenSent && !_isCloseSent)
- {
- EndpointImpl endpoint = _connectionEndpoint.getTransportHead();
- while(endpoint != null)
- {
- if(endpoint instanceof ReceiverImpl)
- {
- ReceiverImpl receiver = (ReceiverImpl) endpoint;
- TransportLink<?> transportLink = getTransportState(receiver);
- TransportSession transportSession = getTransportState(receiver.getSession());
-
- if(receiver.getLocalState() == EndpointState.ACTIVE && transportSession.isLocalChannelSet() && !receiver.detached())
- {
- int credits = receiver.clearUnsentCredits();
- if(credits != 0 || receiver.getDrain() ||
- transportSession.getIncomingWindowSize().equals(UnsignedInteger.ZERO))
- {
- transportLink.addCredit(credits);
- writeFlow(transportSession, transportLink);
- }
- }
- }
- endpoint = endpoint.transportNext();
- }
- endpoint = _connectionEndpoint.getTransportHead();
- while(endpoint != null)
- {
- if(endpoint instanceof SessionImpl)
- {
-
- SessionImpl session = (SessionImpl) endpoint;
- TransportSession transportSession = getTransportState(session);
-
- if(session.getLocalState() == EndpointState.ACTIVE && transportSession.isLocalChannelSet())
- {
- if(transportSession.getIncomingWindowSize().equals(UnsignedInteger.ZERO))
- {
- writeFlow(transportSession, null);
- }
- }
- }
- endpoint = endpoint.transportNext();
- }
- }
- }
-
- private void processAttach()
- {
- if(_connectionEndpoint != null && _isOpenSent && !_isCloseSent)
- {
- EndpointImpl endpoint = _connectionEndpoint.getTransportHead();
-
- while(endpoint != null)
- {
- if(endpoint instanceof LinkImpl)
- {
-
- LinkImpl link = (LinkImpl) endpoint;
- TransportLink<?> transportLink = getTransportState(link);
- SessionImpl session = link.getSession();
- TransportSession transportSession = getTransportState(session);
- if(link.getLocalState() != EndpointState.UNINITIALIZED && !transportLink.attachSent() && transportSession.isLocalChannelSet())
- {
-
- if( (link.getRemoteState() == EndpointState.ACTIVE
- && !transportLink.isLocalHandleSet()) || link.getRemoteState() == EndpointState.UNINITIALIZED)
- {
-
- UnsignedInteger localHandle = transportSession.allocateLocalHandle(transportLink);
-
- if(link.getRemoteState() == EndpointState.UNINITIALIZED)
- {
- transportSession.addHalfOpenLink(transportLink);
- }
-
- Attach attach = new Attach();
- attach.setHandle(localHandle);
- attach.setName(transportLink.getName());
-
- if(link.getSenderSettleMode() != null)
- {
- attach.setSndSettleMode(link.getSenderSettleMode());
- }
-
- if(link.getReceiverSettleMode() != null)
- {
- attach.setRcvSettleMode(link.getReceiverSettleMode());
- }
-
- if(link.getSource() != null)
- {
- attach.setSource(link.getSource());
- }
-
- if(link.getTarget() != null)
- {
- attach.setTarget(link.getTarget());
- }
-
- if(link.getProperties() != null)
- {
- attach.setProperties(link.getProperties());
- }
-
- if(link.getOfferedCapabilities() != null)
- {
- attach.setOfferedCapabilities(link.getOfferedCapabilities());
- }
-
- if(link.getDesiredCapabilities() != null)
- {
- attach.setDesiredCapabilities(link.getDesiredCapabilities());
- }
-
- attach.setRole(endpoint instanceof ReceiverImpl ? Role.RECEIVER : Role.SENDER);
-
- if(link instanceof SenderImpl)
- {
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- }
-
- writeFrame(transportSession.getLocalChannel(), attach, null, null);
- transportLink.sentAttach();
- }
- }
- }
- endpoint = endpoint.transportNext();
- }
- }
- }
-
- private void processHeader()
- {
- if(!_headerWritten)
- {
- _frameWriter.writeHeader(AmqpHeader.HEADER);
- _headerWritten = true;
- }
- }
-
- private void processOpen()
- {
- if (!_isOpenSent && (_condition != null ||
- (_connectionEndpoint != null &&
- _connectionEndpoint.getLocalState() != EndpointState.UNINITIALIZED)))
- {
- Open open = new Open();
- if (_connectionEndpoint != null) {
- String cid = _connectionEndpoint.getLocalContainerId();
- open.setContainerId(cid == null ? "" : cid);
- open.setHostname(_connectionEndpoint.getHostname());
- open.setDesiredCapabilities(_connectionEndpoint.getDesiredCapabilities());
- open.setOfferedCapabilities(_connectionEndpoint.getOfferedCapabilities());
- open.setProperties(_connectionEndpoint.getProperties());
- } else {
- open.setContainerId("");
- }
-
- if (_maxFrameSize > 0) {
- open.setMaxFrameSize(UnsignedInteger.valueOf(_maxFrameSize));
- }
- if (_channelMax > 0) {
- open.setChannelMax(UnsignedShort.valueOf((short) _channelMax));
- }
-
- // as per the recommendation in the spec, advertise half our
- // actual timeout to the remote
- if (_localIdleTimeout > 0) {
- open.setIdleTimeOut(new UnsignedInteger(_localIdleTimeout / 2));
- }
- _isOpenSent = true;
-
- writeFrame(0, open, null, null);
- }
- }
-
- private void processBegin()
- {
- if(_connectionEndpoint != null && _isOpenSent && !_isCloseSent)
- {
- EndpointImpl endpoint = _connectionEndpoint.getTransportHead();
- while(endpoint != null)
- {
- if(endpoint instanceof SessionImpl)
- {
- SessionImpl session = (SessionImpl) endpoint;
- TransportSession transportSession = getTransportState(session);
- if(session.getLocalState() != EndpointState.UNINITIALIZED && !transportSession.beginSent())
- {
- int channelId = allocateLocalChannel(transportSession);
- Begin begin = new Begin();
-
- if(session.getRemoteState() != EndpointState.UNINITIALIZED)
- {
- begin.setRemoteChannel(UnsignedShort.valueOf((short) transportSession.getRemoteChannel()));
- }
-
- transportSession.updateIncomingWindow();
-
- begin.setHandleMax(transportSession.getHandleMax());
- begin.setIncomingWindow(transportSession.getIncomingWindowSize());
- begin.setOutgoingWindow(transportSession.getOutgoingWindowSize());
- begin.setNextOutgoingId(transportSession.getNextOutgoingId());
-
- if(session.getProperties() != null)
- {
- begin.setProperties(session.getProperties());
- }
-
- if(session.getOfferedCapabilities() != null)
- {
- begin.setOfferedCapabilities(session.getOfferedCapabilities());
- }
-
- if(session.getDesiredCapabilities() != null)
- {
- begin.setDesiredCapabilities(session.getDesiredCapabilities());
- }
-
- writeFrame(channelId, begin, null, null);
- transportSession.sentBegin();
- }
- }
- endpoint = endpoint.transportNext();
- }
- }
- }
-
- private TransportSession getTransportState(SessionImpl session)
- {
- TransportSession transportSession = session.getTransportSession();
- if(transportSession == null)
- {
- transportSession = new TransportSession(this, session);
- session.setTransportSession(transportSession);
- }
- return transportSession;
- }
-
- private TransportLink<?> getTransportState(LinkImpl link)
- {
- TransportLink<?> transportLink = link.getTransportLink();
- if(transportLink == null)
- {
- transportLink = TransportLink.createTransportLink(link);
- }
- return transportLink;
- }
-
- private int allocateLocalChannel(TransportSession transportSession)
- {
- for (int i = 0; i < _connectionEndpoint.getMaxChannels(); i++)
- {
- if (!_localSessions.containsKey(i))
- {
- _localSessions.put(i, transportSession);
- transportSession.setLocalChannel(i);
- return i;
- }
- }
-
- return -1;
- }
-
- private int freeLocalChannel(TransportSession transportSession)
- {
- final int channel = transportSession.getLocalChannel();
- _localSessions.remove(channel);
- transportSession.freeLocalChannel();
- return channel;
- }
-
- private void processEnd()
- {
- if(_connectionEndpoint != null && _isOpenSent)
- {
- EndpointImpl endpoint = _connectionEndpoint.getTransportHead();
- while(endpoint != null)
- {
- SessionImpl session;
- TransportSession transportSession;
-
- if((endpoint instanceof SessionImpl)) {
- if ((session = (SessionImpl)endpoint).getLocalState() == EndpointState.CLOSED
- && (transportSession = session.getTransportSession()).isLocalChannelSet()
- && !_isCloseSent)
- {
- if (hasSendableMessages(session)) {
- endpoint = endpoint.transportNext();
- continue;
- }
-
- int channel = freeLocalChannel(transportSession);
- End end = new End();
- ErrorCondition localError = endpoint.getCondition();
- if( localError.getCondition() !=null )
- {
- end.setError(localError);
- }
-
- writeFrame(channel, end, null, null);
- }
-
- endpoint.clearModified();
- }
-
- endpoint = endpoint.transportNext();
- }
- }
- }
-
- private boolean hasSendableMessages(SessionImpl session)
- {
- if (_connectionEndpoint == null) {
- return false;
- }
-
- if(!_closeReceived && (session == null || !session.getTransportSession().endReceived()))
- {
- EndpointImpl endpoint = _connectionEndpoint.getTransportHead();
- while(endpoint != null)
- {
- if(endpoint instanceof SenderImpl)
- {
- SenderImpl sender = (SenderImpl) endpoint;
- if((session == null || sender.getSession() == session)
- && sender.getQueued() != 0
- && !getTransportState(sender).detachReceived())
- {
- return true;
- }
- }
- endpoint = endpoint.transportNext();
- }
- }
- return false;
- }
-
- private void processClose()
- {
- if ((_condition != null ||
- (_connectionEndpoint != null &&
- _connectionEndpoint.getLocalState() == EndpointState.CLOSED)) &&
- !_isCloseSent) {
- if(!hasSendableMessages(null))
- {
- Close close = new Close();
-
- ErrorCondition localError;
-
- if (_connectionEndpoint == null) {
- localError = _condition;
- } else {
- localError = _connectionEndpoint.getCondition();
- }
-
- if(localError.getCondition() != null)
- {
- close.setError(localError);
- }
-
- _isCloseSent = true;
-
- writeFrame(0, close, null, null);
-
- if (_connectionEndpoint != null) {
- _connectionEndpoint.clearModified();
- }
- }
- }
- }
-
- protected void writeFrame(int channel, FrameBody frameBody,
- ByteBuffer payload, Runnable onPayloadTooLarge)
- {
- _frameWriter.writeFrame(channel, frameBody, payload, onPayloadTooLarge);
- }
-
- //==================================================================================================================
-
- @Override
- protected ConnectionImpl getConnectionImpl()
- {
- return _connectionEndpoint;
- }
-
- @Override
- void postFinal() {}
-
- @Override
- void doFree() { }
-
- //==================================================================================================================
- // handle incoming amqp data
-
-
- @Override
- public void handleOpen(Open open, Binary payload, Integer channel)
- {
- setRemoteState(EndpointState.ACTIVE);
- if(_connectionEndpoint != null)
- {
- _connectionEndpoint.handleOpen(open);
- }
- else
- {
- _open = open;
- }
-
- if(open.getMaxFrameSize().longValue() > 0)
- {
- _remoteMaxFrameSize = (int) open.getMaxFrameSize().longValue();
- _frameWriter.setMaxFrameSize(_remoteMaxFrameSize);
- }
-
- if (open.getChannelMax().longValue() > 0)
- {
- _remoteChannelMax = (int) open.getChannelMax().longValue();
- }
-
- if (open.getIdleTimeOut() != null && open.getIdleTimeOut().longValue() > 0)
- {
- _remoteIdleTimeout = open.getIdleTimeOut().intValue();
- }
- }
-
- @Override
- public void handleBegin(Begin begin, Binary payload, Integer channel)
- {
- // TODO - check channel < max_channel
- TransportSession transportSession = _remoteSessions.get(channel);
- if(transportSession != null)
- {
- // TODO - fail due to begin on begun session
- }
- else
- {
- SessionImpl session;
- if(begin.getRemoteChannel() == null)
- {
- session = _connectionEndpoint.session();
- transportSession = getTransportState(session);
- }
- else
- {
- transportSession = _localSessions.get(begin.getRemoteChannel().intValue());
- if (transportSession == null) {
- // TODO handle failure rather than just throwing a nicer NPE
- throw new NullPointerException("uncorrelated channel: " + begin.getRemoteChannel());
- }
- session = transportSession.getSession();
-
- }
- transportSession.setRemoteChannel(channel);
- session.setRemoteState(EndpointState.ACTIVE);
- transportSession.setNextIncomingId(begin.getNextOutgoingId());
- session.setRemoteProperties(begin.getProperties());
- session.setRemoteDesiredCapabilities(begin.getDesiredCapabilities());
- session.setRemoteOfferedCapabilities(begin.getOfferedCapabilities());
-
- _remoteSessions.put(channel, transportSession);
-
- _connectionEndpoint.put(Event.Type.SESSION_REMOTE_OPEN, session);
- }
-
- }
-
- @Override
- public void handleAttach(Attach attach, Binary payload, Integer channel)
- {
- TransportSession transportSession = _remoteSessions.get(channel);
- if(transportSession == null)
- {
- // TODO - fail due to attach on non-begun session
- }
- else
- {
- SessionImpl session = transportSession.getSession();
- final UnsignedInteger handle = attach.getHandle();
- if (handle.compareTo(transportSession.getHandleMax()) > 0) {
- // The handle-max value is the highest handle value that can be used on the session. A peer MUST
- // NOT attempt to attach a link using a handle value outside the range that its partner can handle.
- // A peer that receives a handle outside the supported range MUST close the connection with the
- // framing-error error-code.
- ErrorCondition condition =
- new ErrorCondition(ConnectionError.FRAMING_ERROR,
- "handle-max exceeded");
- _connectionEndpoint.setCondition(condition);
- _connectionEndpoint.setLocalState(EndpointState.CLOSED);
- if (!_isCloseSent) {
- Close close = new Close();
- close.setError(condition);
- _isCloseSent = true;
- writeFrame(0, close, null, null);
- }
- close_tail();
- return;
- }
- TransportLink<?> transportLink = transportSession.getLinkFromRemoteHandle(handle);
- LinkImpl link = null;
-
- if(transportLink != null)
- {
- // TODO - fail - attempt attach on a handle which is in use
- }
- else
- {
- transportLink = transportSession.resolveHalfOpenLink(attach.getName());
- if(transportLink == null)
- {
-
- link = (attach.getRole() == Role.RECEIVER)
- ? session.sender(attach.getName())
- : session.receiver(attach.getName());
- transportLink = getTransportState(link);
- }
- else
- {
- link = transportLink.getLink();
- }
- if(attach.getRole() == Role.SENDER)
- {
- transportLink.setDeliveryCount(attach.getInitialDeliveryCount());
- }
-
- link.setRemoteState(EndpointState.ACTIVE);
- link.setRemoteSource(attach.getSource());
- link.setRemoteTarget(attach.getTarget());
-
- link.setRemoteReceiverSettleMode(attach.getRcvSettleMode());
- link.setRemoteSenderSettleMode(attach.getSndSettleMode());
-
- link.setRemoteProperties(attach.getProperties());
-
- link.setRemoteDesiredCapabilities(attach.getDesiredCapabilities());
- link.setRemoteOfferedCapabilities(attach.getOfferedCapabilities());
-
- transportLink.setName(attach.getName());
- transportLink.setRemoteHandle(handle);
- transportSession.addLinkRemoteHandle(transportLink, handle);
-
- }
-
- _connectionEndpoint.put(Event.Type.LINK_REMOTE_OPEN, link);
- }
- }
-
- @Override
- public void handleFlow(Flow flow, Binary payload, Integer channel)
- {
- TransportSession transportSession = _remoteSessions.get(channel);
- if(transportSession == null)
- {
- // TODO - fail due to attach on non-begun session
- }
- else
- {
- transportSession.handleFlow(flow);
- }
-
- }
-
- @Override
- public void handleTransfer(Transfer transfer, Binary payload, Integer channel)
- {
- // TODO - check channel < max_channel
- TransportSession transportSession = _remoteSessions.get(channel);
- if(transportSession != null)
- {
- transportSession.handleTransfer(transfer, payload);
- }
- else
- {
- // TODO - fail due to begin on begun session
- }
- }
-
- @Override
- public void handleDisposition(Disposition disposition, Binary payload, Integer channel)
- {
- TransportSession transportSession = _remoteSessions.get(channel);
- if(transportSession == null)
- {
- // TODO - fail due to attach on non-begun session
- }
- else
- {
- transportSession.handleDisposition(disposition);
- }
- }
-
- @Override
- public void handleDetach(Detach detach, Binary payload, Integer channel)
- {
- TransportSession transportSession = _remoteSessions.get(channel);
- if(transportSession == null)
- {
- // TODO - fail due to attach on non-begun session
- }
- else
- {
- TransportLink<?> transportLink = transportSession.getLinkFromRemoteHandle(detach.getHandle());
-
- if(transportLink != null)
- {
- LinkImpl link = transportLink.getLink();
- transportLink.receivedDetach();
- transportSession.freeRemoteHandle(transportLink.getRemoteHandle());
- if (detach.getClosed()) {
- _connectionEndpoint.put(Event.Type.LINK_REMOTE_CLOSE, link);
- } else {
- _connectionEndpoint.put(Event.Type.LINK_REMOTE_DETACH, link);
- }
- transportLink.clearRemoteHandle();
- link.setRemoteState(EndpointState.CLOSED);
- if(detach.getError() != null)
- {
- link.getRemoteCondition().copyFrom(detach.getError());
- }
- }
- else
- {
- // TODO - fail - attempt attach on a handle which is in use
- }
- }
- }
-
- @Override
- public void handleEnd(End end, Binary payload, Integer channel)
- {
- TransportSession transportSession = _remoteSessions.get(channel);
- if(transportSession == null)
- {
- // TODO - fail due to attach on non-begun session
- }
- else
- {
- _remoteSessions.remove(channel);
- transportSession.receivedEnd();
- transportSession.unsetRemoteChannel();
- SessionImpl session = transportSession.getSession();
- session.setRemoteState(EndpointState.CLOSED);
- ErrorCondition errorCondition = end.getError();
- if(errorCondition != null)
- {
- session.getRemoteCondition().copyFrom(errorCondition);
- }
-
- _connectionEndpoint.put(Event.Type.SESSION_REMOTE_CLOSE, session);
- }
- }
-
- @Override
- public void handleClose(Close close, Binary payload, Integer channel)
- {
- _closeReceived = true;
- _remoteIdleTimeout = 0;
- setRemoteState(EndpointState.CLOSED);
- if(_connectionEndpoint != null)
- {
- _connectionEndpoint.setRemoteState(EndpointState.CLOSED);
- if(close.getError() != null)
- {
- _connectionEndpoint.getRemoteCondition().copyFrom(close.getError());
- }
-
- _connectionEndpoint.put(Event.Type.CONNECTION_REMOTE_CLOSE, _connectionEndpoint);
- }
-
- }
-
- @Override
- public boolean handleFrame(TransportFrame frame)
- {
- if (!isHandlingFrames())
- {
- throw new IllegalStateException("Transport cannot accept frame: " + frame);
- }
-
- log(INCOMING, frame);
-
- ProtocolTracer tracer = _protocolTracer.get();
- if( tracer != null )
- {
- tracer.receivedFrame(frame);
- }
-
- frame.getBody().invoke(this,frame.getPayload(), frame.getChannel());
- return _closeReceived;
- }
-
- void put(Event.Type type, Object context) {
- if (_connectionEndpoint != null) {
- _connectionEndpoint.put(type, context);
- }
- }
-
- private void maybePostClosed()
- {
- if (postedHeadClosed && postedTailClosed) {
- put(Event.Type.TRANSPORT_CLOSED, this);
- }
- }
-
- @Override
- public void closed(TransportException error)
- {
- if (!_closeReceived || error != null) {
- if (error == null) {
- _condition = new ErrorCondition(ConnectionError.FRAMING_ERROR,
- "connection aborted");
- } else {
- _condition = new ErrorCondition(ConnectionError.FRAMING_ERROR,
- error.toString());
- }
- _head_closed = true;
- }
- if (_condition != null && !postedTransportError) {
- put(Event.Type.TRANSPORT_ERROR, this);
- postedTransportError = true;
- }
- if (!postedTailClosed) {
- put(Event.Type.TRANSPORT_TAIL_CLOSED, this);
- postedTailClosed = true;
- maybePostClosed();
- }
- }
-
- @Override
- public boolean isHandlingFrames()
- {
- return _connectionEndpoint != null || getRemoteState() == EndpointState.UNINITIALIZED;
- }
-
- @Override
- public ProtocolTracer getProtocolTracer()
- {
- return _protocolTracer.get();
- }
-
- @Override
- public void setProtocolTracer(ProtocolTracer protocolTracer)
- {
- this._protocolTracer.set(protocolTracer);
- }
-
- @Override
- public ByteBuffer getInputBuffer()
- {
- return tail();
- }
-
- @Override
- public TransportResult processInput()
- {
- try {
- process();
- return TransportResultFactory.ok();
- } catch (TransportException e) {
- return TransportResultFactory.error(e);
- }
- }
-
- @Override
- public ByteBuffer getOutputBuffer()
- {
- pending();
- return head();
- }
-
- @Override
- public void outputConsumed()
- {
- pop(_outputProcessor.head().position());
- }
-
- @Override
- public int capacity()
- {
- init();
- return _inputProcessor.capacity();
- }
-
- @Override
- public ByteBuffer tail()
- {
- init();
- return _inputProcessor.tail();
- }
-
- @Override
- public void process() throws TransportException
- {
- _processingStarted = true;
-
- try {
- init();
- int beforePosition = _inputProcessor.position();
- _inputProcessor.process();
- _bytesInput += beforePosition - _inputProcessor.position();
- } catch (TransportException e) {
- _head_closed = true;
- throw e;
- }
- }
-
- @Override
- public void close_tail()
- {
- init();
- _inputProcessor.close_tail();
- }
-
- @Override
- public int pending()
- {
- init();
- return _outputProcessor.pending();
- }
-
- @Override
- public ByteBuffer head()
- {
- init();
- return _outputProcessor.head();
- }
-
- @Override
- public void pop(int bytes)
- {
- init();
- _outputProcessor.pop(bytes);
- _bytesOutput += bytes;
-
- int p = pending();
- if (p < 0 && !postedHeadClosed) {
- put(Event.Type.TRANSPORT_HEAD_CLOSED, this);
- postedHeadClosed = true;
- maybePostClosed();
- }
- }
-
- @Override
- public void setIdleTimeout(int timeout) {
- _localIdleTimeout = timeout;
- }
-
- @Override
- public int getIdleTimeout() {
- return _localIdleTimeout;
- }
-
- @Override
- public int getRemoteIdleTimeout() {
- return _remoteIdleTimeout;
- }
-
- @Override
- public long tick(long now)
- {
- long timeout = 0;
-
- if (_localIdleTimeout > 0) {
- if (_localIdleDeadline == 0 || _lastBytesInput != _bytesInput) {
- _localIdleDeadline = now + _localIdleTimeout;
- _lastBytesInput = _bytesInput;
- } else if (_localIdleDeadline <= now) {
- _localIdleDeadline = now + _localIdleTimeout;
-
- if (_connectionEndpoint != null &&
- _connectionEndpoint.getLocalState() != EndpointState.CLOSED) {
- ErrorCondition condition =
- new ErrorCondition(Symbol.getSymbol("amqp:resource-limit-exceeded"),
- "local-idle-timeout expired");
- _connectionEndpoint.setCondition(condition);
- _connectionEndpoint.setLocalState(EndpointState.CLOSED);
-
- if (!_isOpenSent) {
- if ((_sasl != null) && (!_sasl.isDone())) {
- _sasl.fail();
- }
- Open open = new Open();
- _isOpenSent = true;
- writeFrame(0, open, null, null);
- }
- if (!_isCloseSent) {
- Close close = new Close();
- close.setError(condition);
- _isCloseSent = true;
- writeFrame(0, close, null, null);
- }
- close_tail();
- }
- }
- timeout = _localIdleDeadline;
- }
-
- if (_remoteIdleTimeout != 0 && !_isCloseSent) {
- if (_remoteIdleDeadline == 0 || _lastBytesOutput != _bytesOutput) {
- _remoteIdleDeadline = now + (_remoteIdleTimeout / 2);
- _lastBytesOutput = _bytesOutput;
- } else if (_remoteIdleDeadline <= now) {
- _remoteIdleDeadline = now + (_remoteIdleTimeout / 2);
- if (pending() == 0) {
- writeFrame(0, null, null, null);
- _lastBytesOutput += pending();
- }
- }
- timeout = Math.min(timeout == 0 ? _remoteIdleDeadline : timeout, _remoteIdleDeadline);
- }
-
- return timeout;
- }
-
- @Override
- public long getFramesOutput()
- {
- return _frameWriter.getFramesOutput();
- }
-
- @Override
- public long getFramesInput()
- {
- return _frameParser.getFramesInput();
- }
-
- @Override
- public void close_head()
- {
- _outputProcessor.close_head();
- }
-
- @Override
- public boolean isClosed() {
- int p = pending();
- int c = capacity();
- return p == END_OF_STREAM && c == END_OF_STREAM;
- }
-
- @Override
- public String toString()
- {
- return "TransportImpl [_connectionEndpoint=" + _connectionEndpoint + ", " + super.toString() + "]";
- }
-
- private static class PartialTransfer implements Runnable
- {
- private final Transfer _transfer;
-
- public PartialTransfer(Transfer transfer)
- {
- _transfer = transfer;
- }
-
- @Override
- public void run()
- {
- _transfer.setMore(true);
- }
- }
-
- /**
- * Override the default frame handler. Must be called before the transport starts being used
- * (e.g. {@link #getInputBuffer()}, {@link #getOutputBuffer()}, {@link #ssl(SslDomain)} etc).
- */
- public void setFrameHandler(FrameHandler frameHandler)
- {
- _frameHandler = frameHandler;
- }
-
- static String INCOMING = "<-";
- static String OUTGOING = "->";
-
- void log(String event, TransportFrame frame)
- {
- if (isTraceFramesEnabled()) {
- StringBuilder msg = new StringBuilder();
- msg.append("[").append(System.identityHashCode(this)).append(":")
- .append(frame.getChannel()).append("]");
- msg.append(" ").append(event).append(" ").append(frame.getBody());
-
- Binary bin = frame.getPayload();
- if (bin != null) {
- msg.append(" (").append(bin.getLength()).append(") ");
- msg.append(StringUtils.toQuotedString(bin, TRACE_FRAME_PAYLOAD_LENGTH, true));
- }
- System.out.println(msg.toString());
- }
- }
-
- boolean isTraceFramesEnabled()
- {
- return (_levels & TRACE_FRM) != 0;
- }
-
- @Override
- void localOpen() {}
-
- @Override
- void localClose() {}
-
- public void setSelectable(Selectable selectable) {
- _selectable = selectable;
- }
-
- public Selectable getSelectable() {
- return _selectable;
- }
-
- public void setReactor(Reactor reactor) {
- _reactor = reactor;
- }
-
- public Reactor getReactor() {
- return _reactor;
- }
-
- @Override
- public void setEmitFlowEventOnSend(boolean emitFlowEventOnSend)
- {
- _emitFlowEventOnSend = emitFlowEventOnSend;
- }
-
- @Override
- public boolean isEmitFlowEventOnSend()
- {
- return _emitFlowEventOnSend;
- }
-
- // From TransportInternal
- @Override
- public void addTransportLayer(TransportLayer layer)
- {
- if (_processingStarted)
- {
- throw new IllegalStateException("Additional layer can't be added after transport has started processing");
- }
-
- if (_additionalTransportLayers == null)
- {
- _additionalTransportLayers = new ArrayList<TransportLayer>();
- }
-
- if (!_additionalTransportLayers.contains(layer))
- {
- init();
- TransportWrapper transportWrapper = layer.wrap(_inputProcessor, _outputProcessor);
- _inputProcessor = transportWrapper;
- _outputProcessor = transportWrapper;
- _additionalTransportLayers.add(layer);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportInput.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportInput.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportInput.java
deleted file mode 100644
index f2699d0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportInput.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.TransportException;
-
-
-public interface TransportInput
-{
-
- int capacity();
-
- int position();
-
- ByteBuffer tail() throws TransportException;
-
- void process() throws TransportException;
-
- void close_tail();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportInternal.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportInternal.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportInternal.java
deleted file mode 100644
index 73b4d44..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportInternal.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.engine.Transport;
-
-/**
- * Extended Transport interface providing access to certain methods intended mainly for internal
- * use, or use in extending implementation details not strictly considered part of the public
- * Transport API.
- */
-public interface TransportInternal extends Transport
-{
- /**
- * Add a {@link TransportLayer} to the transport, wrapping the input and output process handlers
- * in the state they currently exist. No effect if the given layer was previously added.
- *
- * @param layer the layer to add (if it was not previously added)
- * @throws IllegalStateException if processing has already started.
- */
- void addTransportLayer(TransportLayer layer) throws IllegalStateException;
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLayer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLayer.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLayer.java
deleted file mode 100644
index a6cdeb1..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLayer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.engine.impl.TransportInput;
-import org.apache.qpid.proton.engine.impl.TransportOutput;
-import org.apache.qpid.proton.engine.impl.TransportWrapper;
-
-public interface TransportLayer
-{
- public TransportWrapper wrap(TransportInput input, TransportOutput output);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java
deleted file mode 100644
index 836cf71..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.transport.Flow;
-import org.apache.qpid.proton.engine.Event;
-
-class TransportLink<T extends LinkImpl>
-{
- private UnsignedInteger _localHandle;
- private String _name;
- private UnsignedInteger _remoteHandle;
- private UnsignedInteger _deliveryCount;
- private UnsignedInteger _linkCredit = UnsignedInteger.ZERO;
- private T _link;
- private UnsignedInteger _remoteDeliveryCount;
- private UnsignedInteger _remoteLinkCredit;
- private boolean _detachReceived;
- private boolean _attachSent;
-
- protected TransportLink(T link)
- {
- _link = link;
- _name = link.getName();
- }
-
- static <L extends LinkImpl> TransportLink<L> createTransportLink(L link)
- {
- if (link instanceof ReceiverImpl)
- {
- ReceiverImpl r = (ReceiverImpl) link;
- TransportReceiver tr = new TransportReceiver(r);
- r.setTransportLink(tr);
-
- return (TransportLink<L>) tr;
- }
- else
- {
- SenderImpl s = (SenderImpl) link;
- TransportSender ts = new TransportSender(s);
- s.setTransportLink(ts);
-
- return (TransportLink<L>) ts;
- }
- }
-
- void unbind()
- {
- clearLocalHandle();
- clearRemoteHandle();
- }
-
- public UnsignedInteger getLocalHandle()
- {
- return _localHandle;
- }
-
- public void setLocalHandle(UnsignedInteger localHandle)
- {
- if (_localHandle == null) {
- _link.incref();
- }
- _localHandle = localHandle;
- }
-
- public boolean isLocalHandleSet()
- {
- return _localHandle != null;
- }
-
- public String getName()
- {
- return _name;
- }
-
- public void setName(String name)
- {
- _name = name;
- }
-
- public void clearLocalHandle()
- {
- if (_localHandle != null) {
- _link.decref();
- }
- _localHandle = null;
- }
-
- public UnsignedInteger getRemoteHandle()
- {
- return _remoteHandle;
- }
-
- public void setRemoteHandle(UnsignedInteger remoteHandle)
- {
- if (_remoteHandle == null) {
- _link.incref();
- }
- _remoteHandle = remoteHandle;
- }
-
- public void clearRemoteHandle()
- {
- if (_remoteHandle != null) {
- _link.decref();
- }
- _remoteHandle = null;
- }
-
- public UnsignedInteger getDeliveryCount()
- {
- return _deliveryCount;
- }
-
- public UnsignedInteger getLinkCredit()
- {
- return _linkCredit;
- }
-
- public void addCredit(int credits)
- {
- _linkCredit = UnsignedInteger.valueOf(_linkCredit.intValue() + credits);
- }
-
- public boolean hasCredit()
- {
- return getLinkCredit().compareTo(UnsignedInteger.ZERO) > 0;
- }
-
- public T getLink()
- {
- return _link;
- }
-
- void handleFlow(Flow flow)
- {
- _remoteDeliveryCount = flow.getDeliveryCount();
- _remoteLinkCredit = flow.getLinkCredit();
-
-
- _link.getConnectionImpl().put(Event.Type.LINK_FLOW, _link);
- }
-
- void setLinkCredit(UnsignedInteger linkCredit)
- {
- _linkCredit = linkCredit;
- }
-
- public void setDeliveryCount(UnsignedInteger deliveryCount)
- {
- _deliveryCount = deliveryCount;
- }
-
- public void settled(TransportDelivery transportDelivery)
- {
- getLink().getSession().getTransportSession().settled(transportDelivery);
- }
-
-
- UnsignedInteger getRemoteDeliveryCount()
- {
- return _remoteDeliveryCount;
- }
-
- UnsignedInteger getRemoteLinkCredit()
- {
- return _remoteLinkCredit;
- }
-
- public void setRemoteLinkCredit(UnsignedInteger remoteLinkCredit)
- {
- _remoteLinkCredit = remoteLinkCredit;
- }
-
- void decrementLinkCredit()
- {
- _linkCredit = _linkCredit.subtract(UnsignedInteger.ONE);
- }
-
- void incrementDeliveryCount()
- {
- _deliveryCount = _deliveryCount.add(UnsignedInteger.ONE);
- }
-
- public void receivedDetach()
- {
- _detachReceived = true;
- }
-
- public boolean detachReceived()
- {
- return _detachReceived;
- }
-
- public boolean attachSent()
- {
- return _attachSent;
- }
-
- public void sentAttach()
- {
- _attachSent = true;
- }
-
- public void setRemoteDeliveryCount(UnsignedInteger remoteDeliveryCount)
- {
- _remoteDeliveryCount = remoteDeliveryCount;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[30/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/JoinerTest.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/JoinerTest.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/JoinerTest.java
deleted file mode 100644
index 134d4fe..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/JoinerTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import static java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.qpid.proton.apireconciliation.reportwriter.AnnotationAccessor;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JoinerTest
-{
- private static final String C_FUNCTION1 = "cFunction1";
- private static final String C_FUNCTION2 = "cFunction2";
- private Joiner _joiner;
- private Method _method1 = null;
- private Method _method2 = null;
- private Method _methodSharingFunctionNameAnnotationWithMethod2 = null;
- private Method _methodWithoutAnnotation;
-
- @Before
- public void setUp() throws Exception
- {
- _method1 = getClass().getMethod("javaMethodWithMapping1");
- _method2 = getClass().getMethod("javaMethodWithMapping2");
- _methodSharingFunctionNameAnnotationWithMethod2 = getClass().getMethod("javaMethodSharingFunctionNameAnnotationWithMethod2");
- _methodWithoutAnnotation = getClass().getMethod("javaMethodWithoutAnnotation");
-
- AnnotationAccessor annotationAccessor = new AnnotationAccessor(TestAnnotation.class.getName());
-
- _joiner = new Joiner(annotationAccessor);
- }
-
- @Test
- public void testSingleRowReport() throws Exception
- {
- List<String> protonCFunctions = asList(C_FUNCTION1);
- Set<Method> javaMethods = new HashSet<Method>(asList(_method1));
-
- ReconciliationReport reconciliationReport = _joiner.join(protonCFunctions, javaMethods);
- assertSingleRowEquals(reconciliationReport, C_FUNCTION1, _method1);
- }
-
- @Test
- public void testCFunctionWithoutCorrespondingAnnotatedJavaMethod() throws Exception
- {
- List<String> protonCFunctions = asList("functionX");
- Set<Method> javaMethods = Collections.emptySet();
-
- ReconciliationReport reconciliationReport = _joiner.join(protonCFunctions, javaMethods);
- assertSingleRowEquals(reconciliationReport, "functionX", null);
- }
-
- @Test
- public void testJavaMethodAnnotatedWithUnknownCFunctionName() throws Exception
- {
- List<String> protonCFunctions = Collections.emptyList();
- Set<Method> javaMethods = new HashSet<Method>(asList(_method1));
-
- ReconciliationReport reconciliationReport = _joiner.join(protonCFunctions, javaMethods);
- assertSingleRowEquals(reconciliationReport, null, _method1);
- }
-
- @Test
- public void testJavaMethodWithoutAnnotation() throws Exception
- {
- List<String> protonCFunctions = Collections.emptyList();
- Set<Method> javaMethods = new HashSet<Method>(asList(_methodWithoutAnnotation));
-
- ReconciliationReport reconciliationReport = _joiner.join(protonCFunctions, javaMethods);
- assertSingleRowEquals(reconciliationReport, null, _methodWithoutAnnotation);
- }
-
- @Test
- public void testJavaMethodsWithAnnotationToSameFunction() throws Exception
- {
- List<String> protonCFunctions = asList(C_FUNCTION2);
- Set<Method> javaMethods = new HashSet<Method>(asList(_method2, _methodSharingFunctionNameAnnotationWithMethod2));
-
- ReconciliationReport reconciliationReport = _joiner.join(protonCFunctions, javaMethods);
- Set<ReportRow> rowSet = TestUtils.getReportRowsFrom(reconciliationReport);
-
- Set<ReportRow> expectedRowSet = new HashSet<ReportRow>(asList(
- new ReportRow(C_FUNCTION2, null),
- new ReportRow(null, _method2),
- new ReportRow(null, _methodSharingFunctionNameAnnotationWithMethod2)));
-
- assertEquals(expectedRowSet, rowSet);
- }
-
- @Test
- public void testMultipleRowReport() throws Exception
- {
- List<String> protonCFunctions = asList(C_FUNCTION1, C_FUNCTION2);
- Set<Method> javaMethods = new HashSet<Method>(asList(_method1, _method2));
-
- ReconciliationReport reconciliationReport = _joiner.join(protonCFunctions, javaMethods);
-
- Set<ReportRow> rowSet = TestUtils.getReportRowsFrom(reconciliationReport);
-
- Set<ReportRow> expectedRowSet = new HashSet<ReportRow>(asList(
- new ReportRow(C_FUNCTION1, _method1),
- new ReportRow(C_FUNCTION2, _method2)));
-
- assertEquals(expectedRowSet,rowSet);
- }
-
- private void assertSingleRowEquals(ReconciliationReport reconciliationReport, String expectedCFunctionName, Method expectedJavaMethod)
- {
- Iterator<ReportRow> rowIterator = reconciliationReport.rowIterator();
- ReportRow row = rowIterator.next();
- assertReportRowEquals(row, expectedCFunctionName, expectedJavaMethod);
-
- assertFalse(rowIterator.hasNext());
- }
-
- private void assertReportRowEquals(ReportRow row, String expectedCFunctionName, Method expectedMethod)
- {
- assertEquals(expectedCFunctionName, row.getCFunction());
- assertEquals(expectedMethod, row.getJavaMethod());
- }
-
- @TestAnnotation(C_FUNCTION1)
- public void javaMethodWithMapping1()
- {
- }
-
- @TestAnnotation(C_FUNCTION2)
- public void javaMethodWithMapping2()
- {
- }
-
- @TestAnnotation(C_FUNCTION2)
- public void javaMethodSharingFunctionNameAnnotationWithMethod2()
- {
- }
-
- public void javaMethodWithoutAnnotation()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/ReportRowTest.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/ReportRowTest.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/ReportRowTest.java
deleted file mode 100644
index 65613d3..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/ReportRowTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import static org.junit.Assert.*;
-
-import java.lang.reflect.Method;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ReportRowTest
-{
-
- private Method _javaMethod1;
- private Method _javaMethod2;
-
- @Before
- public void setUp() throws Exception
- {
- _javaMethod1 = getClass().getMethod("javaMethod1");
- _javaMethod2 = getClass().getMethod("javaMethod2");
- }
-
- @Test
- public void testSames() throws Exception
- {
-
- ReportRow reportRow = new ReportRow("cfunction", _javaMethod1);
- Object other = new Object();
-
- assertTrue(reportRow.equals(reportRow));
- assertFalse(reportRow.equals(other));
- }
-
- @Test
- public void testEquals() throws Exception
- {
-
- assertTrue(new ReportRow("cfunction", _javaMethod1).equals(new ReportRow("cfunction", _javaMethod1)));
-
- assertFalse(new ReportRow("cfunction", _javaMethod1).equals(new ReportRow("cfunction2", _javaMethod1)));
- assertFalse(new ReportRow("cfunction2", _javaMethod1).equals(new ReportRow("cfunction2", _javaMethod2)));
-
- assertFalse(new ReportRow("cfunction", _javaMethod1).equals(null));
-
- }
-
- @Test
- public void testEqualsWithNulls() throws Exception
- {
- assertTrue(new ReportRow("cfunction", null).equals(new ReportRow("cfunction", null)));
- assertTrue(new ReportRow(null, _javaMethod1).equals(new ReportRow(null, _javaMethod1)));
-
- assertFalse(new ReportRow("cfunction", _javaMethod1).equals(new ReportRow("cfunction", null)));
- assertFalse(new ReportRow("cfunction", _javaMethod1).equals(new ReportRow(null, _javaMethod1)));
- }
-
- // Used by reflection by test methods
- public void javaMethod1()
- {
- }
-
- // Used by reflection by test methods
- public void javaMethod2()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/TestAnnotation.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/TestAnnotation.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/TestAnnotation.java
deleted file mode 100644
index 146e397..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/TestAnnotation.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface TestAnnotation
-{
- String value();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/TestUtils.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/TestUtils.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/TestUtils.java
deleted file mode 100644
index 19ba849..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/TestUtils.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-public class TestUtils
-{
- public static Set<ReportRow> getReportRowsFrom(ReconciliationReport reconciliationReport)
- {
- Iterator<ReportRow> rowIterator = reconciliationReport.rowIterator();
- Set<ReportRow> rows = new HashSet<ReportRow>();
- while (rowIterator.hasNext())
- {
- rows.add(rowIterator.next());
- }
- return rows;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/PackageSearcherTest.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/PackageSearcherTest.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/PackageSearcherTest.java
deleted file mode 100644
index b85cacb..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/PackageSearcherTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher;
-
-import static org.junit.Assert.assertEquals;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.manyimpls.Impl1;
-import org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.manyimpls.Impl2;
-import org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.manyimpls.InterfaceWithManyImpls;
-import org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.noimpl.InterfaceWithoutImpl;
-import org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.tree.ImplAtTreeTop;
-import org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.tree.InterfaceAtTreeTop;
-import org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.tree.leaf.ImplAtLeaf;
-import org.junit.Test;
-
-public class PackageSearcherTest
-{
- private PackageSearcher _packageSearcher = new PackageSearcher();
-
- @Test
- public void testFindDescendsPackageTree() throws Exception
- {
- String testDataPackage = InterfaceAtTreeTop.class.getPackage().getName();
- Set<Method> actualMethods = _packageSearcher.findMethods(testDataPackage);
- assertEquals(2, actualMethods.size());
-
- Set<Method> expectedMethods = new HashSet<Method>(Arrays.asList(
- ImplAtTreeTop.class.getMethod("method"),
- ImplAtLeaf.class.getMethod("method")));
-
- assertEquals(expectedMethods, actualMethods);
- }
-
- @Test
- public void testZeroImplenentationsOfInterface() throws Exception
- {
- String testDataPackage = InterfaceWithoutImpl.class.getPackage().getName();
-
- Method expectedMethod = InterfaceWithoutImpl.class.getMethod("method");
-
- Set<Method> actualMethods = _packageSearcher.findMethods(testDataPackage);
- assertEquals(1, actualMethods.size());
-
- Method actualMethod = actualMethods.iterator().next();
- assertEquals(expectedMethod, actualMethod);
- }
-
- @Test
- public void testManyImplenentationsOfInterface() throws Exception
- {
- String testDataPackage = InterfaceWithManyImpls.class.getPackage().getName();
-
- Set<Method> actualMethods = _packageSearcher.findMethods(testDataPackage);
- assertEquals(2, actualMethods.size());
-
- String methodName = "method";
- Set<Method> expectedMethods = new HashSet<Method>(Arrays.asList(
- Impl1.class.getMethod(methodName),
- Impl2.class.getMethod(methodName)));
-
- assertEquals(expectedMethods, actualMethods);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/Impl1.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/Impl1.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/Impl1.java
deleted file mode 100644
index 6f9c539..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/Impl1.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.manyimpls;
-
-public class Impl1 implements InterfaceWithManyImpls
-{
-
- public void method()
- {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/Impl2.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/Impl2.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/Impl2.java
deleted file mode 100644
index 97ac514..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/Impl2.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.manyimpls;
-
-public class Impl2 implements InterfaceWithManyImpls
-{
-
- public void method()
- {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/InterfaceWithManyImpls.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/InterfaceWithManyImpls.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/InterfaceWithManyImpls.java
deleted file mode 100644
index d5f01fa..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/manyimpls/InterfaceWithManyImpls.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.manyimpls;
-
-public interface InterfaceWithManyImpls
-{
- void method();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/noimpl/InterfaceWithoutImpl.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/noimpl/InterfaceWithoutImpl.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/noimpl/InterfaceWithoutImpl.java
deleted file mode 100644
index 8d8302f..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/noimpl/InterfaceWithoutImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.noimpl;
-
-public interface InterfaceWithoutImpl
-{
- void method();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/subpackage/InterfaceInSubPackage.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/subpackage/InterfaceInSubPackage.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/subpackage/InterfaceInSubPackage.java
deleted file mode 100644
index c2b5530..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/subpackage/InterfaceInSubPackage.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.subpackage;
-
-public interface InterfaceInSubPackage
-{
- void methodWithinSubpackage();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/subpackage/impl/ImplOfInterfaceInSubPackage.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/subpackage/impl/ImplOfInterfaceInSubPackage.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/subpackage/impl/ImplOfInterfaceInSubPackage.java
deleted file mode 100644
index dfda90d..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/subpackage/impl/ImplOfInterfaceInSubPackage.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.subpackage.impl;
-
-import org.apache.qpid.proton.apireconciliation.TestAnnotation;
-import org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.subpackage.InterfaceInSubPackage;
-
-public class ImplOfInterfaceInSubPackage implements InterfaceInSubPackage
-{
-
- public static final String VALUE_WITHIN_SUBPACKAGE = "subpackageFunction";
- public static final String METHOD_WITHIN_SUBPACKAGE = "methodWithinSubpackage";
-
- @TestAnnotation(VALUE_WITHIN_SUBPACKAGE)
- public void methodWithinSubpackage()
- {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/ImplAtTreeTop.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/ImplAtTreeTop.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/ImplAtTreeTop.java
deleted file mode 100644
index 8660d68..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/ImplAtTreeTop.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.tree;
-
-public class ImplAtTreeTop implements InterfaceAtTreeTop
-{
-
- public void method()
- {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/InterfaceAtTreeTop.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/InterfaceAtTreeTop.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/InterfaceAtTreeTop.java
deleted file mode 100644
index 9b85666..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/InterfaceAtTreeTop.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.tree;
-
-public interface InterfaceAtTreeTop
-{
- void method();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/leaf/ImplAtLeaf.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/leaf/ImplAtLeaf.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/leaf/ImplAtLeaf.java
deleted file mode 100644
index 511cd76..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/leaf/ImplAtLeaf.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.tree.leaf;
-
-public class ImplAtLeaf implements InterfaceAtLeaf
-{
-
- public void method()
- {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/leaf/InterfaceAtLeaf.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/leaf/InterfaceAtLeaf.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/leaf/InterfaceAtLeaf.java
deleted file mode 100644
index b12d794..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/packagesearcher/testdata/tree/leaf/InterfaceAtLeaf.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.packagesearcher.testdata.tree.leaf;
-
-public interface InterfaceAtLeaf
-{
- void method();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/reportwriter/AnnotationAccessorTest.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/reportwriter/AnnotationAccessorTest.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/reportwriter/AnnotationAccessorTest.java
deleted file mode 100644
index 7df2640..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/reportwriter/AnnotationAccessorTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.reportwriter;
-
-import static org.junit.Assert.*;
-
-import java.lang.reflect.Method;
-
-import org.apache.qpid.proton.apireconciliation.TestAnnotation;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AnnotationAccessorTest
-{
- private static final String ANNOTATION_VALUE_1 = "value1";
- private static final String ANNOTATED_METHOD_NAME = "annotatedMethod";
- private static final String UNANNOTATED_METHOD_NAME = "unannotatedMethod";
-
- private Method _annotatedMethod;
- private Method _unannotatedMethod;
-
- private String _annotationClassName;
-
- private AnnotationAccessor _annotationAccessor;
-
- @Before
- public void setUp() throws Exception
- {
- _annotatedMethod = getClass().getMethod(ANNOTATED_METHOD_NAME);
- _unannotatedMethod = getClass().getMethod(UNANNOTATED_METHOD_NAME);
- _annotationClassName = TestAnnotation.class.getName();
- _annotationAccessor = new AnnotationAccessor(_annotationClassName);
- }
-
- @Test
- public void testGetAnnotationValue()
- {
- assertEquals(ANNOTATION_VALUE_1, _annotationAccessor.getAnnotationValue(_annotatedMethod));
- }
-
- @Test
- public void testGetAnnotationValueWithoutAnnotationReturnsNull()
- {
- assertNull(_annotationAccessor.getAnnotationValue(_unannotatedMethod));
- }
-
- @TestAnnotation(ANNOTATION_VALUE_1)
- public void annotatedMethod()
- {
- }
-
- public void unannotatedMethod()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/reportwriter/ReconciliationReportWriterTest.java
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/reportwriter/ReconciliationReportWriterTest.java b/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/reportwriter/ReconciliationReportWriterTest.java
deleted file mode 100644
index 331c9fe..0000000
--- a/design/api-reconciliation/src/test/java/org/apache/qpid/proton/apireconciliation/reportwriter/ReconciliationReportWriterTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.apireconciliation.reportwriter;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.qpid.proton.apireconciliation.ReconciliationReport;
-import org.apache.qpid.proton.apireconciliation.TestAnnotation;
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class ReconciliationReportWriterTest
-{
- private ReconciliationReportWriter _writer;
- private ReconciliationReport _report = new ReconciliationReport();
-
- @Before
- public void setUp()
- {
- _writer = new ReconciliationReportWriter(new AnnotationAccessor(TestAnnotation.class.getName()));
- }
-
- @Test
- public void testReportWithSingleFullyMappedRow() throws Exception
- {
- File expectedReport = getClasspathResource("expectedsingle.csv");
- File outputFile = createTemporaryFile();
-
- _report.addRow("function1", getClass().getMethod("methodWithMapping"));
- _writer.write(outputFile.getAbsolutePath(), _report);
-
- assertFilesSame(expectedReport, outputFile);
- }
-
- @Test
- public void testReportWithManyRowsSomeUnmapped() throws Exception
- {
- File expectedReport = getClasspathResource("expectedmany.csv");
- File outputFile = createTemporaryFile();
-
- _report.addRow("function1", getClass().getMethod("methodWithMapping"));
- _report.addRow("function2", getClass().getMethod("anotherMethodWithMapping"));
- _report.addRow(null, getClass().getMethod("methodWithoutMapping"));
- _report.addRow("function4", null);
- _writer.write(outputFile.getAbsolutePath(), _report);
-
- assertFilesSame(expectedReport, outputFile);
- }
-
- private File getClasspathResource(String filename) throws URISyntaxException
- {
- URL resource = getClass().getResource(filename);
- assertNotNull("Resource " + filename + " could not be found",resource);
- return new File(resource.toURI());
- }
-
- private File createTemporaryFile() throws Exception
- {
- File tmpFile = File.createTempFile(getClass().getSimpleName(), "csv");
- tmpFile.deleteOnExit();
- return tmpFile;
- }
-
- private void assertFilesSame(File expectedReport, File actualReport) throws IOException
- {
- assertTrue(expectedReport.canRead());
- assertTrue(actualReport.canRead());
- assertEquals("Report contents unexpected",
- FileUtils.readFileToString(expectedReport),
- FileUtils.readFileToString(actualReport));
- }
-
- @TestAnnotation("function1")
- public void methodWithMapping()
- {
- }
-
- @TestAnnotation("function2")
- public void anotherMethodWithMapping()
- {
- }
-
- public void methodWithoutMapping()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedmany.csv
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedmany.csv b/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedmany.csv
deleted file mode 100644
index 8c8ba3e..0000000
--- a/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedmany.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-C function,Java Method,Java Annotation
-function1,org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriterTest#methodWithMapping,function1
-function2,org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriterTest#anotherMethodWithMapping,function2
-,org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriterTest#methodWithoutMapping,
-function4,,
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedsingle.csv
----------------------------------------------------------------------
diff --git a/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedsingle.csv b/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedsingle.csv
deleted file mode 100644
index 082f623..0000000
--- a/design/api-reconciliation/src/test/resources/org/apache/qpid/proton/apireconciliation/reportwriter/expectedsingle.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-C function,Java Method,Java Annotation
-function1,org.apache.qpid.proton.apireconciliation.reportwriter.ReconciliationReportWriterTest#methodWithMapping,function1
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/build.xml
----------------------------------------------------------------------
diff --git a/design/build.xml b/design/build.xml
deleted file mode 100644
index e884b68..0000000
--- a/design/build.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project name="Qpid Proton Design" default="dist" basedir=".">
- <description>
- simple example build file
- </description>
-
- <!-- global properties for this build -->
- <property name="src" location="src"/>
- <property name="build" location="build"/>
- <property name="dist" location="dist"/>
- <property name="classes" location="${build}/classes"/>
- <property name="docs" location="${build}/docs"/>
- <property name="umlgraph.jar" location="/usr/share/java/umlgraph.jar"/>
-
- <target name="init">
- <tstamp/>
- <mkdir dir="${classes}"/>
- </target>
-
- <target name="compile" depends="init" description="compile the source ">
- <javac srcdir="${src}" destdir="${classes}"/>
- </target>
-
- <target name="uml">
- <property name="uml.dir" value="${docs}/uml"/>
- <mkdir dir="${uml.dir}"/>
- <path id="uml.source.path">
- <pathelement path="${src}/"/>
- </path>
- <javadoc sourcepathref="uml.source.path" packagenames="*" package="true">
- <doclet name="org.umlgraph.doclet.UmlGraph" path="${umlgraph.jar}">
- <param name="-d" value="${uml.dir}"/>
- </doclet>
- </javadoc>
- <apply executable="dot" dest="${uml.dir}" parallel="false">
- <arg value="-Tpng"/>
- <arg value="-o"/>
- <targetfile/>
- <srcfile/>
- <fileset dir="${uml.dir}" includes="*.dot"/>
- <mapper type="glob" from="*.dot" to="*.png"/>
- </apply>
- </target>
-
- <target name="apidoc">
- <javadoc destdir="${docs}/api" author="true" version="true" use="true"
- windowtitle="Qpid Proton API">
-
- <fileset dir="src" defaultexcludes="yes">
- <include name="proton/**.java"/>
- </fileset>
-
- <doctitle><![CDATA[<h1>Qpid Proton</h1>]]></doctitle>
- <bottom><![CDATA[<i>Copyright © 2011 Rafael Schloming All Rights Reserved.</i>]]></bottom>
- <tag name="todo" scope="all" description="To do:"/>
- <link offline="true" href="http://download.oracle.com/javase/6/docs/api/" packagelistLoc="C:\tmp"/>
- <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
- </javadoc>
- </target>
-
- <target name="doc" depends="uml,apidoc"/>
-
- <target name="dist" depends="compile,doc" description="generate the distribution">
- <mkdir dir="${dist}/lib"/>
-
- <jar jarfile="${dist}/lib/qpidproton.jar" basedir="${classes}"/>
- <zip destfile="${dist}/docs.zip" basedir="${docs}"/>
- <zip destfile="${dist}/srcs.zip" basedir="${basedir}" excludes="build/**,dist/**"/>
- </target>
-
- <target name="clean" description="clean up" >
- <delete dir="${build}"/>
- <delete dir="${dist}"/>
- </target>
-</project>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/proton_objects.dia
----------------------------------------------------------------------
diff --git a/design/proton_objects.dia b/design/proton_objects.dia
deleted file mode 100644
index 4fc2634..0000000
Binary files a/design/proton_objects.dia and /dev/null differ
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Accepted.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Accepted.java b/design/src/proton/Accepted.java
deleted file mode 100644
index 246eb6c..0000000
--- a/design/src/proton/Accepted.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Accepted
- *
- * @hidden
- *
- */
-
-public interface Accepted extends Outcome
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Connection.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Connection.java b/design/src/proton/Connection.java
deleted file mode 100644
index a7f4af7..0000000
--- a/design/src/proton/Connection.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-import java.util.Iterator;
-
-
-/**
- * Connection
- *
- * @opt operations
- * @opt types
- *
- * @composed 1 - "0..n" Session
- * @composed 1 - "0..?" Transport
- *
- */
-
-public interface Connection extends Endpoint
-{
-
- /**
- * transition local state to ACTIVE
- */
- public void open();
-
- /**
- * transition local state to CLOSED
- */
- public void close();
-
- /**
- * @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 Iterator<Endpoint> endpoints(Endpoint.State local, Endpoint.State remote);
-
- /**
- * @return iterator for incoming link endpoints with pending
- * transfers
- */
- public Iterator<Receiver> incoming();
-
- /**
- * @return iterator for unblocked outgoing link endpoints with
- * offered credits
- */
- public Iterator<Sender> outgoing();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Delivery.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Delivery.java b/design/src/proton/Delivery.java
deleted file mode 100644
index f68b020..0000000
--- a/design/src/proton/Delivery.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Delivery
- *
- * @opt operations
- * @opt types
- *
- * @assoc - local 0..1 DeliveryState
- * @assoc - remote 0..1 DeliveryState
- *
- * @todo deliveries need to track important link state (source and
- * targets) at the point that they were created
- *
- */
-
-public interface Delivery
-{
-
- public byte[] getTag();
-
- public Link getLink();
-
- public DeliveryState getLocalState();
-
- public DeliveryState getRemoteState();
-
- public boolean remoteSettled();
-
- public int getMessageFormat();
-
- /**
- * updates the state of the delivery
- *
- * @param state the new delivery state
- */
- public void disposition(DeliveryState state);
-
- /**
- * settle the delivery
- */
- public void settle();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/DeliveryBuffer.java
----------------------------------------------------------------------
diff --git a/design/src/proton/DeliveryBuffer.java b/design/src/proton/DeliveryBuffer.java
deleted file mode 100644
index bdd592e..0000000
--- a/design/src/proton/DeliveryBuffer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * DeliveryBuffer
- *
- * @opt operations
- * @opt attributes
- * @opt types
- *
- * @composed 1 - "0..n" Delivery
- *
- */
-
-public interface DeliveryBuffer
-{
-
- int next = 0;
-
- public int getCapacity();
-
- public int getSize();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/DeliveryState.java
----------------------------------------------------------------------
diff --git a/design/src/proton/DeliveryState.java b/design/src/proton/DeliveryState.java
deleted file mode 100644
index 50d23e3..0000000
--- a/design/src/proton/DeliveryState.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * DeliveryState
- *
- */
-
-public interface DeliveryState
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Endpoint.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Endpoint.java b/design/src/proton/Endpoint.java
deleted file mode 100644
index 6d7a997..0000000
--- a/design/src/proton/Endpoint.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Endpoint
- *
- * @opt operations
- * @opt types
- *
- * @assoc - local 1 Endpoint.State
- * @assoc - remote 1 Endpoint.State
- * @assoc - local 0..1 Endpoint.Error
- * @assoc - remote 0..1 Endpoint.Error
- */
-
-public interface Endpoint
-{
-
- /**
- * Represents the state of a communication endpoint.
- */
- public static final class State {
-
- private String name;
-
- private State(String name)
- {
- this.name = name;
- }
-
- public String toString()
- {
- return name;
- }
-
- };
-
- public static final State UNINIT = new State("UNINIT");
- public static final State ACTIVE = new State("ACTIVE");
- public static final State CLOSED = new State("CLOSED");
-
- /**
- * Holds information about an endpoint error.
- */
- public static final class Error {
-
- private String name;
- private String description;
-
- public Error(String name, String description)
- {
- this.name = name;
- this.description = description;
- }
-
- public Error(String name)
- {
- this(name, null);
- }
-
- public String toString()
- {
- if (description == null)
- {
- return name;
- }
- else
- {
- return String.format("%s -- %s", name, description);
- }
- }
- }
-
- /**
- * @return the local endpoint state
- */
- public State getLocalState();
-
- /**
- * @return the remote endpoint state (as last communicated)
- */
- public State getRemoteState();
-
- /**
- * @return the local endpoint error, or null if there is none
- */
- public Error getLocalError();
-
- /**
- * @return the remote endpoint error, or null if there is none
- */
- public Error getRemoteError();
-
- /**
- * free the endpoint and any associated resources
- */
- public void free();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Link.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Link.java b/design/src/proton/Link.java
deleted file mode 100644
index ec80b62..0000000
--- a/design/src/proton/Link.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-import java.util.Iterator;
-
-
-/**
- * Link
- *
- * @opt operations
- * @opt types
- *
- * @assoc 1 - n Delivery
- *
- * @todo make links able to exist independently from
- * sessions/connections and allow to migrate
- *
- */
-
-public interface Link extends Endpoint
-{
-
- /**
- * transition local state to ACTIVE
- */
- public void attach();
-
- /**
- * transition local state to CLOSED
- */
- public void detach();
-
- /**
- * @param tag a tag for the delivery
- *
- * @return a Delivery object
- */
- public Delivery delivery(byte[] tag);
-
- /**
- * @return the unsettled deliveries for this link
- */
- public Iterator<Delivery> unsettled();
-
- /**
- * Advances the current delivery to the next delivery on the link.
- *
- * @return the next delivery or null if there is none
- */
- public Delivery next();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Modified.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Modified.java b/design/src/proton/Modified.java
deleted file mode 100644
index 1f07cb0..0000000
--- a/design/src/proton/Modified.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Modified
- *
- * @hidden
- *
- */
-
-public interface Modified extends Outcome
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Outcome.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Outcome.java b/design/src/proton/Outcome.java
deleted file mode 100644
index d0a4064..0000000
--- a/design/src/proton/Outcome.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Outcome
- *
- * @hidden
- *
- */
-
-public interface Outcome extends DeliveryState
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Received.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Received.java b/design/src/proton/Received.java
deleted file mode 100644
index 37856bf..0000000
--- a/design/src/proton/Received.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Received
- *
- * @hidden
- *
- */
-
-public interface Received extends DeliveryState
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Receiver.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Receiver.java b/design/src/proton/Receiver.java
deleted file mode 100644
index f46bfa4..0000000
--- a/design/src/proton/Receiver.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Receiver
- *
- * @opt operations
- * @opt types
- *
- */
-
-public interface Receiver extends Link
-{
-
- /**
- * issue the specified number of credits
- */
- public void flow(int credits);
-
- /**
- * Receive message data for the current delivery.
- *
- * @param bytes the destination array where the message data is written
- * @param offset the index to begin writing into the array
- * @param size the maximum number of bytes to write
- *
- * @return the number of bytes written or -1 if there is no more
- * message data for the current delivery
- */
- public int recv(byte[] bytes, int offset, int size);
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Rejected.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Rejected.java b/design/src/proton/Rejected.java
deleted file mode 100644
index 92f1ec4..0000000
--- a/design/src/proton/Rejected.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Rejected
- *
- * @hidden
- *
- */
-
-public interface Rejected extends Outcome
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Released.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Released.java b/design/src/proton/Released.java
deleted file mode 100644
index e480ef7..0000000
--- a/design/src/proton/Released.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Released
- *
- * @hidden
- *
- */
-
-public interface Released extends Outcome
-{
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Sender.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Sender.java b/design/src/proton/Sender.java
deleted file mode 100644
index 36bd68d..0000000
--- a/design/src/proton/Sender.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Sender
- *
- * @opt operations
- * @opt types
- *
- */
-
-public interface Sender extends Link
-{
-
- /**
- * indicates pending deliveries
- *
- * @param credits the number of pending deliveries
- * @todo is this absolute or cumulative?
- */
- public void offer(int credits);
-
- /**
- * Sends message data for the current delivery.
- *
- * @param bytes the message data
- */
- public void send(byte[] bytes);
-
- /**
- * Abort the current delivery.
- */
- public void abort();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Session.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Session.java b/design/src/proton/Session.java
deleted file mode 100644
index b6ae6f9..0000000
--- a/design/src/proton/Session.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-import java.util.Iterator;
-
-
-/**
- * Session
- *
- * @opt operations
- * @opt types
- *
- * @composed 1 - "0..n" Link
- * @composed 1 incoming 1 DeliveryBuffer
- * @composed 1 outgoing 1 DeliveryBuffer
- *
- */
-
-public interface Session extends Endpoint
-{
-
- /**
- * transition local state to ACTIVE
- */
- public void begin();
-
- /**
- * transition local state to CLOSED
- */
- public void end();
-
- /**
- * @return a newly created outgoing link
- */
- public Sender sender();
-
- /**
- * @return a newly created incoming link
- */
- public Receiver receiver();
-
- /**
- * @see Connection#endpoints(Endpoint.State, Endpoint.State)
- */
- public Iterator<Endpoint> endpoints(Endpoint.State local, Endpoint.State remote);
-
- /**
- * @see Connection#incoming()
- */
- public Iterator<Receiver> incoming();
-
- /**
- * @see Connection#outgoing()
- */
- public Iterator<Sender> outgoing();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/Transport.java
----------------------------------------------------------------------
diff --git a/design/src/proton/Transport.java b/design/src/proton/Transport.java
deleted file mode 100644
index 0ff89ac..0000000
--- a/design/src/proton/Transport.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package proton;
-
-
-/**
- * Transport
- *
- * @opt operations
- * @opt types
- *
- */
-
-public interface Transport extends Endpoint
-{
-
- /**
- * @param bytes input bytes for consumption
- * @param offset the offset within bytes where input begins
- * @param size the number of bytes available for input
- *
- * @return the number of bytes consumed
- */
- public int input(byte[] bytes, int offset, int size);
-
- /**
- * @param bytes array for output bytes
- * @param offset the offset within bytes where output begins
- * @param size the number of bytes available for output
- *
- * @return the number of bytes written
- */
- public int output(byte[] bytes, int offset, int size);
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/design/src/proton/package.html
----------------------------------------------------------------------
diff --git a/design/src/proton/package.html b/design/src/proton/package.html
deleted file mode 100644
index c72c78f..0000000
--- a/design/src/proton/package.html
+++ /dev/null
@@ -1,122 +0,0 @@
-<html>
- <body>
- <p>
- Connections are the primary unit of resource management.
- Sessions and Links are components of connections. When the
- Connection is freed/discarded, any resources associated with
- the Sessions and Links are automatically destroyed or discarded
- as well.
- </p>
-
- <p>
- Each of the Connection, Session, and Link endpoints share a
- common state model. Note that although this follows the same
- pattern as the protocol state model for open/close, begin/end,
- and attach/detach, this does not necessarily correspond one to
- one to the protocol state model for endpoints. For example the
- engine implementation may detach/reattach a link endpoint
- without visibly changing the external state.
- </p>
-
- <p>
- The state of each endpoint is divided into two parts, one
- reflecting the state of the local endpoint, and the other
- reflecting the state of the remote endpoint as last
- communicated.
- </p>
-
- <pre>
- LOCAL:
- UNINIT
- ACTIVE
- CLOSED
-
- REMOTE:
- UNINIT
- ACTIVE
- CLOSED
- </pre>
-
- <p>In total there are 9 possible states:</p>
-
- <pre>
- LOCAL REMOTE Example
- -------------------------------------------------------------------------
- UNINIT UNINIT A newly created connection.
-
- UNINIT ACTIVE A remotely initiated connection
- prior to full establishment.
-
- UNINIT CLOSED A remotely initiated connection that
- has been closed prior to full
- establishment.
-
- ACTIVE UNINIT A locally initiated connection prior
- to full establishment.
-
- ACTIVE ACTIVE A fully established connection.
-
- ACTIVE CLOSED A remotely terminated connection.
-
- CLOSED UNINIT A locally initiated connection that
- has been closed prior to full
- establishment.
-
- CLOSED ACTIVE A locally terminated connection.
-
- CLOSED CLOSED A fully terminated connection.
- </pre>
-
- <p>
- Additionally each endpoint has an error slot which may be filled
- with additional information regarding error conditions, e.g. why
- the remote endpoint was transitioned to CLOSED.
- </p>
-
- <h3>Questions:</h3>
-
- <ul>
- <li>The transfer buffer class may not necessarily be explicitly part
- of the external interface, e.g. it could be absorbed into the
- session interface.</li>
- <li>how do we confirm acheiving active/active without iterating
- over all active/active endpoints?
- <ul>
- <li>add an ignore/interest flag as part of generic endpoint state?</li>
- <li>add pending state to local state?</li>
- </ul>
- </li>
- <li>what are credits exactly?
- <ul>
- <li>how does synchronous get work?
- <ul><li>implies credit unit needs to be messages?</li></ul>
- <li>credits may not correspond exactly with on-the-wire credits due
- to local buffering</li>
- </ul>
- </li>
- <li>how would 0-x impls work given that we're passing bytes directly to send?
- <ul>
- <li>have a generic property get/set API?
- <ul><li>this could address per transfer flags as well</li></ul>
- </li>
- </ul>
- </li>
- <li>how do large messages work?
- <ul><li>does send need a done flag for multiple transfers?</li></ul>
- </li>
- <li>how does resume work?</li>
- <li>how does abort work?</li>
- <li>how do we send settled?
- <ul>
- <li>just call settle on the returned transfer, the engine MUST optimize</li>
- </ul>
- </li>
- <li>
- how do we deal with send and receive modes on individual transfers?
- <ul><li>could just twiddle the link ones and set them on the
- transfer frame if they differ from what they were when the
- attach was made</li></ul>
- </li>
- </ul>
- </body>
-</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[18/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/EndType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/EndType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/EndType.java
deleted file mode 100644
index 7945fd4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/EndType.java
+++ /dev/null
@@ -1,97 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.End;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public final class EndType extends AbstractDescribedType<End,List> implements DescribedTypeConstructor<End>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000017L), Symbol.valueOf("amqp:end:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000017L);
-
- private EndType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(End val)
- {
- ErrorCondition errorCondition = val.getError();
- return errorCondition == null ? Collections.EMPTY_LIST : Collections.singletonList(errorCondition);
- }
-
-
- public End newInstance(Object described)
- {
- List l = (List) described;
-
- End o = new End();
-
- if(!l.isEmpty())
- {
- o.setError( (ErrorCondition) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<End> getTypeClass()
- {
- return End.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- EndType type = new EndType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/ErrorConditionType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/ErrorConditionType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/ErrorConditionType.java
deleted file mode 100644
index c8ff939..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/ErrorConditionType.java
+++ /dev/null
@@ -1,147 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public final class ErrorConditionType extends AbstractDescribedType<ErrorCondition,List> implements DescribedTypeConstructor<ErrorCondition>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x000000000000001dL), Symbol.valueOf("amqp:error:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x000000000000001dL);
-
- private ErrorConditionType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(ErrorCondition val)
- {
- return new ErrorConditionWrapper(val);
- }
-
- public static class ErrorConditionWrapper extends AbstractList
- {
-
- private ErrorCondition _errorCondition;
-
- public ErrorConditionWrapper(ErrorCondition errorCondition)
- {
- _errorCondition = errorCondition;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _errorCondition.getCondition();
- case 1:
- return _errorCondition.getDescription();
- case 2:
- return _errorCondition.getInfo();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _errorCondition.getInfo() != null
- ? 3
- : _errorCondition.getDescription() != null
- ? 2
- : 1;
-
- }
-
- }
-
- public ErrorCondition newInstance(Object described)
- {
- List l = (List) described;
-
- ErrorCondition o = new ErrorCondition();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The condition field cannot be omitted");
- }
-
- switch(3 - l.size())
- {
-
- case 0:
- o.setInfo( (Map) l.get( 2 ) );
- case 1:
- o.setDescription( (String) l.get( 1 ) );
- case 2:
- o.setCondition( (Symbol) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<ErrorCondition> getTypeClass()
- {
- return ErrorCondition.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- ErrorConditionType type = new ErrorConditionType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FlowType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FlowType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FlowType.java
deleted file mode 100644
index f9e91dc..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FlowType.java
+++ /dev/null
@@ -1,191 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.Flow;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public final class FlowType extends AbstractDescribedType<Flow,List> implements DescribedTypeConstructor<Flow>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000013L), Symbol.valueOf("amqp:flow:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000013L);
-
- private FlowType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Flow val)
- {
- return new FlowWrapper(val);
- }
-
- public static class FlowWrapper extends AbstractList
- {
-
-
- private Flow _flow;
-
- public FlowWrapper(Flow flow)
- {
- _flow = flow;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _flow.getNextIncomingId();
- case 1:
- return _flow.getIncomingWindow();
- case 2:
- return _flow.getNextOutgoingId();
- case 3:
- return _flow.getOutgoingWindow();
- case 4:
- return _flow.getHandle();
- case 5:
- return _flow.getDeliveryCount();
- case 6:
- return _flow.getLinkCredit();
- case 7:
- return _flow.getAvailable();
- case 8:
- return _flow.getDrain();
- case 9:
- return _flow.getEcho();
- case 10:
- return _flow.getProperties();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _flow.getProperties() != null
- ? 11
- : _flow.getEcho()
- ? 10
- : _flow.getDrain()
- ? 9
- : _flow.getAvailable() != null
- ? 8
- : _flow.getLinkCredit() != null
- ? 7
- : _flow.getDeliveryCount() != null
- ? 6
- : _flow.getHandle() != null
- ? 5
- : 4;
-
- }
- }
-
- 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 static void register(Decoder decoder, EncoderImpl encoder)
- {
- FlowType type = new FlowType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/OpenType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/OpenType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/OpenType.java
deleted file mode 100644
index 21e1205..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/OpenType.java
+++ /dev/null
@@ -1,226 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public final class OpenType extends AbstractDescribedType<Open,List> implements DescribedTypeConstructor<Open>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000010L), Symbol.valueOf("amqp:open:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000010L);
-
- private OpenType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Open val)
- {
- return new OpenWrapper(val);
- }
-
-
- public static class OpenWrapper extends AbstractList
- {
-
- private Open _open;
-
- public OpenWrapper(Open open)
- {
- _open = open;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _open.getContainerId();
- case 1:
- return _open.getHostname();
- case 2:
- return _open.getMaxFrameSize();
- case 3:
- return _open.getChannelMax();
- case 4:
- return _open.getIdleTimeOut();
- case 5:
- return _open.getOutgoingLocales();
- case 6:
- return _open.getIncomingLocales();
- case 7:
- return _open.getOfferedCapabilities();
- case 8:
- return _open.getDesiredCapabilities();
- case 9:
- return _open.getProperties();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _open.getProperties() != null
- ? 10
- : _open.getDesiredCapabilities() != null
- ? 9
- : _open.getOfferedCapabilities() != null
- ? 8
- : _open.getIncomingLocales() != null
- ? 7
- : _open.getOutgoingLocales() != null
- ? 6
- : _open.getIdleTimeOut() != null
- ? 5
- : (_open.getChannelMax() != null && !_open.getChannelMax().equals(UnsignedShort.MAX_VALUE))
- ? 4
- : (_open.getMaxFrameSize() != null && !_open.getMaxFrameSize().equals(UnsignedInteger.MAX_VALUE))
- ? 3
- : _open.getHostname() != null
- ? 2
- : 1;
-
- }
-
- }
-
- public Open newInstance(Object described)
- {
- List l = (List) described;
-
- Open o = new Open();
-
- if(l.isEmpty())
- {
- 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 static void register(Decoder decoder, EncoderImpl encoder)
- {
- OpenType type = new OpenType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/TransferType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/TransferType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/TransferType.java
deleted file mode 100644
index 4ddbd49..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/TransferType.java
+++ /dev/null
@@ -1,207 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.Transfer;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public final class TransferType extends AbstractDescribedType<Transfer,List> implements DescribedTypeConstructor<Transfer>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000014L), Symbol.valueOf("amqp:transfer:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000014L);
-
- private TransferType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Transfer val)
- {
- return new TransferWrapper(val);
- }
-
-
- public static class TransferWrapper extends AbstractList
- {
-
- private Transfer _transfer;
-
- public TransferWrapper(Transfer transfer)
- {
- _transfer = transfer;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _transfer.getHandle();
- case 1:
- return _transfer.getDeliveryId();
- case 2:
- return _transfer.getDeliveryTag();
- case 3:
- return _transfer.getMessageFormat();
- case 4:
- return _transfer.getSettled();
- case 5:
- return _transfer.getMore();
- case 6:
- return _transfer.getRcvSettleMode() == null ? null : _transfer.getRcvSettleMode().getValue();
- case 7:
- return _transfer.getState();
- case 8:
- return _transfer.getResume();
- case 9:
- return _transfer.getAborted();
- case 10:
- return _transfer.getBatchable();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _transfer.getBatchable()
- ? 11
- : _transfer.getAborted()
- ? 10
- : _transfer.getResume()
- ? 9
- : _transfer.getState() != null
- ? 8
- : _transfer.getRcvSettleMode() != null
- ? 7
- : _transfer.getMore()
- ? 6
- : _transfer.getSettled() != null
- ? 5
- : _transfer.getMessageFormat() != null
- ? 4
- : _transfer.getDeliveryTag() != null
- ? 3
- : _transfer.getDeliveryId() != null
- ? 2
- : 1;
-
- }
-
- }
-
- public Transfer newInstance(Object described)
- {
- List l = (List) described;
-
- Transfer o = new Transfer();
-
- if(l.isEmpty())
- {
- 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:
- UnsignedByte receiverSettleMode = (UnsignedByte) l.get(6);
- o.setRcvSettleMode(receiverSettleMode == null ? null : ReceiverSettleMode.values()[receiverSettleMode.intValue()]);
- 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 static void register(Decoder decoder, EncoderImpl encoder)
- {
- TransferType type = new TransferType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/Connector.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/Connector.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/Connector.java
deleted file mode 100644
index 619b1cf..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/driver/Connector.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.driver;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Sasl;
-import org.apache.qpid.proton.engine.Transport;
-
-/**
- * Intermediates between a proton engine {@link Connection} and the I/O
- * layer.
- *
- * The top half of the engine can be access via {@link #getConnection()}.
- * The bottom half of the engine is used by {@link #process()}.
- * Stores application specific context using {@link #setContext(Object)}.
- *
- * Implementations are not necessarily thread-safe.
- *
- * @param <C> application supplied context
- * @deprecated Messenger and its connector will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public interface Connector<C>
-{
- /**
- * Handle any inbound data, outbound data, or timing events pending on
- * the connector.
- * Typically, applications repeatedly invoke this method
- * during the lifetime of a connection.
- */
- boolean process() throws IOException;
-
- /**
- * Access the listener which opened this connector.
- *
- * @return the listener which created this connector, or null if the
- * connector has no listener (e.g. an outbound client
- * connection).
- */
- @SuppressWarnings("rawtypes")
- Listener listener();
-
- /**
- * Access the Authentication and Security context of the connector.
- *
- * @return the Authentication and Security context for the connector,
- * or null if none.
- */
- Sasl sasl();
-
- /**
- * Access the Transport associated with the connector.
- *
- */
-
- Transport getTransport();
-
- /**
- * Access the AMQP Connection associated with the connector.
- *
- * @return the connection context for the connector, or null if none.
- */
- Connection getConnection();
-
- /**
- * Assign the AMQP Connection associated with the connector.
- *
- * @param connection the connection to associate with the connector.
- */
- void setConnection(Connection connection);
-
- /**
- * Access the application context that is associated with the connector.
- *
- * @return the application context that was passed when creating this
- * connector. See
- * {@link Driver#createConnector(String, int, Object)
- * createConnector(String, int, Object)} and
- * {@link Driver#createConnector(java.nio.channels.SelectableChannel, Object)
- * createConnector(java.nio.channels.SelectableChannel, Object)}.
- */
- C getContext();
-
- /**
- * Assign a new application context to the connector.
- *
- * @param context new application context to associate with the connector
- */
- void setContext(C context);
-
- /**
- * Close the socket used by the connector.
- */
- void close();
-
- /**
- * Determine if the connector is closed.
- */
- boolean isClosed();
-
- /**
- * Destructor for the given connector.
- *
- * Assumes the connector's socket has been closed prior to call.
- */
- void destroy();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java
deleted file mode 100644
index 3d8ada3..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.driver;
-
-import java.io.IOException;
-import java.nio.channels.SelectableChannel;
-import java.nio.channels.ServerSocketChannel;
-
-import org.apache.qpid.proton.driver.impl.DriverImpl;
-
-/**
- * A driver for the proton engine.
- *
- * Manages {@link Connector}'s and {@link Listener}'s, which act as intermediaries between
- * the proton engine and the network.
- *
- * Provides methods for the application to access the "top half" of the engine API when the state
- * of the engine may have changed due to I/O or timing events - see {@link #connector()}.
- *
- * Connectors incorporate the SASL engine in order to provide a complete network stack:
- * AMQP over SASL over TCP.
- *
- * Unless otherwise stated, methods on Driver implementations are not necessarily thread-safe.
- *
- * @deprecated Messenger and its driver will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public interface Driver
-{
- /**
- * @deprecated Messenger and its driver will be removed from upcoming proton-j releases.
- */
- @Deprecated
- public static final class Factory
- {
- public static Driver create() throws IOException {
- return new DriverImpl();
- }
- }
-
- /**
- * Force {@link #doWait(long)} to return.
- *
- * If the driver is not currently waiting then the next invocation of {@link #doWait(long)}
- * will return immediately unless the {@link #connector()} method is invoked in the meantime.
- *
- * Thread-safe.
- */
- void wakeup();
-
- /**
- * Wait for an active connector or listener, or for {@link #wakeup()} to be called.
- *
- * Thread-safe.
- *
- * @param timeout maximum time in milliseconds to wait. -1 means wait indefinitely.
- *
- * @return true if woken up
- */
- boolean doWait(long timeout);
-
- /**
- * Get the next listener with pending data in the driver.
- *
- * @return null if no active listener available
- */
- @SuppressWarnings("rawtypes")
- Listener listener();
-
- /**
- * Get the next active connector in the driver.
- *
- * Returns the next connector with pending inbound data, available capacity
- * for outbound data, or pending tick.
- *
- * Clears the wake-up status that is set by {@link #wakeup()}.
- *
- * @return null if no active connector available
- */
- @SuppressWarnings("rawtypes")
- Connector connector();
-
- /**
- * Destruct the driver and all associated listeners, connectors and other resources.
- */
- void destroy();
-
- /**
- * Construct a listener for the given address.
- *
- * @param host local host address to listen on
- * @param port local port to listen on
- * @param context application-supplied, can be accessed via
- * {@link Listener#getContext() getContext()} method on a listener.
- * @return a new listener on the given host:port, null if error
- */
- <C> Listener<C> createListener(String host, int port, C context);
-
- /**
- * Create a listener using the existing channel.
- *
- * @param c existing SocketChannel for listener to listen on
- * @param context application-supplied, can be accessed via
- * {@link Listener#getContext() getContext()} method on a listener.
- * @return a new listener on the given channel, null if error
- */
- <C> Listener<C> createListener(ServerSocketChannel c, C context);
-
- /**
- * Construct a connector to the given remote address.
- *
- * @param host remote host to connect to.
- * @param port remote port to connect to.
- * @param context application-supplied, can be accessed via
- * {@link Connector#getContext() getContext()} method on a listener.
- *
- * @return a new connector to the given remote, or null on error.
- */
- <C> Connector<C> createConnector(String host, int port, C context);
-
- /**
- * Create a connector using the existing file descriptor.
- *
- * @param fd existing SocketChannel for listener to listen on
- * @param context application-supplied, can be accessed via
- * {@link Connector#getContext() getContext()} method on a listener.
- *
- * @return a new connector to the given host:port, null if error.
- */
- <C> Connector<C> createConnector(SelectableChannel fd, C context);
-
- /**
- * Return an iterator over all listeners.
- */
- Iterable<Listener> listeners();
- /**
- * Return an iterator over all connectors.
- */
- Iterable<Connector> connectors();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/Listener.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/Listener.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/Listener.java
deleted file mode 100644
index 7541d4d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/driver/Listener.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.driver;
-
-/**
- * Server API.
- *
- * @param <C> application supplied context
- * @deprecated Messenger and its listener will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public interface Listener<C>
-{
- /**
- * Accept a connection that is pending on the listener.
- *
- * @return a new connector for the remote, or NULL on error.
- */
- Connector<C> accept();
-
- /**
- * Access the application context that is associated with the listener.
- *
- * @return the application context that was passed when creating this
- * listener. See {@link Driver#createListener(String, int, Object)
- * createListener(String, int, Object)} and
- * {@link Driver#createConnector(java.nio.channels.SelectableChannel, Object)
- * createConnector(java.nio.channels.SelectableChannel, Object)}
- */
- C getContext();
-
- /**
- * Set the application context that is associated with this listener.
- *
- */
- void setContext(C ctx);
-
- /**
- * Close the socket used by the listener.
- *
- */
- void close() throws java.io.IOException;
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java
deleted file mode 100644
index 18cad9a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.proton.driver.impl;
-
-import static org.apache.qpid.proton.driver.impl.ConnectorImpl.ConnectorState.UNINITIALIZED;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.SocketChannel;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.driver.Connector;
-import org.apache.qpid.proton.driver.Listener;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Sasl;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-
-@SuppressWarnings("deprecation")
-class ConnectorImpl<C> implements Connector<C>
-{
- private static int DEFAULT_BUFFER_SIZE = 64 * 1024;
- private static int readBufferSize = Integer.getInteger
- ("pn.receive_buffer_size", DEFAULT_BUFFER_SIZE);
- private static int writeBufferSize = Integer.getInteger
- ("pn.send_buffer_size", DEFAULT_BUFFER_SIZE);
-
- enum ConnectorState {UNINITIALIZED, OPENED, EOS, CLOSED};
-
- private final DriverImpl _driver;
- private final Listener<C> _listener;
- private final SocketChannel _channel;
- private final Logger _logger = Logger.getLogger("proton.driver");
- private C _context;
-
- private Connection _connection;
- private Transport _transport = Proton.transport();
- private SelectionKey _key;
- private ConnectorState _state = UNINITIALIZED;
-
- private boolean _inputDone = false;
- private boolean _outputDone = false;
- private boolean _closed = false;
-
- private boolean _selected = false;
- private boolean _readAllowed = false;
-
- ConnectorImpl(DriverImpl driver, Listener<C> listener, SocketChannel c, C context, SelectionKey key)
- {
- _driver = driver;
- _listener = listener;
- _channel = c;
- _context = context;
- _key = key;
- }
-
- void selected()
- {
- if (!_selected) {
- _selected = true;
- _driver.selectConnector(this);
- _readAllowed = true;
- }
- }
-
- void unselected()
- {
- _selected = false;
- }
-
- public boolean process() throws IOException
- {
- if (isClosed() || !_channel.finishConnect()) return false;
-
- boolean processed = false;
- if (!_inputDone)
- {
- if (read()) {
- processed = true;
- }
- }
-
- if (!_outputDone)
- {
- if (write()) {
- processed = true;
- }
- }
-
- if (_outputDone && _inputDone)
- {
- close();
- }
-
- return processed;
- }
-
- private boolean read() throws IOException
- {
- if (!_readAllowed) return false;
- _readAllowed = false;
- boolean processed = false;
-
- int interest = _key.interestOps();
- int capacity = _transport.capacity();
- if (capacity == Transport.END_OF_STREAM)
- {
- _inputDone = true;
- }
- else
- {
- ByteBuffer tail = _transport.tail();
- int bytesRead = _channel.read(tail);
- if (bytesRead < 0) {
- _transport.close_tail();
- _inputDone = true;
- } else if (bytesRead > 0) {
- try {
- _transport.process();
- } catch (TransportException e) {
- _logger.log(Level.SEVERE, this + " error processing input", e);
- }
- processed = true;
- }
- }
-
- capacity = _transport.capacity();
- if (capacity > 0) {
- interest |= SelectionKey.OP_READ;
- } else {
- interest &= ~SelectionKey.OP_READ;
- if (capacity < 0) {
- _inputDone = true;
- }
- }
- _key.interestOps(interest);
-
- return processed;
- }
-
- private boolean write() throws IOException
- {
- boolean processed = false;
-
- int interest = _key.interestOps();
- boolean writeBlocked = false;
-
- try {
- while (_transport.pending() > 0 && !writeBlocked)
- {
- ByteBuffer head = _transport.head();
- int wrote = _channel.write(head);
- if (wrote > 0) {
- processed = true;
- _transport.pop(wrote);
- } else {
- writeBlocked = true;
- }
- }
-
- int pending = _transport.pending();
- if (pending > 0) {
- interest |= SelectionKey.OP_WRITE;
- } else {
- interest &= ~SelectionKey.OP_WRITE;
- if (pending < 0) {
- _outputDone = true;
- }
- }
- } catch (TransportException e) {
- _logger.log(Level.SEVERE, this + " error", e);
- interest &= ~SelectionKey.OP_WRITE;
- _inputDone = true;
- _outputDone = true;
- }
-
- _key.interestOps(interest);
-
- return processed;
- }
-
- public Listener<C> listener()
- {
- return _listener;
- }
-
- public Sasl sasl()
- {
- if (_transport != null)
- {
- return _transport.sasl();
- }
- else
- {
- return null;
- }
- }
-
- public Connection getConnection()
- {
- return _connection;
- }
-
- public void setConnection(Connection connection)
- {
- _connection = connection;
- _transport.bind(_connection);
- }
-
- public Transport getTransport()
- {
- return _transport;
- }
-
- public C getContext()
- {
- return _context;
- }
-
- public void setContext(C context)
- {
- _context = context;
- }
-
- public void close()
- {
- if (!isClosed())
- {
- try
- {
- _channel.close();
- }
- catch (IOException e)
- {
- _logger.log(Level.SEVERE, "Exception when closing connection",e);
- }
- finally
- {
- _closed = true;
- selected();
- }
- }
- }
-
- public boolean isClosed()
- {
- return _closed;
- }
-
- public void destroy()
- {
- close(); // close if not closed already
- _driver.removeConnector(this);
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("ConnectorImpl [_channel=").append(_channel).append("]");
- return builder.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java
deleted file mode 100644
index 6264d7a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.driver.impl;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.SelectableChannel;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.util.ArrayDeque;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.driver.Connector;
-import org.apache.qpid.proton.driver.Driver;
-import org.apache.qpid.proton.driver.Listener;
-
-@SuppressWarnings("deprecation")
-public class DriverImpl implements Driver
-{
- private Selector _selector;
- private Collection<Listener> _listeners = new LinkedList();
- private Collection<Connector> _connectors = new LinkedList();
- private Logger _logger = Logger.getLogger("proton.driver");
- private Object _wakeupLock = new Object();
- private boolean _woken = false;
- private Queue<ConnectorImpl> _selectedConnectors = new ArrayDeque<ConnectorImpl>();
- private Queue<ListenerImpl> _selectedListeners = new ArrayDeque<ListenerImpl>();
-
- public DriverImpl() throws IOException
- {
- _selector = Selector.open();
- }
-
- public void wakeup()
- {
- synchronized (_wakeupLock) {
- _woken = true;
- }
- _selector.wakeup();
- }
-
- public boolean doWait(long timeout)
- {
- try
- {
- boolean woken;
- synchronized (_wakeupLock) {
- woken = _woken;
- }
-
- if (woken || timeout == 0) {
- _selector.selectNow();
- } else if (timeout < 0) {
- _selector.select();
- } else {
- _selector.select(timeout);
- }
-
- synchronized (_wakeupLock) {
- woken = woken || _woken;
- _woken = false;
- }
-
- for (SelectionKey key : _selector.selectedKeys()) {
- if (key.isAcceptable()) {
- ListenerImpl l = (ListenerImpl) key.attachment();
- l.selected();
- } else {
- ConnectorImpl c = (ConnectorImpl) key.attachment();
- c.selected();
- }
- }
-
- _selector.selectedKeys().clear();
-
- return woken;
- }
- catch (IOException e)
- {
- _logger.log(Level.SEVERE, "Exception when waiting for IO Event",e);
- throw new RuntimeException(e);
- }
- }
-
- void selectListener(ListenerImpl l)
- {
- _selectedListeners.add(l);
- }
-
- public Listener listener()
- {
- ListenerImpl listener = _selectedListeners.poll();
- if (listener != null) {
- listener.unselected();
- }
-
- return listener;
- }
-
- void selectConnector(ConnectorImpl c)
- {
- _selectedConnectors.add(c);
- }
-
- public Connector connector()
- {
- ConnectorImpl connector = _selectedConnectors.poll();
- if (connector != null) {
- connector.unselected();
- }
- return connector;
- }
-
- public void destroy()
- {
- try
- {
- _selector.close();
- }
- catch (IOException e)
- {
- _logger.log(Level.SEVERE, "Exception when closing selector",e);
- throw new RuntimeException(e);
- }
- _listeners.clear();
- _connectors.clear();
- }
-
- public <C> Listener<C> createListener(String host, int port, C context)
- {
- try
- {
- ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
- ServerSocket serverSocket = serverSocketChannel.socket();
- serverSocket.bind(new InetSocketAddress(host, port));
- serverSocketChannel.configureBlocking(false);
- Listener<C> listener = createListener(serverSocketChannel, context);
- _logger.fine("Created listener on " + host + ":" + port + ": " + context);
-
- return listener;
- }
- catch (ClosedChannelException e)
- {
- e.printStackTrace(); // TODO - Implement
- }
- catch (IOException e)
- {
- e.printStackTrace(); // TODO - Implement
- }
- return null;
- }
-
- public <C> Listener<C> createListener(ServerSocketChannel c, C context)
- {
- Listener<C> l = new ListenerImpl<C>(this, c, context);
- SelectionKey key = registerInterest(c,SelectionKey.OP_ACCEPT);
- key.attach(l);
- _listeners.add(l);
- return l;
- }
-
- public <C> Connector<C> createConnector(String host, int port, C context)
- {
- try
- {
- SocketChannel channel = SocketChannel.open();
- channel.configureBlocking(false);
- // Disable the Nagle algorithm on TCP connections.
- channel.socket().setTcpNoDelay(true);
- channel.connect(new InetSocketAddress(host, port));
- return createConnector(channel, context);
- }
- catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
-
- public <C> Connector<C> createConnector(SelectableChannel c, C context)
- {
- SelectionKey key = registerInterest(c, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
- Connector<C> co = new ConnectorImpl<C>(this, null, (SocketChannel)c, context, key);
- key.attach(co);
- _connectors.add(co);
- return co;
- }
-
- public <C> void removeConnector(Connector<C> c)
- {
- _connectors.remove(c);
- }
-
- public Iterable<Listener> listeners()
- {
- return _listeners;
- }
-
- public Iterable<Connector> connectors()
- {
- return _connectors;
- }
-
- protected <C> Connector<C> createServerConnector(SelectableChannel c, C context, Listener<C> l)
- {
- SelectionKey key = registerInterest(c, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
- Connector<C> co = new ConnectorImpl<C>(this, l, (SocketChannel)c, context, key);
- key.attach(co);
- _connectors.add(co);
- return co;
- }
-
- private <C> SelectionKey registerInterest(SelectableChannel c, int opKeys)
- {
- try
- {
- return c.register(_selector, opKeys);
- }
- catch (ClosedChannelException e)
- {
- e.printStackTrace(); // TODO - Implement
- throw new RuntimeException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ListenerImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ListenerImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ListenerImpl.java
deleted file mode 100644
index a7dd936..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ListenerImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.driver.impl;
-
-import java.io.IOException;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.driver.Connector;
-import org.apache.qpid.proton.driver.Listener;
-
-@SuppressWarnings("deprecation")
-class ListenerImpl<C> implements Listener<C>
-{
- private C _context;
- private final ServerSocketChannel _channel;
- private final DriverImpl _driver;
- private final Logger _logger = Logger.getLogger("proton.driver");
- private boolean _selected = false;
-
- ListenerImpl(DriverImpl driver, ServerSocketChannel c, C context)
- {
- _driver = driver;
- _channel = c;
- _context = context;
- }
-
- void selected()
- {
- if (!_selected) {
- _selected = true;
- _driver.selectListener(this);
- }
- }
-
- void unselected()
- {
- _selected = false;
- }
-
- public Connector<C> accept()
- {
- try
- {
- SocketChannel c = _channel.accept();
- if(c != null)
- {
- c.configureBlocking(false);
- return _driver.createServerConnector(c, null, this);
- }
- }
- catch (IOException e)
- {
- _logger.log(Level.SEVERE, "Exception when accepting connection",e);
- }
- return null; //TODO - we should probably throw an exception instead of returning null?
- }
-
- public C getContext()
- {
- return _context;
- }
-
- public void setContext(C context)
- {
- _context = context;
- }
-
- public void close() throws IOException
- {
- _channel.socket().close();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java
deleted file mode 100644
index 2490052..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-
-
-/**
- * BaseHandler
- *
- */
-
-public class BaseHandler implements CoreHandler
-{
-
- public static Handler getHandler(Record r) {
- return r.get(Handler.class, Handler.class);
- }
-
- public static void setHandler(Record r, Handler handler) {
- r.set(Handler.class, Handler.class, handler);
- }
-
- public static Handler getHandler(Extendable ext) {
- return ext.attachments().get(Handler.class, Handler.class);
- }
-
- public static void setHandler(Extendable ext, Handler handler) {
- ext.attachments().set(Handler.class, Handler.class, handler);
- }
-
- private LinkedHashSet<Handler> children = new LinkedHashSet<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 onReactorInit(Event e) { onUnhandled(e); }
- @Override public void onReactorQuiesced(Event e) { onUnhandled(e); }
- @Override public void onReactorFinal(Event e) { onUnhandled(e); }
-
- @Override public void onTimerTask(Event e) { onUnhandled(e); }
-
- @Override public void onSelectableInit(Event e) { onUnhandled(e); }
- @Override public void onSelectableUpdated(Event e) { onUnhandled(e); }
- @Override public void onSelectableReadable(Event e) { onUnhandled(e); }
- @Override public void onSelectableWritable(Event e) { onUnhandled(e); }
- @Override public void onSelectableExpired(Event e) { onUnhandled(e); }
- @Override public void onSelectableError(Event e) { onUnhandled(e); }
- @Override public void onSelectableFinal(Event e) { onUnhandled(e); }
-
- @Override public void onUnhandled(Event event) {}
-
- @Override
- public void add(Handler child) {
- children.add(child);
- }
-
- @Override
- public Iterator<Handler> children() {
- return children.iterator();
- }
-
- @Override
- public void handle(Event e) {
- switch (e.getType()) {
- case CONNECTION_INIT:
- onConnectionInit(e);
- break;
- case CONNECTION_LOCAL_OPEN:
- onConnectionLocalOpen(e);
- break;
- case CONNECTION_REMOTE_OPEN:
- onConnectionRemoteOpen(e);
- break;
- case CONNECTION_LOCAL_CLOSE:
- onConnectionLocalClose(e);
- break;
- case CONNECTION_REMOTE_CLOSE:
- onConnectionRemoteClose(e);
- break;
- case CONNECTION_BOUND:
- onConnectionBound(e);
- break;
- case CONNECTION_UNBOUND:
- onConnectionUnbound(e);
- break;
- case CONNECTION_FINAL:
- onConnectionFinal(e);
- break;
- case SESSION_INIT:
- onSessionInit(e);
- break;
- case SESSION_LOCAL_OPEN:
- onSessionLocalOpen(e);
- break;
- case SESSION_REMOTE_OPEN:
- onSessionRemoteOpen(e);
- break;
- case SESSION_LOCAL_CLOSE:
- onSessionLocalClose(e);
- break;
- case SESSION_REMOTE_CLOSE:
- onSessionRemoteClose(e);
- break;
- case SESSION_FINAL:
- onSessionFinal(e);
- break;
- case LINK_INIT:
- onLinkInit(e);
- break;
- case LINK_LOCAL_OPEN:
- onLinkLocalOpen(e);
- break;
- case LINK_REMOTE_OPEN:
- onLinkRemoteOpen(e);
- break;
- case LINK_LOCAL_DETACH:
- onLinkLocalDetach(e);
- break;
- case LINK_REMOTE_DETACH:
- onLinkRemoteDetach(e);
- break;
- case LINK_LOCAL_CLOSE:
- onLinkLocalClose(e);
- break;
- case LINK_REMOTE_CLOSE:
- onLinkRemoteClose(e);
- break;
- case LINK_FLOW:
- onLinkFlow(e);
- break;
- case LINK_FINAL:
- onLinkFinal(e);
- break;
- case DELIVERY:
- onDelivery(e);
- break;
- case TRANSPORT:
- onTransport(e);
- break;
- case TRANSPORT_ERROR:
- onTransportError(e);
- break;
- case TRANSPORT_HEAD_CLOSED:
- onTransportHeadClosed(e);
- break;
- case TRANSPORT_TAIL_CLOSED:
- onTransportTailClosed(e);
- break;
- case TRANSPORT_CLOSED:
- onTransportClosed(e);
- break;
- case REACTOR_FINAL:
- onReactorFinal(e);
- break;
- case REACTOR_QUIESCED:
- onReactorQuiesced(e);
- break;
- case REACTOR_INIT:
- onReactorInit(e);
- break;
- case SELECTABLE_ERROR:
- onSelectableError(e);
- break;
- case SELECTABLE_EXPIRED:
- onSelectableExpired(e);
- break;
- case SELECTABLE_FINAL:
- onSelectableFinal(e);
- break;
- case SELECTABLE_INIT:
- onSelectableInit(e);
- break;
- case SELECTABLE_READABLE:
- onSelectableReadable(e);
- break;
- case SELECTABLE_UPDATED:
- onSelectableWritable(e);
- break;
- case SELECTABLE_WRITABLE:
- onSelectableWritable(e);
- break;
- case TIMER_TASK:
- onTimerTask(e);
- break;
- case NON_CORE_EVENT:
- onUnhandled(e);
- break;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Collector.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Collector.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Collector.java
deleted file mode 100644
index 142406e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Collector.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.engine.impl.CollectorImpl;
-
-/**
- * Collector
- *
- */
-
-public interface Collector
-{
-
- public static final class Factory
- {
- public static Collector create() {
- return new CollectorImpl();
- }
- }
-
- Event peek();
-
- void pop();
-
- boolean more();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Connection.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Connection.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Connection.java
deleted file mode 100644
index fb4de11..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Connection.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import java.util.EnumSet;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.engine.impl.ConnectionImpl;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.ReactorChild;
-
-
-/**
- * Maintains lists of sessions, links and deliveries in a state
- * that is interesting to the application.
- *
- * These are exposed by returning the head of those lists via
- * {@link #sessionHead(EnumSet, EnumSet)}, {@link #linkHead(EnumSet, EnumSet)}
- * {@link #getWorkHead()} respectively.
- */
-public interface Connection extends Endpoint, ReactorChild
-{
-
- public static final class Factory
- {
- public static Connection create() {
- return new ConnectionImpl();
- }
- }
-
- /**
- * Returns a newly created session
- *
- * TODO does the Connection's channel-max property limit how many sessions can be created,
- * or opened, or neither?
- */
- public Session session();
-
- /**
- * Returns the head of the list of sessions in the specified states.
- *
- * Typically used to discover sessions whose remote state has acquired
- * particular values, e.g. sessions that have been remotely opened or closed.
- *
- * TODO what ordering guarantees on the returned "linked list" are provided?
- *
- * @see Session#next(EnumSet, EnumSet)
- */
- public Session sessionHead(EnumSet<EndpointState> local, EnumSet<EndpointState> remote);
-
- /**
- * Returns the head of the list of links in the specified states.
- *
- * Typically used to discover links whose remote state has acquired
- * particular values, e.g. links that have been remotely opened or closed.
- *
- * @see Link#next(EnumSet, EnumSet)
- */
- public Link linkHead(EnumSet<EndpointState> local, EnumSet<EndpointState> remote);
-
- /**
- * Returns the head of the delivery work list. The delivery work list consists of
- * unsettled deliveries whose state has been changed by the other container
- * and not yet locally processed.
- *
- * @see Receiver#recv(byte[], int, int)
- * @see Delivery#settle()
- * @see Delivery#getWorkNext()
- */
- public Delivery getWorkHead();
-
- public void setContainer(String container);
-
- public String getContainer();
-
- /**
- * Set the name of the host (either fully qualified or relative) to which
- * this connection is connecting to. This information may be used by the
- * remote peer to determine the correct back-end service to connect the
- * client to. This value will be sent in the Open performative.
- *
- * <b>Note that it is illegal to set the hostname to a numeric IP
- * address or include a port number.</b>
- *
- * @param hostname the RFC1035 compliant host name.
- */
- public void setHostname(String hostname);
-
- public String getHostname();
-
- public String getRemoteContainer();
-
- public String getRemoteHostname();
-
- void setOfferedCapabilities(Symbol[] capabilities);
-
- void setDesiredCapabilities(Symbol[] capabilities);
-
- Symbol[] getRemoteOfferedCapabilities();
-
- Symbol[] getRemoteDesiredCapabilities();
-
- Map<Symbol,Object> getRemoteProperties();
-
- void setProperties(Map<Symbol,Object> properties);
-
- @Override
- Object getContext();
-
- @Override
- void setContext(Object context);
-
- void collect(Collector collector);
-
- Transport getTransport();
-
- Reactor getReactor();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/CoreHandler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/CoreHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/CoreHandler.java
deleted file mode 100644
index 81c66db..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/CoreHandler.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-public interface CoreHandler extends 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 onReactorInit(Event e);
- void onReactorQuiesced(Event e);
- void onReactorFinal(Event e);
-
- void onTimerTask(Event e);
-
- void onSelectableInit(Event e);
- void onSelectableUpdated(Event e);
- void onSelectableReadable(Event e);
- void onSelectableWritable(Event e);
- void onSelectableExpired(Event e);
- void onSelectableError(Event e);
- void onSelectableFinal(Event e);
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java
deleted file mode 100644
index c5f6d73..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-
-/**
- * A delivery of a message on a particular link.
- *
- * Whilst a message is logically a long-lived object, a delivery is short-lived - it
- * is only intended to be used by the application until it is settled and all its data has been read.
- */
-public interface Delivery extends Extendable
-{
-
- public byte[] getTag();
-
- public Link getLink();
-
- public DeliveryState getLocalState();
-
- public DeliveryState getRemoteState();
-
- /**
- * updates the state of the delivery
- *
- * @param state the new delivery state
- */
- public void disposition(DeliveryState state);
-
- /**
- * Settles this delivery.
- *
- * Causes the delivery to be removed from the connection's work list (see {@link Connection#getWorkHead()}).
- * If this delivery is its link's current delivery, the link's current delivery pointer is advanced.
- */
- public void settle();
-
- /**
- * Returns whether this delivery has been settled.
- *
- * TODO proton-j and proton-c return the local and remote statuses respectively. Resolve this ambiguity.
- *
- * @see #settle()
- */
- public boolean isSettled();
-
- public boolean remotelySettled();
-
- /**
- * TODO When does an application call this method? Do we really need this?
- */
- public void free();
-
- /**
- * @see Connection#getWorkHead()
- */
- public Delivery getWorkNext();
-
- public Delivery next();
-
- public boolean isWritable();
-
- /**
- * Returns whether this delivery has data ready to be received.
- *
- * @see Receiver#recv(byte[], int, int)
- */
- public boolean isReadable();
-
- public void setContext(Object o);
-
- public Object getContext();
-
- /**
- * Returns whether this delivery's state or settled flag has ever remotely changed.
- *
- * TODO what is the main intended use case for calling this method?
- */
- public boolean isUpdated();
-
- public void clear();
-
- public boolean isPartial();
-
- public int pending();
-
- public boolean isBuffered();
-
- /**
- * Configures a default DeliveryState to be used if a
- * received delivery is settled/freed without any disposition
- * state having been previously applied.
- *
- * @param state the default delivery state
- */
- public void setDefaultDeliveryState(DeliveryState state);
-
- public DeliveryState getDefaultDeliveryState();
-
- /**
- * Sets the message-format for this Delivery, representing the 32bit value using an int.
- *
- * The default value is 0 as per the message format defined in the core AMQP 1.0 specification.<p>
- *
- * See the following for more details:<br>
- * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-transfer">
- * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-transfer</a><br>
- * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-message-format">
- * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-message-format</a><br>
- * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format">
- * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format</a><br>
- * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#definition-MESSAGE-FORMAT">
- * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#definition-MESSAGE-FORMAT</a><br>
- *
- * @param messageFormat the message format
- */
- public void setMessageFormat(int messageFormat);
-
- /**
- * Gets the message-format for this Delivery, representing the 32bit value using an int.
- *
- * @return the message-format
- * @see #setMessageFormat(int)
- */
- public int getMessageFormat();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java
deleted file mode 100644
index d88087b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine;
-
-
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-
-public interface Endpoint extends Extendable
-{
- /**
- * @return the local endpoint state
- */
- public EndpointState getLocalState();
-
- /**
- * @return the remote endpoint state (as last communicated)
- */
- public EndpointState getRemoteState();
-
- /**
- * @return the local endpoint error, or null if there is none
- */
- public ErrorCondition getCondition();
-
- /**
- * Set the local error condition
- * @param condition
- */
- public void setCondition(ErrorCondition condition);
-
- /**
- * @return the remote endpoint error, or null if there is none
- */
- public ErrorCondition getRemoteCondition();
-
- /**
- * free the endpoint and any associated resources
- */
- public void free();
-
- /**
- * transition local state to ACTIVE
- */
- void open();
-
- /**
- * transition local state to CLOSED
- */
- void close();
-
- /**
- * Sets an arbitrary an application owned object on the end-point. This object
- * is not used by Proton.
- */
- public void setContext(Object o);
-
- /**
- * @see #setContext(Object)
- */
- public Object getContext();
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[05/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtonEngineExampleTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtonEngineExampleTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtonEngineExampleTest.java
deleted file mode 100644
index cb167f8..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtonEngineExampleTest.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static java.util.EnumSet.of;
-import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
-import static org.apache.qpid.proton.engine.EndpointState.CLOSED;
-import static org.apache.qpid.proton.engine.EndpointState.UNINITIALIZED;
-import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.messaging.Accepted;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.amqp.messaging.Section;
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Receiver;
-import org.apache.qpid.proton.message.Message;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Simple example to illustrate the use of the Engine and Message APIs.
- *
- * Implemented as a JUnit test for convenience, although the main purpose is to educate the reader
- * rather than test the code.
- *
- * To see the protocol trace, add the following line to test/resources/logging.properties:
- *
- * org.apache.qpid.proton.logging.LoggingProtocolTracer.sent.level = ALL
- *
- * and to see the byte level trace, add the following:
- *
- * org.apache.qpid.proton.systemtests.ProtonEngineExampleTest.level = ALL
- *
- * Does not illustrate use of the Messenger API.
- */
-public class ProtonEngineExampleTest extends EngineTestBase
-{
- private static final Logger LOGGER = Logger.getLogger(ProtonEngineExampleTest.class.getName());
-
- private static final int BUFFER_SIZE = 4096;
-
- private final String _targetAddress = getServer().containerId + "-link1-target";
-
- @Test
- public void test() throws Exception
- {
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
- getClient().session.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().session, ACTIVE, ACTIVE);
-
- LOGGER.fine(bold("======== About to create sender"));
-
- getClient().source = new Source();
- getClient().source.setAddress(null);
-
- getClient().target = new Target();
- getClient().target.setAddress(_targetAddress);
-
- getClient().sender = getClient().session.sender("link1");
- getClient().sender.setTarget(getClient().target);
- getClient().sender.setSource(getClient().source);
- // Exactly once delivery semantics
- getClient().sender.setSenderSettleMode(SenderSettleMode.UNSETTLED);
- getClient().sender.setReceiverSettleMode(ReceiverSettleMode.SECOND);
-
- assertEndpointState(getClient().sender, UNINITIALIZED, UNINITIALIZED);
-
- getClient().sender.open();
- assertEndpointState(getClient().sender, ACTIVE, UNINITIALIZED);
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== About to set up implicitly created receiver"));
-
- // A real application would be interested in more states than simply ACTIVE, as there
- // exists the possibility that the link could have moved to another state already e.g. CLOSED.
- // (See pipelining).
- getServer().receiver = (Receiver) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
- // Accept the settlement modes suggested by the client
- getServer().receiver.setSenderSettleMode(getServer().receiver.getRemoteSenderSettleMode());
- getServer().receiver.setReceiverSettleMode(getServer().receiver.getRemoteReceiverSettleMode());
-
- org.apache.qpid.proton.amqp.transport.Target serverRemoteTarget = getServer().receiver.getRemoteTarget();
- assertTerminusEquals(getClient().target, serverRemoteTarget);
-
- getServer().receiver.setTarget(applicationDeriveTarget(serverRemoteTarget));
-
- assertEndpointState(getServer().receiver, UNINITIALIZED, ACTIVE);
- getServer().receiver.open();
-
- assertEndpointState(getServer().receiver, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().sender, ACTIVE, ACTIVE);
-
- getServer().receiver.flow(1);
- pumpServerToClient();
-
- LOGGER.fine(bold("======== About to create a message and send it to the server"));
-
- getClient().message = Proton.message();
- Section messageBody = new AmqpValue("Hello");
- getClient().message.setBody(messageBody);
- getClient().messageData = new byte[BUFFER_SIZE];
- int lengthOfEncodedMessage = getClient().message.encode(getClient().messageData, 0, BUFFER_SIZE);
- getTestLoggingHelper().prettyPrint(TestLoggingHelper.MESSAGE_PREFIX, Arrays.copyOf(getClient().messageData, lengthOfEncodedMessage));
-
- byte[] deliveryTag = "delivery1".getBytes();
- getClient().delivery = getClient().sender.delivery(deliveryTag);
- int numberOfBytesAcceptedBySender = getClient().sender.send(getClient().messageData, 0, lengthOfEncodedMessage);
- assertEquals("For simplicity, assume the sender can accept all the data",
- lengthOfEncodedMessage, numberOfBytesAcceptedBySender);
-
- assertNull(getClient().delivery.getLocalState());
-
- boolean senderAdvanced = getClient().sender.advance();
- assertTrue("sender has not advanced", senderAdvanced);
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== About to process the message on the server"));
-
- getServer().delivery = getServer().connection.getWorkHead();
- assertEquals("The received delivery should be on our receiver",
- getServer().receiver, getServer().delivery.getLink());
- assertNull(getServer().delivery.getLocalState());
- assertNull(getServer().delivery.getRemoteState());
-
- assertFalse(getServer().delivery.isPartial());
- assertTrue(getServer().delivery.isReadable());
-
- getServer().messageData = new byte[BUFFER_SIZE];
- int numberOfBytesProducedByReceiver = getServer().receiver.recv(getServer().messageData, 0, BUFFER_SIZE);
- assertEquals(numberOfBytesAcceptedBySender, numberOfBytesProducedByReceiver);
-
- getServer().message = Proton.message();
- getServer().message.decode(getServer().messageData, 0, numberOfBytesProducedByReceiver);
-
- boolean messageProcessed = applicationProcessMessage(getServer().message);
- assertTrue(messageProcessed);
-
- getServer().delivery.disposition(Accepted.getInstance());
- assertEquals(Accepted.getInstance(), getServer().delivery.getLocalState());
-
- pumpServerToClient();
- assertEquals(Accepted.getInstance(), getClient().delivery.getRemoteState());
-
- LOGGER.fine(bold("======== About to accept and settle the message on the client"));
-
- Delivery clientDelivery = getClient().connection.getWorkHead();
- assertEquals(getClient().delivery, clientDelivery);
- assertTrue(clientDelivery.isUpdated());
- assertEquals(getClient().sender, clientDelivery.getLink());
- clientDelivery.disposition(clientDelivery.getRemoteState());
- assertEquals(Accepted.getInstance(), getClient().delivery.getLocalState());
-
- clientDelivery.settle();
- assertNull("Now we've settled, the delivery should no longer be in the work list", getClient().connection.getWorkHead());
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== About to settle the message on the server"));
-
- assertEquals(Accepted.getInstance(), getServer().delivery.getRemoteState());
- Delivery serverDelivery = getServer().connection.getWorkHead();
- assertEquals(getServer().delivery, serverDelivery);
- assertTrue(serverDelivery.isUpdated());
- assertTrue("Client should have already settled", serverDelivery.remotelySettled());
- serverDelivery.settle();
- assertTrue(serverDelivery.isSettled());
- assertNull("Now we've settled, the delivery should no longer be in the work list", getServer().connection.getWorkHead());
-
- // Increment the receiver's credit so its ready for another message.
- // When using proton-c, this call is required in order to generate a Flow frame
- // (proton-j sends one even without it to eagerly restore the session incoming window).
- getServer().receiver.flow(1);
- pumpServerToClient();
-
- LOGGER.fine(bold("======== About to close client's sender"));
-
- getClient().sender.close();
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== Server about to process client's link closure"));
-
- assertSame(getServer().receiver, getServer().connection.linkHead(of(ACTIVE), of(CLOSED)));
- getServer().receiver.close();
-
- pumpServerToClient();
-
- LOGGER.fine(bold("======== About to close client's session"));
-
- getClient().session.close();
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== Server about to process client's session closure"));
-
- assertSame(getServer().session, getServer().connection.sessionHead(of(ACTIVE), of(CLOSED)));
- getServer().session.close();
-
- pumpServerToClient();
-
- LOGGER.fine(bold("======== About to close client's connection"));
-
- getClient().connection.close();
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== Server about to process client's connection closure"));
-
- assertEquals(CLOSED, getServer().connection.getRemoteState());
- getServer().connection.close();
-
- pumpServerToClient();
-
- LOGGER.fine(bold("======== Checking client has nothing more to pump"));
-
- assertClientHasNothingToOutput();
-
- LOGGER.fine(bold("======== Done!"));
- }
-
- @Ignore("This test does not have a fix yet")
- @Test
- public void testPROTON_1017() throws Exception
- {
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
- LOGGER.fine(bold("======== About to open and close client session"));
- getClient().session = getClient().connection.session();
- getClient().session.open();
- getClient().session.close();
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(CLOSED));
- assertEndpointState(getServer().session, UNINITIALIZED, CLOSED);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, CLOSED);
-
- getServer().session.close();
- assertEndpointState(getServer().session, CLOSED, CLOSED);
-
- pumpServerToClient();
- assertEndpointState(getClient().session, CLOSED, CLOSED);
-
- LOGGER.fine(bold("======== About to close client's connection"));
-
- getClient().connection.close();
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== Server about to process client's connection closure"));
-
- assertEquals(CLOSED, getServer().connection.getRemoteState());
- getServer().connection.close();
-
- pumpServerToClient();
-
- LOGGER.fine(bold("======== Checking client has nothing more to pump"));
-
- assertClientHasNothingToOutput();
-
- LOGGER.fine(bold("======== Done!"));
- }
-
- /**
- * Simulates creating a local terminus using the properties supplied by the remote link endpoint.
- *
- * In a broker you'd usually overlay serverRemoteTarget (eg its filter properties) onto
- * an existing object (which eg contains whether it's a queue or a topic), creating a new one from that
- * overlay. Also if this is link recovery then you'd fetch the unsettled map too.
- */
- private org.apache.qpid.proton.amqp.transport.Target applicationDeriveTarget(org.apache.qpid.proton.amqp.transport.Target serverRemoteTarget)
- {
- return serverRemoteTarget;
- }
-
- /**
- * Simulates processing a message.
- */
- private boolean applicationProcessMessage(Message message)
- {
- Object messageBody = ((AmqpValue)message.getBody()).getValue();
- return "Hello".equals(messageBody);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SaslTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SaslTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SaslTest.java
deleted file mode 100644
index 2980565..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SaslTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.Sasl;
-import org.junit.Test;
-
-public class SaslTest extends EngineTestBase
-{
- private static final Logger LOGGER = Logger.getLogger(SaslTest.class.getName());
-
- @Test
- public void testSaslHostnamePropagationAndRetrieval() throws Exception
- {
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- Sasl clientSasl = getClient().transport.sasl();
- clientSasl.client();
-
- // Set the server hostname we are connecting to from the client
- String hostname = "my-remote-host-123";
- clientSasl.setRemoteHostname(hostname);
-
- // Verify we can't get the hostname on the client
- try
- {
- clientSasl.getHostname();
- fail("should have throw IllegalStateException");
- }
- catch (IllegalStateException ise)
- {
- // expected
- }
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- // Configure the server to do ANONYMOUS
- Sasl serverSasl = getServer().transport.sasl();
- serverSasl.server();
- serverSasl.setMechanisms("ANONYMOUS");
-
- // Verify we can't set the hostname on the server
- try
- {
- serverSasl.setRemoteHostname("some-other-host");
- fail("should have throw IllegalStateException");
- }
- catch (IllegalStateException ise)
- {
- // expected
- }
-
- assertNull(serverSasl.getHostname());
- assertArrayEquals(new String[0], clientSasl.getRemoteMechanisms());
-
- pumpClientToServer();
- pumpServerToClient();
-
- // Verify we got the mechs, set the chosen mech, and verify the
- // server still doesnt know the hostname set/requested by the client
- assertArrayEquals(new String[] {"ANONYMOUS"} , clientSasl.getRemoteMechanisms());
- clientSasl.setMechanisms("ANONYMOUS");
- assertNull(serverSasl.getHostname());
-
- pumpClientToServer();
-
- // Verify the server now knows that the client set the hostname field
- assertEquals(hostname, serverSasl.getHostname());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SessionTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SessionTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SessionTest.java
deleted file mode 100644
index 728c6b9..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SessionTest.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static java.util.EnumSet.of;
-import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
-import static org.apache.qpid.proton.engine.EndpointState.UNINITIALIZED;
-import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.junit.Test;
-
-public class SessionTest extends EngineTestBase
-{
- private static final Logger LOGGER = Logger.getLogger(SessionTest.class.getName());
-
- @Test
- public void testCapabilities() throws Exception
- {
- final Symbol clientOfferedCap = Symbol.valueOf("clientOfferedCapability");
- final Symbol clientDesiredCap = Symbol.valueOf("clientDesiredCapability");
- final Symbol serverOfferedCap = Symbol.valueOf("serverOfferedCapability");
- final Symbol serverDesiredCap = Symbol.valueOf("serverDesiredCapability");
-
- Symbol[] clientOfferedCapabilities = new Symbol[] { clientOfferedCap };
- Symbol[] clientDesiredCapabilities = new Symbol[] { clientDesiredCap };
-
- Symbol[] serverOfferedCapabilities = new Symbol[] { serverOfferedCap };
- Symbol[] serverDesiredCapabilities = new Symbol[] { serverDesiredCap };
-
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
-
- // Set the client session capabilities
- getClient().session.setOfferedCapabilities(clientOfferedCapabilities);
- getClient().session.setDesiredCapabilities(clientDesiredCapabilities);
-
- getClient().session.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- // Set the server session capabilities
- getServer().session.setOfferedCapabilities(serverOfferedCapabilities);
- getServer().session.setDesiredCapabilities(serverDesiredCapabilities);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- pumpServerToClient();
-
- // Verify server side got the clients session capabilities as expected
- Symbol[] serverRemoteOfferedCapabilities = getServer().session.getRemoteOfferedCapabilities();
- assertNotNull("Server had no remote offered capabilities", serverRemoteOfferedCapabilities);
- assertEquals("Server remote offered capabilities not expected size", 1, serverRemoteOfferedCapabilities.length);
- assertTrue("Server remote offered capabilities lack expected value: " + clientOfferedCap, Arrays.asList(serverRemoteOfferedCapabilities).contains(clientOfferedCap));
-
- Symbol[] serverRemoteDesiredCapabilities = getServer().session.getRemoteDesiredCapabilities();
- assertNotNull("Server had no remote desired capabilities", serverRemoteDesiredCapabilities);
- assertEquals("Server remote desired capabilities not expected size", 1, serverRemoteDesiredCapabilities.length);
- assertTrue("Server remote desired capabilities lack expected value: " + clientDesiredCap, Arrays.asList(serverRemoteDesiredCapabilities).contains(clientDesiredCap));
-
- // Verify the client side got the servers session capabilities as expected
- Symbol[] clientRemoteOfferedCapabilities = getClient().session.getRemoteOfferedCapabilities();
- assertNotNull("Client had no remote offered capabilities", clientRemoteOfferedCapabilities);
- assertEquals("Client remote offered capabilities not expected size", 1, clientRemoteOfferedCapabilities.length);
- assertTrue("Client remote offered capabilities lack expected value: " + serverOfferedCap, Arrays.asList(clientRemoteOfferedCapabilities).contains(serverOfferedCap));
-
- Symbol[] clientRemoteDesiredCapabilities = getClient().session.getRemoteDesiredCapabilities();
- assertNotNull("Client had no remote desired capabilities", clientRemoteDesiredCapabilities);
- assertEquals("Client remote desired capabilities not expected size", 1, clientRemoteDesiredCapabilities.length);
- assertTrue("Client remote desired capabilities lack expected value: " + serverDesiredCap, Arrays.asList(clientRemoteDesiredCapabilities).contains(serverDesiredCap));
- }
-
- @Test
- public void testProperties() throws Exception
- {
- final Symbol clientPropName = Symbol.valueOf("ClientPropName");
- final Integer clientPropValue = 1234;
- final Symbol serverPropName = Symbol.valueOf("ServerPropName");
- final Integer serverPropValue = 5678;
-
- Map<Symbol, Object> clientProps = new HashMap<>();
- clientProps.put(clientPropName, clientPropValue);
-
- Map<Symbol, Object> serverProps = new HashMap<>();
- serverProps.put(serverPropName, serverPropValue);
-
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
-
- // Set the client session properties
- getClient().session.setProperties(clientProps);
-
- getClient().session.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- // Set the server session properties
- getServer().session.setProperties(serverProps);
-
- getServer().session.open();
-
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- pumpServerToClient();
-
- assertEndpointState(getClient().session, ACTIVE, ACTIVE);
-
- // Verify server side got the clients session properties as expected
- Map<Symbol, Object> serverRemoteProperties = getServer().session.getRemoteProperties();
- assertNotNull("Server had no remote properties", serverRemoteProperties);
- assertEquals("Server remote properties not expected size", 1, serverRemoteProperties.size());
- assertTrue("Server remote properties lack expected key: " + clientPropName, serverRemoteProperties.containsKey(clientPropName));
- assertEquals("Server remote properties contain unexpected value for key: " + clientPropName, clientPropValue, serverRemoteProperties.get(clientPropName));
-
- // Verify the client side got the servers session properties as expected
- Map<Symbol, Object> clientRemoteProperties = getClient().session.getRemoteProperties();
- assertNotNull("Client had no remote properties", clientRemoteProperties);
- assertEquals("Client remote properties not expected size", 1, clientRemoteProperties.size());
- assertTrue("Client remote properties lack expected key: " + serverPropName, clientRemoteProperties.containsKey(serverPropName));
- assertEquals("Client remote properties contain unexpected value for key: " + serverPropName, serverPropValue, clientRemoteProperties.get(serverPropName));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java
deleted file mode 100644
index 2a4df7e..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Transport;
-import org.junit.Test;
-
-public class SimpleTest
-{
-
- @Test
- public void test()
- {
- Connection connection1 = Proton.connection();
- Connection connection2 = Proton.connection();;
- Transport transport1 = Proton.transport();
- transport1.bind(connection1);
-
- Transport transport2 = Proton.transport();
- transport2.bind(connection2);
-
- assertEquals(EndpointState.UNINITIALIZED, connection1.getLocalState());
- assertEquals(EndpointState.UNINITIALIZED, connection1.getRemoteState());
-
- connection1.open();
- connection2.open();
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/TestLoggingHelper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/TestLoggingHelper.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/TestLoggingHelper.java
deleted file mode 100644
index 1dd71f1..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/TestLoggingHelper.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import java.nio.ByteBuffer;
-import java.util.logging.Logger;
-
-/**
- * Provides functions for Proton tests to produce readable logging.
- * Uses terminal colours if system property {@value #PROTON_TEST_TERMINAL_COLOURS_PROPERTY}
- * is true
- */
-public class TestLoggingHelper
-{
- public static final String PROTON_TEST_TERMINAL_COLOURS_PROPERTY = "proton.test.terminal.colours";
-
- private static final String COLOUR_RESET;
- private static final String SERVER_COLOUR;
- private static final String CLIENT_COLOUR;
- private static final String BOLD;
-
- static
- {
- if(Boolean.getBoolean(PROTON_TEST_TERMINAL_COLOURS_PROPERTY))
- {
- BOLD = "\033[1m";
- SERVER_COLOUR = "\033[34m"; // blue
- CLIENT_COLOUR = "\033[32m"; // green
- COLOUR_RESET = "\033[0m";
- }
- else
- {
- BOLD = SERVER_COLOUR = CLIENT_COLOUR = COLOUR_RESET = "";
- }
- }
-
- public static final String CLIENT_PREFIX = CLIENT_COLOUR + "CLIENT" + COLOUR_RESET;
- public static final String SERVER_PREFIX = SERVER_COLOUR + "SERVER" + COLOUR_RESET;
- public static final String MESSAGE_PREFIX = "MESSAGE";
-
-
- private final BinaryFormatter _binaryFormatter = new BinaryFormatter();
- private Logger _logger;
-
- public TestLoggingHelper(Logger logger)
- {
- _logger = logger;
- }
-
- public void prettyPrint(String prefix, byte[] bytes)
- {
- _logger.fine(prefix + " " + bytes.length + " byte(s) " + _binaryFormatter.format(bytes));
- }
-
- /**
- * Note that ByteBuffer is assumed to be readable. Its state is unchanged by this operation.
- */
- public void prettyPrint(String prefix, ByteBuffer buf)
- {
- byte[] bytes = new byte[buf.remaining()];
- buf.duplicate().get(bytes);
- prettyPrint(prefix, bytes);
- }
-
- public static String bold(String string)
- {
- return BOLD + string + TestLoggingHelper.COLOUR_RESET;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/ConnectionTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/ConnectionTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/ConnectionTest.java
deleted file mode 100644
index 10f6d52..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/ConnectionTest.java
+++ /dev/null
@@ -1,789 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests.engine;
-
-import static java.util.EnumSet.of;
-import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
-import static org.apache.qpid.proton.engine.EndpointState.CLOSED;
-import static org.apache.qpid.proton.engine.EndpointState.UNINITIALIZED;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.transport.Close;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Endpoint;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.impl.AmqpFramer;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Implicitly tests both {@link Connection} and {@link Transport} (e.g. for stuff like the AMQP header exchange).
- *
- * TODO test that the connection properties, connection capability, and error info maps have keys that are exclusively of type Symbol.
- */
-public class ConnectionTest
-{
- private static final String SERVER_CONTAINER = "serverContainer";
- private static final String CLIENT_CONTAINER = "clientContainer";
-
- private final Transport _clientTransport = Proton.transport();
- private final Transport _serverTransport = Proton.transport();
-
- private final TransportPumper _pumper = new TransportPumper(_clientTransport, _serverTransport);
-
- private final Connection _clientConnection = Proton.connection();
- private final Connection _serverConnection = Proton.connection();
-
- private final AmqpFramer _framer = new AmqpFramer();
-
- // 2.4.1 Opening A Connection
-
- /** */
- @Test
- public void testOpenConnection()
- {
- _pumper.pumpAll();
-
- bindAndOpenConnections();
- }
-
-
- /** Container id is a mandatory field so this should cause an error */
- @Test
- public void testReceiptOfOpenWithoutContainerId_causesTODO()
- {
- _pumper.pumpAll();
-
- Open openWithoutContainerId = new Open();
- byte[] openFrameBuffer = _framer.generateFrame(0, openWithoutContainerId);
-
- int serverConsumed = _serverTransport.input(openFrameBuffer, 0, openFrameBuffer.length);
- assertEquals(openFrameBuffer.length, serverConsumed);
- assertEquals(_serverTransport.capacity(), Transport.END_OF_STREAM);
- }
-
- /**
- * "Prior to any explicit negotiation, the maximum frame size is 512 (MIN-MAX-FRAME-SIZE) and the maximum channel number is 0"
- * */
- @Test
- public void testReceiptOfOpenExactlyDefaultMaximumFrameSize()
- {
- _pumper.pumpAll();
-
- _serverTransport.bind(_serverConnection);
- assertEnpointState(_serverConnection, UNINITIALIZED, UNINITIALIZED);
-
- // containerId and extended header sized to give an open frame
- // exactly 512 bytes in length.
- String containerId = "12345678";
- int extendedHeaderSize = 122 * 4;
-
- Open open = new Open();
- open.setContainerId(containerId);
- byte[] openFrameBuffer = _framer.generateFrame(0, new byte[extendedHeaderSize], open);
- assertEquals("Test requires a frame of size MIN_MAX_FRAME_SIZE",
- Transport.MIN_MAX_FRAME_SIZE, openFrameBuffer.length);
-
- int serverConsumed = _serverTransport.input(openFrameBuffer, 0, openFrameBuffer.length);
- assertEquals(openFrameBuffer.length, serverConsumed);
-
- // Verify that the server has seen the Open arrive
- assertEnpointState(_serverConnection, UNINITIALIZED, ACTIVE);
- assertEquals(containerId, _serverConnection.getRemoteContainer());
- }
-
- /**
- * "Prior to any explicit negotiation, the maximum frame size is 512 (MIN-MAX-FRAME-SIZE) and the maximum channel number is 0"
- */
- @Test
- public void testReceiptOfOpenBiggerThanDefaultMaximumFrameSize_causesTODO()
- {
- _pumper.pumpAll();
-
- _serverTransport.bind(_serverConnection);
- assertEnpointState(_serverConnection, UNINITIALIZED, UNINITIALIZED);
-
- // containerId and extended header sized to give an open frame
- // 1 byte larger the than 512 bytes permitted before negotiation by the AMQP spec.
-
- String containerId = "123456789";
- int extendedHeaderSize = 122 * 4;
-
- Open bigOpen = new Open();
- bigOpen.setContainerId(containerId);
- byte[] openFrameBuffer = _framer.generateFrame(0, new byte[extendedHeaderSize], bigOpen);
- assertEquals("Test requires a frame of size MIN_MAX_FRAME_SIZE + 1",
- Transport.MIN_MAX_FRAME_SIZE + 1, openFrameBuffer.length);
-
- int serverConsumed = _serverTransport.input(openFrameBuffer, 0, openFrameBuffer.length);
- assertEquals(openFrameBuffer.length, serverConsumed);
-
- // TODO server should indicate error but currently both implementations currently process
- // the larger frames. The following assertions should fail but currently pass.
- assertEnpointState(_serverConnection, UNINITIALIZED, ACTIVE);
- assertNotNull(_serverConnection.getRemoteContainer());
- }
-
- @Test
- public void testReceiptOfSecondOpen_causesTODO()
- {
- bindAndOpenConnections();
-
- Open secondOpen = new Open(); // erroneous
- secondOpen.setContainerId("secondOpen");
- byte[] openFrameBuffer = _framer.generateFrame(0, secondOpen);
-
- int serverConsumed = _serverTransport.input(openFrameBuffer, 0, openFrameBuffer.length);
- assertEquals(openFrameBuffer.length, serverConsumed);
-
- // TODO server should indicate error but currently both implementation currently
- // allow this condition
- }
-
- /** "each peer MUST send an open frame before sending any other frames"
- *
- * @see ConnectionTest#testReceiptOfCloseBeforeOpen_causesTODO()
- */
- public void testReceiptOfIntialFrameOtherThanOpen_causesTODO()
- {
- }
-
- /**
- * 2.4.5 "Implementations MUST be prepared to handle empty frames arriving on any valid channel"
- *
- * TODO consider moving to {@link TransportTest} once we have a less Connection-centric way of
- * checking health than calling {@link #bindAndOpenConnections()}
- */
- @Test
- public void testReceiptOfInitialEmptyFrame_isAllowed()
- {
- _pumper.pumpAll();
-
- byte[] emptyFrame = _framer.createEmptyFrame(0);
- int bytesConsumed = _serverTransport.input(emptyFrame, 0, emptyFrame.length);
- assertEquals(emptyFrame.length, bytesConsumed);
-
- bindAndOpenConnections();
- }
-
-
- /** "The open frame can only be sent on channel 0" */
- @Test
- @Ignore("Reinstate once it is agreed how error condition will be reported to user of API")
- public void testReceiptOfOpenOnNonZeroChannelNumber_causesTODO()
- {
- _pumper.pumpAll();
-
- Open open = new Open();
- open.setContainerId(SERVER_CONTAINER);
-
- int nonZeroChannelId = 1;
- byte[] buf = _framer.generateFrame(nonZeroChannelId, open);
- int rv = _serverTransport.input(buf, 0, buf.length);
- // TODO server should indicate error
- }
-
-
- /**
- * "After sending the open frame and reading its partner's open frame a peer MUST operate within
- * mutually acceptable limitations from this point forward"
- * see 2.7.1 "A peer that receives an oversized frame MUST close the connection with the framing-error error-code"
- */
- public void testReceiptOfFrameLargerThanAgreedMaximumSize_causesTODO()
- {
- }
-
- public void testThatSentFramesAreWithinMaximumSizeLimit()
- {
- }
-
- // 2.4.2 Pipelined Open
-
- /** test that the other peer accepts the pipelined frames and creates an open connection */
- @Test
- public void testReceiptOfOpenUsingPipelining()
- {
- _clientConnection.setContainer(CLIENT_CONTAINER);
- _clientTransport.bind(_clientConnection);
- _clientConnection.open();
-
- _serverTransport.bind(_serverConnection);
-
- // when pipelining, we delay pumping until the connection is both bound and opened
- _pumper.pumpOnceFromClientToServer();
-
- assertEnpointState(_clientConnection, ACTIVE, UNINITIALIZED);
- assertEnpointState(_serverConnection, UNINITIALIZED, ACTIVE);
- }
-
-
- /** test that the other peer accepts the pipelined frames and creates an already-closed connection */
- @Test
- public void testReceiptOfOpenThenCloseUsingPipelining()
- {
- _clientConnection.setContainer(CLIENT_CONTAINER);
- _clientTransport.bind(_clientConnection);
- _clientConnection.open();
- _clientConnection.close();
-
- _serverTransport.bind(_serverConnection);
- _pumper.pumpOnceFromClientToServer();
-
- assertEnpointState(_clientConnection, CLOSED, UNINITIALIZED);
- assertEnpointState(_serverConnection, UNINITIALIZED, CLOSED);
- }
-
- /**
- * Similar to {@link #testReceiptOfOpenUsingPipelining()} but opens both ends of the connection
- * so we can actually use it.
- */
- @Test
- public void testOpenConnectionUsingPipelining()
- {
- _clientConnection.setContainer(CLIENT_CONTAINER);
- _clientTransport.bind(_clientConnection);
- _clientConnection.open();
-
-
- _serverConnection.setContainer(SERVER_CONTAINER);
- _serverTransport.bind(_serverConnection);
- _serverConnection.open();
-
- _pumper.pumpAll();
-
- assertEnpointState(_clientConnection, ACTIVE, ACTIVE);
- assertEnpointState(_serverConnection, ACTIVE, ACTIVE);
-
- assertConnectionIsUsable();
- }
-
- // 2.4.3 Closing A Connection and 2.7.9 Close
-
- /**
- * "each peer MUST write a close frame"
- * Omits the optional error field
- */
- @Test
- public void testCloseConnection()
- {
- bindAndOpenConnections();
-
- assertEnpointState(_clientConnection, ACTIVE, ACTIVE);
- assertEnpointState(_serverConnection, ACTIVE, ACTIVE);
-
- _clientConnection.close();
-
- assertEnpointState(_clientConnection, CLOSED, ACTIVE);
- assertEnpointState(_serverConnection, ACTIVE, ACTIVE);
-
- _pumper.pumpAll();
-
- assertEnpointState(_clientConnection, CLOSED, ACTIVE);
- assertEnpointState(_serverConnection, ACTIVE, CLOSED);
-
- _serverConnection.close();
-
- assertEnpointState(_clientConnection, CLOSED, ACTIVE);
- assertEnpointState(_serverConnection, CLOSED, CLOSED);
-
- _pumper.pumpAll();
-
- assertEnpointState(_clientConnection, CLOSED, CLOSED);
- assertEnpointState(_serverConnection, CLOSED, CLOSED);
- }
-
- /**
- * "each peer MUST write a close frame with a code indicating the reason for closing"
- * Also see 2.8.16 Connection Error
- */
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testCloseConnectionWithErrorCode_causesCloseFrameContainingErrorCodeToBeSent()
- {
- bindAndOpenConnections();
-
- /*
- * TODO javadoc for {@link Connection#getCondition()} states null is returned if there is no condition,
- * this differs from the implementation of both Proton-c and Proton-j.
- */
- assertNull(_clientConnection.getCondition().getCondition());
- assertNull(_serverConnection.getCondition().getCondition());
-
- assertNull(_clientConnection.getRemoteCondition().getCondition());
- assertNull(_serverConnection.getRemoteCondition().getCondition());
-
- ErrorCondition clientErrorCondition = new ErrorCondition(Symbol.getSymbol("myerror"), "mydescription");
- Map info = new HashMap();
- info.put(Symbol.getSymbol("simplevalue"), "value");
- info.put(Symbol.getSymbol("list"), Arrays.asList("e1", "e2", "e3"));
- clientErrorCondition.setInfo(info);
- _clientConnection.setCondition(clientErrorCondition);
-
- _clientConnection.close();
- _pumper.pumpAll();
-
- assertEquals(clientErrorCondition, _serverConnection.getRemoteCondition());
- assertNull(_serverConnection.getCondition().getCondition());
- }
-
- /**
- * "each peer MUST write a close frame with a code indicating the reason for closing"
- */
- public void testReceiptOfConnectionCloseContainingErrorCode_allowsErrorCodeToBeObserved()
- {
- }
-
- /**
- * A test for when the connection close frame contains a session error
- * rather than a connection error. This is allowed by the spec.
- */
- public void testReceiptOfConnectionCloseContainingNonConnectionErrorCode_causesTODO()
- {
- }
-
- /** "This frame MUST be the last thing ever written onto a connection." */
- public void testUsingProtonAfterClosingConnection_doesntCauseFrameToBeSent()
- {
- }
-
- /** "This frame MUST be the last thing ever written onto a connection." */
- public void testReceiptOfFrameAfterClose_causesTODO()
- {
- }
-
- /** "A close frame MAY be received on any channel up to the maximum channel number negotiated in open" */
- public void testReceiptOfCloseOnNonZeroChannelNumber_causesHappyPathTODO()
- {
- }
-
- /**
- * "each peer MUST send an open frame before sending any other frames"
- */
- @Test
- public void testReceiptOfCloseBeforeOpen_causesTODO()
- {
- _pumper.pumpAll();
-
- Close surprisingClose = new Close();
-
- byte[] buf = _framer.generateFrame(0, surprisingClose);
- _serverTransport.input(buf, 0, buf.length);
-
- // TODO server should indicate error
- }
-
- // 2.4.4 Simultaneous Close
-
- /** "both endpoints MAY simultaneously" */
- public void testPeersCloseConnectionSimultaneously()
- {
- }
-
- // 2.4.5 Idle Timeout Of A Connection
-
- public void testReceiptOfFrame_preventsIdleTimeoutOccurring()
- {
- }
-
- /** "If the threshold is exceeded, then a peer SHOULD try to gracefully close the connection using a close frame with an error explaining why" */
- public void testReceiptOfFrameTooLate_causedIdleTimeoutToOccur()
- {
- }
-
- /** "Each peer has its own (independent) idle timeout." */
- public void testPeersWithDifferentIdleTimeouts_timeOutAtTheCorrectTimes()
- {
- }
-
- /**
- * "If the value is not set, then the sender does not have an idle time-out. However,
- * senders doing this SHOULD be aware that implementations MAY choose to use an internal default
- * to efficiently manage a peer's resources."
- */
- public void testReceiptOfFrameWithZeroIdleTimeout_causesNoIdleFramesToBeSent()
- {
- }
-
- /**
- * "If a peer can not, for any reason support a proposed idle timeout,
- * then it SHOULD close the connection using a close frame with an error explaining why"
- */
- public void testReceiptOfOpenWithUnsupportedTimeout_causesCloseWithError()
- {
- }
-
- /**
- * implementations ... MUST use channel 0 if a maximum channel number has not yet been negotiated
- * (i.e., before an open frame has been received)
- */
- public void testReceiptOfEmptyFrameOnNonZeroChannelBeforeMaximumChannelsNegotiated_causesTODO()
- {
- }
-
-
- // 2.4.7 State transitions
-
- /**
- * The DISCARDING state is a variant of the CLOSE_SENT state where the close is triggered by an error.
- * In this case any incoming frames on the connection MUST be silently discarded until the peer's close frame is received
- */
- public void testReceiptOfFrameWhenInDiscardingState_isIgnored()
- {
- }
-
- // 2.7.1 Open
-
- public void testReceiptOfOpen_containerCanBeRetrieved()
- {
- }
-
- /**
- * The spec says:
- * "If no hostname is provided the receiving peer SHOULD select a default based on its own configuration"
- * but Proton's Engine layer does not do any defaulting - this is the responsibility
- * of other layers e.g. Messenger or Driver.
- */
- public void testReceiptOfOpenWithoutHostname_nullHostnameIsRetrieved()
- {
- }
-
- public void testReceiptOfOpenWithHostname_hostnameCanBeRetrieved()
- {
- }
-
- /**
- * "Both peers MUST accept frames of up to 512 (MIN-MAX-FRAME-SIZE) octets."
- */
- public void testReceiptOfOpenWithMaximumFramesizeLowerThanMinMaxFrameSize_causesTODO()
- {
- }
-
- public void testInitiatingPeerAndReceivingPeerUseDifferentMaxFrameSizes()
- {
- }
-
- public void testReceiptOfSessionBeginThatBreaksChannelMax_causesTODO()
- {
- }
-
- public void testCreationOfSessionThatBreaksChannelMax_causesTODO()
- {
- }
-
- public void testOpenConnectionWithPeersUsingUnequalChannelMax_enforcesLowerOfTwoValues()
- {
- }
-
- public void testOpenConnectionWithOnePeerUsingUnsetChannelMax_enforcesTheSetValue()
- {
- }
-
- public void testReceiptOfBeginWithInUseChannelId_causesTODO()
- {
- }
-
- /** "If a session is locally initiated, the remote-channel MUST NOT be set." */
- public void testReceiptOfUnsolicitedBeginWithChannelId_causesTODO()
- {
- }
-
- /**
- * "When an endpoint responds to a remotely initiated session, the remote-channel MUST be set
- * to the channel on which the remote session sent the begin."
- */
- public void testThatBeginResponseContainsChannelId()
- {
- }
-
- /**
- * I imagine we will want to begin ChannelMax number of sessions, then end
- * a session from the 'middle'. Then check we are correctly begin a new
- * channel.
- */
- public void testEnd_channelNumberAvailableForReuse()
- {
- }
-
- public void testReceiptOfOpenWithOutgoingLocales_outgoingLocalesCanBeRetrieved()
- {
- }
-
- /** "A null value or an empty list implies that only en-US is supported. " */
- public void testReceiptOfOpenWithNullOutgoingLocales_defaultOutgoingLocaleCanBeRetrieved()
- {
- }
-
- /** "A null value or an empty list implies that only en-US is supported. " */
- public void testReceiptOfOpenWithEmptyListOfOutgoingLocales_defaultOutgoingLocaleCanBeRetrieved()
- {
- }
-
- public void testReceiptOfOpenWithIncomingLocales_incomingLocalesCanBeRetrieved()
- {
- }
-
- /** "A null value or an empty list implies that only en-US is supported. " */
- public void testReceiptOfOpenWithNullIncomingLocales_defaultIncomingLocaleCanBeRetrieved()
- {
- }
-
- /** "A null value or an empty list implies that only en-US is supported. " */
- public void testReceiptOfOpenWithEmptyListOfIncomingLocales_defaultIncomingLocaleCanBeRetrieved()
- {
- }
-
- // TODO It seems that currently Proton-j merely exposes the remote capabilities to
- // the user and is seems to be a end-user responsibility to enforce "If the receiver of the
- // offered-capabilities requires an extension capability which is not present in the
- // offered-capability list then it MUST close the connection.". However, i wonder if this
- // is an omission -- surely Proton could valid that request desirable capabilities are
- // offered by the remote???
-
- public void testReceiptOfOpenWithOfferedCapabilities_offeredCapabilitiesCanBeRetrieved()
- {
- }
-
- public void testReceiptOfOpenWithDesiredCapabilities_desiredCapabilitiesCanBeRetrieved()
- {
- }
-
- public void testReceiptOfOpenWithProperties_propertiesCanBeRetrieved()
- {
- }
-
- // Transport/Connection related api-inspired tests
-
- /**
- * TODO is there a limit on the number of connections?
- * Also try closing them in a different order to their creation.
- */
- public void testCreateMultipleConnections()
- {
- }
-
- public void testBindTwoConnectionsToATransport_causesTODO()
- {
- }
-
- public void testBindAConnectionToTwoTransports_causesTODO()
- {
- }
-
- /**
- * TODO possibly try to bind this "opened" connection too if it doesn't go pop before this.
- */
- public void testOpenBeforeBind_causesTODO()
- {
- }
-
- public void testOpenTwice_throwsExceptionTODO()
- {
- }
-
- public void testOpenAfterClose_throwsExceptionTODO()
- {
- }
-
- // Connection.java-related api-inspired tests
-
- /**
- * also test that the session appears in the connection's session list
- */
- public void testCreateSession()
- {
- }
-
- public void testSessionHeadWhenNoSessionsExist_returnsNull()
- {
- }
-
- public void testSessionHead_returnsSessionsMatchingCriteria()
- {
- }
-
- public void testLinkHeadWhenNoLinksExist_returnsNull()
- {
- }
-
- public void testLinkHead_returnsLinksMatchingCriteria()
- {
- }
-
- public void testGetWorkHeadWhenNoWork_returnsNull()
- {
- }
-
- public void testGetWorkHeadWhenOneDeliveryIsPending_returnsTheDelivery()
- {
- }
-
- /**
- * use a name that is longer than the limit of AMQShortString
- */
- public void testSetContainerWithLongName_isAllowed()
- {
- }
-
- public void testSetContainerWithNullName_throwsException()
- {
- }
-
- public void testSetContainerWithEmptyName_throwsException()
- {
- }
-
- public void testSetContainerAfterOpeningConnection_throwsExceptionTODO()
- {
- }
-
- public void testOpenWithoutContainerName_throwsExceptionTODO()
- {
- }
-
- public void testGetRemoteContainerBeforeOpen_returnsNull()
- {
- }
-
- public void testGetRemoteContainerBeforeReceiptOfOpen_returnsNull()
- {
- }
-
- public void testSetHostnameWithLongName_isAllowed()
- {
- }
-
- /**
- * Proton does not require the conventional foo.bar.com format for hostnames.
- */
- public void testSetHostnameWithNonstandardName_isAllowed()
- {
- }
-
- public void testSetHostnameAfterOpeningConnection_throwsExceptionTODO()
- {
- }
-
- public void testSetOfferedCapabilitiesAfterOpeningConnection_throwsExceptionTODO()
- {
- }
-
- public void testSetDesiredCapabilitiesAfterOpeningConnection_throwsExceptionTODO()
- {
- }
-
- public void testSetPropertiesAfterOpeningConnection_throwsExceptionTODO()
- {
- }
-
- // Endpoint api-inspired tests
-
- public void testGetLocalStateBeforeOpen_returnsUninitialised()
- {
- }
-
- public void testGetLocalStateAfterClose_returnsClosed()
- {
- }
-
- public void testGetRemoteStateBeforeReceiptOfOpen_returnsUninitialised()
- {
- }
-
- public void testGetRemoteStateAfterReceiptOfClose_returnsClosed()
- {
- }
-
- public void testFree_isAllowed()
- {
- }
-
- public void testSetContext_contextCanBeRetrieved()
- {
- }
-
- public void testGetContextWithoutSettingContext_returnsNull()
- {
- }
-
- private void assertConnectionIsUsable()
- {
- Session clientSesion = _clientConnection.session();
- clientSesion.open();
- _pumper.pumpAll();
-
- Session serverSession = _serverConnection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- serverSession.open();
- _pumper.pumpAll();
-
- assertEnpointState(clientSesion, ACTIVE, ACTIVE);
- assertEnpointState(serverSession, ACTIVE, ACTIVE);
- }
-
- private void bindAndOpenConnections()
- {
- // TODO should we be checking local and remote error conditions as part of this?
-
- _clientConnection.setContainer(CLIENT_CONTAINER);
- _serverConnection.setContainer(SERVER_CONTAINER);
-
- assertEnpointState(_clientConnection, UNINITIALIZED, UNINITIALIZED);
- assertEnpointState(_serverConnection, UNINITIALIZED, UNINITIALIZED);
-
- _clientTransport.bind(_clientConnection);
- _serverTransport.bind(_serverConnection);
-
- _clientConnection.open();
-
- assertEnpointState(_clientConnection, ACTIVE, UNINITIALIZED);
- assertEnpointState(_serverConnection, UNINITIALIZED, UNINITIALIZED);
-
- _pumper.pumpAll();
-
- assertEnpointState(_clientConnection, ACTIVE, UNINITIALIZED);
- assertEnpointState(_serverConnection, UNINITIALIZED, ACTIVE);
-
- _serverConnection.open();
-
- assertEnpointState(_clientConnection, ACTIVE, UNINITIALIZED);
- assertEnpointState(_serverConnection, ACTIVE, ACTIVE);
-
- _pumper.pumpAll();
-
- assertEnpointState(_clientConnection, ACTIVE, ACTIVE);
- assertEnpointState(_serverConnection, ACTIVE, ACTIVE);
- }
-
- private void assertEnpointState(Endpoint endpoint, EndpointState localState, EndpointState remoteState)
- {
- assertEquals("Unexpected local state", localState, endpoint.getLocalState());
- assertEquals("Unexpected remote state", remoteState, endpoint.getRemoteState());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/TransportPumper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/TransportPumper.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/TransportPumper.java
deleted file mode 100644
index fd1d198..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/TransportPumper.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.systemtests.engine;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.qpid.proton.engine.Transport;
-
-public class TransportPumper
-{
- private static final String SERVER_ROLE = "server";
- private static final String CLIENT_ROLE = "client";
-
- private final Transport _clientTransport;
- private final Transport _serverTransport;
-
- public TransportPumper(Transport clientTransport, Transport serverTransport)
- {
- _clientTransport = clientTransport;
- _serverTransport = serverTransport;
- }
-
- public void pumpAll()
- {
- boolean bytesToTransfer = true;
- while(bytesToTransfer)
- {
- int clientOutputLength = pumpOnceFromClientToServer();
- int serverOutputLength = pumpOnceFromServerToClient();
- bytesToTransfer = clientOutputLength > 0 || serverOutputLength > 0;
- }
- }
-
- public int pumpOnceFromClientToServer()
- {
- return pumpOnce(_clientTransport, CLIENT_ROLE, _serverTransport, SERVER_ROLE);
- }
-
- public int pumpOnceFromServerToClient()
- {
- return pumpOnce(_serverTransport, SERVER_ROLE, _clientTransport, CLIENT_ROLE);
- }
-
- private int pumpOnce(Transport transportFrom, String fromRole, Transport transportTo, String toRole)
- {
- final byte[] output = new byte[1024];
- int outputLength = transportFrom.output(output, 0, output.length);
- if (outputLength > 0)
- {
- int numberConsumedByServer = transportTo.input(output, 0, outputLength);
- assertEquals("Expecting " + toRole + " to consume all of " + fromRole + "'s output", outputLength, numberConsumedByServer);
- }
- return outputLength;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/TransportTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/TransportTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/TransportTest.java
deleted file mode 100644
index 01852bb..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/engine/TransportTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.systemtests.engine;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * TODO add test for 2.3.1 "The frame is malformed if the size is less than the size of the frame header (8 bytes)"
- * TODO add test using empty byte arrays (calling {@link Transport#input(byte[], int, int)} with empty byte array in Proton-j-impl currently throws "TransportException Unexpected EOS")
- */
-public class TransportTest
-{
- private final Transport _transport = Proton.transport();
-
- /**
- * Note that Proton does not yet give the application explicit control over protocol version negotiation
- * TODO does Proton give *visibility* of the negotiated protocol version?
- */
- public void testReceiptOfHeaderContainingUnsupportedProtocolVersionNumber_causesAmqp10Response()
- {
- }
-
- @Test
- @Ignore("Reinstate once it is agreed how error condition will be reported by to use of API")
- public void testReceiptOfNonAmqpHeader_causesAmqp10Response()
- {
- byte[] nonAmqpHeader = "HTTP/1.0".getBytes();
- try
- {
- _transport.input(nonAmqpHeader, 0, nonAmqpHeader.length);
-
- // TODO Proton-c gives rv PN_ERROR and a pn_transport_error "AMQP header mismatch: 'HTTP/1.0'" and then
- // jni layer turns this into a TransportException.
- // Proton-j just throws TransportException
- }
- catch (TransportException te)
- {
- // TODO - exception should not be thrown
- }
-
- byte[] buf = new byte[255];
- int bytesWritten = _transport.output(buf, 0, buf.length);
- byte[] response = new byte[bytesWritten];
- System.arraycopy(buf, 0, response, 0, bytesWritten);
- assertArrayEquals("AMQP\0\1\0\0".getBytes(), response);
-
- // how should further input be handled??
-
- assertTransportRefusesFurtherInputOutput(_transport);
- }
-
- private void assertTransportRefusesFurtherInputOutput(Transport transport)
- {
- byte[] sourceBufferThatShouldBeUnread = "REFUSEME".getBytes();
- int bytesConsumed = transport.input(sourceBufferThatShouldBeUnread, 0, sourceBufferThatShouldBeUnread.length);
- // assertEquals(-1, bytesConsumed); // TODO reinstate with testReceiptOfNonAmqpHeader_causesAmqp10Response
-
- byte[] destBufferThatShouldRemainUnwritten = new byte[255];
- int bytesWritten = transport.output(destBufferThatShouldRemainUnwritten, 0, destBufferThatShouldRemainUnwritten.length);
- assertEquals(-1, bytesWritten);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/test/ProtonTestCase.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/test/ProtonTestCase.java b/proton-j/src/test/java/org/apache/qpid/proton/test/ProtonTestCase.java
deleted file mode 100644
index 68a00d8..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/test/ProtonTestCase.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.test;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-
-public class ProtonTestCase
-{
- private static final Logger _logger = Logger.getLogger(ProtonTestCase.class.getName());
-
- private final Map<String, String> _propertiesSetForTest = new HashMap<String, String>();
-
- @Rule public TestName _testName = new TestName();
-
- /**
- * Set a System property for duration of this test only. The tearDown will
- * guarantee to reset the property to its previous value after the test
- * completes.
- *
- * @param property The property to set
- * @param value the value to set it to, if null, the property will be cleared
- */
- protected void setTestSystemProperty(final String property, final String value)
- {
- if (!_propertiesSetForTest.containsKey(property))
- {
- // Record the current value so we can revert it later.
- _propertiesSetForTest.put(property, System.getProperty(property));
- }
-
- if (value == null)
- {
- System.clearProperty(property);
- _logger.info("Set system property '" + property + "' to be cleared");
- }
- else
- {
- System.setProperty(property, value);
- _logger.info("Set system property '" + property + "' to: '" + value + "'");
- }
-
- }
-
- /**
- * Restore the System property values that were set by this test run.
- */
- protected void revertTestSystemProperties()
- {
- if(!_propertiesSetForTest.isEmpty())
- {
- for (String key : _propertiesSetForTest.keySet())
- {
- String value = _propertiesSetForTest.get(key);
- if (value != null)
- {
- System.setProperty(key, value);
- _logger.info("Reverted system property '" + key + "' to: '" + value + "'");
- }
- else
- {
- System.clearProperty(key);
- _logger.info("Reverted system property '" + key + "' to be cleared");
- }
- }
-
- _propertiesSetForTest.clear();
- }
- }
-
- @After
- public void tearDown() throws java.lang.Exception
- {
- _logger.info("========== tearDown " + getTestName() + " ==========");
- revertTestSystemProperties();
- }
-
- @Before
- public void setUp() throws Exception
- {
- _logger.info("========== start " + getTestName() + " ==========");
- }
-
- protected String getTestName()
- {
- return getClass().getSimpleName() + "." +_testName.getMethodName();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/resources/META-INF/services/org.apache.qpid.proton.factoryloadertesting.DummyProtonFactory
----------------------------------------------------------------------
diff --git a/proton-j/src/test/resources/META-INF/services/org.apache.qpid.proton.factoryloadertesting.DummyProtonFactory b/proton-j/src/test/resources/META-INF/services/org.apache.qpid.proton.factoryloadertesting.DummyProtonFactory
deleted file mode 100644
index bd4307b..0000000
--- a/proton-j/src/test/resources/META-INF/services/org.apache.qpid.proton.factoryloadertesting.DummyProtonFactory
+++ /dev/null
@@ -1,2 +0,0 @@
-org.apache.qpid.proton.factoryloadertesting.DummyProtonCFactory
-org.apache.qpid.proton.factoryloadertesting.DummyProtonJFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/README.txt
----------------------------------------------------------------------
diff --git a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/README.txt b/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/README.txt
deleted file mode 100644
index 24e1f13..0000000
--- a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/README.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# These resources are used during the unittesting of the SSL capabilities
-#
-# cert.pem.txt - A public certificate
-# key.pem.txt - A passphrase protected private key
-# private-key-clear.pem.txt - An unprotected private key
-
-# Files have a .txt suffix to prevent undesired handling by other tooling (IDEs etc)
-# and can easilly be re-created using the following openssl commands or you can
-# execute this file directly with
-# sh README.txt
-
-## Clean Up
-
-echo
-echo Clean Up
-echo
-
-rm *.pem.txt
-
-# 1. Generate a certificate and protected private key
-
-echo
-echo when prompted use 'unittest' as the passphase, all other fields can be random values
-echo
-
-openssl req -x509 -newkey rsa:2048 -keyout key.pem.txt -out cert.pem.txt -days 10000
-
-# 2. The following command produces an unprotected private key
-
-echo
-echo when prompted, use 'unittest' as the passphrase
-echo
-
-openssl rsa -in key.pem.txt -out private-key-clear.pem.txt -outform PEM
-
-echo
-
-# 3. The following command produces an unprotected PKCS#8 private key
-
-echo
-echo when prompted, use 'unittest' as the passphrase
-echo
-
-openssl pkcs8 -topk8 -nocrypt -in key.pem.txt -out private-key-clear-pkcs8.pem.txt
-
-echo
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/cert.pem.txt
----------------------------------------------------------------------
diff --git a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/cert.pem.txt b/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/cert.pem.txt
deleted file mode 100644
index 84ec75a..0000000
--- a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/cert.pem.txt
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEmzCCA4OgAwIBAgIJAPjD77mpHLocMA0GCSqGSIb3DQEBBQUAMIGPMQswCQYD
-VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2Ux
-EDAOBgNVBAoTB1Rlc3RpbmcxDzANBgNVBAsTBlRlc3RlcjETMBEGA1UEAxMKdGVz
-dGluZy5pdDEgMB4GCSqGSIb3DQEJARYRbm9ib2R5QHRlc3RpbmcuaXQwHhcNMTYw
-NjA5MTgxNjA0WhcNNDMxMDI2MTgxNjA0WjCBjzELMAkGA1UEBhMCVVMxEzARBgNV
-BAgTCkNhbGlmb3JuaWExETAPBgNVBAcTCFNhbiBKb3NlMRAwDgYDVQQKEwdUZXN0
-aW5nMQ8wDQYDVQQLEwZUZXN0ZXIxEzARBgNVBAMTCnRlc3RpbmcuaXQxIDAeBgkq
-hkiG9w0BCQEWEW5vYm9keUB0ZXN0aW5nLml0MIIBIjANBgkqhkiG9w0BAQEFAAOC
-AQ8AMIIBCgKCAQEAxbIpYVTdItTeWy1qaG3Lzs6IeMzAzHFsOw6rmeSM8GZ5S/vS
-PzsKfRCXKc52/2KblROsK2Eez/wt9CB9HgksHr/sjYtivwn/V/jumLb8z9R8jBnF
-jZ0KXyWxtiJFowh+Zd1BxJeQTmmbvJpYGVmKYu+4t66TQGhNUu8e+J5GIgJjDPnA
-TE5bGBMi7HtoXVy+Tp0sO/S7cXLXmWpeyCXS7HFUj+Jdzbed0yMs/JmbBXyLIYMU
-Rq1oSI8DOn5jtrTQz7/xI5qOebIwACcYk6LRI83zIIvcv6olpnzViDjAGT6PQtj5
-FuUe1WHKVjd4Bjyoo+zULwQoF1b6qSe5m6O7IQIDAQABo4H3MIH0MB0GA1UdDgQW
-BBQjS5wYZlVLz3eNVIxFGroXSPhl/zCBxAYDVR0jBIG8MIG5gBQjS5wYZlVLz3eN
-VIxFGroXSPhl/6GBlaSBkjCBjzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlm
-b3JuaWExETAPBgNVBAcTCFNhbiBKb3NlMRAwDgYDVQQKEwdUZXN0aW5nMQ8wDQYD
-VQQLEwZUZXN0ZXIxEzARBgNVBAMTCnRlc3RpbmcuaXQxIDAeBgkqhkiG9w0BCQEW
-EW5vYm9keUB0ZXN0aW5nLml0ggkA+MPvuakcuhwwDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQUFAAOCAQEAM41jrwVEQZltTWiQ8kBMSl4K80gBlLLDu/XD9Dfe6snD
-8wQZD21LLBlsLaVwR8Fk1umFHnwYoTD1tghfW7LeTS3zTMRu269a5xbZ82rOoeYk
-MQwFK7rMXPfNKGSk06lXAzjrlZD+qd8qfm1UEoUmWlmJyBinCnX8x8G5Z6Za4UsK
-LmdZShnbXRvToPZ/xGMeWmB2NGG5uF3evLM6+cdOLhqxoei90dmufWUcRDBXBEED
-8cZpXARYS2Q5EflmrDWOwMN+1cfEZDNssb/GmKouNuVoobxgIo9lftTds+gR319N
-usu7JUbh5QbAOdXg4prQ3ASNq9a95J4Y8O9cW4XdSg==
------END CERTIFICATE-----
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/key.pem.txt
----------------------------------------------------------------------
diff --git a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/key.pem.txt b/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/key.pem.txt
deleted file mode 100644
index e1f72f5..0000000
--- a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/key.pem.txt
+++ /dev/null
@@ -1,30 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,F0AAE930E2D9E692
-
-L9c43ZBCX8aRwhqrpbhKP2jNFi2c5MQO6qNV9/Ubk3fWC2pb0dqnHLBSzdOupIKa
-56wrzz9wtDUbPO3AsFBJmX5ov9rSLhAKeTdrYAUMk7qPhiMTUOvrDtGLHxhnBtYi
-2VV4I4ONhg+uYDa2GW8U/YI216E/t2nA4L6KuxI7ac8kWyMn5IJgk/GvnDlePxTc
-bDUGgRC/kiXhTTeBQoMih09MxCSJEgXbSKKB5FpNwzwwXGf2bHvdId8AY0e/7KDO
-pO5E9YpKu+HO+HbyhQJiIQr9CKkyfsdYST/ojGPGH+Yn8M4ZdBtPclisHkt7mIAz
-swqjpt9XHzVXJh4+Di0VPmvOnDcU8SV62VpyMnPbXL2eexEGrofIwfTHQQTHMfNZ
-OJOtXRJXBijGOd0mAT8ijTnuelBCsQtc0fMT8R0jSaQjONynaewNzBLnRD4E/9Gw
-gGPjEiLtXNSVjCFhIDgLFvuljrOqH+MIgkSFhpM/C9LnPXx3I7Mxe7198Fp/jDRZ
-GVpOQqAo4tbvw3cCOtRxdzwpUi9p6lnBGDRHjRRDMqzqncJhNej/cC8QonUw/7JO
-Rv3OMWIy682rCvS00q0dhm+If0f5Nox7rt1yxWYyX3zj/RdkeZezJTDuxDsyLpiw
-NzRSvLUVfdh1v6Ofcnh/6eDIi4uyCt+rDeZjvG3HGAssOD+27s6i18QDbbuolrkc
-yypQ7Bo/UeuUUCNE/G9ItHOCC1qxdJYIC30dAlmWPjYQrapQOuQWXzxs5u8+hxkb
-u32KA8nuCS1codbxPNXnVbrDyU/vWsxTjPr/ODChWfLeIu/9KwjxLLoOUwkRGJnm
-dQVZeawiSggIL2nwsS2c5hOV0yZZuNzB3RAqYV7ZfB5Xdk3LAEXjrYOELeFUY1vJ
-V3pcEdD8VfTLiEwQ/TMmg03ju+1dA5lMsLaQ0KrhUJbarkAeFEtAPgpaIhHoCAa5
-3ObLx/8dctrbHx4rRgkN6xWQz0qEMzAtpQaUYaFbnRrLKF4fqq+PC35BfwM5hVOa
-rXM1aQ065pV1cPVstqk0jN/36m+tMv5l7NperNS78UaFy+4KyX2/Lj3YvbLlTT75
-Hn6gf+nekTwW2V+P1Yn8MKr7jelCCai1MoLMugrUNfILKAohA/CGdupoUmxr5F3b
-F7XnY1RMAr0FROl5f5Fc6In12mey9mvHh1yT5HZa0SoK79/Bfv+3oiOXbqgKBJ8O
-2FkJtlBd/nx7EYx3teLXClvX+FfQL4gZkyvEE0m8HAFY0HfozNhKfi+PFDXz/R7X
-yCvBdIzE26nRtY9h4uhAcn3AefO8b0Slpmlq/+BDf8Pta9TF8zFWyzPRMIyuEE4l
-GTk1i6p9PDzu7lhC93tIfWZe5Xz1DB+c4bFQbzxAghoEOFz3NA17VEKEkl0t04sA
-lUqJmEftUPBZocgv7zO5v7z17G5yGqS+HyBGWaBqBRH9rGPhHxyEpPtwGNhP+biN
-7cvnlMbhD41KAkYDy3tQkztH/A0g/xNZTElhpXnnHq5AXnn46y/SVH5q6Tdy1xGz
-aEeKdL7JdPZ7XNmkHgbHLmxNFGtoJwx1hKw6slg+kh0j4xcNTpjJcQ==
------END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/private-key-clear-pkcs8.pem.txt
----------------------------------------------------------------------
diff --git a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/private-key-clear-pkcs8.pem.txt b/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/private-key-clear-pkcs8.pem.txt
deleted file mode 100644
index 2956f92..0000000
--- a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/private-key-clear-pkcs8.pem.txt
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDFsilhVN0i1N5b
-LWpobcvOzoh4zMDMcWw7DquZ5IzwZnlL+9I/Owp9EJcpznb/YpuVE6wrYR7P/C30
-IH0eCSwev+yNi2K/Cf9X+O6YtvzP1HyMGcWNnQpfJbG2IkWjCH5l3UHEl5BOaZu8
-mlgZWYpi77i3rpNAaE1S7x74nkYiAmMM+cBMTlsYEyLse2hdXL5OnSw79LtxcteZ
-al7IJdLscVSP4l3Nt53TIyz8mZsFfIshgxRGrWhIjwM6fmO2tNDPv/Ejmo55sjAA
-JxiTotEjzfMgi9y/qiWmfNWIOMAZPo9C2PkW5R7VYcpWN3gGPKij7NQvBCgXVvqp
-J7mbo7shAgMBAAECggEALVFU2QHqGyTuv7nebYfVs1d2wzI0c+kAJV2Mip9wi18C
-KR/VpzbyhY67CBNTBeHlxjuXOO5vcL/fDNoxtCPoIDhgkmXEQgSZquHeV9WCiGWu
-EzOJLJg2G295mEWs7t1wlAsvG1Ce/MqKr6Y10cHLzjgjgL+c86O1LfCwic9GRl8c
-ec6AwUs/sWvZma44yQsulBXT00v94Xtn64D6MG/TPcjXF7fF7KdzOFQO8G/2Wr3R
-5IywXOP8E6Sofybfb0ZCGTSup/i5vLlp08vn3P9Jwnn83mxxMM9niwYegfWslg5A
-oosvebd6wL0xjtjG54tVT2wWLmSrmKt296HSIjNgAQKBgQDqVjnHSLoB5yk27z+2
-x1XzCTCt1b9Dr/0x1bHrMYE3IDzuHOqu2yuPF/vlIVH0BwVmEEsNQ3JyuwbebsAH
-+6umz+xwILw4qR6+8sBQ3HHadPm1B3/QEbc6RUQBAUpmKCyguS+dGJuY86Pk22LL
-Mr0vUfJrk9ppvVbl7irJ13r+IQKBgQDX+MykLC/gq0FstFHbAc75xS/UuXjX0npp
-egWdxhVnx5F6SrP4a0GB4LS/Jh+lChWGmdtlgnL0d/aHqxZuTWKafjg3RAIKRDGE
-bIJf46W/HiRlN0WNBkbjotV1LxWATfX03P4rdqmOMaD03eG3IVXHN3kuEE1gIO42
-Lem8Y38dAQKBgAaiACqq3VD2eQ0sAnKq+7zQUsdo2GwTDCif8tREZ3Lm/7KBsQbX
-/0iilierJMWyeS2lYmpysUecEZq0Kc1QC1DCa9/UnV9BMjSXbGgdhT94tiSwnKaI
-CdalZUJeBfwUQQcflsBslOLkaowsxYQY4I/5UtJGshTyHgaOEjn6VmnhAoGAHrXD
-K6kY2cKgV/vAE/tK2hte9Mm21EGapHr0Z33uN0aaeiA7PRzLQNOaAABEyawIaY5h
-Myr8e6S/SoVaeC7K0ZsXFUy3WYxe2iyv0UDGpcl8dWQJoMb+t4nE/pfGX+s2CS6P
-edCyxYRrFcajPO4hi2Vo9tLcncmw9cVLkj03qwECgYEAgJABS6gx+a0aP9W8wqBJ
-VJogDeAruq3j8+bwr/PqP8bUbjj5gNbblE75jQ890lGv0I71IdxxORprc92pMDRc
-xX6OY4ZzZ2f7fp4kGHF7pHQsg0anYuI1h+87G6Gkyd4RsdZ5EHD1iSJk6DcyD8OH
-ao1P1UBLB8/lyWe+muVftZA=
------END PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/private-key-clear.pem.txt
----------------------------------------------------------------------
diff --git a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/private-key-clear.pem.txt b/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/private-key-clear.pem.txt
deleted file mode 100644
index e3de94c..0000000
--- a/proton-j/src/test/resources/org/apache/qpid/proton/engine/impl/ssl/private-key-clear.pem.txt
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEAxbIpYVTdItTeWy1qaG3Lzs6IeMzAzHFsOw6rmeSM8GZ5S/vS
-PzsKfRCXKc52/2KblROsK2Eez/wt9CB9HgksHr/sjYtivwn/V/jumLb8z9R8jBnF
-jZ0KXyWxtiJFowh+Zd1BxJeQTmmbvJpYGVmKYu+4t66TQGhNUu8e+J5GIgJjDPnA
-TE5bGBMi7HtoXVy+Tp0sO/S7cXLXmWpeyCXS7HFUj+Jdzbed0yMs/JmbBXyLIYMU
-Rq1oSI8DOn5jtrTQz7/xI5qOebIwACcYk6LRI83zIIvcv6olpnzViDjAGT6PQtj5
-FuUe1WHKVjd4Bjyoo+zULwQoF1b6qSe5m6O7IQIDAQABAoIBAC1RVNkB6hsk7r+5
-3m2H1bNXdsMyNHPpACVdjIqfcItfAikf1ac28oWOuwgTUwXh5cY7lzjub3C/3wza
-MbQj6CA4YJJlxEIEmarh3lfVgohlrhMziSyYNhtveZhFrO7dcJQLLxtQnvzKiq+m
-NdHBy844I4C/nPOjtS3wsInPRkZfHHnOgMFLP7Fr2ZmuOMkLLpQV09NL/eF7Z+uA
-+jBv0z3I1xe3xeynczhUDvBv9lq90eSMsFzj/BOkqH8m329GQhk0rqf4uby5adPL
-59z/ScJ5/N5scTDPZ4sGHoH1rJYOQKKLL3m3esC9MY7YxueLVU9sFi5kq5irdveh
-0iIzYAECgYEA6lY5x0i6AecpNu8/tsdV8wkwrdW/Q6/9MdWx6zGBNyA87hzqrtsr
-jxf75SFR9AcFZhBLDUNycrsG3m7AB/urps/scCC8OKkevvLAUNxx2nT5tQd/0BG3
-OkVEAQFKZigsoLkvnRibmPOj5NtiyzK9L1Hya5Paab1W5e4qydd6/iECgYEA1/jM
-pCwv4KtBbLRR2wHO+cUv1Ll419J6aXoFncYVZ8eRekqz+GtBgeC0vyYfpQoVhpnb
-ZYJy9Hf2h6sWbk1imn44N0QCCkQxhGyCX+Olvx4kZTdFjQZG46LVdS8VgE319Nz+
-K3apjjGg9N3htyFVxzd5LhBNYCDuNi3pvGN/HQECgYAGogAqqt1Q9nkNLAJyqvu8
-0FLHaNhsEwwon/LURGdy5v+ygbEG1/9IopYnqyTFsnktpWJqcrFHnBGatCnNUAtQ
-wmvf1J1fQTI0l2xoHYU/eLYksJymiAnWpWVCXgX8FEEHH5bAbJTi5GqMLMWEGOCP
-+VLSRrIU8h4GjhI5+lZp4QKBgB61wyupGNnCoFf7wBP7StobXvTJttRBmqR69Gd9
-7jdGmnogOz0cy0DTmgAARMmsCGmOYTMq/Hukv0qFWnguytGbFxVMt1mMXtosr9FA
-xqXJfHVkCaDG/reJxP6Xxl/rNgkuj3nQssWEaxXGozzuIYtlaPbS3J3JsPXFS5I9
-N6sBAoGBAICQAUuoMfmtGj/VvMKgSVSaIA3gK7qt4/Pm8K/z6j/G1G44+YDW25RO
-+Y0PPdJRr9CO9SHccTkaa3PdqTA0XMV+jmOGc2dn+36eJBhxe6R0LINGp2LiNYfv
-OxuhpMneEbHWeRBw9YkiZOg3Mg/Dh2qNT9VASwfP5clnvprlX7WQ
------END RSA PRIVATE KEY-----
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[28/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java
deleted file mode 100644
index cb8ceca..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.Pipe.SourceChannel;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Selectable;
-
-public class Cat extends BaseHandler {
-
- private class EchoHandler extends BaseHandler {
- @Override
- public void onSelectableInit(Event event) {
- Selectable selectable = event.getSelectable();
- // We can configure a selectable with any SelectableChannel we want.
- selectable.setChannel(channel);
- // Ask to be notified when the channel is readable
- selectable.setReading(true);
- event.getReactor().update(selectable);
- }
-
- @Override
- public void onSelectableReadable(Event event) {
- Selectable selectable = event.getSelectable();
-
- // The onSelectableReadable event tells us that there is data
- // to be read, or the end of stream has been reached.
- SourceChannel channel = (SourceChannel)selectable.getChannel();
- ByteBuffer buffer = ByteBuffer.allocate(1024);
- try {
- while(true) {
- int amount = channel.read(buffer);
- if (amount < 0) {
- selectable.terminate();
- selectable.getReactor().update(selectable);
- }
- if (amount <= 0) break;
- System.out.write(buffer.array(), 0, buffer.position());
- buffer.clear();
- }
- } catch(IOException ioException) {
- ioException.printStackTrace();
- selectable.terminate();
- selectable.getReactor().update(selectable);
- }
- }
- }
-
- private final SourceChannel channel;
-
- private Cat(SourceChannel channel) {
- this.channel = channel;
- }
-
- @Override
- public void onReactorInit(Event event) {
- Reactor reactor = event.getReactor();
- Selectable selectable = reactor.selectable();
- setHandler(selectable, new EchoHandler());
- reactor.update(selectable);
- }
-
- public static void main(String[] args) throws IOException {
- if (args.length != 1) {
- System.err.println("Specify a file name as an argument.");
- System.exit(1);
- }
- FileInputStream inFile = new FileInputStream(args[0]);
- SourceChannel inChannel = EchoInputStreamWrapper.wrap(inFile);
- Reactor reactor = Proton.reactor(new Cat(inChannel));
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/CountRandomly.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/CountRandomly.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/CountRandomly.java
deleted file mode 100644
index 9a5a0b4..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/CountRandomly.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-
-// Let's try to modify our counter example. In addition to counting to
-// 10 in quarter second intervals, let's also print out a random number
-// every half second. This is not a super easy thing to express in a
-// purely sequential program, but not so difficult using events.
-public class CountRandomly extends BaseHandler {
-
- private long startTime;
- private CounterHandler counter;
-
- class CounterHandler extends BaseHandler {
- private final int limit;
- private int count;
-
- CounterHandler(int limit) {
- this.limit = limit;
- }
-
- @Override
- public void onTimerTask(Event event) {
- count += 1;
- System.out.println(count);
-
- if (!done()) {
- event.getReactor().schedule(250, this);
- }
- }
-
- // Provide a method to check for doneness
- private boolean done() {
- return count >= limit;
- }
- }
-
- @Override
- public void onReactorInit(Event event) {
- startTime = System.currentTimeMillis();
- System.out.println("Hello, World!");
-
- // Save the counter instance in an attribute so we can refer to
- // it later.
- counter = new CounterHandler(10);
- event.getReactor().schedule(250, counter);
-
- // Now schedule another event with a different handler. Note
- // that the timer tasks go to separate handlers, and they don't
- // interfere with each other.
- event.getReactor().schedule(500, this);
- }
-
- @Override
- public void onTimerTask(Event event) {
- // keep on shouting until we are done counting
- System.out.println("Yay, " + Math.round(Math.abs((Math.random() * 110) - 10)));
- if (!counter.done()) {
- event.getReactor().schedule(500, this);
- }
- }
-
- @Override
- public void onReactorFinal(Event event) {
- long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Goodbye, World! (after " + elapsedTime + " long milliseconds)");
- }
-
- public static void main(String[] args) throws IOException {
- // In HelloWorld.java we said the reactor exits when there are no more
- // events to process. While this is true, it's not actually complete.
- // The reactor exits when there are no more events to process and no
- // possibility of future events arising. For that reason the reactor
- // will keep running until there are no more scheduled events and then
- // exit.
- Reactor reactor = Proton.reactor(new CountRandomly());
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Counter.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Counter.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Counter.java
deleted file mode 100644
index b05685a..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Counter.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-
-public class Counter extends BaseHandler {
-
- private long startTime;
-
- class CounterHandler extends BaseHandler {
- private final int limit;
- private int count;
-
- CounterHandler(int limit) {
- this.limit = limit;
- }
-
- @Override
- public void onTimerTask(Event event) {
- count += 1;
- System.out.println(count);
- if (count < limit) {
- // A recurring task can be accomplished by just scheduling
- // another event.
- event.getReactor().schedule(250, this);
- }
- }
- }
-
- @Override
- public void onReactorInit(Event event) {
- startTime = System.currentTimeMillis();
- System.out.println("Hello, World!");
-
- // Note that unlike the previous scheduling example, we pass in
- // a separate object for the handler. This means that the timer
- // event we just scheduled will not be seen by the Counter
- // implementation of BaseHandler as it is being handled by the
- // CounterHandler instance we create.
- event.getReactor().schedule(250, new CounterHandler(10));
- }
-
- @Override
- public void onReactorFinal(Event event) {
- long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Goodbye, World! (after " + elapsedTime + " long milliseconds)");
- }
-
- public static void main(String[] args) throws IOException {
- // In HelloWorld.java we said the reactor exits when there are no more
- // events to process. While this is true, it's not actually complete.
- // The reactor exits when there are no more events to process and no
- // possibility of future events arising. For that reason the reactor
- // will keep running until there are no more scheduled events and then
- // exit.
- Reactor reactor = Proton.reactor(new Counter());
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Delegates.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Delegates.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Delegates.java
deleted file mode 100644
index 7b4e36f..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Delegates.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Handler;
-import org.apache.qpid.proton.reactor.Reactor;
-
-// Events know how to dispatch themselves to handlers. By combining
-// this with on_unhandled, you can provide a kind of inheritance
-/// between handlers using delegation.
-public class Delegates extends BaseHandler {
-
- private final Handler[] handlers;
-
- static class Hello extends BaseHandler {
- @Override
- public void onReactorInit(Event e) {
- System.out.println("Hello, World!");
- }
- }
-
- static class Goodbye extends BaseHandler {
- @Override
- public void onReactorFinal(Event e) {
- System.out.println("Goodbye, World!");
- }
- }
-
- public Delegates(Handler... handlers) {
- this.handlers = handlers;
- }
-
- @Override
- public void onUnhandled(Event event) {
- for (Handler handler : handlers) {
- event.dispatch(handler);
- }
- }
-
- public static void main(String[] args) throws IOException {
- Reactor reactor = Proton.reactor(new Delegates(new Hello(), new Goodbye()));
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java
deleted file mode 100644
index 852bf8e..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.Pipe.SourceChannel;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Selectable;
-
-public class Echo extends BaseHandler {
-
- private class EchoHandler extends BaseHandler {
- @Override
- public void onSelectableInit(Event event) {
- Selectable selectable = event.getSelectable();
- // We can configure a selectable with any SelectableChannel we want.
- selectable.setChannel(channel);
- // Ask to be notified when the channel is readable
- selectable.setReading(true);
- event.getReactor().update(selectable);
- }
-
- @Override
- public void onSelectableReadable(Event event) {
- Selectable selectable = event.getSelectable();
-
- // The onSelectableReadable event tells us that there is data
- // to be read, or the end of stream has been reached.
- SourceChannel channel = (SourceChannel)selectable.getChannel();
- ByteBuffer buffer = ByteBuffer.allocate(1024);
- try {
- while(true) {
- int amount = channel.read(buffer);
- if (amount < 0) {
- selectable.terminate();
- selectable.getReactor().update(selectable);
- }
- if (amount <= 0) break;
- System.out.write(buffer.array(), 0, buffer.position());
- buffer.clear();
- }
- } catch(IOException ioException) {
- ioException.printStackTrace();
- selectable.terminate();
- selectable.getReactor().update(selectable);
- }
- }
- }
-
- private final SourceChannel channel;
-
- private Echo(SourceChannel channel) {
- this.channel = channel;
- }
-
- @Override
- public void onReactorInit(Event event) {
- // Every selectable is a possible source of future events. Our
- // selectable stays alive until it reads the end of stream
- // marker. This will keep the whole reactor running until we
- // type Control-D.
- System.out.println("Type whatever you want and then use Control-D to exit:");
- Reactor reactor = event.getReactor();
- Selectable selectable = reactor.selectable();
- setHandler(selectable, new EchoHandler());
- reactor.update(selectable);
- }
-
- public static void main(String[] args) throws IOException {
- SourceChannel inChannel = EchoInputStreamWrapper.wrap(System.in);
- Reactor reactor = Proton.reactor(new Echo(inChannel));
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/EchoInputStreamWrapper.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/EchoInputStreamWrapper.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/EchoInputStreamWrapper.java
deleted file mode 100644
index 2e53d09..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/EchoInputStreamWrapper.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.Pipe;
-import java.nio.channels.Pipe.SinkChannel;
-import java.nio.channels.Pipe.SourceChannel;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class EchoInputStreamWrapper extends Thread {
-
- private final InputStream in;
- private final SinkChannel out;
- private final byte[] bufferBytes = new byte[1024];
- private final ByteBuffer buffer = ByteBuffer.wrap(bufferBytes);
- private final AtomicInteger idCounter = new AtomicInteger();
-
- private EchoInputStreamWrapper(InputStream in, SinkChannel out) {
- this.in = in;
- this.out = out;
- setName(getClass().getName() + "-" + idCounter.incrementAndGet());
- setDaemon(true);
- }
-
- @Override
- public void run() {
- try {
- while(true) {
- int amount = in.read(bufferBytes);
- if (amount < 0) break;
- buffer.position(0);
- buffer.limit(amount);
- out.write(buffer);
- }
- } catch(IOException ioException) {
- ioException.printStackTrace();
- } finally {
- try {
- out.close();
- } catch(IOException ioException) {
- ioException.printStackTrace();
- }
- }
- }
-
- public static SourceChannel wrap(InputStream in) throws IOException {
- Pipe pipe = Pipe.open();
- new EchoInputStreamWrapper(in, pipe.sink()).start();
- SourceChannel result = pipe.source();
- result.configureBlocking(false);
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GlobalLogger.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GlobalLogger.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GlobalLogger.java
deleted file mode 100644
index ec56bd5..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GlobalLogger.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-
-// Not every event goes to the reactor's event handler. If we have a
-// separate handler for something like a scheduled task, then those
-// events aren't logged by the logger associated with the reactor's
-// handler. Sometimes this is useful if you don't want to see them, but
-// sometimes you want the global picture.
-public class GlobalLogger extends BaseHandler {
-
- static class Logger extends BaseHandler {
- @Override
- public void onUnhandled(Event event) {
- System.out.println("LOG: " + event);
- }
- }
-
- static class Task extends BaseHandler {
- @Override
- public void onTimerTask(Event e) {
- System.out.println("Mission accomplished!");
- }
- }
-
- @Override
- public void onReactorInit(Event event) {
- System.out.println("Hello, World!");
- event.getReactor().schedule(0, new Task());
- }
-
- @Override
- public void onReactorFinal(Event e) {
- System.out.println("Goodbye, World!");
- }
-
- public static void main(String[] args) throws IOException {
- Reactor reactor = Proton.reactor(new GlobalLogger());
-
- // In addition to having a regular handler, the reactor also has a
- // global handler that sees every event. By adding the Logger to the
- // global handler instead of the regular handler, we can log every
- // single event that occurs in the system regardless of whether or not
- // there are specific handlers associated with the objects that are the
- // target of those events.
- reactor.getGlobalHandler().add(new Logger());
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GoodbyeWorld.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GoodbyeWorld.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GoodbyeWorld.java
deleted file mode 100644
index 6a69ba1..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GoodbyeWorld.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-
-// So far the reactive hello-world doesn't look too different from a
-// regular old non-reactive hello-world. The onReactorInit method can
-// be used roughly as a 'main' method would. A program that only uses
-// that one event, however, isn't going to be very reactive. By using
-// other events, we can write a fully reactive program.
-public class GoodbyeWorld extends BaseHandler {
-
- // As before we handle the reactor init event.
- @Override
- public void onReactorInit(Event event) {
- System.out.println("Hello, World!");
- }
-
- // In addition to an initial event, the reactor also produces an
- // event when it is about to exit. This may not behave much
- // differently than just putting the goodbye print statement inside
- // onReactorInit, but as we grow our program, this piece of it
- // will always be what happens last, and will always happen
- // regardless of what other paths the main logic of our program
- // might take.
- @Override
- public void onReactorFinal(Event e) {
- System.out.println("Goodbye, World!");;
- }
-
- public static void main(String[] args) throws IOException {
- Reactor reactor = Proton.reactor(new GoodbyeWorld());
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/HelloWorld.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/HelloWorld.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/HelloWorld.java
deleted file mode 100644
index 39a36fb..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/HelloWorld.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-
-/*
- * The proton reactor provides a general purpose event processing
- * library for writing reactive programs. A reactive program is defined
- * by a set of event handlers. An event handler is just any class or
- * object that extends the Handler interface. For convenience, a class
- * can extend BaseHandler and only handle the events that it cares to
- * implement methods for.
- */
-public class HelloWorld extends BaseHandler {
-
- // The reactor init event is produced by the reactor itself when it
- // starts.
- @Override
- public void onReactorInit(Event event) {
- System.out.println("Hello, World!");
- }
-
- public static void main(String[] args) throws IOException {
-
- // When you construct a reactor, you can give it a handler that
- // is used, by default, to receive events generated by the reactor.
- Reactor reactor = Proton.reactor(new HelloWorld());
-
- // When you call run, the reactor will process events. The reactor init
- // event is what kicks off everything else. When the reactor has no
- // more events to process, it exits.
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/README.md
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/README.md b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/README.md
deleted file mode 100644
index 73fbb87..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-The examples in this directory provide a basic introduction to the
-proton reactor API and are best viewed in the order presented below.
-
-The examples contain comments that explain things in a tutorial-style
-manner. At some point soon this content will be pulled out into a
-proper tutorial that references the relevant code snippets from these
-examples. Until then please bear with this clumsy style of
-presentation.
-
-This API is present in Java and Python as well. Most of these examples will
-transliterate into C in a fairly straightforward way.
-
- - HelloWorld.java
- - GoodbyeWorld.java
-
- - Scheduling.java
- - Counter.java
- - CountRandomly.java
-
- - Unhandled.java
- - ReactorLogger.java
- - GlobalLogger.java
- - Delegates.java
-
- - Handlers.java
-
- - Echo.java
- - Cat.java
-
- - Send.java
- - Recv.java
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/ReactorLogger.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/ReactorLogger.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/ReactorLogger.java
deleted file mode 100644
index 31c7511..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/ReactorLogger.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-
-public class ReactorLogger extends BaseHandler {
-
- public static class Logger extends BaseHandler {
- @Override
- public void onUnhandled(Event event) {
- System.out.println("LOG: " + event);
- }
- }
-
- @Override
- public void onReactorInit(Event e) {
- System.out.println("Hello, World!");
- }
-
- @Override
- public void onReactorFinal(Event e) {
- System.out.println("Goodbye, World!");
- }
-
- private static boolean loggingEnabled = false;
-
- public static void main(String[] args) throws IOException {
-
- // You can pass multiple handlers to a reactor when you construct it.
- // Each of these handlers will see every event the reactor sees. By
- // combining this with on_unhandled, you can log each event that goes
- // to the reactor.
- Reactor reactor = Proton.reactor(new ReactorLogger(), new Logger());
- reactor.run();
-
- // Note that if you wanted to add the logger later, you could also
- // write the above as below. All arguments to the reactor are just
- // added to the default handler for the reactor.
- reactor = Proton.reactor(new ReactorLogger());
- if (loggingEnabled)
- reactor.getHandler().add(new Logger());
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Recv.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Recv.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Recv.java
deleted file mode 100644
index 96a348a..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Recv.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Receiver;
-import org.apache.qpid.proton.message.Message;
-import org.apache.qpid.proton.reactor.FlowController;
-import org.apache.qpid.proton.reactor.Handshaker;
-import org.apache.qpid.proton.reactor.Reactor;
-
-public class Recv extends BaseHandler {
-
- private Recv() {
- add(new Handshaker());
- add(new FlowController());
- }
-
- @Override
- public void onReactorInit(Event event) {
- try {
- // Create an amqp acceptor.
- event.getReactor().acceptor("0.0.0.0", 5672);
-
- // There is an optional third argument to the Reactor.acceptor
- // call. Using it, we could supply a handler here that would
- // become the handler for all accepted connections. If we omit
- // it, the reactor simply inherits all the connection events.
- } catch(IOException ioException) {
- ioException.printStackTrace();
- }
- }
-
- @Override
- public void onDelivery(Event event) {
- Receiver recv = (Receiver)event.getLink();
- Delivery delivery = recv.current();
- if (delivery.isReadable() && !delivery.isPartial()) {
- int size = delivery.pending();
- byte[] buffer = new byte[size];
- int read = recv.recv(buffer, 0, buffer.length);
- recv.advance();
-
- Message msg = Proton.message();
- msg.decode(buffer, 0, read);
- System.out.println(((AmqpValue)msg.getBody()).getValue());
- }
- }
-
- public static void main(String[] args) throws IOException {
- Reactor r = Proton.reactor(new Recv());
- r.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java
deleted file mode 100644
index 3aed27a..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-import org.apache.qpid.proton.reactor.Task;
-
-public class Scheduling extends BaseHandler {
-
- private long startTime;
-
- @Override
- public void onReactorInit(Event event) {
- startTime = System.currentTimeMillis();
- System.out.println("Hello, World!");
-
- // We can schedule a task event for some point in the future.
- // This will cause the reactor to stick around until it has a
- // chance to process the event.
-
- // The first argument is the delay. The second argument is the
- // handler for the event. We are just using self for now, but
- // we could pass in another object if we wanted.
- Task task = event.getReactor().schedule(1000, this);
-
- // We can ignore the task if we want to, but we can also use it
- // to pass stuff to the handler.
- task.attachments().set("key", String.class, "Yay");
- }
-
- @Override
- public void onTimerTask(Event event) {
- Task task = event.getTask();
- System.out.println(task.attachments().get("key", String.class) + " my task is complete!");
- }
-
- @Override
- public void onReactorFinal(Event e) {
- long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Goodbye, World! (after " + elapsedTime + " long milliseconds)");
- }
-
- public static void main(String[] args) throws IOException {
- Reactor reactor = Proton.reactor(new Scheduling());
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Send.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Send.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Send.java
deleted file mode 100644
index 5978c45..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Send.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-import java.nio.BufferOverflowException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.message.Message;
-import org.apache.qpid.proton.reactor.Handshaker;
-import org.apache.qpid.proton.reactor.Reactor;
-
-// This is a send in terms of low level AMQP events.
-public class Send extends BaseHandler {
-
- private class SendHandler extends BaseHandler {
-
- private final Message message;
- private int nextTag = 0;
-
- private SendHandler(Message message) {
- this.message = message;
-
- // Add a child handler that performs some default handshaking
- // behaviour.
- add(new Handshaker());
- }
-
- @Override
- public void onConnectionInit(Event event) {
- Connection conn = event.getConnection();
-
- // Every session or link could have their own handler(s) if we
- // wanted simply by adding the handler to the given session
- // or link
- Session ssn = conn.session();
-
- // If a link doesn't have an event handler, the events go to
- // its parent session. If the session doesn't have a handler
- // the events go to its parent connection. If the connection
- // doesn't have a handler, the events go to the reactor.
- Sender snd = ssn.sender("sender");
- conn.open();
- ssn.open();
- snd.open();
- }
-
- @Override
- public void onLinkFlow(Event event) {
- Sender snd = (Sender)event.getLink();
- if (snd.getCredit() > 0) {
- byte[] msgData = new byte[1024];
- int length;
- while(true) {
- try {
- length = message.encode(msgData, 0, msgData.length);
- break;
- } catch(BufferOverflowException e) {
- msgData = new byte[msgData.length * 2];
- }
- }
- byte[] tag = String.valueOf(nextTag++).getBytes();
- Delivery dlv = snd.delivery(tag);
- snd.send(msgData, 0, length);
- dlv.settle();
- snd.advance();
- snd.close();
- snd.getSession().close();
- snd.getSession().getConnection().close();
- }
- }
-
- @Override
- public void onTransportError(Event event) {
- ErrorCondition condition = event.getTransport().getCondition();
- if (condition != null) {
- System.err.println("Error: " + condition.getDescription());
- } else {
- System.err.println("Error (no description returned).");
- }
- }
- }
-
- private final String host;
- private final int port;
- private final Message message;
-
- private Send(String host, int port, String content) {
- this.host = host;
- this.port = port;
- message = Proton.message();
- message.setBody(new AmqpValue(content));
- }
-
- @Override
- public void onReactorInit(Event event) {
- // You can use the connection method to create AMQP connections.
-
- // This connection's handler is the SendHandler object. All the events
- // for this connection will go to the SendHandler object instead of
- // going to the reactor. If you were to omit the SendHandler object,
- // all the events would go to the reactor.
- event.getReactor().connectionToHost(host, port, new SendHandler(message));
- }
-
- public static void main(String[] args) throws IOException {
- int port = 5672;
- String host = "localhost";
- if (args.length > 0) {
- String[] parts = args[0].split(":", 2);
- host = parts[0];
- if (parts.length > 1) {
- port = Integer.parseInt(parts[1]);
- }
- }
- String content = args.length > 1 ? args[1] : "Hello World!";
-
- Reactor r = Proton.reactor(new Send(host, port, content));
- r.run();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Unhandled.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Unhandled.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Unhandled.java
deleted file mode 100644
index a3cc200..0000000
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Unhandled.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.example.reactor;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.reactor.Reactor;
-
-public class Unhandled extends BaseHandler {
-
- // If an event occurs and its handler doesn't have an on_<event>
- // method, the reactor will attempt to call the on_unhandled method
- // if it exists. This can be useful not only for debugging, but for
- // logging and for delegating/inheritance.
- @Override
- public void onUnhandled(Event event) {
- System.out.println(event);
- }
-
- public static void main(String[] args) throws IOException {
- Reactor reactor = Proton.reactor(new Unhandled());
- reactor.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 7391713..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <description>Proton is a library for speaking AMQP.</description>
- <parent>
- <groupId>org.apache</groupId>
- <artifactId>apache</artifactId>
- <version>12</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-project</artifactId>
- <version>0.17.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <properties>
- <junit-version>4.12</junit-version>
- <mockito-version>1.10.19</mockito-version>
- <doxia-module-version>1.3</doxia-module-version>
-
- <maven-source-plugin-version>2.2.1</maven-source-plugin-version>
- <maven-bundle-plugin-version>2.5.4</maven-bundle-plugin-version>
- </properties>
-
- <distributionManagement>
- <site>
- <id>proton-site-id</id>
- <!-- Maven requires a site url even if you only run site:stage -->
- <url>file:///tmp/proton-site</url>
- </site>
- </distributionManagement>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- <optimize>true</optimize>
- <showDeprecation>true</showDeprecation>
- <showWarnings>true</showWarnings>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.doxia</groupId>
- <artifactId>doxia-module-markdown</artifactId>
- <version>${doxia-module-version}</version>
- </dependency>
- </dependencies>
- <configuration>
- <inputEncoding>UTF-8</inputEncoding>
- <outputEncoding>UTF-8</outputEncoding>
- <siteDirectory>docs</siteDirectory>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${maven-bundle-plugin-version}</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>${project.groupId}.proton.*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <versionRange>[2.4.0,)</versionRange>
- <goals>
- <goal>manifest</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit-version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>${mockito-version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <modules>
- <module>proton-j</module>
- <module>tests</module>
- <module>examples/engine/java</module>
- <module>examples/java/messenger</module>
- <module>examples/java/reactor</module>
- </modules>
-
- <url>http://qpid.apache.org/proton</url>
- <scm>
- <url>http://svn.apache.org/viewvc/qpid/proton/</url>
- </scm>
- <issueManagement>
- <url>https://issues.apache.org/jira/browse/PROTON</url>
- </issueManagement>
- <ciManagement>
- <url>https://builds.apache.org/view/M-R/view/Qpid/job/Qpid-proton-j/</url>
- </ciManagement>
-
- <profiles>
- <profile>
- <id>sources</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>${maven-source-plugin-version}</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-j/CMakeLists.txt b/proton-j/CMakeLists.txt
deleted file mode 100644
index 81cb5a1..0000000
--- a/proton-j/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-include(UseJava)
-include(ProtonUseJava)
-set(CMAKE_JAVA_TARGET_VERSION ${PN_VERSION})
-file(GLOB_RECURSE SOURCES_ABS "src/main/java/*.java" "../tests/*/ProtonJInterop.java")
-add_jar(proton-j ${SOURCES_ABS})
-rebuild_jar(proton-j proton-j-${PN_VERSION}.jar)
-set (JAVA_INSTALL_DIR ${SHARE_INSTALL_DIR}/java CACHE PATH "Installation directory for all JARs except those using JNI")
-mark_as_advanced (JAVA_INSTALL_DIR)
-install_jar(proton-j ${JAVA_INSTALL_DIR})
-
-# add relevant CTest support
-find_program (MAVEN_EXE NAMES mvn.cmd mvn DOC "Location of the maven program")
-mark_as_advanced (MAVEN_EXE)
-if (CMAKE_BUILD_TYPE MATCHES "Coverage")
- message (STATUS "Building for coverage analysis: testing disabled for Proton-J")
-elseif (MAVEN_EXE)
- add_test (proton-java ${MAVEN_EXE} clean test --file ${Proton_SOURCE_DIR}/pom.xml)
-else ()
- message (STATUS "Cannot find Maven: testing disabled for Proton-J")
-endif ()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/LICENSE
----------------------------------------------------------------------
diff --git a/proton-j/LICENSE b/proton-j/LICENSE
deleted file mode 100644
index 6b0b127..0000000
--- a/proton-j/LICENSE
+++ /dev/null
@@ -1,203 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/pom.xml
----------------------------------------------------------------------
diff --git a/proton-j/pom.xml b/proton-j/pom.xml
deleted file mode 100644
index 167bf6e..0000000
--- a/proton-j/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-project</artifactId>
- <version>0.17.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>proton-j</artifactId>
- <name>proton-j</name>
- <packaging>bundle</packaging>
-
- <scm>
- <url>http://svn.apache.org/viewvc/qpid/proton/</url>
- </scm>
-
- <dependencies>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcpkix-jdk15on</artifactId>
- <version>1.53</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${maven-bundle-plugin-version}</version>
- <configuration>
- <instructions>
- <Import-Package>
- javax.net.ssl*;resolution:=optional,*
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/InterruptException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/InterruptException.java b/proton-j/src/main/java/org/apache/qpid/proton/InterruptException.java
deleted file mode 100644
index 73c2b9d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/InterruptException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton;
-
-public class InterruptException extends ProtonException
-{
- public InterruptException()
- {
- }
-
- public InterruptException(String message)
- {
- super(message);
- }
-
- public InterruptException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public InterruptException(Throwable cause)
- {
- super(cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/Proton.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/Proton.java b/proton-j/src/main/java/org/apache/qpid/proton/Proton.java
deleted file mode 100644
index 38f39e0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/Proton.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton;
-
-import java.io.IOException;
-
-import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
-import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations;
-import org.apache.qpid.proton.amqp.messaging.Footer;
-import org.apache.qpid.proton.amqp.messaging.Header;
-import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
-import org.apache.qpid.proton.amqp.messaging.Properties;
-import org.apache.qpid.proton.amqp.messaging.Section;
-import org.apache.qpid.proton.codec.Codec;
-import org.apache.qpid.proton.codec.Data;
-import org.apache.qpid.proton.driver.Driver;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Engine;
-import org.apache.qpid.proton.engine.Handler;
-import org.apache.qpid.proton.engine.SslDomain;
-import org.apache.qpid.proton.engine.SslPeerDetails;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.message.Message;
-import org.apache.qpid.proton.messenger.Messenger;
-import org.apache.qpid.proton.reactor.Reactor;
-
-@SuppressWarnings("deprecation")
-public final class Proton
-{
-
- private Proton()
- {
- }
-
- public static Collector collector()
- {
- return Engine.collector();
- }
-
- public static Connection connection()
- {
- return Engine.connection();
- }
-
- public static Transport transport()
- {
- return Engine.transport();
- }
-
- public static SslDomain sslDomain()
- {
- return Engine.sslDomain();
- }
-
- public static SslPeerDetails sslPeerDetails(String hostname, int port)
- {
- return Engine.sslPeerDetails(hostname, port);
- }
-
- public static Data data(long capacity)
- {
- return Codec.data(capacity);
- }
-
- public static Message message()
- {
- return Message.Factory.create();
- }
-
- public static Message message(Header header,
- DeliveryAnnotations deliveryAnnotations, MessageAnnotations messageAnnotations,
- Properties properties, ApplicationProperties applicationProperties,
- Section body, Footer footer)
- {
- return Message.Factory.create(header, deliveryAnnotations,
- messageAnnotations, properties,
- applicationProperties, body, footer);
- }
-
- /**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
- @Deprecated
- public static Messenger messenger()
- {
- return Messenger.Factory.create();
- }
-
- /**
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
- @Deprecated
- public static Messenger messenger(String name)
- {
- return Messenger.Factory.create(name);
- }
-
- /**
- * @deprecated Messenger and its driver will be removed from upcoming proton-j releases.
- */
- @Deprecated
- public static Driver driver() throws IOException
- {
- return Driver.Factory.create();
- }
-
- public static Reactor reactor() throws IOException
- {
- return Reactor.Factory.create();
- }
-
- public static Reactor reactor(Handler... handlers) throws IOException
- {
- Reactor reactor = Reactor.Factory.create();
- for (Handler handler : handlers) {
- reactor.getHandler().add(handler);
- }
- return reactor;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/ProtonException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/ProtonException.java b/proton-j/src/main/java/org/apache/qpid/proton/ProtonException.java
deleted file mode 100644
index 14f5e6e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/ProtonException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton;
-
-public class ProtonException extends RuntimeException
-{
- public ProtonException()
- {
- }
-
- public ProtonException(String message)
- {
- super(message);
- }
-
- public ProtonException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public ProtonException(Throwable cause)
- {
- super(cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java b/proton-j/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java
deleted file mode 100644
index 3981646..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton;
-
-/**
- * Use to indicate that a feature of the Proton API is not supported by a particular implementation
- * (e.g. proton-j or proton-c-via-JNI).
- */
-public class ProtonUnsupportedOperationException extends UnsupportedOperationException
-{
- /** Used by the Python test layer to detect an unsupported operation */
- public static final boolean skipped = true;
-
- public ProtonUnsupportedOperationException()
- {
- }
-
- public ProtonUnsupportedOperationException(String message)
- {
- super(message);
- }
-
- public ProtonUnsupportedOperationException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public ProtonUnsupportedOperationException(Throwable cause)
- {
- super(cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/TimeoutException.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/TimeoutException.java b/proton-j/src/main/java/org/apache/qpid/proton/TimeoutException.java
deleted file mode 100644
index b94de18..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/TimeoutException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton;
-
-public class TimeoutException extends ProtonException
-{
- public TimeoutException()
- {
- }
-
- public TimeoutException(String message)
- {
- super(message);
- }
-
- public TimeoutException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public TimeoutException(Throwable cause)
- {
- super(cause);
- }
-
- public TimeoutException(long timeoutMillis, String pendingCondition)
- {
- this("Timed out after " + timeoutMillis + " ms waiting for condition: " + pendingCondition);
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[13/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutput.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutput.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutput.java
deleted file mode 100644
index b8df26b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutput.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.Transport;
-
-public interface TransportOutput
-{
-
- int pending();
-
- ByteBuffer head();
-
- void pop(int bytes);
-
- void close_head();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutputAdaptor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutputAdaptor.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutputAdaptor.java
deleted file mode 100644
index 2c43bfe..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutputAdaptor.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.*;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.Transport;
-
-class TransportOutputAdaptor implements TransportOutput
-{
- private static final ByteBuffer _emptyHead = newReadableBuffer(0).asReadOnlyBuffer();
-
- private final TransportOutputWriter _transportOutputWriter;
- private final int _maxFrameSize;
-
- private ByteBuffer _outputBuffer = null;
- private ByteBuffer _head = null;
- private boolean _output_done = false;
- private boolean _head_closed = false;
-
- TransportOutputAdaptor(TransportOutputWriter transportOutputWriter, int maxFrameSize)
- {
- _transportOutputWriter = transportOutputWriter;
- _maxFrameSize = maxFrameSize > 0 ? maxFrameSize : 4*1024;
- }
-
- @Override
- public int pending()
- {
- if (_head_closed) {
- return Transport.END_OF_STREAM;
- }
-
- if(_outputBuffer == null)
- {
- init_buffers();
- }
-
- _output_done = _transportOutputWriter.writeInto(_outputBuffer);
- _head.limit(_outputBuffer.position());
-
- if (_outputBuffer.position() == 0 && _outputBuffer.capacity() > TransportImpl.BUFFER_RELEASE_THRESHOLD)
- {
- release_buffers();
- }
-
- if (_output_done && (_outputBuffer == null || _outputBuffer.position() == 0))
- {
- return Transport.END_OF_STREAM;
- }
- else
- {
- return _outputBuffer == null ? 0 : _outputBuffer.position();
- }
- }
-
- @Override
- public ByteBuffer head()
- {
- pending();
- return _head != null ? _head : _emptyHead;
- }
-
- @Override
- public void pop(int bytes)
- {
- if (_outputBuffer != null) {
- _outputBuffer.flip();
- _outputBuffer.position(bytes);
- _outputBuffer.compact();
- _head.position(0);
- _head.limit(_outputBuffer.position());
- if (_outputBuffer.position() == 0 && _outputBuffer.capacity() > TransportImpl.BUFFER_RELEASE_THRESHOLD) {
- release_buffers();
- }
- }
- }
-
- @Override
- public void close_head()
- {
- _head_closed = true;
- _transportOutputWriter.closed(null);
- release_buffers();
- }
-
- private void init_buffers() {
- _outputBuffer = newWriteableBuffer(_maxFrameSize);
- _head = _outputBuffer.asReadOnlyBuffer();
- _head.limit(0);
- }
-
- private void release_buffers() {
- _head = null;
- _outputBuffer = null;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutputWriter.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutputWriter.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutputWriter.java
deleted file mode 100644
index 76c0df7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportOutputWriter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.TransportException;
-
-interface TransportOutputWriter
-{
- /**
- * Writes my pending output bytes into outputBuffer. Does not
- * subsequently flip it. Returns true on end of stream.
- */
- boolean writeInto(ByteBuffer outputBuffer);
-
- void closed(TransportException error);
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java
deleted file mode 100644
index 29d97c4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.transport.Flow;
-
-class TransportReceiver extends TransportLink<ReceiverImpl>
-{
-
-
- TransportReceiver(ReceiverImpl link)
- {
- super(link);
- link.setTransportLink(this);
- }
-
- public ReceiverImpl getReceiver()
- {
- return getLink();
- }
-
- @Override
- void handleFlow(Flow flow)
- {
- super.handleFlow(flow);
- int remote = getRemoteDeliveryCount().intValue();
- int local = getDeliveryCount().intValue();
- int delta = remote - local;
- if(delta > 0)
- {
- getLink().addCredit(-delta);
- addCredit(-delta);
- setDeliveryCount(getRemoteDeliveryCount());
- getLink().setDrained(getLink().getDrained() + delta);
- }
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSender.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSender.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSender.java
deleted file mode 100644
index cebe577..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSender.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.transport.Flow;
-
-class TransportSender extends TransportLink<SenderImpl>
-{
- private boolean _drain;
- private DeliveryImpl _inProgressDelivery;
- private static final UnsignedInteger ORIGINAL_DELIVERY_COUNT = UnsignedInteger.ZERO;
-
- TransportSender(SenderImpl link)
- {
- super(link);
- setDeliveryCount(ORIGINAL_DELIVERY_COUNT);
- link.setTransportLink(this);
- }
-
- @Override
- void handleFlow(Flow flow)
- {
- super.handleFlow(flow);
- _drain = flow.getDrain();
- getLink().setDrain(flow.getDrain());
- int oldCredit = getLink().getCredit();
- UnsignedInteger oldLimit = getLinkCredit().add(getDeliveryCount());
- UnsignedInteger transferLimit = flow.getLinkCredit().add(flow.getDeliveryCount() == null
- ? ORIGINAL_DELIVERY_COUNT
- : flow.getDeliveryCount());
- UnsignedInteger linkCredit = transferLimit.subtract(getDeliveryCount());
-
- setLinkCredit(linkCredit);
- getLink().setCredit(transferLimit.subtract(oldLimit).intValue() + oldCredit);
-
- DeliveryImpl current = getLink().current();
- getLink().getConnectionImpl().workUpdate(current);
- setLinkCredit(linkCredit);
- }
-
- public void setInProgressDelivery(DeliveryImpl inProgressDelivery)
- {
- _inProgressDelivery = inProgressDelivery;
- }
-
- public DeliveryImpl getInProgressDelivery()
- {
- return _inProgressDelivery;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java
deleted file mode 100644
index d9c1083..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.engine.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.transport.Disposition;
-import org.apache.qpid.proton.amqp.transport.Flow;
-import org.apache.qpid.proton.amqp.transport.Role;
-import org.apache.qpid.proton.amqp.transport.Transfer;
-import org.apache.qpid.proton.engine.Event;
-
-class TransportSession
-{
- private static final int HANDLE_MAX = 65535;
-
- private final TransportImpl _transport;
- private final SessionImpl _session;
- private int _localChannel = -1;
- private int _remoteChannel = -1;
- private boolean _openSent;
- private final UnsignedInteger _handleMax = UnsignedInteger.valueOf(HANDLE_MAX); //TODO: should this be configurable?
- // This is used for the delivery-id actually stamped in each transfer frame of a given message delivery.
- private UnsignedInteger _outgoingDeliveryId = UnsignedInteger.ZERO;
- // These are used for the session windows communicated via Begin/Flow frames
- // and the conceptual transfer-id relating to updating them.
- private UnsignedInteger _incomingWindowSize = UnsignedInteger.ZERO;
- private UnsignedInteger _outgoingWindowSize = UnsignedInteger.ZERO;
- private UnsignedInteger _nextOutgoingId = UnsignedInteger.ONE;
- private UnsignedInteger _nextIncomingId = null;
-
- private final Map<UnsignedInteger, TransportLink<?>> _remoteHandlesMap = new HashMap<UnsignedInteger, TransportLink<?>>();
- private final Map<UnsignedInteger, TransportLink<?>> _localHandlesMap = new HashMap<UnsignedInteger, TransportLink<?>>();
- private final Map<String, TransportLink> _halfOpenLinks = new HashMap<String, TransportLink>();
-
-
- private UnsignedInteger _incomingDeliveryId = null;
- private UnsignedInteger _remoteIncomingWindow;
- private UnsignedInteger _remoteOutgoingWindow;
- private UnsignedInteger _remoteNextIncomingId = _nextOutgoingId;
- private UnsignedInteger _remoteNextOutgoingId;
- private final Map<UnsignedInteger, DeliveryImpl>
- _unsettledIncomingDeliveriesById = new HashMap<UnsignedInteger, DeliveryImpl>();
- private final Map<UnsignedInteger, DeliveryImpl>
- _unsettledOutgoingDeliveriesById = new HashMap<UnsignedInteger, DeliveryImpl>();
- private int _unsettledIncomingSize;
- private boolean _endReceived;
- private boolean _beginSent;
-
- TransportSession(TransportImpl transport, SessionImpl session)
- {
- _transport = transport;
- _session = session;
- _outgoingWindowSize = UnsignedInteger.valueOf(session.getOutgoingWindow());
- }
-
- void unbind()
- {
- unsetLocalChannel();
- unsetRemoteChannel();
- }
-
- public SessionImpl getSession()
- {
- return _session;
- }
-
- public int getLocalChannel()
- {
- return _localChannel;
- }
-
- public void setLocalChannel(int localChannel)
- {
- if (!isLocalChannelSet()) {
- _session.incref();
- }
- _localChannel = localChannel;
- }
-
- public int getRemoteChannel()
- {
- return _remoteChannel;
- }
-
- public void setRemoteChannel(int remoteChannel)
- {
- if (!isRemoteChannelSet()) {
- _session.incref();
- }
- _remoteChannel = remoteChannel;
- }
-
- public boolean isOpenSent()
- {
- return _openSent;
- }
-
- public void setOpenSent(boolean openSent)
- {
- _openSent = openSent;
- }
-
- public boolean isRemoteChannelSet()
- {
- return _remoteChannel != -1;
- }
-
- public boolean isLocalChannelSet()
- {
- return _localChannel != -1;
- }
-
- public void unsetLocalChannel()
- {
- if (isLocalChannelSet()) {
- unsetLocalHandles();
- _session.decref();
- }
- _localChannel = -1;
- }
-
- private void unsetLocalHandles()
- {
- for (TransportLink<?> tl : _localHandlesMap.values())
- {
- tl.clearLocalHandle();
- }
- _localHandlesMap.clear();
- }
-
- public void unsetRemoteChannel()
- {
- if (isRemoteChannelSet()) {
- unsetRemoteHandles();
- _session.decref();
- }
- _remoteChannel = -1;
- }
-
- private void unsetRemoteHandles()
- {
- for (TransportLink<?> tl : _remoteHandlesMap.values())
- {
- tl.clearRemoteHandle();
- }
- _remoteHandlesMap.clear();
- }
-
- public UnsignedInteger getHandleMax()
- {
- return _handleMax;
- }
-
- public UnsignedInteger getIncomingWindowSize()
- {
- return _incomingWindowSize;
- }
-
- void updateIncomingWindow()
- {
- int size = _transport.getMaxFrameSize();
- if (size <= 0) {
- _incomingWindowSize = UnsignedInteger.valueOf(2147483647); // biggest legal value
- } else {
- _incomingWindowSize = UnsignedInteger.valueOf((_session.getIncomingCapacity() - _session.getIncomingBytes())/size);
- }
- }
-
- public UnsignedInteger getOutgoingDeliveryId()
- {
- return _outgoingDeliveryId;
- }
-
- void incrementOutgoingDeliveryId()
- {
- _outgoingDeliveryId = _outgoingDeliveryId.add(UnsignedInteger.ONE);
- }
-
- public UnsignedInteger getOutgoingWindowSize()
- {
- return _outgoingWindowSize;
- }
-
- public UnsignedInteger getNextOutgoingId()
- {
- return _nextOutgoingId;
- }
-
- public TransportLink getLinkFromRemoteHandle(UnsignedInteger handle)
- {
- return _remoteHandlesMap.get(handle);
- }
-
- public UnsignedInteger allocateLocalHandle(TransportLink transportLink)
- {
- for(int i = 0; i <= HANDLE_MAX; i++)
- {
- UnsignedInteger handle = UnsignedInteger.valueOf(i);
- if(!_localHandlesMap.containsKey(handle))
- {
- _localHandlesMap.put(handle, transportLink);
- transportLink.setLocalHandle(handle);
- return handle;
- }
- }
- throw new IllegalStateException("no local handle available for allocation");
- }
-
- public void addLinkRemoteHandle(TransportLink link, UnsignedInteger remoteHandle)
- {
- _remoteHandlesMap.put(remoteHandle, link);
- }
-
- public void addLinkLocalHandle(TransportLink link, UnsignedInteger localhandle)
- {
- _localHandlesMap.put(localhandle, link);
- }
-
- public void freeLocalHandle(UnsignedInteger handle)
- {
- _localHandlesMap.remove(handle);
- }
-
- public void freeRemoteHandle(UnsignedInteger handle)
- {
- _remoteHandlesMap.remove(handle);
- }
-
- public TransportLink resolveHalfOpenLink(String name)
- {
- return _halfOpenLinks.remove(name);
- }
-
- public void addHalfOpenLink(TransportLink link)
- {
- _halfOpenLinks.put(link.getName(), link);
- }
-
- public void handleTransfer(Transfer transfer, Binary payload)
- {
- DeliveryImpl delivery;
- incrementNextIncomingId();
- if(transfer.getDeliveryId() == null || transfer.getDeliveryId().equals(_incomingDeliveryId))
- {
- TransportReceiver transportReceiver = (TransportReceiver) getLinkFromRemoteHandle(transfer.getHandle());
- ReceiverImpl receiver = transportReceiver.getReceiver();
- Binary deliveryTag = transfer.getDeliveryTag();
- delivery = _unsettledIncomingDeliveriesById.get(_incomingDeliveryId);
- delivery.getTransportDelivery().incrementSessionSize();
-
- }
- else
- {
- // TODO - check deliveryId has been incremented by one
- _incomingDeliveryId = transfer.getDeliveryId();
- // TODO - check link handle valid and a receiver
- TransportReceiver transportReceiver = (TransportReceiver) getLinkFromRemoteHandle(transfer.getHandle());
- ReceiverImpl receiver = transportReceiver.getReceiver();
- Binary deliveryTag = transfer.getDeliveryTag();
- delivery = receiver.delivery(deliveryTag.getArray(), deliveryTag.getArrayOffset(),
- deliveryTag.getLength());
- UnsignedInteger messageFormat = transfer.getMessageFormat();
- if(messageFormat != null) {
- delivery.setMessageFormat(messageFormat.intValue());
- }
- TransportDelivery transportDelivery = new TransportDelivery(_incomingDeliveryId, delivery, transportReceiver);
- delivery.setTransportDelivery(transportDelivery);
- _unsettledIncomingDeliveriesById.put(_incomingDeliveryId, delivery);
- getSession().incrementIncomingDeliveries(1);
- }
- if( transfer.getState()!=null )
- {
- delivery.setRemoteDeliveryState(transfer.getState());
- }
- _unsettledIncomingSize++;
- // TODO - should this be a copy?
- if(payload != null)
- {
- if(delivery.getDataLength() == 0)
- {
- delivery.setData(payload.getArray());
- delivery.setDataLength(payload.getLength());
- delivery.setDataOffset(payload.getArrayOffset());
- }
- else
- {
- byte[] data = new byte[delivery.getDataLength() + payload.getLength()];
- System.arraycopy(delivery.getData(), delivery.getDataOffset(), data, 0, delivery.getDataLength());
- System.arraycopy(payload.getArray(), payload.getArrayOffset(), data, delivery.getDataLength(), payload.getLength());
- delivery.setData(data);
- delivery.setDataOffset(0);
- delivery.setDataLength(data.length);
- }
- getSession().incrementIncomingBytes(payload.getLength());
- }
- delivery.updateWork();
-
-
- if(!(transfer.getMore() || transfer.getAborted()))
- {
- delivery.setComplete();
- delivery.getLink().getTransportLink().decrementLinkCredit();
- delivery.getLink().getTransportLink().incrementDeliveryCount();
- }
- if(Boolean.TRUE.equals(transfer.getSettled()))
- {
- delivery.setRemoteSettled(true);
- }
-
- _incomingWindowSize = _incomingWindowSize.subtract(UnsignedInteger.ONE);
-
- // this will cause a flow to happen
- if (_incomingWindowSize.equals(UnsignedInteger.ZERO)) {
- delivery.getLink().modified(false);
- }
-
- getSession().getConnection().put(Event.Type.DELIVERY, delivery);
- }
-
- public void freeLocalChannel()
- {
- unsetLocalChannel();
- }
-
- public void freeRemoteChannel()
- {
- unsetRemoteChannel();
- }
-
- private void setRemoteIncomingWindow(UnsignedInteger incomingWindow)
- {
- _remoteIncomingWindow = incomingWindow;
- }
-
- void decrementRemoteIncomingWindow()
- {
- _remoteIncomingWindow = _remoteIncomingWindow.subtract(UnsignedInteger.ONE);
- }
-
- private void setRemoteOutgoingWindow(UnsignedInteger outgoingWindow)
- {
- _remoteOutgoingWindow = outgoingWindow;
- }
-
- void handleFlow(Flow flow)
- {
- UnsignedInteger inext = flow.getNextIncomingId();
- UnsignedInteger iwin = flow.getIncomingWindow();
-
- if(inext != null)
- {
- setRemoteNextIncomingId(inext);
- setRemoteIncomingWindow(inext.add(iwin).subtract(_nextOutgoingId));
- }
- else
- {
- setRemoteIncomingWindow(iwin);
- }
- setRemoteNextOutgoingId(flow.getNextOutgoingId());
- setRemoteOutgoingWindow(flow.getOutgoingWindow());
-
- if(flow.getHandle() != null)
- {
- TransportLink transportLink = getLinkFromRemoteHandle(flow.getHandle());
- transportLink.handleFlow(flow);
-
-
- }
- }
-
- private void setRemoteNextOutgoingId(UnsignedInteger nextOutgoingId)
- {
- _remoteNextOutgoingId = nextOutgoingId;
- }
-
- private void setRemoteNextIncomingId(UnsignedInteger remoteNextIncomingId)
- {
- _remoteNextIncomingId = remoteNextIncomingId;
- }
-
- void handleDisposition(Disposition disposition)
- {
- UnsignedInteger id = disposition.getFirst();
- UnsignedInteger last = disposition.getLast() == null ? id : disposition.getLast();
- final Map<UnsignedInteger, DeliveryImpl> unsettledDeliveries =
- disposition.getRole() == Role.RECEIVER ? _unsettledOutgoingDeliveriesById
- : _unsettledIncomingDeliveriesById;
-
- while(id.compareTo(last)<=0)
- {
- DeliveryImpl delivery = unsettledDeliveries.get(id);
- if(delivery != null)
- {
- if(disposition.getState() != null)
- {
- delivery.setRemoteDeliveryState(disposition.getState());
- }
- if(Boolean.TRUE.equals(disposition.getSettled()))
- {
- delivery.setRemoteSettled(true);
- unsettledDeliveries.remove(id);
- }
- delivery.updateWork();
-
- getSession().getConnection().put(Event.Type.DELIVERY, delivery);
- }
- id = id.add(UnsignedInteger.ONE);
- }
- //TODO - Implement.
- }
-
- void addUnsettledOutgoing(UnsignedInteger deliveryId, DeliveryImpl delivery)
- {
- _unsettledOutgoingDeliveriesById.put(deliveryId, delivery);
- }
-
- public boolean hasOutgoingCredit()
- {
- return _remoteIncomingWindow == null ? false
- : _remoteIncomingWindow.compareTo(UnsignedInteger.ZERO)>0;
-
- }
-
- void incrementOutgoingId()
- {
- _nextOutgoingId = _nextOutgoingId.add(UnsignedInteger.ONE);
- }
-
- public void settled(TransportDelivery transportDelivery)
- {
- if(transportDelivery.getTransportLink().getLink() instanceof ReceiverImpl)
- {
- _unsettledIncomingDeliveriesById.remove(transportDelivery.getDeliveryId());
- getSession().modified(false);
- }
- else
- {
- _unsettledOutgoingDeliveriesById.remove(transportDelivery.getDeliveryId());
- getSession().modified(false);
- }
- }
-
- public UnsignedInteger getNextIncomingId()
- {
- return _nextIncomingId;
- }
-
- public void setNextIncomingId(UnsignedInteger nextIncomingId)
- {
- _nextIncomingId = nextIncomingId;
- }
-
- public void incrementNextIncomingId()
- {
- _nextIncomingId = _nextIncomingId.add(UnsignedInteger.ONE);
- }
-
- public boolean endReceived()
- {
- return _endReceived;
- }
-
- public void receivedEnd()
- {
- _endReceived = true;
- }
-
- public boolean beginSent()
- {
- return _beginSent;
- }
-
- public void sentBegin()
- {
- _beginSent = true;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportWrapper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportWrapper.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportWrapper.java
deleted file mode 100644
index f0b5f5c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportWrapper.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-
-public interface TransportWrapper extends TransportInput, TransportOutput
-{
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/DefaultSslEngineFacade.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/DefaultSslEngineFacade.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/DefaultSslEngineFacade.java
deleted file mode 100644
index 8c38126..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/DefaultSslEngineFacade.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import java.nio.ByteBuffer;
-
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLEngineResult.HandshakeStatus;
-import javax.net.ssl.SSLEngineResult.Status;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLSession;
-
-
-class DefaultSslEngineFacade implements ProtonSslEngine
-{
- private final SSLEngine _sslEngine;
-
- /**
- * Our testing has shown that application buffers need to be a bit larger
- * than that provided by {@link SSLSession#getApplicationBufferSize()} otherwise
- * {@link Status#BUFFER_OVERFLOW} will result on {@link SSLEngine#unwrap()}.
- * Sun's own example uses 50, so we use the same.
- */
- private static final int APPLICATION_BUFFER_EXTRA = 50;
-
- DefaultSslEngineFacade(SSLEngine sslEngine)
- {
- _sslEngine = sslEngine;
- }
-
- @Override
- public SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst) throws SSLException
- {
- return _sslEngine.wrap(src, dst);
- }
-
- @Override
- public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst) throws SSLException
- {
- return _sslEngine.unwrap(src, dst);
- }
-
- /**
- * @see #APPLICATION_BUFFER_EXTRA
- */
- @Override
- public int getEffectiveApplicationBufferSize()
- {
- return getApplicationBufferSize() + APPLICATION_BUFFER_EXTRA;
- }
-
- private int getApplicationBufferSize()
- {
- return _sslEngine.getSession().getApplicationBufferSize();
- }
-
- @Override
- public int getPacketBufferSize()
- {
- return _sslEngine.getSession().getPacketBufferSize();
- }
-
- @Override
- public String getCipherSuite()
- {
- return _sslEngine.getSession().getCipherSuite();
- }
-
- @Override
- public String getProtocol()
- {
- return _sslEngine.getSession().getProtocol();
- }
-
- @Override
- public Runnable getDelegatedTask()
- {
- return _sslEngine.getDelegatedTask();
- }
-
- @Override
- public HandshakeStatus getHandshakeStatus()
- {
- return _sslEngine.getHandshakeStatus();
- }
-
- @Override
- public boolean getUseClientMode()
- {
- return _sslEngine.getUseClientMode();
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("DefaultSslEngineFacade [_sslEngine=").append(_sslEngine).append("]");
- return builder.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngine.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngine.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngine.java
deleted file mode 100644
index a5ebc65..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngine.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import java.nio.ByteBuffer;
-
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLEngineResult.HandshakeStatus;
-import javax.net.ssl.SSLEngineResult.Status;
-import javax.net.ssl.SSLException;
-
-/**
- * Thin wrapper around an {@link SSLEngine}.
- */
-public interface ProtonSslEngine
-{
- /**
- * @see SSLEngine#wrap(ByteBuffer, ByteBuffer)
- *
- * Note that wrap really does write <em>one</em> packet worth of data to the
- * dst byte buffer. If dst byte buffer is insufficiently large the
- * pointers within both src and dst are unchanged and the bytesConsumed and
- * bytesProduced on the returned result are zero.
- */
- SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst) throws SSLException;
-
- /**
- * @see SSLEngine#unwrap(ByteBuffer, ByteBuffer)
- *
- * Note that unwrap does read exactly one packet of encoded data from src
- * and write to dst. If src contains insufficient bytes to read a complete
- * packet {@link Status#BUFFER_UNDERFLOW} occurs. If underflow occurs the
- * pointers within both src and dst are unchanged and the bytesConsumed and
- * bytesProduced on the returned result are zero.
- */
- SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst) throws SSLException;
-
- Runnable getDelegatedTask();
- HandshakeStatus getHandshakeStatus();
-
- /**
- * Gets the application buffer size.
- */
- int getEffectiveApplicationBufferSize();
-
- int getPacketBufferSize();
- String getCipherSuite();
- String getProtocol();
- boolean getUseClientMode();
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java
deleted file mode 100644
index 95ae337..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import org.apache.qpid.proton.engine.SslPeerDetails;
-
-public interface ProtonSslEngineProvider
-{
- /**
- * Returns an SSL engine.
- *
- * @param peerDetails the details of the remote peer. If non-null, may be used to assist SSL session resumption.
- */
- public ProtonSslEngine createSslEngine(SslPeerDetails peerDetails);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapper.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapper.java
deleted file mode 100644
index a30e88b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SimpleSslTransportWrapper.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-
-import static org.apache.qpid.proton.engine.impl.ByteBufferUtils.newWriteableBuffer;
-
-import java.nio.ByteBuffer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLEngineResult.HandshakeStatus;
-import javax.net.ssl.SSLEngineResult.Status;
-import javax.net.ssl.SSLException;
-
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.engine.impl.TransportInput;
-import org.apache.qpid.proton.engine.impl.TransportOutput;
-
-/**
- * TODO close the SSLEngine when told to, and modify {@link #wrapOutput()} and {@link #unwrapInput()}
- * to respond appropriately thereafter.
- */
-public class SimpleSslTransportWrapper implements SslTransportWrapper
-{
- private static final Logger _logger = Logger.getLogger(SimpleSslTransportWrapper.class.getName());
-
- private final ProtonSslEngine _sslEngine;
-
- private final TransportInput _underlyingInput;
- private final TransportOutput _underlyingOutput;
-
- private boolean _tail_closed = false;
- private ByteBuffer _inputBuffer;
-
- private boolean _head_closed = false;
- private ByteBuffer _outputBuffer;
- private ByteBuffer _head;
-
- /**
- * A buffer for the decoded bytes that will be passed to _underlyingInput.
- * This extra layer of buffering is necessary in case the underlying input's buffer
- * is too small for SSLEngine to ever unwrap into.
- */
- private ByteBuffer _decodedInputBuffer;
-
- /** could change during the lifetime of the ssl connection owing to renegotiation. */
- private String _cipherName;
-
- /** could change during the lifetime of the ssl connection owing to renegotiation. */
- private String _protocolName;
-
-
- SimpleSslTransportWrapper(ProtonSslEngine sslEngine, TransportInput underlyingInput, TransportOutput underlyingOutput)
- {
- _underlyingInput = underlyingInput;
- _underlyingOutput = underlyingOutput;
- _sslEngine = sslEngine;
-
- int effectiveAppBufferMax = _sslEngine.getEffectiveApplicationBufferSize();
- int packetSize = _sslEngine.getPacketBufferSize();
-
- // Input and output buffers need to be large enough to contain one SSL packet,
- // as stated in SSLEngine JavaDoc.
- _inputBuffer = newWriteableBuffer(packetSize);
- _outputBuffer = newWriteableBuffer(packetSize);
- _head = _outputBuffer.asReadOnlyBuffer();
- _head.limit(0);
-
- _decodedInputBuffer = newWriteableBuffer(effectiveAppBufferMax);
-
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine("Constructed " + this);
- }
- }
-
-
- /**
- * Unwraps the contents of {@link #_inputBuffer} and passes it to {@link #_underlyingInput}.
- *
- * Regarding the state of {@link #_inputBuffer}:
- * - On entry, it is assumed to be readable.
- * - On exit, it is still readable and its "remaining" bytes are those that we were unable
- * to unwrap (e.g. if they don't form a whole packet).
- */
- private void unwrapInput() throws SSLException
- {
- while (true) {
- SSLEngineResult result = _sslEngine.unwrap(_inputBuffer, _decodedInputBuffer);
- logEngineClientModeAndResult(result, "input");
-
- int read = result.bytesProduced();
- Status status = result.getStatus();
- HandshakeStatus hstatus = result.getHandshakeStatus();
-
- int capacity = _underlyingInput.capacity();
- if (capacity == Transport.END_OF_STREAM || capacity <= 0) {
- _tail_closed = true;
- if (_decodedInputBuffer.position() > 0) {
- throw new TransportException("bytes left unconsumed");
- }
- } else {
- _decodedInputBuffer.flip();
-
- while (_decodedInputBuffer.hasRemaining() && capacity > 0) {
- ByteBuffer tail = _underlyingInput.tail();
- int limit = _decodedInputBuffer.limit();
- int overflow = _decodedInputBuffer.remaining() - capacity;
- if (overflow > 0) {
- _decodedInputBuffer.limit(limit - overflow);
- }
- tail.put(_decodedInputBuffer);
- _decodedInputBuffer.limit(limit);
- _underlyingInput.process();
- capacity = _underlyingInput.capacity();
- }
-
- if (capacity == Transport.END_OF_STREAM || capacity <= 0) {
- _tail_closed = true;
- if (_decodedInputBuffer.hasRemaining()) {
- throw new TransportException("bytes left unconsumed");
- }
- }
-
- _decodedInputBuffer.compact();
- }
-
- switch (status) {
- case CLOSED:
- _tail_closed = true;
- break;
- case BUFFER_OVERFLOW:
- {
- ByteBuffer old = _decodedInputBuffer;
- _decodedInputBuffer = newWriteableBuffer(old.capacity()*2);
- old.flip();
- _decodedInputBuffer.put(old);
- }
- continue;
- case BUFFER_UNDERFLOW:
- if (_tail_closed) {
- _head_closed = true;
- }
- // wait for more data
- break;
- case OK:
- break;
- }
-
- switch (hstatus)
- {
- case NEED_WRAP:
- // wait for write to kick in
- break;
- case NEED_TASK:
- runDelegatedTasks(result);
- continue;
- case FINISHED:
- updateCipherAndProtocolName(result);
- case NOT_HANDSHAKING:
- case NEED_UNWRAP:
- if (_inputBuffer.position() > 0 && status == Status.OK) {
- continue;
- } else {
- if (_inputBuffer.position() == 0 &&
- hstatus == HandshakeStatus.NEED_UNWRAP &&
- _tail_closed) {
- _head_closed = true;
- }
- break;
- }
- }
-
- break;
- }
- }
-
- /**
- * Wrap the underlying transport's output, passing it to the output buffer.
- *
- * {@link #_outputBuffer} is assumed to be writeable on entry and is guaranteed to
- * be still writeable on exit.
- */
- private void wrapOutput() throws SSLException
- {
- while (true) {
- int pending = _underlyingOutput.pending();
- if (pending < 0) {
- _head_closed = true;
- }
-
- ByteBuffer clearOutputBuffer = _underlyingOutput.head();
- SSLEngineResult result = _sslEngine.wrap(clearOutputBuffer, _outputBuffer);
- logEngineClientModeAndResult(result, "output");
-
- int written = result.bytesConsumed();
- _underlyingOutput.pop(written);
- pending = _underlyingOutput.pending();
-
- Status status = result.getStatus();
- switch (status) {
- case CLOSED:
- _head_closed = true;
- break;
- case OK:
- break;
- case BUFFER_OVERFLOW:
- ByteBuffer old = _outputBuffer;
- _outputBuffer = newWriteableBuffer(_outputBuffer.capacity()*2);
- _head = _outputBuffer.asReadOnlyBuffer();
- old.flip();
- _outputBuffer.put(old);
- continue;
- case BUFFER_UNDERFLOW:
- throw new IllegalStateException("app buffer underflow");
- }
-
- HandshakeStatus hstatus = result.getHandshakeStatus();
- switch (hstatus) {
- case NEED_UNWRAP:
- // wait for input data
- if (_inputBuffer.position() == 0 && _tail_closed) {
- _head_closed = true;
- }
- break;
- case NEED_WRAP:
- // keep looping
- continue;
- case NEED_TASK:
- runDelegatedTasks(result);
- continue;
- case FINISHED:
- updateCipherAndProtocolName(result);
- // intentionally fall through
- case NOT_HANDSHAKING:
- if (pending > 0 && status == Status.OK) {
- continue;
- } else {
- break;
- }
- }
-
- break;
- }
- }
-
- private boolean hasSpaceForSslPacket(ByteBuffer byteBuffer)
- {
- return byteBuffer.remaining() >= _sslEngine.getPacketBufferSize();
- }
-
- /** @return the cipher name, which is null until the SSL handshaking is completed */
- @Override
- public String getCipherName()
- {
- return _cipherName;
- }
-
- /** @return the protocol name, which is null until the SSL handshaking is completed */
- @Override
- public String getProtocolName()
- {
- return _protocolName;
- }
-
- private void updateCipherAndProtocolName(SSLEngineResult result)
- {
- if (result.getHandshakeStatus() == HandshakeStatus.FINISHED)
- {
- _cipherName = _sslEngine.getCipherSuite();
- _protocolName = _sslEngine.getProtocol();
- }
- }
-
- private void runDelegatedTasks(SSLEngineResult result)
- {
- if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK)
- {
- Runnable runnable;
- while ((runnable = _sslEngine.getDelegatedTask()) != null)
- {
- runnable.run();
- }
-
- HandshakeStatus hsStatus = _sslEngine.getHandshakeStatus();
- if (hsStatus == HandshakeStatus.NEED_TASK)
- {
- throw new RuntimeException("handshake shouldn't need additional tasks");
- }
- }
- }
-
- private void logEngineClientModeAndResult(SSLEngineResult result, String direction)
- {
- if(_logger.isLoggable(Level.FINEST))
- {
- _logger.log(Level.FINEST, "useClientMode = " + _sslEngine.getUseClientMode() + " direction = " + direction
- + " " + resultToString(result));
- }
- }
-
- private String resultToString(SSLEngineResult result)
- {
- return new StringBuilder("[SSLEngineResult status = ").append(result.getStatus())
- .append(" handshakeStatus = ").append(result.getHandshakeStatus())
- .append(" bytesConsumed = ").append(result.bytesConsumed())
- .append(" bytesProduced = ").append(result.bytesProduced())
- .append("]").toString();
- }
-
- @Override
- public int capacity()
- {
- if (_tail_closed) return Transport.END_OF_STREAM;
- return _inputBuffer.remaining();
- }
-
- @Override
- public int position()
- {
- if (_tail_closed) return Transport.END_OF_STREAM;
- return _inputBuffer.position();
- }
-
- @Override
- public ByteBuffer tail()
- {
- if (_tail_closed) throw new TransportException("tail closed");
- return _inputBuffer;
- }
-
- @Override
- public void process() throws TransportException
- {
- if (_tail_closed) throw new TransportException("tail closed");
-
- _inputBuffer.flip();
-
- try {
- unwrapInput();
- } catch (SSLException e) {
- _logger.log(Level.WARNING, e.getMessage());
- _inputBuffer.position(_inputBuffer.limit());
- _tail_closed = true;
- } finally {
- _inputBuffer.compact();
- }
- }
-
- @Override
- public void close_tail()
- {
- try {
- _underlyingInput.close_tail();
- } finally {
- _tail_closed = true;
- }
- }
-
- @Override
- public int pending()
- {
- try {
- wrapOutput();
- } catch (SSLException e) {
- _logger.log(Level.WARNING, e.getMessage());
- _head_closed = true;
- }
-
- _head.limit(_outputBuffer.position());
-
- if (_head_closed && _outputBuffer.position() == 0) {
- return Transport.END_OF_STREAM;
- }
-
- return _outputBuffer.position();
- }
-
- @Override
- public ByteBuffer head()
- {
- pending();
- return _head;
- }
-
- @Override
- public void pop(int bytes)
- {
- _outputBuffer.flip();
- _outputBuffer.position(bytes);
- _outputBuffer.compact();
- _head.position(0);
- _head.limit(_outputBuffer.position());
- }
-
- @Override
- public void close_head()
- {
- _underlyingOutput.close_head();
- int p = pending();
- if (p > 0) {
- pop(p);
- }
- }
-
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("SimpleSslTransportWrapper [sslEngine=").append(_sslEngine)
- .append(", inputBuffer=").append(_inputBuffer)
- .append(", outputBuffer=").append(_outputBuffer)
- .append(", decodedInputBuffer=").append(_decodedInputBuffer)
- .append(", cipherName=").append(_cipherName)
- .append(", protocolName=").append(_protocolName)
- .append("]");
- return builder.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java
deleted file mode 100644
index 583e3ca..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import org.apache.qpid.proton.ProtonUnsupportedOperationException;
-import org.apache.qpid.proton.engine.ProtonJSslDomain;
-import org.apache.qpid.proton.engine.SslDomain;
-import org.apache.qpid.proton.engine.SslPeerDetails;
-
-public class SslDomainImpl implements SslDomain, ProtonSslEngineProvider, ProtonJSslDomain
-{
- private Mode _mode;
- private VerifyMode _verifyMode = VerifyMode.ANONYMOUS_PEER;
- private String _certificateFile;
- private String _privateKeyFile;
- private String _privateKeyPassword;
- private String _trustedCaDb;
- private boolean _allowUnsecuredClient;
-
- private final SslEngineFacadeFactory _sslEngineFacadeFactory = new SslEngineFacadeFactory();
-
- /**
- * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
- * Client code outside this module should use {@link SslDomain.Factory#create()} instead.
- */
- @Deprecated public SslDomainImpl()
- {
- }
-
- @Override
- public void init(Mode mode)
- {
- _sslEngineFacadeFactory.resetCache();
- _mode = mode;
- }
-
- @Override
- public Mode getMode()
- {
- return _mode;
- }
-
- @Override
- public void setCredentials(String certificateFile, String privateKeyFile, String privateKeyPassword)
- {
- _certificateFile = certificateFile;
- _privateKeyFile = privateKeyFile;
- _privateKeyPassword = privateKeyPassword;
- _sslEngineFacadeFactory.resetCache();
- }
-
- @Override
- public void setTrustedCaDb(String certificateDb)
- {
- _trustedCaDb = certificateDb;
- _sslEngineFacadeFactory.resetCache();
- }
-
- @Override
- public String getTrustedCaDb()
- {
- return _trustedCaDb;
- }
-
- @Override
- public void setPeerAuthentication(VerifyMode verifyMode)
- {
- if(verifyMode == VerifyMode.VERIFY_PEER_NAME)
- {
- throw new ProtonUnsupportedOperationException();
- }
- _verifyMode = verifyMode;
- _sslEngineFacadeFactory.resetCache();
- }
-
- @Override
- public VerifyMode getPeerAuthentication()
- {
- return _verifyMode;
- }
-
- @Override
- public String getPrivateKeyFile()
- {
- return _privateKeyFile;
- }
-
- @Override
- public String getPrivateKeyPassword()
- {
- return _privateKeyPassword;
- }
-
- @Override
- public String getCertificateFile()
- {
- return _certificateFile;
- }
-
- @Override
- public void allowUnsecuredClient(boolean allowUnsecured)
- {
- _allowUnsecuredClient = allowUnsecured;
- _sslEngineFacadeFactory.resetCache();
- }
-
- @Override
- public boolean allowUnsecuredClient()
- {
- return _allowUnsecuredClient;
- }
-
- @Override
- public ProtonSslEngine createSslEngine(SslPeerDetails peerDetails)
- {
- return _sslEngineFacadeFactory.createProtonSslEngine(this, peerDetails);
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("SslDomainImpl [_mode=").append(_mode)
- .append(", _verifyMode=").append(_verifyMode)
- .append(", _certificateFile=").append(_certificateFile)
- .append(", _privateKeyFile=").append(_privateKeyFile)
- .append(", _trustedCaDb=").append(_trustedCaDb)
- .append(", _allowUnsecuredClient=").append(_allowUnsecuredClient)
- .append("]");
- return builder.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslEngineFacadeFactory.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslEngineFacadeFactory.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslEngineFacadeFactory.java
deleted file mode 100644
index f6346aa..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslEngineFacadeFactory.java
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import java.io.Closeable;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.KeyManagementException;
-import java.security.KeyPair;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.Security;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.qpid.proton.engine.SslDomain;
-import org.apache.qpid.proton.engine.SslPeerDetails;
-import org.apache.qpid.proton.engine.TransportException;
-
-public class SslEngineFacadeFactory
-{
- private static final Logger _logger = Logger.getLogger(SslEngineFacadeFactory.class.getName());
-
- /**
- * The protocol name used to create an {@link SSLContext}, taken from Java's list of
- * standard names at http://docs.oracle.com/javase/6/docs/technotes/guides/security/StandardNames.html
- *
- * TODO allow the protocol name to be overridden somehow
- */
- private static final String TLS_PROTOCOL = "TLS";
-
- // BouncyCastle Reflection Helpers
- private static final Constructor<?> pemParserCons;
- private static final Method pemReadMethod;
-
- private static final Constructor<?> JcaPEMKeyConverterCons;
- private static final Class<?> PEMKeyPairClass;
- private static final Method getKeyPairMethod;
- private static final Method getPrivateKeyMethod;
-
- private static final Class<?> PEMEncryptedKeyPairClass;
- private static final Method decryptKeyPairMethod;
-
- private static final Constructor<?> JcePEMDecryptorProviderBuilderCons;
- private static final Method builderMethod;
-
- private static final Class<?> PrivateKeyInfoClass;
- private static final Exception bouncyCastleSetupException;
-
- static
- {
- // Setup BouncyCastle Reflection artifacts
- Constructor<?> pemParserConsResult = null;
- Method pemReadMethodResult = null;
- Constructor<?> JcaPEMKeyConverterConsResult = null;
- Class<?> PEMKeyPairClassResult = null;
- Method getKeyPairMethodResult = null;
- Method getPrivateKeyMethodResult = null;
- Class<?> PEMEncryptedKeyPairClassResult = null;
- Method decryptKeyPairMethodResult = null;
- Constructor<?> JcePEMDecryptorProviderBuilderConsResult = null;
- Method builderMethodResult = null;
- Class<?> PrivateKeyInfoClassResult = null;
- Exception bouncyCastleSetupExceptionResult = null;
-
- try
- {
- final Class<?> pemParserClass = Class.forName("org.bouncycastle.openssl.PEMParser");
- pemParserConsResult = pemParserClass.getConstructor(Reader.class);
- pemReadMethodResult = pemParserClass.getMethod("readObject");
-
- final Class<?> jcaPEMKeyConverterClass = Class.forName("org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter");
- JcaPEMKeyConverterConsResult = jcaPEMKeyConverterClass.getConstructor();
- PEMKeyPairClassResult = Class.forName("org.bouncycastle.openssl.PEMKeyPair");
- getKeyPairMethodResult = jcaPEMKeyConverterClass.getMethod("getKeyPair", PEMKeyPairClassResult);
-
- final Class<?> PEMDecrypterProvider = Class.forName("org.bouncycastle.openssl.PEMDecryptorProvider");
-
- PEMEncryptedKeyPairClassResult = Class.forName("org.bouncycastle.openssl.PEMEncryptedKeyPair");
- decryptKeyPairMethodResult = PEMEncryptedKeyPairClassResult.getMethod("decryptKeyPair", PEMDecrypterProvider);
-
- final Class<?> jcePEMDecryptorProviderBuilderClass = Class.forName(
- "org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder");
- JcePEMDecryptorProviderBuilderConsResult = jcePEMDecryptorProviderBuilderClass.getConstructor();
- builderMethodResult = jcePEMDecryptorProviderBuilderClass.getMethod("build", char[].class);
-
- PrivateKeyInfoClassResult = Class.forName("org.bouncycastle.asn1.pkcs.PrivateKeyInfo");
- getPrivateKeyMethodResult = jcaPEMKeyConverterClass.getMethod("getPrivateKey", PrivateKeyInfoClassResult);
-
- // Try loading BC as a provider
- Class<?> klass = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
- Provider provider = (Provider) klass.getConstructor().newInstance();
- Security.addProvider(provider);
- }
- catch (Exception e)
- {
- bouncyCastleSetupExceptionResult = e;
- }
- finally {
- pemParserCons = pemParserConsResult;
- pemReadMethod = pemReadMethodResult;
- JcaPEMKeyConverterCons = JcaPEMKeyConverterConsResult;
- PEMKeyPairClass = PEMKeyPairClassResult;
- getKeyPairMethod = getKeyPairMethodResult;
- getPrivateKeyMethod = getPrivateKeyMethodResult;
- PEMEncryptedKeyPairClass = PEMEncryptedKeyPairClassResult;
- decryptKeyPairMethod = decryptKeyPairMethodResult;
- JcePEMDecryptorProviderBuilderCons = JcePEMDecryptorProviderBuilderConsResult;
- builderMethod = builderMethodResult;
- PrivateKeyInfoClass = PrivateKeyInfoClassResult;
- bouncyCastleSetupException = bouncyCastleSetupExceptionResult;
- }
- }
-
- SslEngineFacadeFactory()
- {
- }
-
- /**
- * This is a list of all anonymous cipher suites supported by Java 6, excluding those that
- * use MD5. These are all supported by both Oracle's and IBM's Java 6 implementation.
- */
- private static final List<String> ANONYMOUS_CIPHER_SUITES = Arrays.asList(
- "TLS_DH_anon_WITH_AES_128_CBC_SHA",
- "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",
- "SSL_DH_anon_WITH_DES_CBC_SHA",
- "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA");
-
- /** lazily initialized */
- private SSLContext _sslContext;
-
-
- /**
- * Returns a {@link ProtonSslEngine}. May cache the domain's settings so callers should invoke
- * {@link #resetCache()} if the domain changes.
- *
- * @param peerDetails may be used to return an engine that supports SSL resume.
- */
- public ProtonSslEngine createProtonSslEngine(SslDomain domain, SslPeerDetails peerDetails)
- {
- SSLEngine engine = createAndInitialiseSslEngine(domain, peerDetails);
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine("Created SSL engine: " + engineToString(engine));
- }
- return new DefaultSslEngineFacade(engine);
- }
-
-
- /**
- * Guarantees that no cached settings are used in subsequent calls to
- * {@link #createProtonSslEngine(SslDomain, SslPeerDetails)}.
- */
- public void resetCache()
- {
- _sslContext = null;
- }
-
-
- private SSLEngine createAndInitialiseSslEngine(SslDomain domain, SslPeerDetails peerDetails)
- {
- SslDomain.Mode mode = domain.getMode();
-
- SSLContext sslContext = getOrCreateSslContext(domain);
- SSLEngine sslEngine = createSslEngine(sslContext, peerDetails);
-
- if (domain.getPeerAuthentication() == SslDomain.VerifyMode.ANONYMOUS_PEER)
- {
- addAnonymousCipherSuites(sslEngine);
- }
- else
- {
- if (mode == SslDomain.Mode.SERVER)
- {
- sslEngine.setNeedClientAuth(true);
- }
- }
-
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.log(Level.FINE, mode + " Enabled cipher suites " + Arrays.asList(sslEngine.getEnabledCipherSuites()));
- }
-
- boolean useClientMode = mode == SslDomain.Mode.CLIENT ? true : false;
- sslEngine.setUseClientMode(useClientMode);
-
- removeSSLv3Support(sslEngine);
-
- return sslEngine;
- }
-
- private static final String SSLV3_PROTOCOL = "SSLv3";
-
- private static void removeSSLv3Support(final SSLEngine engine)
- {
- List<String> enabledProtocols = Arrays.asList(engine.getEnabledProtocols());
- if(enabledProtocols.contains(SSLV3_PROTOCOL))
- {
- List<String> allowedProtocols = new ArrayList<String>(enabledProtocols);
- allowedProtocols.remove(SSLV3_PROTOCOL);
- engine.setEnabledProtocols(allowedProtocols.toArray(new String[allowedProtocols.size()]));
- }
- }
-
- /**
- * @param sslPeerDetails is allowed to be null. A non-null value is used to hint that SSL resumption
- * should be attempted
- */
- private SSLEngine createSslEngine(SSLContext sslContext, SslPeerDetails sslPeerDetails)
- {
- final SSLEngine sslEngine;
- if(sslPeerDetails == null)
- {
- sslEngine = sslContext.createSSLEngine();
- }
- else
- {
- sslEngine = sslContext.createSSLEngine(sslPeerDetails.getHostname(), sslPeerDetails.getPort());
- }
- return sslEngine;
- }
-
- private SSLContext getOrCreateSslContext(SslDomain sslDomain)
- {
- if(_sslContext == null)
- {
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine("lazily creating new SSLContext using domain " + sslDomain);
- }
-
- final char[] dummyPassword = "unused-passphrase".toCharArray(); // Dummy password required by KeyStore and KeyManagerFactory, but never referred to again
-
- try
- {
- SSLContext sslContext = SSLContext.getInstance(TLS_PROTOCOL);
- KeyStore ksKeys = createKeyStoreFrom(sslDomain, dummyPassword);
-
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- kmf.init(ksKeys, dummyPassword);
-
- final TrustManager[] trustManagers;
- if (sslDomain.getPeerAuthentication() == SslDomain.VerifyMode.ANONYMOUS_PEER)
- {
- trustManagers = new TrustManager[] { new AlwaysTrustingTrustManager() };
- }
- else
- {
- TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- tmf.init(ksKeys);
- trustManagers = tmf.getTrustManagers();
- }
-
- sslContext.init(kmf.getKeyManagers(), trustManagers, null);
- _sslContext = sslContext;
- }
- catch (NoSuchAlgorithmException e)
- {
- throw new TransportException("Unexpected exception creating SSLContext", e);
- }
- catch (KeyStoreException e)
- {
- throw new TransportException("Unexpected exception creating SSLContext", e);
- }
- catch (UnrecoverableKeyException e)
- {
- throw new TransportException("Unexpected exception creating SSLContext", e);
- }
- catch (KeyManagementException e)
- {
- throw new TransportException("Unexpected exception creating SSLContext", e);
- }
- }
- return _sslContext;
- }
-
- private KeyStore createKeyStoreFrom(SslDomain sslDomain, char[] dummyPassword)
- {
- try
- {
- KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
- keystore.load(null, null);
-
- if (sslDomain.getTrustedCaDb() != null)
- {
- String caCertAlias = "cacert";
-
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.log(Level.FINE, "_sslParams.getTrustedCaDb() : " + sslDomain.getTrustedCaDb());
- }
- Certificate trustedCaCert = readCertificate(sslDomain.getTrustedCaDb());
- keystore.setCertificateEntry(caCertAlias, trustedCaCert);
- }
-
- if (sslDomain.getCertificateFile() != null
- && sslDomain.getPrivateKeyFile() != null)
- {
- String clientPrivateKeyAlias = "clientPrivateKey";
-
- Certificate clientCertificate = (Certificate) readCertificate(sslDomain.getCertificateFile());
- PrivateKey clientPrivateKey = readPrivateKey(sslDomain.getPrivateKeyFile(), sslDomain.getPrivateKeyPassword());
-
- keystore.setKeyEntry(clientPrivateKeyAlias, clientPrivateKey,
- dummyPassword, new Certificate[] { clientCertificate });
- }
-
- return keystore;
- }
- catch (KeyStoreException e)
- {
- throw new TransportException("Unexpected exception creating keystore", e);
- }
- catch (NoSuchAlgorithmException e)
- {
- throw new TransportException("Unexpected exception creating keystore", e);
- }
- catch (CertificateException e)
- {
- throw new TransportException("Unexpected exception creating keystore", e);
- }
- catch (IOException e)
- {
- throw new TransportException("Unexpected exception creating keystore", e);
- }
- }
-
- private void addAnonymousCipherSuites(SSLEngine sslEngine)
- {
- List<String> supportedSuites = Arrays.asList(sslEngine.getSupportedCipherSuites());
- List<String> currentEnabledSuites = Arrays.asList(sslEngine.getEnabledCipherSuites());
-
- List<String> enabledSuites = buildEnabledSuitesIncludingAnonymous(ANONYMOUS_CIPHER_SUITES, supportedSuites, currentEnabledSuites);
- sslEngine.setEnabledCipherSuites(enabledSuites.toArray(new String[0]));
- }
-
- private List<String> buildEnabledSuitesIncludingAnonymous(
- List<String> anonymousCipherSuites, List<String> supportedSuites, List<String> currentEnabled)
- {
- List<String> newEnabled = new ArrayList<String>(currentEnabled);
-
- int addedAnonymousCipherSuites = 0;
- for (String anonymousCipherSuiteName : anonymousCipherSuites)
- {
- if (supportedSuites.contains(anonymousCipherSuiteName))
- {
- newEnabled.add(anonymousCipherSuiteName);
- addedAnonymousCipherSuites++;
- }
- }
-
- if (addedAnonymousCipherSuites == 0)
- {
- throw new TransportException
- ("None of " + anonymousCipherSuites
- + " anonymous cipher suites are within the supported list "
- + supportedSuites);
- }
-
- if(_logger.isLoggable(Level.FINE))
- {
- _logger.fine("There are now " + newEnabled.size()
- + " cipher suites enabled (previously " + currentEnabled.size()
- + "), including " + addedAnonymousCipherSuites + " out of the "
- + anonymousCipherSuites.size() + " requested anonymous ones." );
- }
-
- return newEnabled;
- }
-
- private String engineToString(SSLEngine engine)
- {
- return new StringBuilder("[ " )
- .append(engine)
- .append(", needClientAuth=").append(engine.getNeedClientAuth())
- .append(", useClientMode=").append(engine.getUseClientMode())
- .append(", peerHost=").append(engine.getPeerHost())
- .append(", peerPort=").append(engine.getPeerPort())
- .append(" ]").toString();
- }
-
- Certificate readCertificate(String pemFile)
- {
- InputStream is = null;
-
- try
- {
- CertificateFactory cFactory = CertificateFactory.getInstance("X.509");
- is = new FileInputStream(pemFile);
- return cFactory.generateCertificate(is);
- }
- catch (CertificateException ce)
- {
- String msg = "Failed to load certificate [" + pemFile + "]";
- _logger.log(Level.SEVERE, msg, ce);
- throw new TransportException(msg, ce);
- }
- catch (FileNotFoundException e)
- {
- String msg = "Certificate file not found [" + pemFile + "]";
- _logger.log(Level.SEVERE, msg);
- throw new TransportException(msg, e);
- }
- finally
- {
- closeSafely(is);
- }
- }
-
- PrivateKey readPrivateKey(String pemFile, String password)
- {
- if (bouncyCastleSetupException != null)
- {
- throw new TransportException("BouncyCastle failed to load", bouncyCastleSetupException);
- }
-
- final Object pemObject = readPemObject(pemFile);
- PrivateKey privateKey = null;
-
- try
- {
- Object keyConverter = JcaPEMKeyConverterCons.newInstance();
- setProvider(keyConverter, "BC");
-
- if (PEMEncryptedKeyPairClass.isInstance(pemObject))
- {
- Object decryptorBuilder = JcePEMDecryptorProviderBuilderCons.newInstance();
-
- // Build a PEMDecryptProvider
- Object decryptProvider = builderMethod.invoke(decryptorBuilder, password.toCharArray());
-
- Object decryptedKeyPair = decryptKeyPairMethod.invoke(pemObject, decryptProvider);
- KeyPair keyPair = (KeyPair) getKeyPairMethod.invoke(keyConverter, decryptedKeyPair);
-
- privateKey = keyPair.getPrivate();
- }
- else if (PEMKeyPairClass.isInstance(pemObject))
- {
- // It's a KeyPair but not encrypted.
- KeyPair keyPair = (KeyPair) getKeyPairMethod.invoke(keyConverter, pemObject);
- privateKey = keyPair.getPrivate();
- }
- else if (PrivateKeyInfoClass.isInstance(pemObject))
- {
- // It's an unencrypted private key
- privateKey = (PrivateKey) getPrivateKeyMethod.invoke(keyConverter, pemObject);
- }
- else
- {
- final String msg = "Unable to load PrivateKey, Unpexected Object [" + pemObject.getClass().getName()
- + "]";
- _logger.log(Level.SEVERE, msg);
- throw new TransportException(msg);
- }
- }
- catch (InstantiationException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | NoSuchMethodException | SecurityException e)
- {
- final String msg = "Failed to process key file [" + pemFile + "] - " + e.getMessage();
- throw new TransportException(msg, e);
- }
-
- return privateKey;
- }
-
- private Object readPemObject(String pemFile)
- {
- Reader reader = null;
- Object pemParser = null;
- Object pemObject = null;
-
- try
- {
- reader = new FileReader(pemFile);
- pemParser = pemParserCons.newInstance(reader); // = new PEMParser(reader);
- pemObject = pemReadMethod.invoke(pemParser); // = pemParser.readObject();
- }
- catch (IOException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e)
- {
- _logger.log(Level.SEVERE, "Unable to read PEM object. Perhaps you need the unlimited strength libraries in <java-home>/jre/lib/security/ ?", e);
- throw new TransportException("Unable to read PEM object from file " + pemFile, e);
- }
- finally
- {
- closeSafely(reader);
- }
-
- return pemObject;
- }
-
- private void setProvider(Object obj, String provider) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException
- {
- final Class<?> aClz = obj.getClass();
- final Method setProvider = aClz.getMethod("setProvider", String.class);
- setProvider.invoke(obj, provider);
- }
-
- private void closeSafely(Closeable c)
- {
- if (c != null)
- {
- try
- {
- c.close();
- }
- catch (IOException e)
- {
- // Swallow
- }
- }
- }
-
- private static final class AlwaysTrustingTrustManager implements X509TrustManager
- {
- @Override
- public X509Certificate[] getAcceptedIssuers()
- {
- return null;
- }
-
- @Override
- public void checkServerTrusted(X509Certificate[] arg0, String arg1)
- throws CertificateException
- {
- // Do not check certificate
- }
-
- @Override
- public void checkClientTrusted(X509Certificate[] arg0, String arg1)
- throws CertificateException
- {
- // Do not check certificate
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapper.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapper.java
deleted file mode 100644
index c678343..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslHandshakeSniffingTransportWrapper.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import org.apache.qpid.proton.engine.impl.HandshakeSniffingTransportWrapper;
-import org.apache.qpid.proton.engine.impl.TransportWrapper;
-
-
-/**
- * SslHandshakeSniffingTransportWrapper
- *
- */
-
-public class SslHandshakeSniffingTransportWrapper extends HandshakeSniffingTransportWrapper<SslTransportWrapper, TransportWrapper>
- implements SslTransportWrapper
-{
-
- SslHandshakeSniffingTransportWrapper(SslTransportWrapper ssl, TransportWrapper plain) {
- super(ssl, plain);
- }
-
- @Override
- public String getCipherName()
- {
- if(isSecureWrapperSelected())
- {
- return _wrapper1.getCipherName();
- }
- else
- {
- return null;
- }
- }
-
-
- @Override
- public String getProtocolName()
- {
- if (isSecureWrapperSelected())
- {
- return _wrapper1.getProtocolName();
- }
- else
- {
- return null;
- }
- }
-
- private boolean isSecureWrapperSelected()
- {
- return _selectedTransportWrapper == _wrapper1;
- }
-
- protected int bufferSize() {
- // minimum length for determination
- return 5;
- }
-
- protected void makeDetermination(byte[] bytesInput)
- {
- boolean isSecure = checkForSslHandshake(bytesInput);
- if (isSecure)
- {
- _selectedTransportWrapper = _wrapper1;
- }
- else
- {
- _selectedTransportWrapper = _wrapper2;
- }
- }
-
- // TODO perhaps the sniffer should save up the bytes from each
- // input call until it has sufficient bytes to make the determination
- // and only then pass them to the secure or plain wrapped transport?
- private boolean checkForSslHandshake(byte[] buf)
- {
- if (buf.length >= bufferSize())
- {
- /*
- * SSLv2 Client Hello format
- * http://www.mozilla.org/projects/security/pki/nss/ssl/draft02.html
- *
- * Bytes 0-1: RECORD-LENGTH Byte 2: MSG-CLIENT-HELLO (1) Byte 3:
- * CLIENT-VERSION-MSB Byte 4: CLIENT-VERSION-LSB
- *
- * Allowed versions: 2.0 - SSLv2 3.0 - SSLv3 3.1 - TLS 1.0 3.2 - TLS
- * 1.1 3.3 - TLS 1.2
- *
- * The version sent in the Client-Hello is the latest version
- * supported by the client. NSS may send version 3.x in an SSLv2
- * header for maximum compatibility.
- */
- boolean isSSL2Handshake = buf[2] == 1 && // MSG-CLIENT-HELLO
- ((buf[3] == 3 && buf[4] <= 3) || // SSL 3.0 & TLS 1.0-1.2
- // (v3.1-3.3)
- (buf[3] == 2 && buf[4] == 0)); // SSL 2
-
- /*
- * SSLv3/TLS Client Hello format RFC 2246
- *
- * Byte 0: ContentType (handshake - 22) Bytes 1-2: ProtocolVersion
- * {major, minor}
- *
- * Allowed versions: 3.0 - SSLv3 3.1 - TLS 1.0 3.2 - TLS 1.1 3.3 -
- * TLS 1.2
- */
- boolean isSSL3Handshake = buf[0] == 22 && // handshake
- (buf[1] == 3 && buf[2] <= 3); // SSL 3.0 & TLS 1.0-1.2
- // (v3.1-3.3)
-
- return (isSSL2Handshake || isSSL3Handshake);
- }
- else
- {
- throw new IllegalArgumentException("Too few bytes (" + buf.length + ") to make SSL/plain determination.");
- }
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[06/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/reactor/impl/LeakTestReactor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/reactor/impl/LeakTestReactor.java b/proton-j/src/test/java/org/apache/qpid/proton/reactor/impl/LeakTestReactor.java
deleted file mode 100644
index d06ec0a..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/reactor/impl/LeakTestReactor.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.reactor.impl;
-
-import java.io.IOException;
-import java.nio.channels.Pipe;
-import java.nio.channels.Pipe.SinkChannel;
-import java.nio.channels.Pipe.SourceChannel;
-import java.nio.channels.Selector;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Map.Entry;
-
-import junit.framework.AssertionFailedError;
-
-// Extends the Reactor to substitute a unit-test implementation of the
-// IO class. This detects, and reports, situations where the reactor code
-// fails to close one of the Java I/O related resources that it has created.
-public class LeakTestReactor extends ReactorImpl {
-
- private static class TestIO implements IO {
-
- private final HashMap<Object, Exception> resources = new HashMap<Object, Exception>();
-
- @Override
- public Pipe pipe() throws IOException {
- Pipe pipe = Pipe.open();
- resources.put(pipe.source(), new Exception());
- resources.put(pipe.sink(), new Exception());
- return pipe;
- }
-
- @Override
- public Selector selector() throws IOException {
- Selector selector = Selector.open();
- resources.put(selector, new Exception());
- return selector;
-
- }
-
- @Override
- public ServerSocketChannel serverSocketChannel() throws IOException {
- ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
- resources.put(serverSocketChannel, new Exception());
- return serverSocketChannel;
- }
-
- @Override
- public SocketChannel socketChannel() throws IOException {
- SocketChannel socketChannel = SocketChannel.open();
- resources.put(socketChannel, new Exception());
- return socketChannel;
- }
-
- private boolean isOpen(Object resource) {
- if (resource instanceof SourceChannel) {
- return ((SourceChannel)resource).isOpen();
- } else if (resource instanceof SinkChannel) {
- return ((SinkChannel)resource).isOpen();
- } else if (resource instanceof Selector) {
- return ((Selector)resource).isOpen();
- } else if (resource instanceof ServerSocketChannel) {
- return ((ServerSocketChannel)resource).isOpen();
- } else if (resource instanceof SocketChannel) {
- return ((SocketChannel)resource).isOpen();
- } else {
- throw new AssertionFailedError("Don't know how to check if this type is open: " + resource.getClass());
- }
- }
-
- protected void assertNoLeaks() throws AssertionFailedError {
- boolean fail = false;
- for (Entry<Object, Exception> entry : resources.entrySet()) {
- if (isOpen(entry.getKey())) {
- System.out.println("Leaked an instance of '" + entry.getKey() + "' from:");
- entry.getValue().printStackTrace(System.out);
- fail = true;
- }
- }
- if (fail) {
- throw new AssertionFailedError("Resources leaked");
- }
- resources.clear();
- }
- }
-
- private final TestIO testIO;
-
- public LeakTestReactor() throws IOException {
- super(new TestIO());
- testIO = (TestIO)getIO();
- }
-
- public void assertNoLeaks() throws AssertionFailedError {
- testIO.assertNoLeaks();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/BinaryFormatter.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/BinaryFormatter.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/BinaryFormatter.java
deleted file mode 100644
index 4f87626..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/BinaryFormatter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-public class BinaryFormatter
-{
-
- public String format(byte[] binaryData)
- {
- StringBuilder stringBuilder = new StringBuilder();
- for(int i = 0; i < binaryData.length; i++)
- {
- byte theByte = binaryData[i];
- String formattedByte = formatByte(theByte);
- stringBuilder.append(formattedByte);
- }
- return stringBuilder.toString();
- }
-
- private String formatByte(byte theByte)
- {
- final String retVal;
- if(Character.isLetterOrDigit(theByte))
- {
- retVal = String.format("[ %c ]", theByte);
- }
- else
- {
- retVal = String.format("[x%02x]", theByte);
- }
- return retVal;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/BinaryFormatterTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/BinaryFormatterTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/BinaryFormatterTest.java
deleted file mode 100644
index 6e4567b..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/BinaryFormatterTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class BinaryFormatterTest
-{
-
- private BinaryFormatter _binaryFormatter = new BinaryFormatter();
-
- @Test
- public void testSingleCharacter()
- {
- assertEquals("[ A ]", _binaryFormatter.format("A".getBytes()));
- }
-
- @Test
- public void testSingleSmallNonCharacter()
- {
- byte[] bytes = new byte[] { (byte)0x1 };
- assertEquals("[x01]", _binaryFormatter.format(bytes));
- }
-
- @Test
- public void testSingleLargeNonCharacter()
- {
- int numberToUse = 0xa2;
- byte byteToUse = (byte)numberToUse;
- byte[] bytes = new byte[] { byteToUse };
- assertEquals("[xa2]", _binaryFormatter.format(bytes));
- }
-
- @Test
- public void testComplex()
- {
- byte[] binaryData = new byte[4];
- System.arraycopy("ABC".getBytes(), 0, binaryData, 0, 3);
- binaryData[3] = (byte)0xff;
-
- String formattedString = _binaryFormatter.format(binaryData);
- String expected = "[ A ][ B ][ C ][xff]";
- assertEquals(expected, formattedString);
- }
-
- public void testFormatSubArray()
- {
- fail("TODO");
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/DefaultDeliveryStateTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/DefaultDeliveryStateTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/DefaultDeliveryStateTest.java
deleted file mode 100644
index 198123d..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/DefaultDeliveryStateTest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static java.util.EnumSet.of;
-import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
-import static org.apache.qpid.proton.engine.EndpointState.CLOSED;
-import static org.apache.qpid.proton.engine.EndpointState.UNINITIALIZED;
-import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.messaging.Accepted;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.amqp.messaging.Modified;
-import org.apache.qpid.proton.amqp.messaging.Released;
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.message.Message;
-import org.junit.Test;
-
-public class DefaultDeliveryStateTest extends EngineTestBase
-{
- private static final Logger LOGGER = Logger.getLogger(DefaultDeliveryStateTest.class.getName());
-
- private static final int BUFFER_SIZE = 4096;
-
- private final String _sourceAddress = getServer().containerId + "-link1-source";
-
- @Test
- public void testDefaultDeliveryState() throws Exception
- {
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
- getClient().session.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().session, ACTIVE, ACTIVE);
-
- LOGGER.fine(bold("======== About to create reciever"));
-
- getClient().source = new Source();
- getClient().source.setAddress(_sourceAddress);
-
- getClient().target = new Target();
- getClient().target.setAddress(null);
-
- getClient().receiver = getClient().session.receiver("link1");
- getClient().receiver.setTarget(getClient().target);
- getClient().receiver.setSource(getClient().source);
-
- getClient().receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
- getClient().receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
-
- assertEndpointState(getClient().receiver, UNINITIALIZED, UNINITIALIZED);
-
- getClient().receiver.open();
- assertEndpointState(getClient().receiver, ACTIVE, UNINITIALIZED);
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== About to set up implicitly created sender"));
-
- getServer().sender = (Sender) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
-
- getServer().sender.setReceiverSettleMode(getServer().sender.getRemoteReceiverSettleMode());
- getServer().sender.setSenderSettleMode(getServer().sender.getRemoteSenderSettleMode());
-
- org.apache.qpid.proton.amqp.transport.Source serverRemoteSource = getServer().sender.getRemoteSource();
- getServer().sender.setSource(serverRemoteSource);
-
- assertEndpointState(getServer().sender, UNINITIALIZED, ACTIVE);
- getServer().sender.open();
-
- assertEndpointState(getServer().sender, ACTIVE, ACTIVE);
-
- pumpServerToClient();
-
- assertEndpointState(getClient().receiver, ACTIVE, ACTIVE);
-
- int messagCount = 3;
- getClient().receiver.flow(messagCount);
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== About to create messages and send to the client"));
-
- Delivery serverDelivery1 = sendMessageToClient("delivery1", "Msg1");
- Delivery serverDelivery2 = sendMessageToClient("delivery2", "Msg2");
- Delivery serverDelivery3 = sendMessageToClient("delivery3", "Msg3");
-
- pumpServerToClient();
-
- assertNull(serverDelivery1.getLocalState());
- assertNull(serverDelivery2.getLocalState());
- assertNull(serverDelivery3.getLocalState());
-
- assertNull(serverDelivery1.getRemoteState());
- assertNull(serverDelivery2.getRemoteState());
- assertNull(serverDelivery3.getRemoteState());
-
- LOGGER.fine(bold("======== About to process the messages on the client"));
-
- Delivery clientDelivery1 = receiveMessageFromServer("delivery1", "Msg1");
- Delivery clientDelivery2 = receiveMessageFromServer("delivery2", "Msg2");
- Delivery clientDelivery3 = receiveMessageFromServer("delivery3", "Msg3");
-
- // Give them some default state
- clientDelivery1.setDefaultDeliveryState(Released.getInstance());
- clientDelivery2.setDefaultDeliveryState(Released.getInstance());
- clientDelivery3.setDefaultDeliveryState(Released.getInstance());
-
- assertEquals(Released.getInstance(), clientDelivery1.getDefaultDeliveryState());
- assertEquals(Released.getInstance(), clientDelivery2.getDefaultDeliveryState());
- assertEquals(Released.getInstance(), clientDelivery3.getDefaultDeliveryState());
-
- // Check the default state doesn't influence the actual state
- assertNull(clientDelivery1.getLocalState());
- assertNull(clientDelivery2.getLocalState());
- assertNull(clientDelivery3.getLocalState());
-
- assertNull(clientDelivery1.getRemoteState());
- assertNull(clientDelivery2.getRemoteState());
- assertNull(clientDelivery3.getRemoteState());
-
- // Accept one for real, update default on another, leave last untouched
- clientDelivery1.disposition(Accepted.getInstance());
- clientDelivery2.setDefaultDeliveryState(new Modified());
-
- // Confirm default and actual states have or have not changed as expected
- assertEquals(Released.getInstance(), clientDelivery1.getDefaultDeliveryState());
- assertTrue(clientDelivery2.getDefaultDeliveryState() instanceof Modified);
- assertEquals(Released.getInstance(), clientDelivery3.getDefaultDeliveryState());
-
- assertEquals(Accepted.getInstance(), clientDelivery1.getLocalState());
- assertNull(clientDelivery2.getLocalState());
- assertNull(clientDelivery3.getLocalState());
-
- // Verify the server gets intended state changes
- pumpClientToServer();
-
- assertEquals(Accepted.getInstance(), serverDelivery1.getRemoteState());
- assertNull(serverDelivery2.getRemoteState());
- assertNull(serverDelivery3.getRemoteState());
-
- // Confirm server sees the default states for second and third
- // messages when they get settled during link free
- getClient().receiver.close();
- assertEndpointState(getClient().receiver, CLOSED, ACTIVE);
-
- pumpClientToServer();
-
- assertEndpointState(getServer().sender, ACTIVE, CLOSED);
- getServer().sender.close();
-
- assertEndpointState(getServer().sender, CLOSED, CLOSED);
-
- pumpServerToClient();
-
- getClient().receiver.free();
-
- assertEndpointState(getClient().receiver, CLOSED, CLOSED);
-
- pumpClientToServer();
-
- assertEquals(Accepted.getInstance(), serverDelivery1.getRemoteState());
- assertTrue(serverDelivery2.getRemoteState() instanceof Modified);
- assertEquals(Released.getInstance(), serverDelivery3.getRemoteState());
- }
-
- private Delivery receiveMessageFromServer(String deliveryTag, String messageContent)
- {
- Delivery delivery = getClient().connection.getWorkHead();
-
- assertTrue(Arrays.equals(deliveryTag.getBytes(StandardCharsets.UTF_8), delivery.getTag()));
- assertEquals("The received delivery should be on our receiver",
- getClient().receiver, delivery.getLink());
-
- assertNull(delivery.getLocalState());
- assertNull(delivery.getRemoteState());
-
- assertFalse(delivery.isPartial());
- assertTrue(delivery.isReadable());
-
- byte[] received = new byte[BUFFER_SIZE];
- int len = getClient().receiver.recv(received, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Message m = Proton.message();
- m.decode(received, 0, len);
-
- Object messageBody = ((AmqpValue)m.getBody()).getValue();
- assertEquals("Unexpected message content", messageContent, messageBody);
-
- boolean receiverAdvanced = getClient().receiver.advance();
- assertTrue("receiver has not advanced", receiverAdvanced);
-
- return delivery;
- }
-
- private Delivery sendMessageToClient(String deliveryTag, String messageBody)
- {
- byte[] tag = deliveryTag.getBytes(StandardCharsets.UTF_8);
-
- Message m = Proton.message();
- m.setBody(new AmqpValue(messageBody));
-
- byte[] encoded = new byte[BUFFER_SIZE];
- int len = m.encode(encoded, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Delivery serverDelivery = getServer().sender.delivery(tag);
- int sent = getServer().sender.send(encoded, 0, len);
-
- assertEquals("sender unable to send all data at once as assumed for simplicity", len, sent);
-
- boolean senderAdvanced = getServer().sender.advance();
- assertTrue("sender has not advanced", senderAdvanced);
-
- return serverDelivery;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/DeliveryTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/DeliveryTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/DeliveryTest.java
deleted file mode 100644
index 69db7c1..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/DeliveryTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static java.util.EnumSet.of;
-import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
-import static org.apache.qpid.proton.engine.EndpointState.UNINITIALIZED;
-import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.message.Message;
-import org.junit.Test;
-
-public class DeliveryTest extends EngineTestBase
-{
- private static final Logger LOGGER = Logger.getLogger(DeliveryTest.class.getName());
-
- private static final int BUFFER_SIZE = 4096;
-
- private final String _sourceAddress = getServer().containerId + "-link1-source";
-
- @Test
- public void testMessageFormat() throws Exception
- {
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
- getClient().session.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().session, ACTIVE, ACTIVE);
-
-
- LOGGER.fine(bold("======== About to create reciever"));
-
- getClient().source = new Source();
- getClient().source.setAddress(_sourceAddress);
-
- getClient().target = new Target();
- getClient().target.setAddress(null);
-
- getClient().receiver = getClient().session.receiver("link1");
- getClient().receiver.setTarget(getClient().target);
- getClient().receiver.setSource(getClient().source);
-
- getClient().receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
- getClient().receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
-
- assertEndpointState(getClient().receiver, UNINITIALIZED, UNINITIALIZED);
-
- getClient().receiver.open();
- assertEndpointState(getClient().receiver, ACTIVE, UNINITIALIZED);
-
- pumpClientToServer();
-
-
- LOGGER.fine(bold("======== About to set up implicitly created sender"));
-
- getServer().sender = (Sender) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
-
- getServer().sender.setReceiverSettleMode(getServer().sender.getRemoteReceiverSettleMode());
- getServer().sender.setSenderSettleMode(getServer().sender.getRemoteSenderSettleMode());
-
- org.apache.qpid.proton.amqp.transport.Source serverRemoteSource = getServer().sender.getRemoteSource();
- getServer().sender.setSource(serverRemoteSource);
-
- assertEndpointState(getServer().sender, UNINITIALIZED, ACTIVE);
- getServer().sender.open();
-
- assertEndpointState(getServer().sender, ACTIVE, ACTIVE);
-
- pumpServerToClient();
-
- assertEndpointState(getClient().receiver, ACTIVE, ACTIVE);
-
- int messagCount = 4;
- getClient().receiver.flow(messagCount);
-
- pumpClientToServer();
-
-
- LOGGER.fine(bold("======== About to create messages and send to the client"));
-
- sendMessageToClient("delivery1", "Msg1", null); // Don't set it, so it should be defaulted
- sendMessageToClient("delivery2", "Msg2", 0); // Explicitly set it to the default
- sendMessageToClient("delivery3", "Msg3", 1);
- sendMessageToClient("delivery4", "Msg4", UnsignedInteger.MAX_VALUE.intValue()); // Limit
-
- pumpServerToClient();
-
- LOGGER.fine(bold("======== About to process the messages on the client"));
-
- Delivery clientDelivery1 = receiveMessageFromServer("delivery1", "Msg1");
- Delivery clientDelivery2 = receiveMessageFromServer("delivery2", "Msg2");
- Delivery clientDelivery3 = receiveMessageFromServer("delivery3", "Msg3");
- Delivery clientDelivery4 = receiveMessageFromServer("delivery4", "Msg4");
-
- // Verify the message format is as expected
- assertEquals("Unexpected message format", 0, clientDelivery1.getMessageFormat());
- assertEquals("Unexpected message format", 0, clientDelivery2.getMessageFormat());
- assertEquals("Unexpected message format", 1, clientDelivery3.getMessageFormat());
- assertEquals("Unexpected message format", UnsignedInteger.MAX_VALUE.intValue(), clientDelivery4.getMessageFormat());
- }
-
- private Delivery receiveMessageFromServer(String deliveryTag, String messageContent)
- {
- Delivery delivery = getClient().connection.getWorkHead();
-
- assertTrue(Arrays.equals(deliveryTag.getBytes(StandardCharsets.UTF_8), delivery.getTag()));
- assertEquals("The received delivery should be on our receiver",
- getClient().receiver, delivery.getLink());
-
- assertNull(delivery.getLocalState());
- assertNull(delivery.getRemoteState());
-
- assertFalse(delivery.isPartial());
- assertTrue(delivery.isReadable());
-
- byte[] received = new byte[BUFFER_SIZE];
- int len = getClient().receiver.recv(received, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Message m = Proton.message();
- m.decode(received, 0, len);
-
- Object messageBody = ((AmqpValue)m.getBody()).getValue();
- assertEquals("Unexpected message content", messageContent, messageBody);
-
- boolean receiverAdvanced = getClient().receiver.advance();
- assertTrue("receiver has not advanced", receiverAdvanced);
-
- return delivery;
- }
-
- private Delivery sendMessageToClient(String deliveryTag, String messageContent, Integer messageFormat)
- {
- byte[] tag = deliveryTag.getBytes(StandardCharsets.UTF_8);
-
- Message m = Proton.message();
- m.setBody(new AmqpValue(messageContent));
-
- byte[] encoded = new byte[BUFFER_SIZE];
- int len = m.encode(encoded, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Delivery serverDelivery = getServer().sender.delivery(tag);
-
- // Verify the default format of 0 is in place
- assertEquals("Unexpected message format", 0, serverDelivery.getMessageFormat());
-
- // Set the message format explicitly if given, or leave it at the default
- if(messageFormat != null) {
- serverDelivery.setMessageFormat(messageFormat);
- }
-
- int sent = getServer().sender.send(encoded, 0, len);
-
- assertEquals("sender unable to send all data at once as assumed for simplicity", len, sent);
-
- boolean senderAdvanced = getServer().sender.advance();
- assertTrue("sender has not advanced", senderAdvanced);
-
- return serverDelivery;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/EngineTestBase.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/EngineTestBase.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/EngineTestBase.java
deleted file mode 100644
index 9dadf29..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/EngineTestBase.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.ByteBuffer;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.engine.Endpoint;
-import org.apache.qpid.proton.engine.EndpointState;
-
-public abstract class EngineTestBase
-{
- private static final Logger LOGGER = Logger.getLogger(EngineTestBase.class.getName());
-
- private final TestLoggingHelper _testLoggingHelper = new TestLoggingHelper(LOGGER);
- private final ProtonContainer _client = new ProtonContainer("clientContainer");
- private final ProtonContainer _server = new ProtonContainer("serverContainer");
-
- protected TestLoggingHelper getTestLoggingHelper()
- {
- return _testLoggingHelper;
- }
-
- protected ProtonContainer getClient()
- {
- return _client;
- }
-
- protected ProtonContainer getServer()
- {
- return _server;
- }
-
- protected void assertClientHasNothingToOutput()
- {
- assertEquals(0, getClient().transport.getOutputBuffer().remaining());
- getClient().transport.outputConsumed();
- }
-
- protected void pumpServerToClient()
- {
- ByteBuffer serverBuffer = getServer().transport.getOutputBuffer();
-
- getTestLoggingHelper().prettyPrint(" <<<" + TestLoggingHelper.SERVER_PREFIX + " ", serverBuffer);
- assertTrue("Server expected to produce some output", serverBuffer.hasRemaining());
-
- ByteBuffer clientBuffer = getClient().transport.getInputBuffer();
-
- clientBuffer.put(serverBuffer);
-
- assertEquals("Client expected to consume all server's output", 0, serverBuffer.remaining());
-
- getClient().transport.processInput().checkIsOk();
- getServer().transport.outputConsumed();
- }
-
- protected void pumpClientToServer()
- {
- ByteBuffer clientBuffer = getClient().transport.getOutputBuffer();
-
- getTestLoggingHelper().prettyPrint(TestLoggingHelper.CLIENT_PREFIX + ">>> ", clientBuffer);
- assertTrue("Client expected to produce some output", clientBuffer.hasRemaining());
-
- ByteBuffer serverBuffer = getServer().transport.getInputBuffer();
-
- serverBuffer.put(clientBuffer);
-
- assertEquals("Server expected to consume all client's output", 0, clientBuffer.remaining());
-
- getClient().transport.outputConsumed();
- getServer().transport.processInput().checkIsOk();
- }
-
- protected void doOutputInputCycle() throws Exception
- {
- pumpClientToServer();
-
- pumpServerToClient();
- }
-
- protected void assertEndpointState(Endpoint endpoint, EndpointState localState, EndpointState remoteState)
- {
- assertEquals(localState, endpoint.getLocalState());
- assertEquals(remoteState, endpoint.getRemoteState());
- }
-
- protected void assertTerminusEquals(org.apache.qpid.proton.amqp.transport.Target expectedTarget, org.apache.qpid.proton.amqp.transport.Target actualTarget)
- {
- assertEquals(
- ((Target)expectedTarget).getAddress(),
- ((Target)actualTarget).getAddress());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/FreeTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/FreeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/FreeTest.java
deleted file mode 100644
index 7687206..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/FreeTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static java.util.EnumSet.of;
-import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
-import static org.apache.qpid.proton.engine.EndpointState.UNINITIALIZED;
-import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.engine.Receiver;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-import org.junit.Test;
-
-public class FreeTest extends EngineTestBase
-{
- private static final Logger LOGGER = Logger.getLogger(FreeTest.class.getName());
-
- @Test
- public void testFreeConnectionWithMultipleSessionsAndSendersAndReceiversDoesNotThrowCME() throws Exception
- {
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
-
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
-
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
- getClient().session.open();
-
- Session clientSession2 = getClient().connection.session();
- clientSession2.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- Session serverSession2 = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertNotNull("Engine did not return expected second server session", serverSession2);
- assertNotSame("Engine did not return expected second server session", serverSession2, getServer().session);
- serverSession2.open();
-
- pumpServerToClient();
- assertEndpointState(getClient().session, ACTIVE, ACTIVE);
- assertEndpointState(clientSession2, ACTIVE, ACTIVE);
-
-
-
- LOGGER.fine(bold("======== About to create client senders"));
-
- getClient().source = new Source();
- getClient().source.setAddress(null);
-
- getClient().target = new Target();
- getClient().target.setAddress("myQueue");
-
- getClient().sender = getClient().session.sender("sender1");
- getClient().sender.setTarget(getClient().target);
- getClient().sender.setSource(getClient().source);
-
- getClient().sender.setSenderSettleMode(SenderSettleMode.UNSETTLED);
- getClient().sender.setReceiverSettleMode(ReceiverSettleMode.FIRST);
-
- assertEndpointState(getClient().sender, UNINITIALIZED, UNINITIALIZED);
-
- getClient().sender.open();
- assertEndpointState(getClient().sender, ACTIVE, UNINITIALIZED);
-
-
- Sender clientSender2 = getClient().session.sender("sender2");
- clientSender2.setTarget(getClient().target);
- clientSender2.setSource(getClient().source);
-
- clientSender2.setSenderSettleMode(SenderSettleMode.UNSETTLED);
- clientSender2.setReceiverSettleMode(ReceiverSettleMode.FIRST);
-
- assertEndpointState(clientSender2, UNINITIALIZED, UNINITIALIZED);
-
- clientSender2.open();
- assertEndpointState(clientSender2, ACTIVE, UNINITIALIZED);
-
- pumpClientToServer();
-
-
- LOGGER.fine(bold("======== About to set up server receivers"));
-
- getServer().receiver = (Receiver) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
- // Accept the settlement modes suggested by the client
- getServer().receiver.setSenderSettleMode(getServer().receiver.getRemoteSenderSettleMode());
- getServer().receiver.setReceiverSettleMode(getServer().receiver.getRemoteReceiverSettleMode());
-
- org.apache.qpid.proton.amqp.transport.Target serverRemoteTarget = getServer().receiver.getRemoteTarget();
- assertTerminusEquals(getClient().target, serverRemoteTarget);
-
- getServer().receiver.setTarget(serverRemoteTarget);
-
- assertEndpointState(getServer().receiver, UNINITIALIZED, ACTIVE);
- getServer().receiver.open();
-
- assertEndpointState(getServer().receiver, ACTIVE, ACTIVE);
-
- Receiver serverReceiver2 = (Receiver) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
- serverReceiver2.open();
- assertEndpointState(serverReceiver2, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().sender, ACTIVE, ACTIVE);
- assertEndpointState(clientSender2, ACTIVE, ACTIVE);
-
-
-
- LOGGER.fine(bold("======== About to create client receivers"));
-
- Source src = new Source();
- src.setAddress("myQueue");
-
- Target tgt1 = new Target();
- tgt1.setAddress("receiver1");
-
- getClient().receiver = getClient().session.receiver("receiver1");
- getClient().receiver.setSource(src);
- getClient().receiver.setTarget(tgt1);
-
- getClient().receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
- getClient().receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
-
- assertEndpointState(getClient().receiver, UNINITIALIZED, UNINITIALIZED);
-
- getClient().receiver.open();
- assertEndpointState(getClient().receiver, ACTIVE, UNINITIALIZED);
-
-
- Target tgt2 = new Target();
- tgt1.setAddress("receiver2");
-
- Receiver clientReceiver2 = getClient().session.receiver("receiver2");
- clientReceiver2.setSource(src);
- clientReceiver2.setTarget(tgt2);
-
- clientReceiver2.setSenderSettleMode(SenderSettleMode.UNSETTLED);
- clientReceiver2.setReceiverSettleMode(ReceiverSettleMode.FIRST);
-
- assertEndpointState(clientReceiver2, UNINITIALIZED, UNINITIALIZED);
-
- clientReceiver2.open();
- assertEndpointState(clientReceiver2, ACTIVE, UNINITIALIZED);
-
- pumpClientToServer();
-
-
-
- LOGGER.fine(bold("======== About to set up server senders"));
-
- getServer().sender = (Sender) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
- // Accept the settlement modes suggested by the client
- getServer().sender.setSenderSettleMode(getServer().sender.getRemoteSenderSettleMode());
- getServer().sender.setReceiverSettleMode(getServer().sender.getRemoteReceiverSettleMode());
-
- org.apache.qpid.proton.amqp.transport.Target serverRemoteTarget2 = getServer().sender.getRemoteTarget();
- assertTerminusEquals(tgt1, serverRemoteTarget2);
-
- getServer().sender.setTarget(serverRemoteTarget2);
-
- assertEndpointState(getServer().sender, UNINITIALIZED, ACTIVE);
- getServer().sender.open();
- assertEndpointState(getServer().sender, ACTIVE, ACTIVE);
-
- Sender serverSender2 = (Sender) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
-
- serverRemoteTarget2 = serverSender2.getRemoteTarget();
- assertTerminusEquals(tgt2, serverRemoteTarget2);
- serverSender2.setTarget(serverRemoteTarget2);
- serverSender2.open();
- assertEndpointState(serverSender2, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().receiver, ACTIVE, ACTIVE);
- assertEndpointState(clientReceiver2, ACTIVE, ACTIVE);
-
-
-
- LOGGER.fine(bold("======== About to close and free client's connection"));
-
- getClient().connection.close();
- getClient().connection.free();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/LinkTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/LinkTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/LinkTest.java
deleted file mode 100644
index 518960c..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/LinkTest.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import static java.util.EnumSet.of;
-import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
-import static org.apache.qpid.proton.engine.EndpointState.UNINITIALIZED;
-import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.message.Message;
-import org.junit.Test;
-
-public class LinkTest extends EngineTestBase
-{
- private static final Logger LOGGER = Logger.getLogger(LinkTest.class.getName());
-
- private static final int BUFFER_SIZE = 4096;
-
- private static final Symbol RCV_PROP = Symbol.valueOf("ReceiverPropName");
- private static final Integer RCV_PROP_VAL = 1234;
- private static final Symbol SND_PROP = Symbol.valueOf("SenderPropName");
- private static final Integer SND_PROP_VAL = 5678;
-
- private final String _sourceAddress = getServer().containerId + "-link1-source";
-
- @Test
- public void testCapabilities() throws Exception
- {
- final Symbol recvOfferedCap = Symbol.valueOf("recvOfferedCapability");
- final Symbol recvDesiredCap = Symbol.valueOf("recvDesiredCapability");
- final Symbol senderOfferedCap = Symbol.valueOf("senderOfferedCapability");
- final Symbol senderDesiredCap = Symbol.valueOf("senderDesiredCapability");
-
- Symbol[] clientOfferedCapabilities = new Symbol[] { recvOfferedCap };
- Symbol[] clientDesiredCapabilities = new Symbol[] { recvDesiredCap };
-
- Symbol[] serverOfferedCapabilities = new Symbol[] { senderOfferedCap };
- Symbol[] serverDesiredCapabilities = new Symbol[] { senderDesiredCap };
-
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
- getClient().session.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().session, ACTIVE, ACTIVE);
-
- LOGGER.fine(bold("======== About to create reciever"));
-
- getClient().source = new Source();
- getClient().source.setAddress(_sourceAddress);
-
- getClient().target = new Target();
- getClient().target.setAddress(null);
-
- getClient().receiver = getClient().session.receiver("link1");
- getClient().receiver.setTarget(getClient().target);
- getClient().receiver.setSource(getClient().source);
-
- getClient().receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
- getClient().receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
-
- // Set the client receivers capabilities
- getClient().receiver.setOfferedCapabilities(clientOfferedCapabilities);
- getClient().receiver.setDesiredCapabilities(clientDesiredCapabilities);
-
- assertEndpointState(getClient().receiver, UNINITIALIZED, UNINITIALIZED);
-
- getClient().receiver.open();
- assertEndpointState(getClient().receiver, ACTIVE, UNINITIALIZED);
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== About to set up implicitly created sender"));
-
- getServer().sender = (Sender) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
-
- getServer().sender.setReceiverSettleMode(getServer().sender.getRemoteReceiverSettleMode());
- getServer().sender.setSenderSettleMode(getServer().sender.getRemoteSenderSettleMode());
-
- org.apache.qpid.proton.amqp.transport.Source serverRemoteSource = getServer().sender.getRemoteSource();
- getServer().sender.setSource(serverRemoteSource);
-
- // Set the server senders capabilities
- getServer().sender.setOfferedCapabilities(serverOfferedCapabilities);
- getServer().sender.setDesiredCapabilities(serverDesiredCapabilities);
-
- assertEndpointState(getServer().sender, UNINITIALIZED, ACTIVE);
- getServer().sender.open();
-
- assertEndpointState(getServer().sender, ACTIVE, ACTIVE);
-
- pumpServerToClient();
-
- assertEndpointState(getClient().receiver, ACTIVE, ACTIVE);
-
- // Verify server side got the clients receiver capabilities as expected
- Symbol[] serverRemoteOfferedCapabilities = getServer().sender.getRemoteOfferedCapabilities();
- assertNotNull("Server had no remote offered capabilities", serverRemoteOfferedCapabilities);
- assertEquals("Server remote offered capabilities not expected size", 1, serverRemoteOfferedCapabilities.length);
- assertTrue("Server remote offered capabilities lack expected value: " + recvOfferedCap, Arrays.asList(serverRemoteOfferedCapabilities).contains(recvOfferedCap));
-
- Symbol[] serverRemoteDesiredCapabilities = getServer().sender.getRemoteDesiredCapabilities();
- assertNotNull("Server had no remote desired capabilities", serverRemoteDesiredCapabilities);
- assertEquals("Server remote desired capabilities not expected size", 1, serverRemoteDesiredCapabilities.length);
- assertTrue("Server remote desired capabilities lack expected value: " + recvDesiredCap, Arrays.asList(serverRemoteDesiredCapabilities).contains(recvDesiredCap));
-
- // Verify the client side got the servers sender capabilities as expected
- Symbol[] clientRemoteOfferedCapabilities = getClient().receiver.getRemoteOfferedCapabilities();
- assertNotNull("Client had no remote offered capabilities", clientRemoteOfferedCapabilities);
- assertEquals("Client remote offered capabilities not expected size", 1, clientRemoteOfferedCapabilities.length);
- assertTrue("Client remote offered capabilities lack expected value: " + senderOfferedCap, Arrays.asList(clientRemoteOfferedCapabilities).contains(senderOfferedCap));
-
- Symbol[] clientRemoteDesiredCapabilities = getClient().receiver.getRemoteDesiredCapabilities();
- assertNotNull("Client had no remote desired capabilities", clientRemoteDesiredCapabilities);
- assertEquals("Client remote desired capabilities not expected size", 1, clientRemoteDesiredCapabilities.length);
- assertTrue("Client remote desired capabilities lack expected value: " + senderDesiredCap, Arrays.asList(clientRemoteDesiredCapabilities).contains(senderDesiredCap));
- }
-
- @Test
- public void testProperties() throws Exception
- {
- Map<Symbol, Object> receiverProps = new HashMap<>();
- receiverProps.put(RCV_PROP, RCV_PROP_VAL);
-
- Map<Symbol, Object> senderProps = new HashMap<>();
- senderProps.put(SND_PROP, SND_PROP_VAL);
-
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
- getClient().session.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().session, ACTIVE, ACTIVE);
-
- LOGGER.fine(bold("======== About to create reciever"));
-
- getClient().source = new Source();
- getClient().source.setAddress(_sourceAddress);
-
- getClient().target = new Target();
- getClient().target.setAddress(null);
-
- getClient().receiver = getClient().session.receiver("link1");
- getClient().receiver.setTarget(getClient().target);
- getClient().receiver.setSource(getClient().source);
-
- getClient().receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
- getClient().receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
-
- // Set the recievers properties
- getClient().receiver.setProperties(receiverProps);
-
- assertEndpointState(getClient().receiver, UNINITIALIZED, UNINITIALIZED);
-
- getClient().receiver.open();
- assertEndpointState(getClient().receiver, ACTIVE, UNINITIALIZED);
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== About to set up implicitly created sender"));
-
- getServer().sender = (Sender) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
-
- getServer().sender.setReceiverSettleMode(getServer().sender.getRemoteReceiverSettleMode());
- getServer().sender.setSenderSettleMode(getServer().sender.getRemoteSenderSettleMode());
-
- org.apache.qpid.proton.amqp.transport.Source serverRemoteSource = getServer().sender.getRemoteSource();
- getServer().sender.setSource(serverRemoteSource);
-
- // Set the senders properties
- getServer().sender.setProperties(senderProps);
-
- assertEndpointState(getServer().sender, UNINITIALIZED, ACTIVE);
- getServer().sender.open();
-
- assertEndpointState(getServer().sender, ACTIVE, ACTIVE);
-
- pumpServerToClient();
-
- assertEndpointState(getClient().receiver, ACTIVE, ACTIVE);
-
- // Verify server side got the clients receiver properties as expected
- Map<Symbol, Object> serverRemoteProperties = getServer().sender.getRemoteProperties();
- assertNotNull("Server had no remote properties", serverRemoteProperties);
- assertEquals("Server remote properties not expected size", 1, serverRemoteProperties.size());
- assertTrue("Server remote properties lack expected key: " + RCV_PROP, serverRemoteProperties.containsKey(RCV_PROP));
- assertEquals("Server remote properties contain unexpected value for key: " + RCV_PROP, RCV_PROP_VAL, serverRemoteProperties.get(RCV_PROP));
-
- // Verify the client side got the servers sender properties as expected
- Map<Symbol, Object> clientRemoteProperties = getClient().receiver.getRemoteProperties();
- assertNotNull("Client had no remote properties", clientRemoteProperties);
- assertEquals("Client remote properties not expected size", 1, clientRemoteProperties.size());
- assertTrue("Client remote properties lack expected key: " + SND_PROP, clientRemoteProperties.containsKey(SND_PROP));
- assertEquals("Client remote properties contain unexpected value for key: " + SND_PROP, SND_PROP_VAL, clientRemoteProperties.get(SND_PROP));
- }
-
- /**
- * Test the {@link Link#getCredit()}, {@link Link#getQueued()}, and
- * {@link Link#getRemoteCredit()} methods behave as expected when sending
- * from server and receiving on client links.
- *
- * @throws Exception
- * if something unexpected occurs
- */
- @Test
- public void testLinkCreditState() throws Exception
- {
- LOGGER.fine(bold("======== About to create transports"));
-
- getClient().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
-
- getServer().transport = Proton.transport();
- ProtocolTracerEnabler.setProtocolTracer(getServer().transport, " " + TestLoggingHelper.SERVER_PREFIX);
-
- doOutputInputCycle();
-
- getClient().connection = Proton.connection();
- getClient().transport.bind(getClient().connection);
-
- getServer().connection = Proton.connection();
- getServer().transport.bind(getServer().connection);
-
- LOGGER.fine(bold("======== About to open connections"));
- getClient().connection.open();
- getServer().connection.open();
-
- doOutputInputCycle();
-
- LOGGER.fine(bold("======== About to open sessions"));
- getClient().session = getClient().connection.session();
- getClient().session.open();
-
- pumpClientToServer();
-
- getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
- assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
-
- getServer().session.open();
- assertEndpointState(getServer().session, ACTIVE, ACTIVE);
-
- pumpServerToClient();
- assertEndpointState(getClient().session, ACTIVE, ACTIVE);
-
- LOGGER.fine(bold("======== About to create reciever"));
-
- getClient().source = new Source();
- getClient().source.setAddress(_sourceAddress);
-
- getClient().target = new Target();
- getClient().target.setAddress(null);
-
- getClient().receiver = getClient().session.receiver("link1");
- getClient().receiver.setTarget(getClient().target);
- getClient().receiver.setSource(getClient().source);
-
- getClient().receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
- getClient().receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
-
- assertEndpointState(getClient().receiver, UNINITIALIZED, UNINITIALIZED);
-
- getClient().receiver.open();
- assertEndpointState(getClient().receiver, ACTIVE, UNINITIALIZED);
-
- pumpClientToServer();
-
- LOGGER.fine(bold("======== About to set up implicitly created sender"));
-
- getServer().sender = (Sender) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
-
- getServer().sender.setReceiverSettleMode(getServer().sender.getRemoteReceiverSettleMode());
- getServer().sender.setSenderSettleMode(getServer().sender.getRemoteSenderSettleMode());
-
- org.apache.qpid.proton.amqp.transport.Source serverRemoteSource = getServer().sender.getRemoteSource();
- getServer().sender.setSource(serverRemoteSource);
-
- assertEndpointState(getServer().sender, UNINITIALIZED, ACTIVE);
- getServer().sender.open();
-
- assertEndpointState(getServer().sender, ACTIVE, ACTIVE);
-
- pumpServerToClient();
-
- assertEndpointState(getClient().receiver, ACTIVE, ACTIVE);
-
- LOGGER.fine(bold("======== About to flow credit"));
-
- // Verify credit state
- assertLinkCreditState(getServer().sender, 0, 0, 0);
- assertLinkCreditState(getClient().receiver, 0, 0, 0);
-
- int messagCount = 4;
- getClient().receiver.flow(messagCount);
-
- // Verify credit state
- assertLinkCreditState(getServer().sender, 0, 0, 0);
- assertLinkCreditState(getClient().receiver, 4, 0, 4);
-
- pumpClientToServer();
-
- // Verify credit state
- assertLinkCreditState(getServer().sender, 4, 0, 4);
- assertLinkCreditState(getClient().receiver, 4, 0, 4);
-
- LOGGER.fine(bold("======== About to create messages and send to the client"));
-
- // 'Send' and verify credit state
- sendMessageToClient("delivery1", "Msg1");
- assertLinkCreditState(getServer().sender, 3, 1, 3);
- assertLinkCreditState(getClient().receiver, 4, 0, 4);
-
- // 'Send' and verify credit state
- sendMessageToClient("delivery2", "Msg2");
- assertLinkCreditState(getServer().sender, 2, 2, 2);
- assertLinkCreditState(getClient().receiver, 4, 0, 4);
-
- // Pump to the client to send messages 'on the wire', verify new state, process messages
- pumpServerToClient();
-
- LOGGER.fine(bold("======== About to process the messages on the client"));
-
- assertLinkCreditState(getServer().sender, 2, 0, 2);
- assertLinkCreditState(getClient().receiver, 4, 2, 2);
-
- receiveMessageFromServer("delivery1", "Msg1");
-
- assertLinkCreditState(getServer().sender, 2, 0, 2);
- assertLinkCreditState(getClient().receiver, 3, 1, 2);
-
- receiveMessageFromServer("delivery2", "Msg2");
-
- assertLinkCreditState(getServer().sender, 2, 0, 2);
- assertLinkCreditState(getClient().receiver, 2, 0, 2);
- }
-
- void assertLinkCreditState(Link link, int credit, int queued, int remoteCredit)
- {
- assertEquals("Unexpected credit", credit, link.getCredit());
- assertEquals("Unexpected queued", queued, link.getQueued());
- assertEquals("Unexpected remote credit", remoteCredit, link.getRemoteCredit());
- }
-
- private Delivery receiveMessageFromServer(String deliveryTag, String messageContent)
- {
- Delivery delivery = getClient().connection.getWorkHead();
-
- assertTrue(Arrays.equals(deliveryTag.getBytes(StandardCharsets.UTF_8), delivery.getTag()));
- assertEquals("The received delivery should be on our receiver",
- getClient().receiver, delivery.getLink());
-
- assertNull(delivery.getLocalState());
- assertNull(delivery.getRemoteState());
-
- assertFalse(delivery.isPartial());
- assertTrue(delivery.isReadable());
-
- byte[] received = new byte[BUFFER_SIZE];
- int len = getClient().receiver.recv(received, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Message m = Proton.message();
- m.decode(received, 0, len);
-
- Object messageBody = ((AmqpValue)m.getBody()).getValue();
- assertEquals("Unexpected message content", messageContent, messageBody);
-
- boolean receiverAdvanced = getClient().receiver.advance();
- assertTrue("receiver has not advanced", receiverAdvanced);
-
- return delivery;
- }
-
- private Delivery sendMessageToClient(String deliveryTag, String messageContent)
- {
- byte[] tag = deliveryTag.getBytes(StandardCharsets.UTF_8);
-
- Message m = Proton.message();
- m.setBody(new AmqpValue(messageContent));
-
- byte[] encoded = new byte[BUFFER_SIZE];
- int len = m.encode(encoded, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Delivery serverDelivery = getServer().sender.delivery(tag);
-
- int sent = getServer().sender.send(encoded, 0, len);
-
- assertEquals("sender unable to send all data at once as assumed for simplicity", len, sent);
-
- boolean senderAdvanced = getServer().sender.advance();
- assertTrue("sender has not advanced", senderAdvanced);
-
- return serverDelivery;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtocolTracerEnabler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtocolTracerEnabler.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtocolTracerEnabler.java
deleted file mode 100644
index a26afa8..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtocolTracerEnabler.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.logging.Logger;
-
-import org.apache.qpid.proton.engine.Transport;
-
-public class ProtocolTracerEnabler
-{
- private static final Logger LOGGER = Logger.getLogger(ProtocolTracerEnabler.class.getName());
-
- private static final String LOGGING_PROTOCOL_TRACER_CLASS_NAME = "org.apache.qpid.proton.logging.LoggingProtocolTracer";
-
- /**
- * Attempts to set up a {@value #LOGGING_PROTOCOL_TRACER_CLASS_NAME} on the supplied transport.
- * Uses reflection so this code can be run without a compile-time dependency on proton-j-impl.
- */
- public static void setProtocolTracer(Transport transport, String prefix)
- {
- try
- {
- Class<?> loggingProtocolTracerClass = Class.forName(LOGGING_PROTOCOL_TRACER_CLASS_NAME);
-
- Constructor<?> loggingProtocolTracerConstructor = loggingProtocolTracerClass.getConstructor(String.class);
- Object newLoggingProtocolTracer = loggingProtocolTracerConstructor.newInstance(prefix);
-
- Class<?> protocolTracerClass = Class.forName("org.apache.qpid.proton.engine.impl.ProtocolTracer");
- Method setPrococolTracerMethod = transport.getClass().getMethod("setProtocolTracer", protocolTracerClass);
-
- setPrococolTracerMethod.invoke(transport, newLoggingProtocolTracer);
- }
- catch(Exception e)
- {
- if(e instanceof ClassNotFoundException || e instanceof NoSuchMethodException)
- {
- LOGGER.fine("Protocol tracing disabled because unable to reflectively set a "
- + LOGGING_PROTOCOL_TRACER_CLASS_NAME + " instance on the supplied transport which is a: "
- + transport.getClass().getName());
- }
- else
- {
- throw new RuntimeException("Unable to set up protocol tracing", e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtonContainer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtonContainer.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtonContainer.java
deleted file mode 100644
index d24d1ce..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/ProtonContainer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.systemtests;
-
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Receiver;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.message.Message;
-
-/**
- * Simple "struct" class used to hold related Engine objects
- */
-public class ProtonContainer
-{
- String containerId;
- Connection connection;
- Transport transport;
- Session session;
- Sender sender;
- Receiver receiver;
- Source source;
- Target target;
- Delivery delivery;
- Message message;
- byte[] messageData;
-
- public ProtonContainer(String containerId)
- {
- this.containerId = containerId;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[08/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/SaslFrameParserTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/SaslFrameParserTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/SaslFrameParserTest.java
deleted file mode 100644
index 31dd200..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/SaslFrameParserTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.mockito.Mockito.*;
-import static org.junit.Assert.*;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.security.SaslFrameBody;
-import org.apache.qpid.proton.amqp.security.SaslInit;
-import org.apache.qpid.proton.amqp.transport.FrameBody;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.codec.AMQPDefinedTypes;
-import org.apache.qpid.proton.codec.ByteBufferDecoder;
-import org.apache.qpid.proton.codec.DecodeException;
-import org.apache.qpid.proton.codec.DecoderImpl;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.engine.TransportException;
-import org.junit.Test;
-
-/**
- * TODO test case where header is malformed
- * TODO test case where input provides frame and half etc
- */
-public class SaslFrameParserTest
-{
- private final SaslFrameHandler _mockSaslFrameHandler = mock(SaslFrameHandler.class);
- private final ByteBufferDecoder _mockDecoder = mock(ByteBufferDecoder.class);
- private final SaslFrameParser _frameParser;
- private final SaslFrameParser _frameParserWithMockDecoder = new SaslFrameParser(_mockSaslFrameHandler, _mockDecoder);
- private final AmqpFramer _amqpFramer = new AmqpFramer();
-
- private final SaslInit _saslFrameBody;
- private final ByteBuffer _saslFrameBytes;
-
- public SaslFrameParserTest()
- {
- DecoderImpl decoder = new DecoderImpl();
- EncoderImpl encoder = new EncoderImpl(decoder);
- AMQPDefinedTypes.registerAllTypes(decoder,encoder);
-
- _frameParser = new SaslFrameParser(_mockSaslFrameHandler, decoder);
- _saslFrameBody = new SaslInit();
- _saslFrameBody.setMechanism(Symbol.getSymbol("unused"));
- _saslFrameBytes = ByteBuffer.wrap(_amqpFramer.generateSaslFrame(0, new byte[0], _saslFrameBody));
- }
-
- @Test
- public void testInputOfValidFrame()
- {
- sendAmqpSaslHeader(_frameParser);
-
- when(_mockSaslFrameHandler.isDone()).thenReturn(false);
-
- _frameParser.input(_saslFrameBytes);
-
- verify(_mockSaslFrameHandler).handle(isA(SaslInit.class), (Binary)isNull());
- }
-
- @Test
- public void testInputOfInvalidFrame_causesErrorAndRefusesFurtherInput()
- {
- sendAmqpSaslHeader(_frameParserWithMockDecoder);
-
- String exceptionMessage = "dummy decode exception";
- when(_mockDecoder.readObject()).thenThrow(new DecodeException(exceptionMessage));
-
- // We send a valid frame but the mock decoder has been configured to reject it
- try {
- _frameParserWithMockDecoder.input(_saslFrameBytes);
- fail("expected exception");
- } catch (TransportException e) {
- assertThat(e.getMessage(), containsString(exceptionMessage));
- }
-
- verify(_mockSaslFrameHandler, never()).handle(any(SaslFrameBody.class), any(Binary.class));
-
- // Check that any further interaction causes an error TransportResult.
- try {
- _frameParserWithMockDecoder.input(ByteBuffer.wrap("".getBytes()));
- fail("expected exception");
- } catch (TransportException e) {
- // this is expected
- }
- }
-
- @Test
- public void testInputOfNonSaslFrame_causesErrorAndRefusesFurtherInput()
- {
- sendAmqpSaslHeader(_frameParserWithMockDecoder);
-
- FrameBody nonSaslFrame = new Open();
- when(_mockDecoder.readObject()).thenReturn(nonSaslFrame);
-
- // We send a valid frame but the mock decoder has been configured to reject it
- try {
- _frameParserWithMockDecoder.input(_saslFrameBytes);
- fail("expected exception");
- } catch (TransportException e) {
- assertThat(e.getMessage(), containsString("Unexpected frame type encountered."));
- }
-
- verify(_mockSaslFrameHandler, never()).handle(any(SaslFrameBody.class), any(Binary.class));
-
- // Check that any further interaction causes an error TransportResult.
- try {
- _frameParserWithMockDecoder.input(ByteBuffer.wrap("".getBytes()));
- fail("expected exception");
- } catch (TransportException e) {
- // this is expected
- }
- }
-
- private void sendAmqpSaslHeader(SaslFrameParser saslFrameParser)
- {
- saslFrameParser.input(ByteBuffer.wrap(AmqpHeader.SASL_HEADER));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/StringUtilsTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/StringUtilsTest.java
deleted file mode 100644
index 8711b9f..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/StringUtilsTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.junit.Assert.*;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.junit.Test;
-
-public class StringUtilsTest
-{
- @Test
- public void testNullBinary()
- {
- assertEquals("unexpected result", "\"\"", StringUtils.toQuotedString(null, 10, true));
- }
-
- @Test
- public void testEmptyBinaryEmptyArray()
- {
- Binary bin = new Binary(new byte[0]);
- assertEquals("unexpected result", "\"\"", StringUtils.toQuotedString(bin, 10, true));
- }
-
- @Test
- public void testEmptyBinaryNonEmptyArray()
- {
- byte[] bytes = new byte[] {(byte) 0, (byte) 0, (byte) 0};
- Binary bin = new Binary(bytes, 0, 0);
- assertEquals("unexpected result", "\"\"", StringUtils.toQuotedString(bin, 10, true));
- }
-
- @Test
- public void testEmptyBinaryNonEmptyArrayWithOffset()
- {
- byte[] bytes = new byte[] {(byte) 0, (byte) 0, (byte) 0};
- Binary bin = new Binary(bytes, 1, 0);
- assertEquals("unexpected result", "\"\"", StringUtils.toQuotedString(bin, 10, true));
- }
-
- @Test
- public void testBinaryStringifiedSmallerThanGivenMaxLength()
- {
- byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3, (byte) 65, (byte) 152};
- String expected = "\"\\x00\\x01\\x03A\\x98\"";
- Binary bin = new Binary(bytes);
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 100, true));
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 100, false));
- }
-
- @Test
- public void testBinaryStringifiedSmallerThanGivenMaxLengthWithOffset()
- {
- byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3, (byte) 65, (byte) 152};
- String expected = "\"\\x01\\x03A\\x98\"";
- Binary bin = new Binary(bytes, 1, 4);
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 100, true));
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 100, false));
- }
-
- @Test
- public void testBinaryStringifiedEqualToGivenMaxLength()
- {
- byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3, (byte) 65};
- String expected = "\"\\x00\\x01\\x03A\"";
- Binary bin = new Binary(bytes);
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 15, true));
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 15, false));
-
- bytes = new byte[] {(byte) 0, (byte) 1, (byte) 65, (byte) 3};
- expected = "\"\\x00\\x01A\\x03\"";
- bin = new Binary(bytes);
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 15, true));
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 15, false));
- }
-
- @Test
- public void testBinaryStringifiedEqualToGivenMaxLengthWithOffset()
- {
- byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3, (byte) 65};
- String expected = "\"\\x01\\x03A\"";
- Binary bin = new Binary(bytes, 1, 3);
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 11, true));
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 11, false));
-
- bytes = new byte[] {(byte) 0, (byte) 1, (byte) 65, (byte) 3};
- expected = "\"\\x01A\\x03\"";
- bin = new Binary(bytes, 1, 3);
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 11, true));
- assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 11, false));
- }
-
- @Test
- public void testBinaryStringifiedLargerThanGivenMaxLength()
- {
- byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3};
- String expected1 = "\"\\x00\\x01\"";
- Binary bin = new Binary(bytes);
-
- assertEquals("unexpected result", expected1, StringUtils.toQuotedString(bin, 10, false));
-
- String expected2 = "\"\\x00\\x01\"...(truncated)";
- assertEquals("unexpected result", expected2, StringUtils.toQuotedString(bin, 10, true));
- }
-
- @Test
- public void testBinaryStringifiedLargerThanGivenMaxLengthWithOffset()
- {
- byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3};
- String expected1 = "\"\\x00\\x01\"";
- Binary bin = new Binary(bytes);
-
- assertEquals("unexpected result", expected1, StringUtils.toQuotedString(bin, 10, false));
-
- String expected2 = "\"\\x00\\x01\"...(truncated)";
- assertEquals("unexpected result", expected2, StringUtils.toQuotedString(bin, 10, true));
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
deleted file mode 100644
index a411cca..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
+++ /dev/null
@@ -1,1640 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.apache.qpid.proton.engine.impl.AmqpHeader.HEADER;
-import static org.apache.qpid.proton.engine.impl.TransportTestHelper.stringOfLength;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
-
-import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.amqp.messaging.Released;
-import org.apache.qpid.proton.amqp.transport.Attach;
-import org.apache.qpid.proton.amqp.transport.Begin;
-import org.apache.qpid.proton.amqp.transport.Close;
-import org.apache.qpid.proton.amqp.transport.Detach;
-import org.apache.qpid.proton.amqp.transport.End;
-import org.apache.qpid.proton.amqp.transport.Flow;
-import org.apache.qpid.proton.amqp.transport.FrameBody;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.amqp.transport.Role;
-import org.apache.qpid.proton.amqp.transport.Transfer;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-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.Session;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-import org.apache.qpid.proton.framing.TransportFrame;
-import org.apache.qpid.proton.message.Message;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-
-public class TransportImplTest
-{
- @SuppressWarnings("deprecation")
- private TransportImpl _transport = new TransportImpl();
-
- private static final int CHANNEL_ID = 1;
- private static final TransportFrame TRANSPORT_FRAME_BEGIN = new TransportFrame(CHANNEL_ID, new Begin(), null);
- private static final TransportFrame TRANSPORT_FRAME_OPEN = new TransportFrame(CHANNEL_ID, new Open(), null);
-
- private static final int BUFFER_SIZE = 4096;
-
- @Rule
- public ExpectedException _expectedException = ExpectedException.none();
-
- @Test
- public void testInput()
- {
- ByteBuffer buffer = _transport.getInputBuffer();
- buffer.put(HEADER);
- _transport.processInput().checkIsOk();
-
- assertNotNull(_transport.getInputBuffer());
- }
-
- @Test
- public void testInitialProcessIsNoop()
- {
- _transport.process();
- }
-
- @Test
- public void testProcessIsIdempotent()
- {
- _transport.process();
- _transport.process();
- }
-
- /**
- * Empty input is always allowed by {@link Transport#getInputBuffer()} and
- * {@link Transport#processInput()}, in contrast to the old API.
- *
- * @see TransportImplTest#testEmptyInputBeforeBindUsingOldApi_causesTransportException()
- */
- @Test
- public void testEmptyInput_isAllowed()
- {
- _transport.getInputBuffer();
- _transport.processInput().checkIsOk();
- }
-
- /**
- * Tests the end-of-stream behaviour specified by {@link Transport#input(byte[], int, int)}.
- */
- @Test
- public void testEmptyInputBeforeBindUsingOldApi_causesTransportException()
- {
- _expectedException.expect(TransportException.class);
- _expectedException.expectMessage("Unexpected EOS when remote connection not closed: connection aborted");
- _transport.input(new byte [0], 0, 0);
- }
-
- /**
- * TODO it's not clear why empty input is specifically allowed in this case.
- */
- @Test
- public void testEmptyInputWhenRemoteConnectionIsClosedUsingOldApi_isAllowed()
- {
- @SuppressWarnings("deprecation")
- ConnectionImpl connection = new ConnectionImpl();
- _transport.bind(connection);
- connection.setRemoteState(EndpointState.CLOSED);
- _transport.input(new byte [0], 0, 0);
- }
-
- @Test
- public void testOutupt()
- {
- {
- // TransportImpl's underlying output spontaneously outputs the AMQP header
- final ByteBuffer outputBuffer = _transport.getOutputBuffer();
- assertEquals(HEADER.length, outputBuffer.remaining());
-
- byte[] outputBytes = new byte[HEADER.length];
- outputBuffer.get(outputBytes);
- assertArrayEquals(HEADER, outputBytes);
-
- _transport.outputConsumed();
- }
-
- {
- final ByteBuffer outputBuffer = _transport.getOutputBuffer();
- assertEquals(0, outputBuffer.remaining());
- _transport.outputConsumed();
- }
- }
-
- @Test
- public void testTransportInitiallyHandlesFrames()
- {
- assertTrue(_transport.isHandlingFrames());
- }
-
- @Test
- public void testBoundTransport_continuesToHandleFrames()
- {
- @SuppressWarnings("deprecation")
- Connection connection = new ConnectionImpl();
-
- assertTrue(_transport.isHandlingFrames());
-
- _transport.bind(connection);
-
- assertTrue(_transport.isHandlingFrames());
-
- _transport.handleFrame(TRANSPORT_FRAME_OPEN);
-
- assertTrue(_transport.isHandlingFrames());
- }
-
- @Test
- public void testUnboundTransport_stopsHandlingFrames()
- {
- assertTrue(_transport.isHandlingFrames());
-
- _transport.handleFrame(TRANSPORT_FRAME_OPEN);
-
- assertFalse(_transport.isHandlingFrames());
- }
-
- @Test
- public void testHandleFrameWhenNotHandling_throwsIllegalStateException()
- {
- assertTrue(_transport.isHandlingFrames());
-
- _transport.handleFrame(TRANSPORT_FRAME_OPEN);
-
- assertFalse(_transport.isHandlingFrames());
-
- _expectedException.expect(IllegalStateException.class);
- _transport.handleFrame(TRANSPORT_FRAME_BEGIN);
- }
-
- @Test
- public void testOutputTooBigToBeWrittenInOneGo()
- {
- int smallMaxFrameSize = 512;
- _transport = new TransportImpl(smallMaxFrameSize);
-
- @SuppressWarnings("deprecation")
- Connection conn = new ConnectionImpl();
- _transport.bind(conn);
-
- // Open frame sized in order to produce a frame that will almost fill output buffer
- conn.setHostname(stringOfLength("x", 500));
- conn.open();
-
- // Close the connection to generate a Close frame which will cause an overflow
- // internally - we'll get the remaining bytes on the next interaction.
- conn.close();
-
- ByteBuffer buf = _transport.getOutputBuffer();
- assertEquals("Expecting buffer to be full", smallMaxFrameSize, buf.remaining());
- buf.position(buf.limit());
- _transport.outputConsumed();
-
- buf = _transport.getOutputBuffer();
- assertTrue("Expecting second buffer to have bytes", buf.remaining() > 0);
- assertTrue("Expecting second buffer to not be full", buf.remaining() < Transport.MIN_MAX_FRAME_SIZE);
- }
-
- @Test
- public void testAttemptToInitiateSaslAfterProcessingBeginsCausesIllegalStateException()
- {
- _transport.process();
-
- try
- {
- _transport.sasl();
- }
- catch(IllegalStateException ise)
- {
- //expected, sasl must be initiated before processing begins
- }
- }
-
- @Test
- public void testChannelMaxDefault() throws Exception
- {
- Transport transport = Proton.transport();
-
- assertEquals("Unesxpected value for channel-max", 65535, transport.getChannelMax());
- }
-
- @Test
- public void testSetGetChannelMax() throws Exception
- {
- Transport transport = Proton.transport();
-
- int channelMax = 456;
- transport.setChannelMax(channelMax);
- assertEquals("Unesxpected value for channel-max", channelMax, transport.getChannelMax());
- }
-
- @Test
- public void testSetChannelMaxOutsideLegalUshortRangeThrowsIAE() throws Exception
- {
- Transport transport = Proton.transport();
-
- try {
- transport.setChannelMax( 1 << 16);
- fail("Expected exception to be thrown");
- } catch (IllegalArgumentException iae ){
- // Expected
- }
-
- try {
- transport.setChannelMax(-1);
- fail("Expected exception to be thrown");
- } catch (IllegalArgumentException iae ){
- // Expected
- }
- }
-
- private class MockTransportImpl extends TransportImpl
- {
- LinkedList<FrameBody> writes = new LinkedList<FrameBody>();
- @Override
- protected void writeFrame(int channel, FrameBody frameBody,
- ByteBuffer payload, Runnable onPayloadTooLarge) {
- super.writeFrame(channel, frameBody, payload, onPayloadTooLarge);
- writes.addLast(frameBody);
- }
- }
-
- @Test
- public void testTickRemoteTimeout()
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- int timeout = 4000;
- Open open = new Open();
- open.setIdleTimeOut(new UnsignedInteger(4000));
- TransportFrame openFrame = new TransportFrame(CHANNEL_ID, open, null);
- transport.handleFrame(openFrame);
- pumpMockTransport(transport);
-
- long deadline = transport.tick(0);
- assertEquals("Expected to be returned a deadline of 2000", 2000, deadline); // deadline = 4000 / 2
-
- deadline = transport.tick(1000); // Wait for less than the deadline with no data - get the same value
- assertEquals("When the deadline hasn't been reached tick() should return the previous deadline", 2000, deadline);
- assertEquals("When the deadline hasn't been reached tick() shouldn't write data", 0, transport.writes.size());
-
- deadline = transport.tick(timeout/2); // Wait for the deadline - next deadline should be (4000/2)*2
- assertEquals("When the deadline has been reached expected a new deadline to be returned 4000", 4000, deadline);
- assertEquals("tick() should have written data", 1, transport.writes.size());
- assertEquals("tick() should have written an empty frame", null, transport.writes.get(0));
-
- transport.writeFrame(CHANNEL_ID, new Begin(), null, null);
- while(transport.pending() > 0) transport.pop(transport.head().remaining());
- int framesWrittenBeforeTick = transport.writes.size();
- deadline = transport.tick(3000);
- assertEquals("Writing data resets the deadline", 5000, deadline);
- assertEquals("When the deadline is reset tick() shouldn't write an empty frame", 0, transport.writes.size() - framesWrittenBeforeTick);
-
- transport.writeFrame(CHANNEL_ID, new Attach(), null, null);
- assertTrue(transport.pending() > 0);
- framesWrittenBeforeTick = transport.writes.size();
- deadline = transport.tick(4000);
- assertEquals("Having pending data does not reset the deadline", 5000, deadline);
- assertEquals("Having pending data prevents tick() from sending an empty frame", 0, transport.writes.size() - framesWrittenBeforeTick);
- }
-
- @Test
- public void testTickLocalTimeout()
- {
- MockTransportImpl transport = new MockTransportImpl();
- transport.setIdleTimeout(4000);
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- transport.handleFrame(TRANSPORT_FRAME_OPEN);
- connection.open();
- pumpMockTransport(transport);
-
- long deadline = transport.tick(0);
- assertEquals("Expected to be returned a deadline of 4000", 4000, deadline);
-
- int framesWrittenBeforeTick = transport.writes.size();
- deadline = transport.tick(1000); // Wait for less than the deadline with no data - get the same value
- assertEquals("When the deadline hasn't been reached tick() should return the previous deadline", 4000, deadline);
- assertEquals("Reading data should never result in a frame being written", 0, transport.writes.size() - framesWrittenBeforeTick);
-
- // Protocol header + empty frame
- ByteBuffer data = ByteBuffer.wrap(new byte[] {'A', 'M', 'Q', 'P', 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00});
- while (data.remaining() > 0)
- {
- int origLimit = data.limit();
- int amount = Math.min(transport.tail().remaining(), data.remaining());
- data.limit(data.position() + amount);
- transport.tail().put(data);
- data.limit(origLimit);
- transport.process();
- }
- framesWrittenBeforeTick = transport.writes.size();
- deadline = transport.tick(2000);
- assertEquals("Reading data data resets the deadline", 6000, deadline);
- assertEquals("Reading data should never result in a frame being written", 0, transport.writes.size() - framesWrittenBeforeTick);
- assertEquals("Reading data before the deadline should keep the connection open", EndpointState.ACTIVE, connection.getLocalState());
-
- framesWrittenBeforeTick = transport.writes.size();
- deadline = transport.tick(7000);
- assertEquals("Calling tick() after the deadline should result in the connection being closed", EndpointState.CLOSED, connection.getLocalState());
- }
-
- /*
- * No frames should be written until the Connection object is
- * opened, at which point the Open, and Begin frames should
- * be pipelined together.
- */
- @Test
- public void testOpenSessionBeforeOpenConnection()
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- Session session = connection.session();
- session.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());
-
- connection.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- }
-
- /*
- * No frames should be written until the Connection object is
- * opened, at which point the Open, Begin, and Attach frames
- * should be pipelined together.
- */
- @Test
- public void testOpenReceiverBeforeOpenConnection()
- {
- doOpenLinkBeforeOpenConnectionTestImpl(true);
- }
-
- /**
- * No frames should be written until the Connection object is
- * opened, at which point the Open, Begin, and Attach frames
- * should be pipelined together.
- */
- @Test
- public void testOpenSenderBeforeOpenConnection()
- {
- doOpenLinkBeforeOpenConnectionTestImpl(false);
- }
-
- void doOpenLinkBeforeOpenConnectionTestImpl(boolean receiverLink)
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- Session session = connection.session();
- session.open();
-
- Link link = null;
- if(receiverLink)
- {
- link = session.receiver("myReceiver");
- }
- else
- {
- link = session.sender("mySender");
- }
- link.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());
-
- // Now open the connection, expect the Open, Begin, and Attach frames
- connection.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
- }
-
- /*
- * No attach frame should be written before the Session begin is sent.
- */
- @Test
- public void testOpenReceiverBeforeOpenSession()
- {
- doOpenLinkBeforeOpenSessionTestImpl(true);
- }
-
- /*
- * No attach frame should be written before the Session begin is sent.
- */
- @Test
- public void testOpenSenderBeforeOpenSession()
- {
- doOpenLinkBeforeOpenSessionTestImpl(false);
- }
-
- void doOpenLinkBeforeOpenSessionTestImpl(boolean receiverLink)
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- // Open the connection
- connection.open();
-
- // Create but don't open the session
- Session session = connection.session();
-
- // Open the link
- Link link = null;
- if(receiverLink)
- {
- link = session.receiver("myReceiver");
- }
- else
- {
- link = session.sender("mySender");
- }
- link.open();
-
- pumpMockTransport(transport);
-
- // Expect only an Open frame, no attach should be sent as the session isn't open
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
-
- // Now open the session, expect the Begin
- session.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- // Note: an Attach wasn't sent because link is no longer 'modified' after earlier pump. It
- // could easily be argued it should, given how the engine generally handles things. Seems
- // unlikely to be of much real world concern.
- //assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
- }
-
- /*
- * Verify that no Attach frame is emitted by the Transport should a Receiver
- * be opened after the session End frame was sent.
- */
- @Test
- public void testReceiverAttachAfterEndSent()
- {
- doLinkAttachAfterEndSentTestImpl(true);
- }
-
- /*
- * Verify that no Attach frame is emitted by the Transport should a Sender
- * be opened after the session End frame was sent.
- */
- @Test
- public void testSenderAttachAfterEndSent()
- {
- doLinkAttachAfterEndSentTestImpl(false);
- }
-
- void doLinkAttachAfterEndSentTestImpl(boolean receiverLink)
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Session session = connection.session();
- session.open();
-
- Link link = null;
- if(receiverLink)
- {
- link = session.receiver("myReceiver");
- }
- else
- {
- link = session.sender("mySender");
- }
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
-
- // Send the necessary responses to open/begin
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
-
- // Cause a End frame to be sent
- session.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof End);
-
- // Open the link and verify the transport doesn't
- // send any Attach frame, as an End frame was sent already.
- link.open();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
- }
-
- /*
- * Verify that no Attach frame is emitted by the Transport should a Receiver
- * be closed after the session End frame was sent.
- */
- @Test
- public void testReceiverCloseAfterEndSent()
- {
- doLinkDetachAfterEndSentTestImpl(true);
- }
-
- /*
- * Verify that no Attach frame is emitted by the Transport should a Sender
- * be closed after the session End frame was sent.
- */
- @Test
- public void testSenderCloseAfterEndSent()
- {
- doLinkDetachAfterEndSentTestImpl(false);
- }
-
- void doLinkDetachAfterEndSentTestImpl(boolean receiverLink)
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Session session = connection.session();
- session.open();
-
- Link link = null;
- if(receiverLink)
- {
- link = session.receiver("myReceiver");
- }
- else
- {
- link = session.sender("mySender");
- }
- link.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
-
- // Send the necessary responses to open/begin
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- // Cause an End frame to be sent
- session.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(3) instanceof End);
-
- // Close the link and verify the transport doesn't
- // send any Detach frame, as an End frame was sent already.
- link.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- }
-
- /*
- * No frames should be written until the Connection object is
- * opened, at which point the Open and Begin frames should
- * be pipelined together.
- */
- @Test
- public void testReceiverFlowBeforeOpenConnection()
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- Session session = connection.session();
- session.open();
-
- Receiver reciever = session.receiver("myReceiver");
- reciever.flow(5);
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());
-
- // Now open the connection, expect the Open and Begin frames but
- // nothing else as we haven't opened the receiver itself yet.
- connection.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- }
-
- @Test
- public void testSenderSendBeforeOpenConnection()
- {
- MockTransportImpl transport = new MockTransportImpl();
-
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- Collector collector = Collector.Factory.create();
- connection.collect(collector);
-
- Session session = connection.session();
- session.open();
-
- String linkName = "mySender";
- Sender sender = session.sender(linkName);
- sender.open();
-
- sendMessage(sender, "tag1", "content1");
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());
-
- // Now open the connection, expect the Open and Begin and Attach frames but
- // nothing else as we the sender wont have credit yet.
- connection.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
-
- // Send the necessary responses to open/begin/attach then give sender credit
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- Attach attach = new Attach();
- attach.setHandle(UnsignedInteger.ZERO);
- attach.setRole(Role.RECEIVER);
- attach.setName(linkName);
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- transport.handleFrame(new TransportFrame(0, attach, null));
-
- Flow flow = new Flow();
- flow.setHandle(UnsignedInteger.ZERO);
- flow.setDeliveryCount(UnsignedInteger.ZERO);
- flow.setNextIncomingId(UnsignedInteger.ONE);
- flow.setNextOutgoingId(UnsignedInteger.ZERO);
- flow.setIncomingWindow(UnsignedInteger.valueOf(1024));
- flow.setOutgoingWindow(UnsignedInteger.valueOf(1024));
- flow.setLinkCredit(UnsignedInteger.valueOf(10));
-
- transport.handleFrame(new TransportFrame(0, flow, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- // Now pump the transport again and expect a transfer for the message
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Transfer);
- }
-
- @Test
- public void testEmitFlowEventOnSend()
- {
- doEmitFlowOnSendTestImpl(true);
- }
-
- public void testSupressFlowEventOnSend()
- {
- doEmitFlowOnSendTestImpl(false);
- }
-
- void doEmitFlowOnSendTestImpl(boolean emitFlowEventOnSend)
- {
- MockTransportImpl transport = new MockTransportImpl();
- transport.setEmitFlowEventOnSend(emitFlowEventOnSend);
-
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- Collector collector = Collector.Factory.create();
- connection.collect(collector);
-
- Session session = connection.session();
- session.open();
-
- String linkName = "mySender";
- Sender sender = session.sender(linkName);
- sender.open();
-
- sendMessage(sender, "tag1", "content1");
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());
-
- assertEvents(collector, Event.Type.CONNECTION_INIT, Event.Type.SESSION_INIT, Event.Type.SESSION_LOCAL_OPEN,
- Event.Type.TRANSPORT, Event.Type.LINK_INIT, Event.Type.LINK_LOCAL_OPEN, Event.Type.TRANSPORT);
-
- // Now open the connection, expect the Open and Begin frames but
- // nothing else as we haven't opened the receiver itself yet.
- connection.open();
-
- pumpMockTransport(transport);
-
- assertEvents(collector, Event.Type.CONNECTION_LOCAL_OPEN, Event.Type.TRANSPORT);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
-
- // Send the necessary responses to open/begin/attach then give sender credit
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- Attach attach = new Attach();
- attach.setHandle(UnsignedInteger.ZERO);
- attach.setRole(Role.RECEIVER);
- attach.setName(linkName);
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- transport.handleFrame(new TransportFrame(0, attach, null));
-
- Flow flow = new Flow();
- flow.setHandle(UnsignedInteger.ZERO);
- flow.setDeliveryCount(UnsignedInteger.ZERO);
- flow.setNextIncomingId(UnsignedInteger.ONE);
- flow.setNextOutgoingId(UnsignedInteger.ZERO);
- flow.setIncomingWindow(UnsignedInteger.valueOf(1024));
- flow.setOutgoingWindow(UnsignedInteger.valueOf(1024));
- flow.setLinkCredit(UnsignedInteger.valueOf(10));
-
- transport.handleFrame(new TransportFrame(0, flow, null));
-
- assertEvents(collector, Event.Type.CONNECTION_REMOTE_OPEN, Event.Type.SESSION_REMOTE_OPEN,
- Event.Type.LINK_REMOTE_OPEN, Event.Type.LINK_FLOW);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- // Now pump the transport again and expect a transfer for the message
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Transfer);
-
- // Verify that we did, or did not, emit a flow event
- if(emitFlowEventOnSend)
- {
- assertEvents(collector, Event.Type.LINK_FLOW);
- }
- else
- {
- assertNoEvents(collector);
- }
- }
-
- /**
- * Verify that no Begin frame is emitted by the Transport should a Session open
- * after the Close frame was sent.
- */
- @Test
- public void testSessionBeginAfterCloseSent()
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Session session = connection.session();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
-
- // Send the necessary response to Open
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());
-
- // Cause a Close frame to be sent
- connection.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Close);
-
- // Open the session and verify the transport doesn't
- // send any Begin frame, as a Close frame was sent already.
- session.open();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
- }
-
- /**
- * Verify that no End frame is emitted by the Transport should a Session close
- * after the Close frame was sent.
- */
- @Test
- public void testSessionEndAfterCloseSent()
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Session session = connection.session();
- session.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
-
- // Send the necessary responses to open/begin
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
-
- // Cause a Close frame to be sent
- connection.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Close);
-
- // Close the session and verify the transport doesn't
- // send any End frame, as a Close frame was sent already.
- session.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
- }
-
- /**
- * Verify that no Attach frame is emitted by the Transport should a Receiver
- * be opened after the Close frame was sent.
- */
- @Test
- public void testReceiverAttachAfterCloseSent()
- {
- doLinkAttachAfterCloseSentTestImpl(true);
- }
-
- /**
- * Verify that no Attach frame is emitted by the Transport should a Sender
- * be opened after the Close frame was sent.
- */
- @Test
- public void testSenderAttachAfterCloseSent()
- {
- doLinkAttachAfterCloseSentTestImpl(false);
- }
-
- void doLinkAttachAfterCloseSentTestImpl(boolean receiverLink)
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Session session = connection.session();
- session.open();
-
- Link link = null;
- if(receiverLink)
- {
- link = session.receiver("myReceiver");
- }
- else
- {
- link = session.sender("mySender");
- }
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
-
- // Send the necessary responses to open/begin
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
-
- // Cause a Close frame to be sent
- connection.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Close);
-
- // Open the link and verify the transport doesn't
- // send any Attach frame, as a Close frame was sent already.
- link.open();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
- }
-
- /**
- * Verify that no Flow frame is emitted by the Transport should a Receiver
- * have credit added after the Close frame was sent.
- */
- @Test
- public void testReceiverFlowAfterCloseSent()
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Session session = connection.session();
- session.open();
-
- String linkName = "myReceiver";
- Receiver receiver = session.receiver(linkName);
- receiver.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
-
- // Send the necessary responses to open/begin/attach
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- Attach attach = new Attach();
- attach.setHandle(UnsignedInteger.ZERO);
- attach.setRole(Role.RECEIVER);
- attach.setName(linkName);
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- transport.handleFrame(new TransportFrame(0, attach, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- // Cause the Close frame to be sent
- connection.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Close);
-
- // Grant new credit for the Receiver and verify the transport doesn't
- // send any Flow frame, as a Close frame was sent already.
- receiver.flow(1);
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- }
-
- /**
- * Verify that no Flow frame is emitted by the Transport should a Receiver
- * have pending drain when a detach is sent for that receiver.
- */
- @Test
- public void testNoReceiverFlowAfterDetachSentWhileDraining()
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Session session = connection.session();
- session.open();
-
- String linkName = "myReceiver";
- Receiver receiver = session.receiver(linkName);
- receiver.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
-
- // Send the necessary responses to open/begin/attach
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- Attach attach = new Attach();
- attach.setHandle(UnsignedInteger.ZERO);
- attach.setRole(Role.RECEIVER);
- attach.setName(linkName);
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- transport.handleFrame(new TransportFrame(0, attach, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- // Start a drain for the Receiver and verify the transport doesn't
- // send any Flow frame, due to the detach being initiated.
- receiver.drain(10);
- pumpMockTransport(transport);
-
- // Cause the Detach frame to be sent
- receiver.detach();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(4) instanceof Detach);
- }
-
- /**
- * Verify that no Flow frame is emitted by the Transport should a Sender
- * have credit drained added after the Close frame was sent.
- */
- @Test
- public void testSenderFlowAfterCloseSent()
- {
- MockTransportImpl transport = new MockTransportImpl();
-
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Collector collector = Collector.Factory.create();
- connection.collect(collector);
-
- Session session = connection.session();
- session.open();
-
- String linkName = "mySender";
- Sender sender = session.sender(linkName);
- sender.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
-
- assertFalse("Should not be in drain yet", sender.getDrain());
-
- // Send the necessary responses to open/begin/attach then give sender credit and drain
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- Attach attach = new Attach();
- attach.setHandle(UnsignedInteger.ZERO);
- attach.setRole(Role.RECEIVER);
- attach.setName(linkName);
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- transport.handleFrame(new TransportFrame(0, attach, null));
-
- int credit = 10;
- Flow flow = new Flow();
- flow.setHandle(UnsignedInteger.ZERO);
- flow.setDeliveryCount(UnsignedInteger.ZERO);
- flow.setNextIncomingId(UnsignedInteger.ONE);
- flow.setNextOutgoingId(UnsignedInteger.ZERO);
- flow.setIncomingWindow(UnsignedInteger.valueOf(1024));
- flow.setOutgoingWindow(UnsignedInteger.valueOf(1024));
- flow.setDrain(true);
- flow.setLinkCredit(UnsignedInteger.valueOf(credit));
-
- transport.handleFrame(new TransportFrame(0, flow, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Should not be in drain", sender.getDrain());
- assertEquals("Should have credit", credit, sender.getCredit());
-
- // Cause the Close frame to be sent
- connection.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Close);
-
- // Drain the credit and verify the transport doesn't
- // send any Flow frame, as a Close frame was sent already.
- int drained = sender.drained();
- assertEquals("Should have drained all credit", credit, drained);
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- }
-
- /**
- * Verify that no Disposition frame is emitted by the Transport should a Delivery
- * have disposition applied after the Close frame was sent.
- */
- @Test
- public void testDispositionAfterCloseSent()
- {
- MockTransportImpl transport = new MockTransportImpl();
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Session session = connection.session();
- session.open();
-
- String linkName = "myReceiver";
- Receiver receiver = session.receiver(linkName);
- receiver.flow(5);
- receiver.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
- assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Flow);
-
- Delivery delivery = receiver.current();
- assertNull("Should not yet have a delivery", delivery);
-
- // Send the necessary responses to open/begin/attach as well as a transfer
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- begin.setNextOutgoingId(UnsignedInteger.ONE);
- begin.setIncomingWindow(UnsignedInteger.valueOf(1024));
- begin.setOutgoingWindow(UnsignedInteger.valueOf(1024));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- Attach attach = new Attach();
- attach.setHandle(UnsignedInteger.ZERO);
- attach.setRole(Role.SENDER);
- attach.setName(linkName);
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- transport.handleFrame(new TransportFrame(0, attach, null));
-
- String deliveryTag = "tag1";
- String messageContent = "content1";
- handleTransfer(transport, 1, deliveryTag, messageContent);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
-
- delivery = verifyDelivery(receiver, deliveryTag, messageContent);
- assertNotNull("Should now have a delivery", delivery);
-
- // Cause the Close frame to be sent
- connection.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(4) instanceof Close);
-
- delivery.disposition(Released.getInstance());
- delivery.settle();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
- }
-
- /**
- * Verify that no Transfer frame is emitted by the Transport should a Delivery
- * be sendable after the Close frame was sent.
- */
- @Test
- public void testTransferAfterCloseSent()
- {
- MockTransportImpl transport = new MockTransportImpl();
-
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- connection.open();
-
- Collector collector = Collector.Factory.create();
- connection.collect(collector);
-
- Session session = connection.session();
- session.open();
-
- String linkName = "mySender";
- Sender sender = session.sender(linkName);
- sender.open();
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
-
- // Send the necessary responses to open/begin/attach then give sender credit
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- Attach attach = new Attach();
- attach.setHandle(UnsignedInteger.ZERO);
- attach.setRole(Role.RECEIVER);
- attach.setName(linkName);
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- transport.handleFrame(new TransportFrame(0, attach, null));
-
- Flow flow = new Flow();
- flow.setHandle(UnsignedInteger.ZERO);
- flow.setDeliveryCount(UnsignedInteger.ZERO);
- flow.setNextIncomingId(UnsignedInteger.ONE);
- flow.setNextOutgoingId(UnsignedInteger.ZERO);
- flow.setIncomingWindow(UnsignedInteger.valueOf(1024));
- flow.setOutgoingWindow(UnsignedInteger.valueOf(1024));
- flow.setLinkCredit(UnsignedInteger.valueOf(10));
-
- transport.handleFrame(new TransportFrame(0, flow, null));
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- // Cause the Close frame to be sent
- connection.close();
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Close);
-
- // Send a new message and verify the transport doesn't
- // send any Transfer frame, as a Close frame was sent already.
- sendMessage(sender, "tag1", "content1");
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- }
-
- private void assertNoEvents(Collector collector)
- {
- assertEvents(collector);
- }
-
- private void assertEvents(Collector collector, Event.Type... expectedEventTypes)
- {
-
- if(expectedEventTypes.length == 0)
- {
- assertNull("Expected no events, but at least one was present: " + collector.peek(), collector.peek());
- }
- else
- {
- ArrayList<Event.Type> eventTypesList = new ArrayList<Event.Type>();
- Event event = null;
- while ((event = collector.peek()) != null) {
- eventTypesList.add(event.getType());
- collector.pop();
- }
-
- assertArrayEquals("Unexpected event types: " + eventTypesList, expectedEventTypes, eventTypesList.toArray(new Event.Type[0]));
- }
- }
-
- private void pumpMockTransport(MockTransportImpl transport)
- {
- while(transport.pending() > 0)
- {
- transport.pop(transport.head().remaining());
- }
- }
-
- private String getFrameTypesWritten(MockTransportImpl transport)
- {
- String result = "";
- for(FrameBody f : transport.writes) {
- result += f.getClass().getSimpleName();
- result += ",";
- }
-
- if(result.isEmpty()) {
- return "no-frames-written";
- } else {
- return result;
- }
- }
-
- private Delivery sendMessage(Sender sender, String deliveryTag, String messageContent)
- {
- byte[] tag = deliveryTag.getBytes(StandardCharsets.UTF_8);
-
- Message m = Message.Factory.create();
- m.setBody(new AmqpValue(messageContent));
-
- byte[] encoded = new byte[BUFFER_SIZE];
- int len = m.encode(encoded, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Delivery delivery = sender.delivery(tag);
-
- int sent = sender.send(encoded, 0, len);
-
- assertEquals("sender unable to send all data at once as assumed for simplicity", len, sent);
-
- boolean senderAdvanced = sender.advance();
- assertTrue("sender has not advanced", senderAdvanced);
-
- return delivery;
- }
-
- private void handleTransfer(TransportImpl transport, int deliveryNumber, String deliveryTag, String messageContent)
- {
- byte[] tag = deliveryTag.getBytes(StandardCharsets.UTF_8);
-
- Message m = Message.Factory.create();
- m.setBody(new AmqpValue(messageContent));
-
- byte[] encoded = new byte[BUFFER_SIZE];
- int len = m.encode(encoded, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Transfer transfer = new Transfer();
- transfer.setDeliveryId(UnsignedInteger.valueOf(deliveryNumber));
- transfer.setHandle(UnsignedInteger.ZERO);
- transfer.setDeliveryTag(new Binary(tag));
- transfer.setMessageFormat(UnsignedInteger.valueOf(DeliveryImpl.DEFAULT_MESSAGE_FORMAT));
-
- transport.handleFrame(new TransportFrame(0, transfer, new Binary(encoded, 0, len)));
- }
-
- private Delivery verifyDelivery(Receiver receiver, String deliveryTag, String messageContent)
- {
- Delivery delivery = receiver.current();
-
- assertTrue(Arrays.equals(deliveryTag.getBytes(StandardCharsets.UTF_8), delivery.getTag()));
-
- assertNull(delivery.getLocalState());
- assertNull(delivery.getRemoteState());
-
- assertFalse(delivery.isPartial());
- assertTrue(delivery.isReadable());
-
- byte[] received = new byte[BUFFER_SIZE];
- int len = receiver.recv(received, 0, BUFFER_SIZE);
-
- assertTrue("given array was too small", len < BUFFER_SIZE);
-
- Message m = Proton.message();
- m.decode(received, 0, len);
-
- Object messageBody = ((AmqpValue)m.getBody()).getValue();
- assertEquals("Unexpected message content", messageContent, messageBody);
-
- boolean receiverAdvanced = receiver.advance();
- assertTrue("receiver has not advanced", receiverAdvanced);
-
- return delivery;
- }
-
- /**
- * Verify that the {@link TransportInternal#addTransportLayer(TransportLayer)} has the desired
- * effect by observing the wrapping effect on related transport input and output methods.
- */
- @Test
- public void testAddAdditionalTransportLayer()
- {
- Integer capacityOverride = 1957;
- Integer pendingOverride = 2846;
-
- MockTransportImpl transport = new MockTransportImpl();
-
- TransportWrapper mockWrapper = Mockito.mock(TransportWrapper.class);
-
- Mockito.when(mockWrapper.capacity()).thenReturn(capacityOverride);
- Mockito.when(mockWrapper.pending()).thenReturn(pendingOverride);
-
- TransportLayer mockLayer = Mockito.mock(TransportLayer.class);
- Mockito.when(mockLayer.wrap(Mockito.any(TransportInput.class), Mockito.any(TransportOutput.class))).thenReturn(mockWrapper);
-
- transport.addTransportLayer(mockLayer);
-
- assertEquals("Unexepcted value, layer override not effective", capacityOverride.intValue(), transport.capacity());
- assertEquals("Unexepcted value, layer override not effective", pendingOverride.intValue(), transport.pending());
- }
-
- @Test
- public void testAddAdditionalTransportLayerThrowsISEIfProcessingStarted()
- {
- MockTransportImpl transport = new MockTransportImpl();
- TransportLayer mockLayer = Mockito.mock(TransportLayer.class);
-
- transport.process();
-
- try
- {
- transport.addTransportLayer(mockLayer);
- fail("Expected exception to be thrown due to processing having started");
- }
- catch (IllegalStateException ise)
- {
- // expected
- }
- }
-
- @Test
- public void testEndpointOpenAndCloseAreIdempotent()
- {
- MockTransportImpl transport = new MockTransportImpl();
-
- Connection connection = Proton.connection();
- transport.bind(connection);
-
- Collector collector = Collector.Factory.create();
- connection.collect(collector);
-
- connection.open();
- connection.open();
-
- Session session = connection.session();
- session.open();
-
- String linkName = "mySender";
- Sender sender = session.sender(linkName);
- sender.open();
-
- pumpMockTransport(transport);
-
- assertEvents(collector, Event.Type.CONNECTION_INIT, Event.Type.CONNECTION_LOCAL_OPEN, Event.Type.TRANSPORT,
- Event.Type.SESSION_INIT, Event.Type.SESSION_LOCAL_OPEN,
- Event.Type.TRANSPORT, Event.Type.LINK_INIT, Event.Type.LINK_LOCAL_OPEN, Event.Type.TRANSPORT);
-
- pumpMockTransport(transport);
-
- connection.open();
- session.open();
- sender.open();
-
- assertNoEvents(collector);
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
- assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
- assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
-
- // Send the necessary responses to open/begin/attach then give sender credit
- transport.handleFrame(new TransportFrame(0, new Open(), null));
-
- Begin begin = new Begin();
- begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
- transport.handleFrame(new TransportFrame(0, begin, null));
-
- Attach attach = new Attach();
- attach.setHandle(UnsignedInteger.ZERO);
- attach.setRole(Role.RECEIVER);
- attach.setName(linkName);
- attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
- transport.handleFrame(new TransportFrame(0, attach, null));
-
- assertEvents(collector, Event.Type.CONNECTION_REMOTE_OPEN, Event.Type.SESSION_REMOTE_OPEN,
- Event.Type.LINK_REMOTE_OPEN);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
-
- // Now close the link and expect one event
- sender.close();
- sender.close();
-
- assertEvents(collector, Event.Type.LINK_LOCAL_CLOSE, Event.Type.TRANSPORT);
-
- pumpMockTransport(transport);
-
- sender.close();
-
- assertNoEvents(collector);
-
- pumpMockTransport(transport);
-
- assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
- assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Detach);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportOutputAdaptorTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportOutputAdaptorTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportOutputAdaptorTest.java
deleted file mode 100644
index 19c2f7b..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportOutputAdaptorTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static java.util.Arrays.copyOfRange;
-import static org.apache.qpid.proton.engine.impl.TransportTestHelper.assertByteArrayContentEquals;
-import static org.apache.qpid.proton.engine.impl.TransportTestHelper.assertByteBufferContentEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.apache.qpid.proton.engine.TransportException;
-
-import java.nio.ByteBuffer;
-
-import org.junit.Test;
-
-public class TransportOutputAdaptorTest
-{
- private final CannedTransportOutputWriter _transportOutputWriter = new CannedTransportOutputWriter();
- private final TransportOutput _transportOutput = new TransportOutputAdaptor(_transportOutputWriter, 1024);
-
- @Test
- public void testThatOutputBufferIsReadOnly()
- {
- assertTrue(_transportOutput.head().isReadOnly());
- }
-
- @Test
- public void testGetOutputBuffer_containsCorrectBytes()
- {
- byte[] testBytes = "testbytes".getBytes();
- _transportOutputWriter.setNextCannedOutput(testBytes);
-
- assertEquals(testBytes.length, _transportOutput.pending());
- final ByteBuffer outputBuffer = _transportOutput.head();
- assertEquals(testBytes.length, outputBuffer.remaining());
-
- byte[] outputBytes = new byte[testBytes.length];
- outputBuffer.get(outputBytes);
- assertByteArrayContentEquals(testBytes, outputBytes);
-
- _transportOutput.pop(outputBuffer.position());
-
- final ByteBuffer outputBuffer2 = _transportOutput.head();
- assertEquals(0, outputBuffer2.remaining());
- }
-
- @Test
- public void testClientConsumesOutputInMultipleChunks()
- {
- byte[] testBytes = "testbytes".getBytes();
- _transportOutputWriter.setNextCannedOutput(testBytes);
-
- // sip the first two bytes into a small byte array
-
- int chunk1Size = 2;
- int chunk2Size = testBytes.length - chunk1Size;
-
- {
- final ByteBuffer outputBuffer1 = _transportOutput.head();
- byte[] byteArray1 = new byte[chunk1Size];
-
- outputBuffer1.get(byteArray1);
- assertEquals(chunk2Size, outputBuffer1.remaining());
- assertByteArrayContentEquals(copyOfRange(testBytes, 0, chunk1Size), byteArray1);
-
- _transportOutput.pop(outputBuffer1.position());
- }
-
- {
- final ByteBuffer outputBuffer2 = _transportOutput.head();
- int chunk2Offset = chunk1Size;
- assertByteBufferContentEquals(copyOfRange(testBytes, chunk2Offset, testBytes.length), outputBuffer2);
- }
- }
-
- @Test
- public void testClientConsumesOutputInMultipleChunksWithAdditionalTransportWriterOutput()
- {
- byte[] initialBytes = "abcd".getBytes();
- _transportOutputWriter.setNextCannedOutput(initialBytes);
-
- // sip the first two bytes into a small byte array
- int chunk1Size = 2;
- int initialRemaining = initialBytes.length - chunk1Size;
-
- {
- final ByteBuffer outputBuffer1 = _transportOutput.head();
- byte[] byteArray1 = new byte[chunk1Size];
-
- outputBuffer1.get(byteArray1);
- assertEquals(initialRemaining, outputBuffer1.remaining());
- assertByteArrayContentEquals(copyOfRange(initialBytes, 0, chunk1Size), byteArray1);
-
- _transportOutput.pop(outputBuffer1.position());
- }
-
- byte[] additionalBytes = "wxyz".getBytes();
- _transportOutputWriter.setNextCannedOutput(additionalBytes);
-
- {
- final ByteBuffer outputBuffer2 = _transportOutput.head();
-
- byte[] expectedBytes = "cdwxyz".getBytes();
- assertByteBufferContentEquals(expectedBytes, outputBuffer2);
- }
- }
-
- private static final class CannedTransportOutputWriter implements TransportOutputWriter
- {
-
- byte[] _cannedOutput = new byte[0];
-
- @Override
- public boolean writeInto(ByteBuffer outputBuffer)
- {
- int bytesWritten = ByteBufferUtils.pourArrayToBuffer(_cannedOutput, 0, _cannedOutput.length, outputBuffer);
- if(bytesWritten < _cannedOutput.length)
- {
- fail("Unable to write all " + _cannedOutput.length + " bytes of my canned output to the provided output buffer: " + outputBuffer);
- }
- _cannedOutput = new byte[0];
- return false;
- }
-
- void setNextCannedOutput(byte[] cannedOutput)
- {
- _cannedOutput = cannedOutput;
- }
-
- public void closed(TransportException error)
- {
- // do nothing
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportTestHelper.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportTestHelper.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportTestHelper.java
deleted file mode 100644
index 995ed54..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportTestHelper.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton.engine.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-
-public class TransportTestHelper
-{
- public static void assertByteArrayContentEquals(byte[] expectedBytes, byte[] actualBytes)
- {
- assertEquals(new String(expectedBytes), new String(actualBytes));
- }
-
- public static void assertByteBufferContentEquals(byte[] expectedBytes, ByteBuffer actualByteBuffer)
- {
- ByteBuffer myByteBuffer = actualByteBuffer.duplicate();
- byte[] actualBytes = new byte[myByteBuffer.remaining()];
- myByteBuffer.get(actualBytes);
-
- assertByteArrayContentEquals(expectedBytes, actualBytes);
- }
-
- public static String pourBufferToString(ByteBuffer source)
- {
- return pourBufferToString(source, source.remaining());
- }
-
- public static String pourBufferToString(ByteBuffer source, int sizeRequested)
- {
- byte[] buf = new byte[sizeRequested];
- int numberRead = ByteBufferUtils.pourBufferToArray(source, buf, 0, sizeRequested);
- return new String(buf, 0, numberRead, StandardCharsets.UTF_8);
- }
-
- public static String stringOfLength(String value, int repeat)
- {
- StringBuilder builder = new StringBuilder();
- for(int i = 0 ; i < repeat; i++)
- {
- builder.append(value);
- }
- return builder.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/CannedTransportOutput.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/CannedTransportOutput.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/CannedTransportOutput.java
deleted file mode 100644
index 8fe8c13..0000000
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/ssl/CannedTransportOutput.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.engine.impl.ssl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.engine.impl.TransportOutput;
-
-public class CannedTransportOutput implements TransportOutput
-{
-
- private ByteBuffer _cannedOutput;
- private ByteBuffer _head;
- private int _popped;
-
- public CannedTransportOutput()
- {
- }
-
- public CannedTransportOutput(String output)
- {
- setOutput(output);
- }
-
- public void setOutput(String output)
- {
- _cannedOutput = ByteBuffer.wrap(output.getBytes());
- _head = _cannedOutput.asReadOnlyBuffer();
- _popped = 0;
- }
-
- @Override
- public int pending()
- {
- return _head.remaining();
- }
-
- @Override
- public ByteBuffer head()
- {
- return _head;
- }
-
- @Override
- public void pop(int bytes)
- {
- _popped += bytes;
- _head.position(_popped);
- }
-
- @Override
- public void close_head()
- {
- // do nothing
- }
-
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[20/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/NullElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/NullElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/NullElement.java
deleted file mode 100644
index c5020f8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/NullElement.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class NullElement extends AtomicElement<Void>
-{
- NullElement(Element parent, Element prev)
- {
- super(parent, prev);
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 0 : 1;
- }
-
- @Override
- public Void getValue()
- {
- return null;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.NULL;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- if(b.hasRemaining() && !isElementOfArray())
- {
- b.put((byte)0x40);
- return 1;
- }
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ShortElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ShortElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ShortElement.java
deleted file mode 100644
index 60ae295..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ShortElement.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.codec.Data;
-
-class ShortElement extends AtomicElement<Short>
-{
-
- private final short _value;
-
- ShortElement(Element parent, Element prev, short s)
- {
- super(parent, prev);
- _value = s;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 2 : 3;
- }
-
- @Override
- public Short getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.SHORT;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- if(isElementOfArray())
- {
- if(b.remaining() >= 2)
- {
- b.putShort(_value);
- return 2;
- }
- }
- else
- {
- if(b.remaining()>=3)
- {
- b.put((byte)0x61);
- b.putShort(_value);
- return 3;
- }
- }
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/StringElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/StringElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/StringElement.java
deleted file mode 100644
index e3be671..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/StringElement.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.codec.Data;
-
-class StringElement extends AtomicElement<String>
-{
-
- private static final Charset UTF_8 = Charset.forName("UTF-8");
- private final String _value;
-
- StringElement(Element parent, Element prev, String s)
- {
- super(parent, prev);
- _value = s;
- }
-
- @Override
- public int size()
- {
- final int length = _value.getBytes(UTF_8).length;
-
- return size(length);
- }
-
- private int size(int length)
- {
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(length > 255)
- {
- parent.setConstructorType(ArrayElement.LARGE);
- return 4+length;
- }
- else
- {
- return 1+length;
- }
- }
- else
- {
- return 4+length;
- }
- }
- else
- {
- if(length >255)
- {
- return 5 + length;
- }
- else
- {
- return 2 + length;
- }
- }
- }
-
- @Override
- public String getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.STRING;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- final byte[] bytes = _value.getBytes(UTF_8);
- final int length = bytes.length;
-
- int size = size(length);
- if(b.remaining()<size)
- {
- return 0;
- }
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- b.put((byte)length);
- }
- else
- {
- b.putInt(length);
- }
- }
- else if(length<=255)
- {
- b.put((byte)0xa1);
- b.put((byte)length);
- }
- else
- {
- b.put((byte)0xb1);
- b.put((byte)length);
- }
- b.put(bytes);
- return size;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/SymbolElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/SymbolElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/SymbolElement.java
deleted file mode 100644
index 4b75b1a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/SymbolElement.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.codec.Data;
-
-class SymbolElement extends AtomicElement<Symbol>
-{
-
- private static final Charset ASCII = Charset.forName("US-ASCII");
- private final Symbol _value;
-
- SymbolElement(Element parent, Element prev, Symbol s)
- {
- super(parent, prev);
- _value = s;
- }
-
- @Override
- public int size()
- {
- final int length = _value.length();
-
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(length > 255)
- {
- parent.setConstructorType(ArrayElement.LARGE);
- return 4+length;
- }
- else
- {
- return 1+length;
- }
- }
- else
- {
- return 4+length;
- }
- }
- else
- {
- if(length >255)
- {
- return 5 + length;
- }
- else
- {
- return 2 + length;
- }
- }
- }
-
- @Override
- public Symbol getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.SYMBOL;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(b.remaining()<size)
- {
- return 0;
- }
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- b.put((byte)_value.length());
- }
- else
- {
- b.putInt(_value.length());
- }
- }
- else if(_value.length()<=255)
- {
- b.put((byte)0xa3);
- b.put((byte)_value.length());
- }
- else
- {
- b.put((byte)0xb3);
- b.put((byte)_value.length());
- }
- b.put(_value.toString().getBytes(ASCII));
- return size;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/TimestampElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/TimestampElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/TimestampElement.java
deleted file mode 100644
index a7123d2..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/TimestampElement.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-
-import org.apache.qpid.proton.codec.Data;
-
-class TimestampElement extends AtomicElement<Date>
-{
-
- private final Date _value;
-
- TimestampElement(Element parent, Element prev, Date d)
- {
- super(parent, prev);
- _value = d;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 8 : 9;
- }
-
- @Override
- public Date getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.TIMESTAMP;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(size > b.remaining())
- {
- return 0;
- }
- if(size == 9)
- {
- b.put((byte)0x83);
- }
- b.putLong(_value.getTime());
-
- return size;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UUIDElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UUIDElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UUIDElement.java
deleted file mode 100644
index b2f7f1b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UUIDElement.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-import java.util.UUID;
-
-import org.apache.qpid.proton.codec.Data;
-
-class UUIDElement extends AtomicElement<UUID>
-{
-
- private final UUID _value;
-
- UUIDElement(Element parent, Element prev, UUID u)
- {
- super(parent, prev);
- _value = u;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 16 : 17;
- }
-
- @Override
- public UUID getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.UUID;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(b.remaining()>=size)
- {
- if(size == 17)
- {
- b.put((byte)0x98);
- }
- b.putLong(_value.getMostSignificantBits());
- b.putLong(_value.getLeastSignificantBits());
- return size;
- }
- else
- {
- return 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedByteElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedByteElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedByteElement.java
deleted file mode 100644
index 86b7a0b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedByteElement.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.codec.Data;
-
-class UnsignedByteElement extends AtomicElement<UnsignedByte>
-{
-
- private final UnsignedByte _value;
-
- UnsignedByteElement(Element parent, Element prev, UnsignedByte ub)
- {
- super(parent, prev);
- _value = ub;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 1 : 2;
- }
-
- @Override
- public UnsignedByte getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.UBYTE;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- if(isElementOfArray())
- {
- if(b.hasRemaining())
- {
- b.put(_value.byteValue());
- return 1;
- }
- }
- else
- {
- if(b.remaining()>=2)
- {
- b.put((byte)0x50);
- b.put(_value.byteValue());
- return 2;
- }
- }
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedIntegerElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedIntegerElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedIntegerElement.java
deleted file mode 100644
index 5268b70..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedIntegerElement.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.codec.Data;
-
-class UnsignedIntegerElement extends AtomicElement<UnsignedInteger>
-{
-
- private final UnsignedInteger _value;
-
- UnsignedIntegerElement(Element parent, Element prev, UnsignedInteger i)
- {
- super(parent, prev);
- _value = i;
- }
-
- @Override
- public int size()
- {
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
- if(parent.constructorType() == ArrayElement.TINY)
- {
- if(_value.intValue() == 0)
- {
- return 0;
- }
- else
- {
- parent.setConstructorType(ArrayElement.SMALL);
- }
- }
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(0 <= _value.intValue() && _value.intValue() <= 255)
- {
- return 1;
- }
- else
- {
- parent.setConstructorType(ArrayElement.LARGE);
- }
- }
-
- return 4;
-
- }
- else
- {
- return 0 == _value.intValue() ? 1 : (1 <= _value.intValue() && _value.intValue() <= 255) ? 2 : 5;
- }
-
- }
-
- @Override
- public UnsignedInteger getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.UINT;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(size > b.remaining())
- {
- return 0;
- }
- switch(size)
- {
- case 1:
- if(isElementOfArray())
- {
- b.put((byte)_value.intValue());
- }
- else
- {
- b.put((byte)0x43);
- }
- break;
- case 2:
- b.put((byte)0x52);
- b.put((byte)_value.intValue());
- break;
- case 5:
- b.put((byte)0x70);
- case 4:
- b.putInt(_value.intValue());
-
- }
-
- return size;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedLongElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedLongElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedLongElement.java
deleted file mode 100644
index 9e5e1cf..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedLongElement.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.codec.Data;
-
-class UnsignedLongElement extends AtomicElement<UnsignedLong>
-{
-
- private final UnsignedLong _value;
-
- UnsignedLongElement(Element parent, Element prev, UnsignedLong ul)
- {
- super(parent, prev);
- _value = ul;
- }
-
- @Override
- public int size()
- {
- if(isElementOfArray())
- {
- final ArrayElement parent = (ArrayElement) parent();
- if(parent.constructorType() == ArrayElement.TINY)
- {
- if(_value.longValue() == 0l)
- {
- return 0;
- }
- else
- {
- parent.setConstructorType(ArrayElement.SMALL);
- }
- }
-
- if(parent.constructorType() == ArrayElement.SMALL)
- {
- if(0l <= _value.longValue() && _value.longValue() <= 255l)
- {
- return 1;
- }
- else
- {
- parent.setConstructorType(ArrayElement.LARGE);
- }
- }
-
- return 8;
-
- }
- else
- {
- return 0l == _value.longValue() ? 1 : (1l <= _value.longValue() && _value.longValue() <= 255l) ? 2 : 9;
- }
-
- }
-
- @Override
- public UnsignedLong getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.ULONG;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- int size = size();
- if(size > b.remaining())
- {
- return 0;
- }
- switch(size)
- {
- case 1:
- if(isElementOfArray())
- {
- b.put((byte)_value.longValue());
- }
- else
- {
- b.put((byte)0x44);
- }
- break;
- case 2:
- b.put((byte)0x53);
- b.put((byte)_value.longValue());
- break;
- case 9:
- b.put((byte)0x80);
- case 8:
- b.putLong(_value.longValue());
-
- }
-
- return size;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedShortElement.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedShortElement.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedShortElement.java
deleted file mode 100644
index e003827..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedShortElement.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton.codec.impl;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.proton.amqp.UnsignedShort;
-import org.apache.qpid.proton.codec.Data;
-
-class UnsignedShortElement extends AtomicElement<UnsignedShort>
-{
-
- private final UnsignedShort _value;
-
- UnsignedShortElement(Element parent, Element prev, UnsignedShort ub)
- {
- super(parent, prev);
- _value = ub;
- }
-
- @Override
- public int size()
- {
- return isElementOfArray() ? 2 : 3;
- }
-
- @Override
- public UnsignedShort getValue()
- {
- return _value;
- }
-
- @Override
- public Data.DataType getDataType()
- {
- return Data.DataType.USHORT;
- }
-
- @Override
- public int encode(ByteBuffer b)
- {
- if(isElementOfArray())
- {
- if(b.remaining()>=2)
- {
- b.putShort(_value.shortValue());
- return 2;
- }
- }
- else
- {
- if(b.remaining()>=3)
- {
- b.put((byte)0x60);
- b.putShort(_value.shortValue());
- return 3;
- }
- }
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java
deleted file mode 100644
index 2da2d2b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Accepted;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-public final class AcceptedType extends AbstractDescribedType<Accepted,List> implements DescribedTypeConstructor<Accepted>
-{
-
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000024L), Symbol.valueOf("amqp:accepted:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000024L);
-
-
- private AcceptedType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- @Override
- protected UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Accepted val)
- {
- return Collections.EMPTY_LIST;
- }
-
- @Override
- public Class<Accepted> getTypeClass()
- {
- return Accepted.class;
- }
-
- public Accepted newInstance(Object described)
- {
- return Accepted.getInstance();
- }
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- AcceptedType type = new AcceptedType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java
deleted file mode 100644
index 8844893..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.AmqpSequence;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class AmqpSequenceType extends AbstractDescribedType<AmqpSequence,List> implements DescribedTypeConstructor<AmqpSequence>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000076L), Symbol.valueOf("amqp:amqp-sequence:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000076L);
-
- private AmqpSequenceType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(AmqpSequence val)
- {
- return val.getValue();
- }
-
- public AmqpSequence newInstance(Object described)
- {
- return new AmqpSequence( (List) described );
- }
-
- public Class<AmqpSequence> getTypeClass()
- {
- return AmqpSequence.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- AmqpSequenceType type = new AmqpSequenceType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java
deleted file mode 100644
index d2dc8e1..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class AmqpValueType extends AbstractDescribedType<AmqpValue,Object> implements DescribedTypeConstructor<AmqpValue>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000077L), Symbol.valueOf("amqp:amqp-value:*"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000077L);
-
- private AmqpValueType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected Object wrap(AmqpValue val)
- {
- return val.getValue();
- }
-
- public AmqpValue newInstance(Object described)
- {
- return new AmqpValue( described );
- }
-
- public Class<AmqpValue> getTypeClass()
- {
- return AmqpValue.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- AmqpValueType type = new AmqpValueType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ApplicationPropertiesType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ApplicationPropertiesType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ApplicationPropertiesType.java
deleted file mode 100644
index 5d0164a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ApplicationPropertiesType.java
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class ApplicationPropertiesType extends AbstractDescribedType<ApplicationProperties,Map> implements DescribedTypeConstructor<ApplicationProperties>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000074L), Symbol.valueOf("amqp:application-properties:map"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000074L);
-
- public ApplicationPropertiesType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected Map wrap(ApplicationProperties val)
- {
- return val.getValue();
- }
-
-
- public ApplicationProperties newInstance(Object described)
- {
- return new ApplicationProperties( (Map) described );
- }
-
- public Class<ApplicationProperties> getTypeClass()
- {
- return ApplicationProperties.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- ApplicationPropertiesType type = new ApplicationPropertiesType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java
deleted file mode 100644
index d7435c2..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Data;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class DataType extends AbstractDescribedType<Data,Binary> implements DescribedTypeConstructor<Data>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000075L), Symbol.valueOf("amqp:data:binary"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000075L);
-
- private DataType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected Binary wrap(Data val)
- {
- return val.getValue();
- }
-
- public Data newInstance(Object described)
- {
- return new Data( (Binary) described );
- }
-
- public Class<Data> getTypeClass()
- {
- return Data.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DataType type = new DataType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnCloseType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnCloseType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnCloseType.java
deleted file mode 100644
index 72e8d89..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnCloseType.java
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.DeleteOnClose;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class DeleteOnCloseType extends AbstractDescribedType<DeleteOnClose,List> implements DescribedTypeConstructor<DeleteOnClose>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x000000000000002bL), Symbol.valueOf("amqp:delete-on-close:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x000000000000002bL);
-
- private DeleteOnCloseType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(DeleteOnClose val)
- {
- return Collections.EMPTY_LIST;
- }
-
- public DeleteOnClose newInstance(Object described)
- {
- return DeleteOnClose.getInstance();
- }
-
- public Class<DeleteOnClose> getTypeClass()
- {
- return DeleteOnClose.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DeleteOnCloseType type = new DeleteOnCloseType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoLinksOrMessagesType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoLinksOrMessagesType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoLinksOrMessagesType.java
deleted file mode 100644
index 9e0b46d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoLinksOrMessagesType.java
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.DeleteOnNoLinksOrMessages;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class DeleteOnNoLinksOrMessagesType extends AbstractDescribedType<DeleteOnNoLinksOrMessages,List> implements DescribedTypeConstructor<DeleteOnNoLinksOrMessages>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x000000000000002eL), Symbol.valueOf("amqp:delete-on-no-links-or-messages:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x000000000000002eL);
-
- private DeleteOnNoLinksOrMessagesType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(DeleteOnNoLinksOrMessages val)
- {
- return Collections.EMPTY_LIST;
- }
-
- public DeleteOnNoLinksOrMessages newInstance(Object described)
- {
- return DeleteOnNoLinksOrMessages.getInstance();
- }
-
- public Class<DeleteOnNoLinksOrMessages> getTypeClass()
- {
- return DeleteOnNoLinksOrMessages.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DeleteOnNoLinksOrMessagesType type = new DeleteOnNoLinksOrMessagesType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoLinksType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoLinksType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoLinksType.java
deleted file mode 100644
index f39f30a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoLinksType.java
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.DeleteOnNoLinks;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-public class DeleteOnNoLinksType extends AbstractDescribedType<DeleteOnNoLinks,List> implements DescribedTypeConstructor<DeleteOnNoLinks>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x000000000000002cL), Symbol.valueOf("amqp:delete-on-no-links:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x000000000000002cL);
-
- private DeleteOnNoLinksType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(DeleteOnNoLinks val)
- {
- return Collections.EMPTY_LIST;
- }
-
- @Override
- public DeleteOnNoLinks newInstance(Object described)
- {
- return DeleteOnNoLinks.getInstance();
- }
-
- @Override
- public Class<DeleteOnNoLinks> getTypeClass()
- {
- return DeleteOnNoLinks.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DeleteOnNoLinksType type = new DeleteOnNoLinksType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoMessagesType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoMessagesType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoMessagesType.java
deleted file mode 100644
index 3ac7039..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeleteOnNoMessagesType.java
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.DeleteOnNoMessages;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class DeleteOnNoMessagesType extends AbstractDescribedType<DeleteOnNoMessages,List> implements DescribedTypeConstructor<DeleteOnNoMessages>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x000000000000002dL), Symbol.valueOf("amqp:delete-on-no-messages:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x000000000000002dL);
-
- private DeleteOnNoMessagesType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(DeleteOnNoMessages val)
- {
- return Collections.EMPTY_LIST;
- }
-
- @Override
- public DeleteOnNoMessages newInstance(Object described)
- {
- return DeleteOnNoMessages.getInstance();
- }
-
- @Override
- public Class<DeleteOnNoMessages> getTypeClass()
- {
- return DeleteOnNoMessages.class;
- }
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DeleteOnNoMessagesType type = new DeleteOnNoMessagesType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeliveryAnnotationsType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeliveryAnnotationsType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeliveryAnnotationsType.java
deleted file mode 100644
index abd422d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DeliveryAnnotationsType.java
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class DeliveryAnnotationsType extends AbstractDescribedType<DeliveryAnnotations,Map> implements DescribedTypeConstructor<DeliveryAnnotations>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000071L), Symbol.valueOf("amqp:delivery-annotations:map"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000071L);
-
- public DeliveryAnnotationsType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected Map wrap(DeliveryAnnotations val)
- {
- return val.getValue();
- }
-
-
- public DeliveryAnnotations newInstance(Object described)
- {
- return new DeliveryAnnotations( (Map) described );
- }
-
- public Class<DeliveryAnnotations> getTypeClass()
- {
- return DeliveryAnnotations.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DeliveryAnnotationsType type = new DeliveryAnnotationsType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FooterType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FooterType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FooterType.java
deleted file mode 100644
index a7c3237..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FooterType.java
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Footer;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class FooterType extends AbstractDescribedType<Footer,Map> implements DescribedTypeConstructor<Footer>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000078L), Symbol.valueOf("amqp:footer:map"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000078L);
-
- public FooterType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected Map wrap(Footer val)
- {
- return val.getValue();
- }
-
- public Footer newInstance(Object described)
- {
- return new Footer( (Map) described );
- }
-
- public Class<Footer> getTypeClass()
- {
- return Footer.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- FooterType type = new FooterType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java
deleted file mode 100644
index b7f5a43..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java
+++ /dev/null
@@ -1,158 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Header;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class HeaderType extends AbstractDescribedType<Header,List> implements DescribedTypeConstructor<Header>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000070L), Symbol.valueOf("amqp:header:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000070L);
-
- public HeaderType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- @Override
- protected UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Header val)
- {
- return new HeaderWrapper(val);
- }
-
-
- public static final class HeaderWrapper extends AbstractList
- {
- private final Header _impl;
-
- public HeaderWrapper(Header impl)
- {
- _impl = impl;
- }
-
-
- @Override
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _impl.getDurable();
- case 1:
- return _impl.getPriority();
- case 2:
- return _impl.getTtl();
- case 3:
- return _impl.getFirstAcquirer();
- case 4:
- return _impl.getDeliveryCount();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _impl.getDeliveryCount() != null
- ? 5
- : _impl.getFirstAcquirer() != null
- ? 4
- : _impl.getTtl() != null
- ? 3
- : _impl.getPriority() != null
- ? 2
- : _impl.getDurable() != null
- ? 1
- : 0;
-
- }
-
-
- }
-
- public Header newInstance(Object described)
- {
- List l = (List) described;
-
- Header o = new Header();
-
-
- switch(5 - l.size())
- {
-
- case 0:
- o.setDeliveryCount( (UnsignedInteger) l.get( 4 ) );
- case 1:
- o.setFirstAcquirer( (Boolean) l.get( 3 ) );
- case 2:
- o.setTtl( (UnsignedInteger) l.get( 2 ) );
- case 3:
- o.setPriority( (UnsignedByte) l.get( 1 ) );
- case 4:
- o.setDurable( (Boolean) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Header> getTypeClass()
- {
- return Header.class;
- }
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- HeaderType type = new HeaderType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/MessageAnnotationsType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/MessageAnnotationsType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/MessageAnnotationsType.java
deleted file mode 100644
index 08fb632..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/MessageAnnotationsType.java
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-import java.util.Map;
-
-
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class MessageAnnotationsType extends AbstractDescribedType<MessageAnnotations,Map> implements DescribedTypeConstructor<MessageAnnotations>
-
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000072L), Symbol.valueOf("amqp:message-annotations:map"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000072L);
-
- public MessageAnnotationsType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected Map wrap(MessageAnnotations val)
- {
- return val.getValue();
- }
-
-
- public MessageAnnotations newInstance(Object described)
- {
- return new MessageAnnotations( (Map) described );
- }
-
- public Class<MessageAnnotations> getTypeClass()
- {
- return MessageAnnotations.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- MessageAnnotationsType constructor = new MessageAnnotationsType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, constructor);
- }
- encoder.register(constructor);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ModifiedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ModifiedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ModifiedType.java
deleted file mode 100644
index fdcacc0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ModifiedType.java
+++ /dev/null
@@ -1,143 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Modified;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class ModifiedType extends AbstractDescribedType<Modified,List> implements DescribedTypeConstructor<Modified>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000027L), Symbol.valueOf("amqp:modified:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000027L);
-
- private ModifiedType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Modified val)
- {
- return new ModifiedWrapper(val);
- }
-
-
- public static final class ModifiedWrapper extends AbstractList
- {
- private final Modified _impl;
-
- public ModifiedWrapper(Modified impl)
- {
- _impl = impl;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _impl.getDeliveryFailed();
- case 1:
- return _impl.getUndeliverableHere();
- case 2:
- return _impl.getMessageAnnotations();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _impl.getMessageAnnotations() != null
- ? 3
- : _impl.getUndeliverableHere() != null
- ? 2
- : _impl.getDeliveryFailed() != null
- ? 1
- : 0;
-
- }
-
- }
-
- public Modified newInstance(Object described)
- {
- List l = (List) described;
-
- Modified o = new Modified();
-
-
- switch(3 - l.size())
- {
-
- case 0:
- o.setMessageAnnotations( (Map) l.get( 2 ) );
- case 1:
- o.setUndeliverableHere( (Boolean) l.get( 1 ) );
- case 2:
- o.setDeliveryFailed( (Boolean) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Modified> getTypeClass()
- {
- return Modified.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- ModifiedType type = new ModifiedType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java
deleted file mode 100644
index 818aaa8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java
+++ /dev/null
@@ -1,205 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.AbstractList;
-import java.util.Date;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Properties;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class PropertiesType extends AbstractDescribedType<Properties,List> implements DescribedTypeConstructor<Properties>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000073L), Symbol.valueOf("amqp:properties:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000073L);
-
- private PropertiesType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Properties val)
- {
- return new PropertiesWrapper(val);
- }
-
- private static final class PropertiesWrapper extends AbstractList
- {
-
- private Properties _impl;
-
- public PropertiesWrapper(Properties propertiesType)
- {
- _impl = propertiesType;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _impl.getMessageId();
- case 1:
- return _impl.getUserId();
- case 2:
- return _impl.getTo();
- case 3:
- return _impl.getSubject();
- case 4:
- return _impl.getReplyTo();
- case 5:
- return _impl.getCorrelationId();
- case 6:
- return _impl.getContentType();
- case 7:
- return _impl.getContentEncoding();
- case 8:
- return _impl.getAbsoluteExpiryTime();
- case 9:
- return _impl.getCreationTime();
- case 10:
- return _impl.getGroupId();
- case 11:
- return _impl.getGroupSequence();
- case 12:
- return _impl.getReplyToGroupId();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _impl.getReplyToGroupId() != null
- ? 13
- : _impl.getGroupSequence() != null
- ? 12
- : _impl.getGroupId() != null
- ? 11
- : _impl.getCreationTime() != null
- ? 10
- : _impl.getAbsoluteExpiryTime() != null
- ? 9
- : _impl.getContentEncoding() != null
- ? 8
- : _impl.getContentType() != null
- ? 7
- : _impl.getCorrelationId() != null
- ? 6
- : _impl.getReplyTo() != null
- ? 5
- : _impl.getSubject() != null
- ? 4
- : _impl.getTo() != null
- ? 3
- : _impl.getUserId() != null
- ? 2
- : _impl.getMessageId() != null
- ? 1
- : 0;
-
- }
-
- }
-
- public Properties newInstance(Object described)
- {
- List l = (List) described;
-
- Properties o = new Properties();
-
-
- switch(13 - l.size())
- {
-
- case 0:
- o.setReplyToGroupId( (String) l.get( 12 ) );
- case 1:
- o.setGroupSequence( (UnsignedInteger) l.get( 11 ) );
- case 2:
- o.setGroupId( (String) l.get( 10 ) );
- case 3:
- o.setCreationTime( (Date) l.get( 9 ) );
- case 4:
- o.setAbsoluteExpiryTime( (Date) l.get( 8 ) );
- case 5:
- o.setContentEncoding( (Symbol) l.get( 7 ) );
- case 6:
- o.setContentType( (Symbol) l.get( 6 ) );
- case 7:
- o.setCorrelationId( (Object) l.get( 5 ) );
- case 8:
- o.setReplyTo( (String) l.get( 4 ) );
- case 9:
- o.setSubject( (String) l.get( 3 ) );
- case 10:
- o.setTo( (String) l.get( 2 ) );
- case 11:
- o.setUserId( (Binary) l.get( 1 ) );
- case 12:
- o.setMessageId( (Object) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Properties> getTypeClass()
- {
- return Properties.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- PropertiesType type = new PropertiesType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ReceivedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ReceivedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ReceivedType.java
deleted file mode 100644
index d10fed6..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ReceivedType.java
+++ /dev/null
@@ -1,135 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Received;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public final class ReceivedType extends AbstractDescribedType<Received,List> implements DescribedTypeConstructor<Received>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000023L), Symbol.valueOf("amqp:received:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000023L);
-
- private ReceivedType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Received val)
- {
- return new ReceivedWrapper(val);
- }
-
-
- private static final class ReceivedWrapper extends AbstractList
- {
- private final Received _impl;
-
- private ReceivedWrapper(Received impl)
- {
- _impl = impl;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _impl.getSectionNumber();
- case 1:
- return _impl.getSectionOffset();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _impl.getSectionOffset() != null
- ? 2
- : _impl.getSectionOffset() != null
- ? 1
- : 0;
-
- }
- }
-
- public Received newInstance(Object described)
- {
- List l = (List) described;
-
- Received o = new Received();
-
-
- switch(2 - l.size())
- {
-
- case 0:
- o.setSectionOffset( (UnsignedLong) l.get( 1 ) );
- case 1:
- o.setSectionNumber( (UnsignedInteger) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Received> getTypeClass()
- {
- return Received.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- ReceivedType type = new ReceivedType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[04/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/org/apache/qpid/proton/InteropTest.java
----------------------------------------------------------------------
diff --git a/tests/java/org/apache/qpid/proton/InteropTest.java b/tests/java/org/apache/qpid/proton/InteropTest.java
deleted file mode 100644
index e9b8c58..0000000
--- a/tests/java/org/apache/qpid/proton/InteropTest.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.proton;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.codec.AMQPDefinedTypes;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DecoderImpl;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.message.Message;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertArrayEquals;
-import org.junit.Test;
-import java.lang.System;
-import java.nio.ByteBuffer;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Vector;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-
-public class InteropTest
-{
-
- static private File findTestsInteropDir()
- {
- File f = new File(System.getProperty("user.dir"));
- while (f != null && !f.getName().equals("tests"))
- f = f.getParentFile();
- if (f != null && f.isDirectory())
- return new File(f, "interop");
- else
- throw new Error("Cannot find tests/interop directory");
- }
-
- static File testsInteropDir = findTestsInteropDir();
-
- byte[] getBytes(String name) throws IOException
- {
- File f = new File(testsInteropDir, name + ".amqp");
- byte[] data = new byte[(int) f.length()];
- FileInputStream fi = new FileInputStream(f);
- assertEquals(f.length(), fi.read(data));
- fi.close();
- return data;
- }
-
- Message decodeMessage(String name) throws IOException
- {
- byte[] data = getBytes(name);
- Message m = Proton.message();
- m.decode(data, 0, data.length);
- return m;
- }
-
- Decoder createDecoder(byte[] data)
- {
- DecoderImpl decoder = new DecoderImpl();
- AMQPDefinedTypes.registerAllTypes(decoder, new EncoderImpl(decoder));
- ByteBuffer buffer = ByteBuffer.allocate(data.length);
- buffer.put(data);
- buffer.rewind();
- decoder.setByteBuffer(buffer);
-
- return decoder;
- }
-
- @Test
- public void testMessage() throws IOException
- {
- Message m = decodeMessage("message");
- Binary b = (Binary) (((AmqpValue) m.getBody()).getValue());
- String s = createDecoder(b.getArray()).readString();
- assertEquals("hello", s);
- }
-
- @Test
- public void testPrimitives() throws IOException
- {
- Decoder d = createDecoder(getBytes("primitives"));
- assertEquals(true, d.readBoolean());
- assertEquals(false, d.readBoolean());
- assertEquals(d.readUnsignedByte().intValue(), 42);
- assertEquals(42, d.readUnsignedShort().intValue());
- assertEquals(-42, d.readShort().intValue());
- assertEquals(12345, d.readUnsignedInteger().intValue());
- assertEquals(-12345, d.readInteger().intValue());
- assertEquals(12345, d.readUnsignedLong().longValue());
- assertEquals(-12345, d.readLong().longValue());
- assertEquals(0.125, d.readFloat().floatValue(), 0e-10);
- assertEquals(0.125, d.readDouble().doubleValue(), 0e-10);
- }
-
- @Test
- public void testStrings() throws IOException
- {
- Decoder d = createDecoder(getBytes("strings"));
- assertEquals(new Binary("abc\0defg".getBytes("UTF-8")), d.readBinary());
- assertEquals("abcdefg", d.readString());
- assertEquals(Symbol.valueOf("abcdefg"), d.readSymbol());
- assertEquals(new Binary(new byte[0]), d.readBinary());
- assertEquals("", d.readString());
- assertEquals(Symbol.valueOf(""), d.readSymbol());
- }
-
- @Test
- public void testDescribed() throws IOException
- {
- Decoder d = createDecoder(getBytes("described"));
- DescribedType dt = (DescribedType) (d.readObject());
- assertEquals(Symbol.valueOf("foo-descriptor"), dt.getDescriptor());
- assertEquals("foo-value", dt.getDescribed());
-
- dt = (DescribedType) (d.readObject());
- assertEquals(12, dt.getDescriptor());
- assertEquals(13, dt.getDescribed());
- }
-
- @Test
- public void testDescribedArray() throws IOException
- {
- Decoder d = createDecoder(getBytes("described_array"));
- DescribedType a[] = (DescribedType[]) (d.readArray());
- for (int i = 0; i < 10; ++i)
- {
- assertEquals(Symbol.valueOf("int-array"), a[i].getDescriptor());
- assertEquals(i, a[i].getDescribed());
- }
- }
-
- @Test
- public void testArrays() throws IOException
- {
- Decoder d = createDecoder(getBytes("arrays"));
-
- // int array
- Vector<Integer> ints = new Vector<Integer>();
- for (int i = 0; i < 100; ++i)
- ints.add(new Integer(i));
- assertArrayEquals(ints.toArray(), d.readArray());
-
- // String array
- String strings[] =
- { "a", "b", "c" };
- assertArrayEquals(strings, d.readArray());
-
- // Empty array
- assertArrayEquals(new Integer[0], d.readArray());
- }
-
- @Test
- public void testLists() throws IOException
- {
- Decoder d = createDecoder(getBytes("lists"));
- List<Object> l = new ArrayList<Object>()
- {
- {
- add(new Integer(32));
- add("foo");
- add(new Boolean(true));
- }
- };
- assertEquals(l, d.readList());
- l.clear();
- assertEquals(l, d.readList());
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testMaps() throws IOException
- {
- Decoder d = createDecoder(getBytes("maps"));
- Map map = new HashMap()
- {
- {
- put("one", 1);
- put("two", 2);
- put("three", 3);
- }
- };
- assertEquals(map, d.readMap());
-
- map = new HashMap()
- {
- {
- put(1, "one");
- put(2, "two");
- put(3, "three");
- }
- };
- assertEquals(map, d.readMap());
-
- map = new HashMap();
- assertEquals(map, d.readMap());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/org/apache/qpid/proton/JythonTest.java
----------------------------------------------------------------------
diff --git a/tests/java/org/apache/qpid/proton/JythonTest.java b/tests/java/org/apache/qpid/proton/JythonTest.java
deleted file mode 100644
index 23eceab..0000000
--- a/tests/java/org/apache/qpid/proton/JythonTest.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.Test;
-import org.python.core.PyException;
-import org.python.core.PyString;
-import org.python.core.PySystemState;
-import org.python.util.PythonInterpreter;
-
-/**
- * Runs all the python tests, or just those that match the system property {@value #TEST_PATTERN_SYSTEM_PROPERTY}
- * if it exists.
- * Use {@value #TEST_INVOCATIONS_SYSTEM_PROPERTY} to specify the number of repetitions, or use 0
- * for unlimited repetitions.
- */
-public class JythonTest
-{
- public interface PathBuilder {
- public PathBuilder append(String path);
- }
- private static final Logger LOGGER = Logger.getLogger(JythonTest.class.getName());
-
- /* System properties expected to be defined in test/pom.xml */
- private static final String PROTON_JYTHON_BINDING = "protonJythonBinding";
- private static final String PROTON_JYTHON_SHIM = "protonJythonShim";
- private static final String PROTON_JYTHON_TEST_ROOT = "protonJythonTestRoot";
- private static final String PROTON_JYTHON_TEST_SCRIPT = "protonJythonTestScript";
- private static final String PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY = "protonJythonTestXmlOutputDirectory";
- private static final String PROTON_JYTHON_IGNORE_FILE = "protonJythonIgnoreFile";
-
- /** Name of the junit style xml report to be written by the python test script */
- private static final String XML_REPORT_NAME = "TEST-jython-test-results.xml";
-
- public static final String TEST_PATTERN_SYSTEM_PROPERTY = "proton.pythontest.pattern";
- public static final String IGNORE_FILE_SYSTEM_PROPERTY = "proton.pythontest.ignore_file";
-
- /** The number of times to run the test, or forever if zero */
- public static final String TEST_INVOCATIONS_SYSTEM_PROPERTY = "proton.pythontest.invocations";
-
- public static final String ALWAYS_COLORIZE_SYSTEM_PROPERTY = "proton.pythontest.always_colorize";
-
- @Test
- public void test() throws Exception
- {
- String testScript = getJythonTestScript();
- String testRoot = getJythonTestRoot();
- String xmlReportFile = getOptionalXmlReportFilename();
- String ignoreFile = getOptionalIgnoreFile();
-
- final PythonInterpreter interp = createInterpreterWithArgs(xmlReportFile, ignoreFile);
- PathBuilder pathBuilder = new PathBuilder() {
- @Override
- public PathBuilder append(String path) {
- interp.getSystemState().path.insert(0, new PyString(path));
- return this;
- }
- };
- extendPath(pathBuilder);
-
- LOGGER.info("About to call Jython test script: '" + testScript
- + "' with '" + testRoot + "' added to Jython path");
-
- int maxInvocations = Integer.getInteger(TEST_INVOCATIONS_SYSTEM_PROPERTY, 1);
- assertTrue("Number of invocations should be non-negative", maxInvocations >= 0);
- boolean loopForever = maxInvocations == 0;
- if(maxInvocations > 1)
- {
- LOGGER.info("Will invoke Python test " + maxInvocations + " times");
- }
- if(loopForever)
- {
- LOGGER.info("Will repeatedly invoke Python test forever");
- }
- int invocations = 1;
- while(loopForever || invocations++ <= maxInvocations)
- {
- runTestOnce(testScript, interp, invocations);
- }
- }
-
- protected void extendPath(PathBuilder pathBuilder) throws Exception {
- String binding = getJythonBinding();
- String shim = getJythonShim();
- String testRoot = getJythonTestRoot();
- pathBuilder.append(binding).append(shim).append(testRoot);
-
- }
-
- private void runTestOnce(String testScript, PythonInterpreter interp, int invocationsSoFar)
- {
- try
- {
- interp.execfile(testScript);
- }
- catch (PyException e)
- {
- if( e.type.toString().equals("<type 'exceptions.SystemExit'>") && e.value.toString().equals("0") )
- {
- // Build succeeded.
- }
- else
- {
- if (LOGGER.isLoggable(Level.FINE))
- {
- LOGGER.log(Level.FINE, "Jython interpreter failed. Test failures?", e);
- }
-
- // This unusual code is necessary because PyException toString() contains the useful Python traceback
- // and getMessage() is usually null
- fail("Caught PyException on invocation number " + invocationsSoFar + ": " + e.toString() + " with message: " + e.getMessage());
- }
- }
- }
-
- private PythonInterpreter createInterpreterWithArgs(String xmlReportFile, String ignoreFile)
- {
- PySystemState systemState = new PySystemState();
-
- if (xmlReportFile != null)
- {
- systemState.argv.append(new PyString("--xml"));
- systemState.argv.append(new PyString(xmlReportFile));
- }
-
- if(ignoreFile == null)
- {
- ignoreFile = System.getProperty(IGNORE_FILE_SYSTEM_PROPERTY);
- }
-
- if(ignoreFile != null)
- {
- systemState.argv.append(new PyString("-I"));
- systemState.argv.append(new PyString(ignoreFile));
- }
-
- String testPattern = System.getProperty(TEST_PATTERN_SYSTEM_PROPERTY);
- if(testPattern != null)
- {
- systemState.argv.append(new PyString(testPattern));
- }
-
- if(Boolean.getBoolean(ALWAYS_COLORIZE_SYSTEM_PROPERTY))
- {
- systemState.argv.append(new PyString("--always-colorize"));
- }
-
- PythonInterpreter interp = new PythonInterpreter(null, systemState);
- return interp;
- }
-
- private String getJythonTestScript() throws FileNotFoundException
- {
- String testScriptString = getNonNullSystemProperty(PROTON_JYTHON_TEST_SCRIPT, "System property '%s' must provide the location of the python test script");
- File testScript = new File(testScriptString);
- if (!testScript.canRead())
- {
- throw new FileNotFoundException("Can't read python test script " + testScript);
- }
- return testScript.getAbsolutePath();
- }
-
- private String getJythonBinding() throws FileNotFoundException
- {
- String str = getNonNullSystemProperty(PROTON_JYTHON_BINDING, "System property '%s' must provide the location of the proton python binding");
- File file = new File(str);
- if (!file.isDirectory())
- {
- throw new FileNotFoundException("Binding location '" + file + "' should be a directory.");
- }
- return file.getAbsolutePath();
- }
-
- private String getJythonShim() throws FileNotFoundException
- {
- String str = getNonNullSystemProperty(PROTON_JYTHON_SHIM, "System property '%s' must provide the location of the proton jython shim");
- File file = new File(str);
- if (!file.isDirectory())
- {
- throw new FileNotFoundException("Shim location '" + file + "' should be a directory.");
- }
- return file.getAbsolutePath();
- }
-
-
- private String getJythonTestRoot() throws FileNotFoundException
- {
- String testRootString = getNonNullSystemProperty(PROTON_JYTHON_TEST_ROOT, "System property '%s' must provide the location of the python test root");
- File testRoot = new File(testRootString);
- if (!testRoot.isDirectory())
- {
- throw new FileNotFoundException("Test root '" + testRoot + "' should be a directory.");
- }
- return testRoot.getAbsolutePath();
- }
-
- private String getOptionalIgnoreFile()
- {
- String ignoreFile = System.getProperty(PROTON_JYTHON_IGNORE_FILE);
-
- if(ignoreFile != null)
- {
- File f = new File(ignoreFile);
- if(f.exists() && f.canRead())
- {
- return ignoreFile;
- }
- else
- {
- LOGGER.info(PROTON_JYTHON_IGNORE_FILE + " system property set to " + ignoreFile + " but this cannot be read.");
- }
- }
- return null;
-
- }
-
- private String getOptionalXmlReportFilename()
- {
- String xmlOutputDirString = System.getProperty(PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY);
- if (xmlOutputDirString == null)
- {
- LOGGER.info(PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY + " system property not set; xml output will not be written");
- }
-
- File xmlOutputDir = new File(xmlOutputDirString);
- createXmlOutputDirectoryIfNecessary(xmlOutputDirString, xmlOutputDir);
- return new File(xmlOutputDir, XML_REPORT_NAME).getAbsolutePath();
- }
-
- private void createXmlOutputDirectoryIfNecessary(String xmlOutputDirString, File xmlOutputDir)
- {
- if (!xmlOutputDir.isDirectory())
- {
- boolean success = xmlOutputDir.mkdirs();
- if (!success)
- {
- LOGGER.warning("Failed to create directory " + xmlOutputDir + " Thread name :" + Thread.currentThread().getName());
- }
-
- if (!xmlOutputDir.isDirectory())
- {
- throw new RuntimeException("Failed to create one or more directories with path " + xmlOutputDirString);
- }
- }
- }
-
- protected String getNonNullSystemProperty(String systemProperty, String messageWithStringFormatToken)
- {
- String testScriptString = System.getProperty(systemProperty);
- if (testScriptString == null)
- {
- String message = messageWithStringFormatToken;
- throw new IllegalStateException(String.format(message, systemProperty));
- }
- return testScriptString;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/org/apache/qpid/proton/ProtonJInterop.java
----------------------------------------------------------------------
diff --git a/tests/java/org/apache/qpid/proton/ProtonJInterop.java b/tests/java/org/apache/qpid/proton/ProtonJInterop.java
deleted file mode 100644
index 58a9c31..0000000
--- a/tests/java/org/apache/qpid/proton/ProtonJInterop.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.proton;
-
-import java.io.IOException;
-import java.nio.BufferOverflowException;
-
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Receiver;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.message.Message;
-import org.apache.qpid.proton.reactor.Acceptor;
-import org.apache.qpid.proton.reactor.FlowController;
-import org.apache.qpid.proton.reactor.Handshaker;
-import org.apache.qpid.proton.reactor.Reactor;
-
-public class ProtonJInterop {
-
- private static class SendHandler extends BaseHandler {
-
- private int numMsgs;
- private int count = 0;
- private boolean result = false;
-
- private SendHandler(int numMsgs) {
- this.numMsgs = numMsgs;
- add(new Handshaker());
- }
-
- @Override
- public void onConnectionInit(Event event) {
- Connection conn = event.getConnection();
- Session ssn = conn.session();
- Sender snd = ssn.sender("sender");
- conn.open();
- ssn.open();
- snd.open();
- }
-
- @Override
- public void onLinkFlow(Event event) {
- Sender snd = (Sender)event.getLink();
- if (snd.getCredit() > 0 && snd.getLocalState() != EndpointState.CLOSED) {
- Message message = Proton.message();
- ++count;
- message.setBody(new AmqpValue("message-"+count));
- byte[] msgData = new byte[1024];
- int length;
- while(true) {
- try {
- length = message.encode(msgData, 0, msgData.length);
- break;
- } catch(BufferOverflowException e) {
- msgData = new byte[msgData.length * 2];
- }
- }
- byte[] tag = String.valueOf(count).getBytes();
- Delivery dlv = snd.delivery(tag);
- snd.send(msgData, 0, length);
- dlv.settle();
- snd.advance();
- if (count == numMsgs) {
- snd.close();
- snd.getSession().close();
- snd.getSession().getConnection().close();
- result = true;
- }
- }
- }
-
- @Override
- public void onTransportError(Event event) {
- result = false;
- ErrorCondition condition = event.getTransport().getCondition();
- if (condition != null) {
- System.err.println("Error: " + condition.getDescription());
- } else {
- System.err.println("Error (no description returned).");
- }
- }
- }
-
- private static class Send extends BaseHandler {
- private final SendHandler sendHandler;
- private final String host;
- private final int port;
-
- private Send(String host, int port, int numMsgs) {
- this.host = host;
- this.port = port;
- sendHandler = new SendHandler(numMsgs);
- }
-
- @Override
- public void onReactorInit(Event event) {
- Reactor r = event.getReactor();
- r.connectionToHost(host, port, sendHandler);
- }
-
- public boolean getResult() {
- return sendHandler.result;
- }
- }
-
- private static class Recv extends BaseHandler {
- private final int port;
- private final int numMsgs;
- private int count = 0;
- private Acceptor acceptor = null;
-
- private Recv(int port, int numMsgs) {
- this.port = port;
- this.numMsgs = numMsgs;
- add(new Handshaker());
- add(new FlowController());
- }
-
- @Override
- public void onReactorInit(Event event) {
- try {
- acceptor = event.getReactor().acceptor("localhost", port);
- } catch(IOException ioException) {
- throw new RuntimeException(ioException);
- }
- }
-
- @Override
- public void onDelivery(Event event) {
- Receiver recv = (Receiver)event.getLink();
- Delivery delivery = recv.current();
- if (delivery.isReadable() && !delivery.isPartial()) {
- int size = delivery.pending();
- byte[] buffer = new byte[size];
- int read = recv.recv(buffer, 0, buffer.length);
- recv.advance();
-
- Message msg = Proton.message();
- msg.decode(buffer, 0, read);
-
- ++count;
- String msgBody = ((AmqpValue)msg.getBody()).getValue().toString();
- String expected = "message-" + count;
- if (!expected.equals(msgBody)) {
- throw new RuntimeException("Received message body '" + msgBody + "', expected: '" + expected + "'");
- }
-
- if (count == numMsgs) {
- recv.close();
- recv.getSession().close();
- recv.getSession().getConnection().close();
- acceptor.close();
- }
- }
- }
- }
-
- public static void main(String[] args) throws IOException {
- try {
- int port = Integer.valueOf(args[1]);
- int numMsgs = Integer.valueOf(args[2]);
- boolean result = false;
-
- if ("send".equalsIgnoreCase(args[0])) {
- Send send = new Send("localhost", port, numMsgs);
- Reactor r = Proton.reactor(send);
- r.run();
- result = send.getResult();
- } else {
- Reactor r = Proton.reactor(new Recv(port, numMsgs));
- r.run();
- result = true;
- }
- System.exit(result ? 0 : 1);
- } catch(Throwable t) {
- t.printStackTrace();
- System.exit(1);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/pythonTests.ignore
----------------------------------------------------------------------
diff --git a/tests/java/pythonTests.ignore b/tests/java/pythonTests.ignore
deleted file mode 100644
index 7911176..0000000
--- a/tests/java/pythonTests.ignore
+++ /dev/null
@@ -1,4 +0,0 @@
-proton_tests.reactor_interop.*
-proton_tests.soak.*
-proton_tests.ssl.SslTest.test_defaults_messenger_app
-proton_tests.ssl.SslTest.test_server_authentication_messenger_app
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/ccodec.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/ccodec.py b/tests/java/shim/ccodec.py
deleted file mode 100644
index 0aa9499..0000000
--- a/tests/java/shim/ccodec.py
+++ /dev/null
@@ -1,356 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-from org.apache.qpid.proton import Proton
-from org.apache.qpid.proton.amqp import Symbol, UnsignedByte, UnsignedInteger, \
- UnsignedShort, UnsignedLong, Decimal32, Decimal64, Decimal128
-from org.apache.qpid.proton.codec.Data import DataType
-from cerror import *
-
-from java.util import UUID as JUUID, Date as JDate
-from java.nio import ByteBuffer
-from compat import array, zeros
-
-# from proton/codec.h
-PN_NULL = 1
-PN_BOOL = 2
-PN_UBYTE = 3
-PN_BYTE = 4
-PN_USHORT = 5
-PN_SHORT = 6
-PN_UINT = 7
-PN_INT = 8
-PN_CHAR = 9
-PN_ULONG = 10
-PN_LONG = 11
-PN_TIMESTAMP = 12
-PN_FLOAT = 13
-PN_DOUBLE = 14
-PN_DECIMAL32 = 15
-PN_DECIMAL64 = 16
-PN_DECIMAL128 = 17
-PN_UUID = 18
-PN_BINARY = 19
-PN_STRING = 20
-PN_SYMBOL = 21
-PN_DESCRIBED = 22
-PN_ARRAY = 23
-PN_LIST = 24
-PN_MAP = 25
-
-DATA_TYPES_J2P = {}
-DATA_TYPES_P2J = {}
-
-def DATA_TYPES(jtype, ptype):
- DATA_TYPES_J2P[jtype] = ptype
- DATA_TYPES_P2J[ptype] = jtype
-
-DATA_TYPES(DataType.NULL, PN_NULL)
-DATA_TYPES(DataType.BOOL, PN_BOOL)
-DATA_TYPES(DataType.BYTE, PN_BYTE)
-DATA_TYPES(DataType.UBYTE, PN_UBYTE)
-DATA_TYPES(DataType.USHORT, PN_USHORT)
-DATA_TYPES(DataType.UINT, PN_UINT)
-DATA_TYPES(DataType.ULONG, PN_ULONG)
-DATA_TYPES(DataType.SHORT, PN_SHORT)
-DATA_TYPES(DataType.INT, PN_INT)
-DATA_TYPES(DataType.LONG, PN_LONG)
-DATA_TYPES(DataType.CHAR, PN_CHAR)
-DATA_TYPES(DataType.TIMESTAMP, PN_TIMESTAMP)
-DATA_TYPES(DataType.FLOAT, PN_FLOAT)
-DATA_TYPES(DataType.DOUBLE, PN_DOUBLE)
-DATA_TYPES(DataType.DECIMAL32, PN_DECIMAL32)
-DATA_TYPES(DataType.DECIMAL64, PN_DECIMAL64)
-DATA_TYPES(DataType.DECIMAL128, PN_DECIMAL128)
-DATA_TYPES(DataType.BINARY, PN_BINARY)
-DATA_TYPES(DataType.STRING, PN_STRING)
-DATA_TYPES(DataType.SYMBOL, PN_SYMBOL)
-DATA_TYPES(DataType.UUID, PN_UUID)
-DATA_TYPES(DataType.LIST, PN_LIST)
-DATA_TYPES(DataType.MAP, PN_MAP)
-DATA_TYPES(DataType.ARRAY, PN_ARRAY)
-DATA_TYPES(DataType.DESCRIBED, PN_DESCRIBED)
-
-def pn_data(capacity):
- return Proton.data(capacity)
-
-def pn_data_put_null(data):
- data.putNull()
- return 0
-
-def pn_data_put_bool(data, b):
- data.putBoolean(b)
- return 0
-
-def pn_data_get_bool(data):
- return data.getBoolean()
-
-def pn_data_get_byte(data):
- return data.getByte()
-
-def pn_data_put_byte(data, u):
- data.putByte(u)
- return 0
-
-def pn_data_get_ubyte(data):
- return data.getUnsignedByte().longValue()
-
-def pn_data_put_ubyte(data, u):
- data.putUnsignedByte(UnsignedByte.valueOf(u))
- return 0
-
-def pn_data_get_ushort(data):
- return data.getUnsignedShort().longValue()
-
-def pn_data_put_ushort(data, u):
- data.putUnsignedShort(UnsignedShort.valueOf(u))
- return 0
-
-def pn_data_get_uint(data):
- return data.getUnsignedInteger().longValue()
-
-def pn_data_put_uint(data, u):
- data.putUnsignedInteger(UnsignedInteger.valueOf(u))
- return 0
-
-def pn_data_put_ulong(data, u):
- data.putUnsignedLong(UnsignedLong.valueOf(u))
- return 0
-
-BITS_64 = 2**64 - 1;
-
-def pn_data_get_ulong(data):
- value = data.getUnsignedLong().longValue()
- if value < 0:
- return value & BITS_64;
- return value
-
-def pn_data_get_short(data):
- return data.getShort()
-
-def pn_data_put_short(data, s):
- data.putShort(s)
- return 0
-
-def pn_data_put_int(data, i):
- data.putInt(i)
- return 0
-
-def pn_data_get_int(data):
- return data.getInt()
-
-def pn_data_put_long(data, l):
- data.putLong(l)
- return 0
-
-def pn_data_get_long(data):
- return data.getLong()
-
-def pn_data_put_char(data, c):
- data.putChar(c)
- return 0
-
-def pn_data_get_char(data):
- return data.getChar()
-
-def pn_data_put_timestamp(data, t):
- data.putTimestamp(JDate(t))
- return 0
-
-def pn_data_get_timestamp(data):
- return data.getTimestamp().getTime()
-
-def pn_data_put_float(data, f):
- data.putFloat(f)
- return 0
-
-def pn_data_get_float(data):
- return data.getFloat()
-
-def pn_data_put_double(data, d):
- data.putDouble(d)
- return 0
-
-def pn_data_get_double(data):
- return data.getDouble()
-
-def pn_data_put_decimal32(data, d):
- data.putDecimal32(Decimal32(d))
- return 0
-
-def pn_data_get_decimal32(data):
- return data.getDecimal32().getBits()
-
-def pn_data_put_decimal64(data, d):
- data.putDecimal64(Decimal64(d))
- return 0
-
-def pn_data_get_decimal64(data):
- return data.getDecimal64().getBits()
-
-def pn_data_put_decimal128(data, d):
- data.putDecimal128(Decimal128(array(d, 'b')))
- return 0
-
-def pn_data_get_decimal128(data):
- return data.getDecimal128().asBytes().tostring()
-
-def pn_data_put_binary(data, b):
- data.putBinary(array(b, 'b'))
- return 0
-
-def pn_data_get_binary(data):
- return data.getBinary().getArray().tostring()
-
-def pn_data_put_string(data, s):
- data.putString(s)
- return 0
-
-def pn_data_get_string(data):
- return data.getString()
-
-def pn_data_put_symbol(data, s):
- data.putSymbol(Symbol.valueOf(s))
- return 0
-
-def pn_data_get_symbol(data):
- return data.getSymbol().toString()
-
-def pn_data_put_uuid(data, u):
- bb = ByteBuffer.wrap(array(u, 'b'))
- first = bb.getLong()
- second = bb.getLong()
- data.putUUID(JUUID(first, second))
- return 0
-
-def pn_data_get_uuid(data):
- u = data.getUUID()
- ba = zeros(16, 'b')
- bb = ByteBuffer.wrap(ba)
- bb.putLong(u.getMostSignificantBits())
- bb.putLong(u.getLeastSignificantBits())
- return ba.tostring()
-
-def pn_data_put_list(data):
- data.putList()
- return 0
-
-def pn_data_get_list(data):
- return data.getList()
-
-def pn_data_put_map(data):
- data.putMap()
- return 0
-
-def pn_data_put_array(data, described, type):
- data.putArray(described, DATA_TYPES_P2J[type])
- return 0
-
-def pn_data_get_array(data):
- return data.getArray()
-
-def pn_data_is_array_described(data):
- return data.isArrayDescribed()
-
-def pn_data_get_array_type(data):
- return DATA_TYPES_J2P[data.getArrayType()]
-
-def pn_data_put_described(data):
- data.putDescribed()
- return 0
-
-def pn_data_rewind(data):
- data.rewind()
-
-def pn_data_next(data):
- t = data.next()
- return t != None
-
-def pn_data_enter(data):
- return data.enter()
-
-def pn_data_exit(data):
- return data.exit()
-
-def pn_data_type(data):
- t = data.type()
- if t is None:
- return -1
- else:
- return DATA_TYPES_J2P[t]
-
-def pn_data_encode(data, size):
- enc = data.encode().getArray().tostring()
- if len(enc) > size:
- return PN_OVERFLOW, None
- else:
- return len(enc), enc
-
-def pn_data_encoded_size(data):
- return data.encodedSize()
-
-def pn_data_decode(data, encoded):
- return data.decode(ByteBuffer.wrap(array(encoded, 'b')))
-
-def pn_data_narrow(data):
- data.narrow()
-
-def pn_data_widen(data):
- data.widen()
-
-def pn_data_copy(data, src):
- data.copy(src)
-
-def pn_data_format(data, n):
- return 0, data.format()
-
-def pn_data_clear(data):
- data.clear()
-
-def pn_data_free(data):
- pass
-
-def dat2obj(dat):
- dat.rewind()
- if dat.next():
- return dat.getObject()
- else:
- return None
-
-def obj2dat(obj, dat=None):
- if dat is None:
- dat = pn_data(0)
- else:
- dat.clear()
- if obj:
- dat.putObject(obj)
- dat.rewind()
- return dat
-
-def array2dat(ary, atype, dat=None):
- if dat is None:
- dat = pn_data(0)
- else:
- dat.clear()
- if ary:
- pn_data_put_array(dat, False, atype)
- pn_data_enter(dat)
- for o in ary:
- dat.putObject(o)
- dat.rewind()
- return dat
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/cengine.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/cengine.py b/tests/java/shim/cengine.py
deleted file mode 100644
index 141c482..0000000
--- a/tests/java/shim/cengine.py
+++ /dev/null
@@ -1,1139 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-from org.apache.qpid.proton import Proton
-from org.apache.qpid.proton.amqp import Symbol
-from org.apache.qpid.proton.amqp.messaging import Source, Target, \
- TerminusDurability, TerminusExpiryPolicy, Received, Accepted, \
- Rejected, Released, Modified
-from org.apache.qpid.proton.amqp.transaction import Coordinator
-from org.apache.qpid.proton.amqp.transport import ErrorCondition, \
- SenderSettleMode, ReceiverSettleMode
-from org.apache.qpid.proton.engine import EndpointState, Sender, \
- Receiver, Transport as _Transport, TransportException, EventType
-
-from java.util import EnumSet
-from compat import array, zeros
-
-from cerror import *
-from ccodec import *
-
-# from proton/engine.h
-PN_LOCAL_UNINIT = 1
-PN_LOCAL_ACTIVE = 2
-PN_LOCAL_CLOSED = 4
-PN_REMOTE_UNINIT = 8
-PN_REMOTE_ACTIVE = 16
-PN_REMOTE_CLOSED = 32
-
-PN_SND_UNSETTLED = 0
-PN_SND_SETTLED = 1
-PN_SND_MIXED = 2
-
-PN_RCV_FIRST = 0
-PN_RCV_SECOND = 1
-
-PN_UNSPECIFIED = 0
-PN_SOURCE = 1
-PN_TARGET = 2
-PN_COORDINATOR = 3
-
-PN_NONDURABLE = 0
-PN_CONFIGURATION = 1
-PN_DELIVERIES = 2
-
-PN_EXPIRE_WITH_LINK = 0
-PN_EXPIRE_WITH_SESSION = 1
-PN_EXPIRE_WITH_CONNECTION = 2
-PN_EXPIRE_NEVER = 3
-
-PN_DIST_MODE_UNSPECIFIED = 0
-PN_DIST_MODE_COPY = 1
-PN_DIST_MODE_MOVE = 2
-
-PN_RECEIVED = (0x0000000000000023)
-PN_ACCEPTED = (0x0000000000000024)
-PN_REJECTED = (0x0000000000000025)
-PN_RELEASED = (0x0000000000000026)
-PN_MODIFIED = (0x0000000000000027)
-
-PN_TRACE_OFF = _Transport.TRACE_OFF
-PN_TRACE_RAW = _Transport.TRACE_RAW
-PN_TRACE_FRM = _Transport.TRACE_FRM
-PN_TRACE_DRV = _Transport.TRACE_DRV
-
-def wrap(obj, wrapper):
- if obj:
- ctx = obj.getContext()
- if not ctx:
- ctx = wrapper(obj)
- obj.setContext(ctx)
- return ctx
-
-class pn_condition:
-
- def __init__(self):
- self.name = None
- self.description = None
- self.info = pn_data(0)
-
- def decode(self, impl):
- if impl is None:
- self.name = None
- self.description = None
- self.info.clear()
- else:
- cond = impl.getCondition()
- if cond is None:
- self.name = None
- else:
- self.name = cond.toString()
- self.description = impl.getDescription()
- obj2dat(impl.getInfo(), self.info)
-
- def encode(self):
- if self.name is None:
- return None
- else:
- impl = ErrorCondition()
- impl.setCondition(Symbol.valueOf(self.name))
- impl.setDescription(self.description)
- impl.setInfo(dat2obj(self.info))
- return impl
-
-def pn_condition_is_set(cond):
- return bool(cond.name)
-
-def pn_condition_get_name(cond):
- return cond.name
-
-def pn_condition_set_name(cond, name):
- cond.name = name
-
-def pn_condition_get_description(cond):
- return cond.description
-
-def pn_condition_set_description(cond, description):
- cond.description = description
-
-def pn_condition_clear(cond):
- cond.name = None
- cond.description = None
- cond.info.clear()
-
-def pn_condition_info(cond):
- return cond.info
-
-class endpoint_wrapper:
-
- def __init__(self, impl):
- self.impl = impl
- self.condition = pn_condition()
- self.remote_condition = pn_condition()
-
- def on_close(self):
- cond = self.condition.encode()
- if cond:
- self.impl.setCondition(cond)
-
-def remote_condition(self):
- self.remote_condition.decode(self.impl.getRemoteCondition())
- return self.remote_condition
-
-class pn_connection_wrapper(endpoint_wrapper):
-
- def __init__(self, impl):
- endpoint_wrapper.__init__(self, impl)
- self.properties = pn_data(0)
- self.offered_capabilities = pn_data(0)
- self.desired_capabilities = pn_data(0)
-
-def pn_connection():
- return wrap(Proton.connection(), pn_connection_wrapper)
-
-def set2mask(local, remote):
- mask = 0
- if local.contains(EndpointState.UNINITIALIZED):
- mask |= PN_LOCAL_UNINIT
- if local.contains(EndpointState.ACTIVE):
- mask |= PN_LOCAL_ACTIVE
- if local.contains(EndpointState.CLOSED):
- mask |= PN_LOCAL_CLOSED
- if remote.contains(EndpointState.UNINITIALIZED):
- mask |= PN_REMOTE_UNINIT
- if remote.contains(EndpointState.ACTIVE):
- mask |= PN_REMOTE_ACTIVE
- if remote.contains(EndpointState.CLOSED):
- mask |= PN_REMOTE_CLOSED
- return mask
-
-def endpoint_state(impl):
- return set2mask(EnumSet.of(impl.getLocalState()),
- EnumSet.of(impl.getRemoteState()))
-
-def pn_connection_state(conn):
- return endpoint_state(conn.impl)
-
-def pn_connection_condition(conn):
- return conn.condition
-
-def pn_connection_remote_condition(conn):
- return remote_condition(conn)
-
-def pn_connection_properties(conn):
- return conn.properties
-
-def pn_connection_remote_properties(conn):
- return obj2dat(conn.impl.getRemoteProperties())
-
-def pn_connection_offered_capabilities(conn):
- return conn.offered_capabilities
-
-def pn_connection_remote_offered_capabilities(conn):
- return array2dat(conn.impl.getRemoteOfferedCapabilities(), PN_SYMBOL)
-
-def pn_connection_desired_capabilities(conn):
- return conn.desired_capabilities
-
-def pn_connection_remote_desired_capabilities(conn):
- return array2dat(conn.impl.getRemoteDesiredCapabilities(), PN_SYMBOL)
-
-def pn_connection_attachments(conn):
- return conn.impl.attachments()
-
-def pn_connection_set_container(conn, name):
- conn.impl.setContainer(name)
-
-def pn_connection_get_container(conn):
- return conn.impl.getContainer()
-
-def pn_connection_remote_container(conn):
- return conn.impl.getRemoteContainer()
-
-def pn_connection_get_hostname(conn):
- return conn.impl.getHostname()
-
-def pn_connection_set_hostname(conn, name):
- conn.impl.setHostname(name)
-
-def pn_connection_remote_hostname(conn):
- return conn.impl.getRemoteHostname()
-
-def pn_connection_open(conn):
- props = dat2obj(conn.properties)
- offered = dat2obj(conn.offered_capabilities)
- desired = dat2obj(conn.desired_capabilities)
- if props:
- conn.impl.setProperties(props)
- if offered:
- conn.impl.setOfferedCapabilities(array(list(offered), Symbol))
- if desired:
- conn.impl.setDesiredCapabilities(array(list(desired), Symbol))
- conn.impl.open()
-
-def pn_connection_close(conn):
- conn.on_close()
- conn.impl.close()
-
-def pn_connection_release(conn):
- conn.impl.free()
-
-def pn_connection_transport(conn):
- return wrap(conn.impl.getTransport(), pn_transport_wrapper)
-
-class pn_session_wrapper(endpoint_wrapper):
- pass
-
-def pn_session(conn):
- return wrap(conn.impl.session(), pn_session_wrapper)
-
-def pn_session_attachments(ssn):
- return ssn.impl.attachments()
-
-def pn_session_state(ssn):
- return endpoint_state(ssn.impl)
-
-def pn_session_get_incoming_capacity(ssn):
- return ssn.impl.getIncomingCapacity()
-
-def pn_session_set_incoming_capacity(ssn, capacity):
- ssn.impl.setIncomingCapacity(capacity)
-
-def pn_session_incoming_bytes(ssn):
- return ssn.impl.getIncomingBytes()
-
-def pn_session_outgoing_bytes(ssn):
- return ssn.impl.getOutgoingBytes()
-
-def pn_session_get_outgoing_window(ssn):
- return ssn.impl.getOutgoingWindow()
-
-def pn_session_set_outgoing_window(ssn, window):
- ssn.impl.setOutgoingWindow(window)
-
-def pn_session_condition(ssn):
- return ssn.condition
-
-def pn_session_remote_condition(ssn):
- return remote_condition(ssn)
-
-def pn_session_open(ssn):
- ssn.impl.open()
-
-def pn_session_close(ssn):
- ssn.on_close()
- ssn.impl.close()
-
-def mask2set(mask):
- local = []
- remote = []
- if PN_LOCAL_UNINIT & mask:
- local.append(EndpointState.UNINITIALIZED)
- if PN_LOCAL_ACTIVE & mask:
- local.append(EndpointState.ACTIVE)
- if PN_LOCAL_CLOSED & mask:
- local.append(EndpointState.CLOSED)
- if PN_REMOTE_UNINIT & mask:
- remote.append(EndpointState.UNINITIALIZED)
- if PN_REMOTE_ACTIVE & mask:
- remote.append(EndpointState.ACTIVE)
- if PN_REMOTE_CLOSED & mask:
- remote.append(EndpointState.CLOSED)
-
- if local:
- local = EnumSet.of(*local)
- else:
- local = None
- if remote:
- remote = EnumSet.of(*remote)
- else:
- remote = None
-
- return local, remote
-
-def pn_session_head(conn, mask):
- local, remote = mask2set(mask)
- return wrap(conn.impl.sessionHead(local, remote), pn_session_wrapper)
-
-def pn_session_connection(ssn):
- return wrap(ssn.impl.getConnection(), pn_connection_wrapper)
-
-def pn_sender(ssn, name):
- return wrap(ssn.impl.sender(name), pn_link_wrapper)
-
-def pn_receiver(ssn, name):
- return wrap(ssn.impl.receiver(name), pn_link_wrapper)
-
-def pn_session_free(ssn):
- ssn.impl.free()
-
-TERMINUS_TYPES_J2P = {
- Source: PN_SOURCE,
- Target: PN_TARGET,
- Coordinator: PN_COORDINATOR,
- None.__class__: PN_UNSPECIFIED
-}
-
-TERMINUS_TYPES_P2J = {
- PN_SOURCE: Source,
- PN_TARGET: Target,
- PN_COORDINATOR: Coordinator,
- PN_UNSPECIFIED: lambda: None
-}
-
-DURABILITY_P2J = {
- PN_NONDURABLE: TerminusDurability.NONE,
- PN_CONFIGURATION: TerminusDurability.CONFIGURATION,
- PN_DELIVERIES: TerminusDurability.UNSETTLED_STATE
-}
-
-DURABILITY_J2P = {
- TerminusDurability.NONE: PN_NONDURABLE,
- TerminusDurability.CONFIGURATION: PN_CONFIGURATION,
- TerminusDurability.UNSETTLED_STATE: PN_DELIVERIES
-}
-
-EXPIRY_POLICY_P2J = {
- PN_EXPIRE_WITH_LINK: TerminusExpiryPolicy.LINK_DETACH,
- PN_EXPIRE_WITH_SESSION: TerminusExpiryPolicy.SESSION_END,
- PN_EXPIRE_WITH_CONNECTION: TerminusExpiryPolicy.CONNECTION_CLOSE,
- PN_EXPIRE_NEVER: TerminusExpiryPolicy.NEVER
-}
-
-EXPIRY_POLICY_J2P = {
- TerminusExpiryPolicy.LINK_DETACH: PN_EXPIRE_WITH_LINK,
- TerminusExpiryPolicy.SESSION_END: PN_EXPIRE_WITH_SESSION,
- TerminusExpiryPolicy.CONNECTION_CLOSE: PN_EXPIRE_WITH_CONNECTION,
- TerminusExpiryPolicy.NEVER: PN_EXPIRE_NEVER
-}
-
-DISTRIBUTION_MODE_P2J = {
- PN_DIST_MODE_UNSPECIFIED: None,
- PN_DIST_MODE_COPY: Symbol.valueOf("copy"),
- PN_DIST_MODE_MOVE: Symbol.valueOf("move")
-}
-
-DISTRIBUTION_MODE_J2P = {
- None: PN_DIST_MODE_UNSPECIFIED,
- Symbol.valueOf("copy"): PN_DIST_MODE_COPY,
- Symbol.valueOf("move"): PN_DIST_MODE_MOVE
-}
-
-class pn_terminus:
-
- def __init__(self, type):
- self.type = type
- self.address = None
- self.durability = PN_NONDURABLE
- self.expiry_policy = PN_EXPIRE_WITH_SESSION
- self.distribution_mode = PN_DIST_MODE_UNSPECIFIED
- self.timeout = 0
- self.dynamic = False
- self.properties = pn_data(0)
- self.capabilities = pn_data(0)
- self.outcomes = pn_data(0)
- self.filter = pn_data(0)
-
- def copy(self, src):
- self.type = src.type
- self.address = src.address
- self.durability = src.durability
- self.expiry_policy = src.expiry_policy
- self.timeout = src.timeout
- self.dynamic = src.dynamic
- self.properties = src.properties
- self.capabilities = src.capabilities
- self.outcomes = src.outcomes
- self.filter = src.filter
-
- def decode(self, impl):
- if impl is not None:
- self.type = TERMINUS_TYPES_J2P[impl.__class__]
- if self.type in (PN_SOURCE, PN_TARGET):
- self.address = impl.getAddress()
- self.durability = DURABILITY_J2P[impl.getDurable()]
- self.expiry_policy = EXPIRY_POLICY_J2P[impl.getExpiryPolicy()]
- self.timeout = impl.getTimeout().longValue()
- self.dynamic = impl.getDynamic()
- obj2dat(impl.getDynamicNodeProperties(), self.properties)
- array2dat(impl.getCapabilities(), PN_SYMBOL, self.capabilities)
- if self.type == PN_SOURCE:
- self.distribution_mode = DISTRIBUTION_MODE_J2P[impl.getDistributionMode()]
- array2dat(impl.getOutcomes(), PN_SYMBOL, self.outcomes)
- obj2dat(impl.getFilter(), self.filter)
-
- def encode(self):
- impl = TERMINUS_TYPES_P2J[self.type]()
- if self.type in (PN_SOURCE, PN_TARGET):
- impl.setAddress(self.address)
- impl.setDurable(DURABILITY_P2J[self.durability])
- impl.setExpiryPolicy(EXPIRY_POLICY_P2J[self.expiry_policy])
- impl.setTimeout(UnsignedInteger.valueOf(self.timeout))
- impl.setDynamic(self.dynamic)
- props = dat2obj(self.properties)
- caps = dat2obj(self.capabilities)
- if props: impl.setDynamicNodeProperties(props)
- if caps:
- impl.setCapabilities(*array(list(caps), Symbol))
- if self.type == PN_SOURCE:
- impl.setDistributionMode(DISTRIBUTION_MODE_P2J[self.distribution_mode])
- outcomes = dat2obj(self.outcomes)
- filter = dat2obj(self.filter)
- if outcomes: impl.setOutcomes(outcomes)
- if filter: impl.setFilter(filter)
- return impl
-
-def pn_terminus_get_type(terminus):
- return terminus.type
-
-def pn_terminus_set_type(terminus, type):
- terminus.type = type
- return 0
-
-def pn_terminus_get_address(terminus):
- return terminus.address
-
-def pn_terminus_set_address(terminus, address):
- terminus.address = address
- return 0
-
-def pn_terminus_get_durability(terminus):
- return terminus.durability
-
-def pn_terminus_get_expiry_policy(terminus):
- return terminus.expiry_policy
-
-def pn_terminus_set_timeout(terminus, timeout):
- terminus.timeout = timeout
- return 0
-
-def pn_terminus_get_timeout(terminus):
- return terminus.timeout
-
-def pn_terminus_get_distribution_mode(terminus):
- return terminus.distribution_mode
-
-def pn_terminus_set_distribution_mode(terminus, mode):
- terminus.distribution_mode = mode
- return 0
-
-def pn_terminus_is_dynamic(terminus):
- return terminus.dynamic
-
-def pn_terminus_set_dynamic(terminus, dynamic):
- terminus.dynamic = dynamic
- return 0
-
-def pn_terminus_properties(terminus):
- return terminus.properties
-
-def pn_terminus_capabilities(terminus):
- return terminus.capabilities
-
-def pn_terminus_outcomes(terminus):
- return terminus.outcomes
-
-def pn_terminus_filter(terminus):
- return terminus.filter
-
-def pn_terminus_copy(terminus, src):
- terminus.copy(src)
- return 0
-
-class pn_link_wrapper(endpoint_wrapper):
-
- def __init__(self, impl):
- endpoint_wrapper.__init__(self, impl)
- self.source = pn_terminus(PN_SOURCE)
- self.remote_source = pn_terminus(PN_UNSPECIFIED)
- self.target = pn_terminus(PN_TARGET)
- self.remote_target = pn_terminus(PN_UNSPECIFIED)
-
- def on_open(self):
- self.impl.setSource(self.source.encode())
- self.impl.setTarget(self.target.encode())
-
-def pn_link_attachments(link):
- return link.impl.attachments()
-
-def pn_link_source(link):
- link.source.decode(link.impl.getSource())
- return link.source
-
-def pn_link_remote_source(link):
- link.remote_source.decode(link.impl.getRemoteSource())
- return link.remote_source
-
-def pn_link_target(link):
- link.target.decode(link.impl.getTarget())
- return link.target
-
-def pn_link_remote_target(link):
- link.remote_target.decode(link.impl.getRemoteTarget())
- return link.remote_target
-
-def pn_link_condition(link):
- return link.condition
-
-def pn_link_remote_condition(link):
- return remote_condition(link)
-
-SND_SETTLE_MODE_P2J = {
- PN_SND_UNSETTLED: SenderSettleMode.UNSETTLED,
- PN_SND_SETTLED: SenderSettleMode.SETTLED,
- PN_SND_MIXED: SenderSettleMode.MIXED,
- None: None
-}
-
-SND_SETTLE_MODE_J2P = {
- SenderSettleMode.UNSETTLED: PN_SND_UNSETTLED,
- SenderSettleMode.SETTLED: PN_SND_SETTLED,
- SenderSettleMode.MIXED: PN_SND_MIXED,
- None: None
-}
-
-def pn_link_set_snd_settle_mode(link, mode):
- link.impl.setSenderSettleMode(SND_SETTLE_MODE_P2J[mode])
-
-def pn_link_snd_settle_mode(link):
- return SND_SETTLE_MODE_J2P[link.impl.getSenderSettleMode()]
-
-def pn_link_remote_snd_settle_mode(link):
- return SND_SETTLE_MODE_J2P[link.impl.getRemoteSenderSettleMode()]
-
-RCV_SETTLE_MODE_P2J = {
- PN_RCV_FIRST: ReceiverSettleMode.FIRST,
- PN_RCV_SECOND: ReceiverSettleMode.SECOND,
- None: None
-}
-
-RCV_SETTLE_MODE_J2P = {
- ReceiverSettleMode.FIRST: PN_RCV_FIRST,
- ReceiverSettleMode.SECOND: PN_RCV_SECOND,
- None: None
-}
-
-def pn_link_set_rcv_settle_mode(link, mode):
- link.impl.setReceiverSettleMode(RCV_SETTLE_MODE_P2J[mode])
-
-def pn_link_rcv_settle_mode(link):
- return RCV_SETTLE_MODE_J2P[link.impl.getReceiverSettleMode()]
-
-def pn_link_remote_rcv_settle_mode(link):
- return RCV_SETTLE_MODE_J2P[link.impl.getRemoteReceiverSettleMode()]
-
-def pn_link_is_sender(link):
- return isinstance(link.impl, Sender)
-
-def pn_link_is_receiver(link):
- return isinstance(link.impl, Receiver)
-
-def pn_link_head(conn, mask):
- local, remote = mask2set(mask)
- return wrap(conn.impl.linkHead(local, remote), pn_link_wrapper)
-
-def pn_link_next(link, mask):
- local, remote = mask2set(mask)
- return wrap(link.impl.next(local, remote), pn_link_wrapper)
-
-def pn_link_session(link):
- return wrap(link.impl.getSession(), pn_session_wrapper)
-
-def pn_link_state(link):
- return endpoint_state(link.impl)
-
-def pn_link_name(link):
- return link.impl.getName()
-
-def pn_link_open(link):
- link.on_open()
- link.impl.open()
-
-def pn_link_close(link):
- link.on_close()
- link.impl.close()
-
-def pn_link_detach(link):
- link.on_close()
- link.impl.detach()
-
-def pn_link_flow(link, n):
- link.impl.flow(n)
-
-def pn_link_drain(link, n):
- link.impl.drain(n)
-
-def pn_link_drained(link):
- return link.impl.drained()
-
-def pn_link_draining(link):
- return link.impl.draining()
-
-def pn_link_credit(link):
- return link.impl.getCredit()
-
-def pn_link_queued(link):
- return link.impl.getQueued()
-
-def pn_link_get_drain(link):
- return link.impl.getDrain();
-
-def pn_link_set_drain(link, drain):
- return link.impl.setDrain(drain);
-
-def pn_link_unsettled(link):
- return link.impl.getUnsettled()
-
-def pn_link_send(link, bytes):
- return link.impl.send(array(bytes, 'b'), 0, len(bytes))
-
-def pn_link_recv(link, limit):
- ary = zeros(limit, 'b')
- n = link.impl.recv(ary, 0, limit)
- if n >= 0:
- bytes = ary[:n].tostring()
- else:
- bytes = None
- return n, bytes
-
-def pn_link_advance(link):
- return link.impl.advance()
-
-def pn_link_current(link):
- return wrap(link.impl.current(), pn_delivery_wrapper)
-
-def pn_link_free(link):
- link.impl.free()
-
-def pn_work_head(conn):
- return wrap(conn.impl.getWorkHead(), pn_delivery_wrapper)
-
-def pn_work_next(dlv):
- return wrap(dlv.impl.getWorkNext(), pn_delivery_wrapper)
-
-DELIVERY_STATES = {
- Received: PN_RECEIVED,
- Accepted: PN_ACCEPTED,
- Rejected: PN_REJECTED,
- Released: PN_RELEASED,
- Modified: PN_MODIFIED,
- None.__class__: 0
- }
-
-DISPOSITIONS = {
- PN_RECEIVED: Received,
- PN_ACCEPTED: Accepted,
- PN_REJECTED: Rejected,
- PN_RELEASED: Released,
- PN_MODIFIED: Modified,
- 0: lambda: None
-}
-
-class pn_disposition:
-
- def __init__(self):
- self.type = 0
- self.data = pn_data(0)
- self.failed = False
- self.undeliverable = False
- self.annotations = pn_data(0)
- self.condition = pn_condition()
- self.section_number = 0
- self.section_offset = 0
-
- def decode(self, impl):
- self.type = DELIVERY_STATES[impl.__class__]
-
- if self.type == PN_REJECTED:
- self.condition.decode(impl.getError())
- else:
- pn_condition_clear(self.condition)
-
- if self.type == PN_MODIFIED:
- self.failed = impl.getDeliveryFailed()
- self.undeliverable = impl.getUndeliverableHere()
- obj2dat(impl.getMessageAnnotations(), self.annotations)
- else:
- self.failed = False
- self.undeliverable = False
- pn_data_clear(self.annotations)
-
- if self.type == PN_RECEIVED:
- self.section_number = impl.getSectionNumber().longValue()
- self.section_offset = impl.getSectionOffset().longValue()
- else:
- self.section_number = 0
- self.section_offset = 0
-
- self.data.clear()
- if impl:
- # XXX
- #self.data.putObject(impl)
- pass
- self.data.rewind()
-
- def encode(self):
- if self.type not in DISPOSITIONS:
- raise Skipped()
- impl = DISPOSITIONS[self.type]()
-
- if impl is None:
- return impl
-
- if self.type == PN_REJECTED:
- impl.setError(self.condition.encode())
-
- if self.type == PN_MODIFIED:
- impl.setDeliveryFailed(self.failed)
- impl.setUndeliverableHere(self.undeliverable)
- ann = dat2obj(self.annotations)
- if ann: impl.setMessageAnnotations(ann)
-
- if self.type == PN_RECEIVED:
- if self.section_number:
- impl.setSectionNumber(UnsignedInteger.valueOf(self.section_number))
- if self.section_offset:
- impl.setSectionOffset(UnsignedLong.valueOf(self.section_offset))
-
- return impl
-
-def pn_disposition_type(dsp):
- return dsp.type
-
-def pn_disposition_is_failed(dsp):
- return dsp.failed
-
-def pn_disposition_set_failed(dsp, failed):
- dsp.failed = failed
-
-def pn_disposition_is_undeliverable(dsp):
- return dsp.undeliverable
-
-def pn_disposition_set_undeliverable(dsp, undeliverable):
- dsp.undeliverable = undeliverable
-
-def pn_disposition_data(dsp):
- return dsp.data
-
-def pn_disposition_annotations(dsp):
- return dsp.annotations
-
-def pn_disposition_condition(dsp):
- return dsp.condition
-
-def pn_disposition_get_section_number(dsp):
- return dsp.section_number
-
-def pn_disposition_set_section_number(dsp, number):
- dsp.section_number = number
-
-def pn_disposition_get_section_offset(dsp):
- return dsp.section_offset
-
-def pn_disposition_set_section_offset(dsp, offset):
- dsp.section_offset = offset
-
-class pn_delivery_wrapper:
-
- def __init__(self, impl):
- self.impl = impl
- self.local = pn_disposition()
- self.remote = pn_disposition()
-
-def pn_delivery(link, tag):
- return wrap(link.impl.delivery(array(tag, 'b')), pn_delivery_wrapper)
-
-def pn_delivery_tag(dlv):
- return dlv.impl.getTag().tostring()
-
-def pn_delivery_attachments(dlv):
- return dlv.impl.attachments()
-
-def pn_delivery_partial(dlv):
- return dlv.impl.isPartial()
-
-def pn_delivery_pending(dlv):
- return dlv.impl.pending()
-
-def pn_delivery_writable(dlv):
- return dlv.impl.isWritable()
-
-def pn_delivery_readable(dlv):
- return dlv.impl.isReadable()
-
-def pn_delivery_updated(dlv):
- return dlv.impl.isUpdated()
-
-def pn_delivery_settled(dlv):
- return dlv.impl.remotelySettled()
-
-def pn_delivery_local(dlv):
- dlv.local.decode(dlv.impl.getLocalState())
- return dlv.local
-
-def pn_delivery_local_state(dlv):
- dlv.local.decode(dlv.impl.getLocalState())
- return dlv.local.type
-
-def pn_delivery_remote(dlv):
- dlv.remote.decode(dlv.impl.getRemoteState())
- return dlv.remote
-
-def pn_delivery_remote_state(dlv):
- dlv.remote.decode(dlv.impl.getRemoteState())
- return dlv.remote.type
-
-def pn_delivery_update(dlv, state):
- dlv.local.type = state
- dlv.impl.disposition(dlv.local.encode())
-
-def pn_delivery_link(dlv):
- return wrap(dlv.impl.getLink(), pn_link_wrapper)
-
-def pn_delivery_settle(dlv):
- dlv.impl.settle()
-
-class pn_transport_wrapper:
- def __init__(self, impl):
- self.impl = impl
- self.server = False
- self.condition = pn_condition()
-
-def pn_transport():
- return wrap(Proton.transport(), pn_transport_wrapper)
-
-def pn_transport_get_pytracer(trans):
- raise Skipped()
-
-def pn_transport_attachments(trans):
- return trans.impl.attachments()
-
-def pn_transport_set_server(trans):
- trans.server = True;
-
-def pn_transport_get_max_frame(trans):
- return trans.impl.getMaxFrameSize()
-
-def pn_transport_set_max_frame(trans, value):
- trans.impl.setMaxFrameSize(value)
-
-def pn_transport_get_remote_max_frame(trans):
- return trans.impl.getRemoteMaxFrameSize()
-
-def pn_transport_set_idle_timeout(trans, value):
- trans.impl.setIdleTimeout(value);
-
-def pn_transport_get_idle_timeout(trans):
- return trans.impl.getIdleTimeout()
-
-def pn_transport_get_remote_idle_timeout(trans):
- return trans.impl.getRemoteIdleTimeout()
-
-def pn_transport_get_frames_input(trans):
- return trans.impl.getFramesInput()
-
-def pn_transport_get_frames_output(trans):
- return trans.impl.getFramesOutput()
-
-def pn_transport_set_channel_max(trans, n):
- trans.impl.setChannelMax(n)
-
-def pn_transport_get_channel_max(trans):
- return trans.impl.getChannelMax()
-
-def pn_transport_remote_channel_max(trans):
- return trans.impl.getRemoteChannelMax()
-
-def pn_transport_tick(trans, now):
- return trans.impl.tick(now);
-
-def pn_transport_bind(trans, conn):
- trans.impl.bind(conn.impl)
- return 0
-
-def pn_transport_unbind(trans):
- trans.impl.unbind()
- return 0
-
-def pn_transport_set_pytracer(trans, tracer):
- import warnings
- warnings.warn("TODO pn_transport_set_tracer", stacklevel=2)
-
-def pn_transport_trace(trans, n):
- trans.impl.trace(n)
-
-def pn_transport_pending(trans):
- return trans.impl.pending()
-
-def pn_transport_peek(trans, size):
- size = min(trans.impl.pending(), size)
- ba = zeros(size, 'b')
- if size:
- bb = trans.impl.head()
- bb.get(ba)
- bb.position(0)
- return 0, ba.tostring()
-
-def pn_transport_pop(trans, size):
- trans.impl.pop(size)
-
-def pn_transport_capacity(trans):
- return trans.impl.capacity()
-
-def pn_transport_push(trans, input):
- result = 0
- while input:
- cap = pn_transport_capacity(trans)
- if cap < 0:
- return cap
- elif len(input) > cap:
- trimmed = input[:cap]
- else:
- trimmed = input
-
- bb = trans.impl.tail()
- bb.put(array(trimmed, 'b'))
- trans.impl.process()
- input = input[cap:]
- result += len(trimmed)
- return result
-
-def pn_transport_close_head(trans):
- trans.impl.close_head()
- return 0
-
-def pn_transport_close_tail(trans):
- trans.impl.close_tail()
- return 0
-
-def pn_transport_closed(trans):
- return trans.impl.isClosed()
-
-def pn_transport_condition(trans):
- trans.condition.decode(trans.impl.getCondition())
- return trans.condition
-
-from org.apache.qpid.proton.engine import Event
-
-PN_REACTOR_INIT = Event.Type.REACTOR_INIT
-PN_REACTOR_QUIESCED = Event.Type.REACTOR_QUIESCED
-PN_REACTOR_FINAL = Event.Type.REACTOR_FINAL
-
-PN_TIMER_TASK = Event.Type.TIMER_TASK
-
-PN_CONNECTION_INIT = Event.Type.CONNECTION_INIT
-PN_CONNECTION_BOUND = Event.Type.CONNECTION_BOUND
-PN_CONNECTION_UNBOUND = Event.Type.CONNECTION_UNBOUND
-PN_CONNECTION_LOCAL_OPEN = Event.Type.CONNECTION_LOCAL_OPEN
-PN_CONNECTION_REMOTE_OPEN = Event.Type.CONNECTION_REMOTE_OPEN
-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_LOCAL_OPEN = Event.Type.SESSION_LOCAL_OPEN
-PN_SESSION_REMOTE_OPEN = Event.Type.SESSION_REMOTE_OPEN
-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_LOCAL_OPEN = Event.Type.LINK_LOCAL_OPEN
-PN_LINK_REMOTE_OPEN = Event.Type.LINK_REMOTE_OPEN
-PN_LINK_LOCAL_CLOSE = Event.Type.LINK_LOCAL_CLOSE
-PN_LINK_REMOTE_CLOSE = Event.Type.LINK_REMOTE_CLOSE
-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
-PN_DELIVERY = Event.Type.DELIVERY
-PN_TRANSPORT = Event.Type.TRANSPORT
-PN_TRANSPORT_ERROR = Event.Type.TRANSPORT_ERROR
-PN_TRANSPORT_HEAD_CLOSED = Event.Type.TRANSPORT_HEAD_CLOSED
-PN_TRANSPORT_TAIL_CLOSED = Event.Type.TRANSPORT_TAIL_CLOSED
-PN_TRANSPORT_CLOSED = Event.Type.TRANSPORT_CLOSED
-PN_SELECTABLE_INIT = Event.Type.SELECTABLE_INIT
-PN_SELECTABLE_UPDATED = Event.Type.SELECTABLE_UPDATED
-PN_SELECTABLE_READABLE = Event.Type.SELECTABLE_READABLE
-PN_SELECTABLE_WRITABLE = Event.Type.SELECTABLE_WRITABLE
-PN_SELECTABLE_EXPIRED = Event.Type.SELECTABLE_EXPIRED
-PN_SELECTABLE_ERROR = Event.Type.SELECTABLE_ERROR
-PN_SELECTABLE_FINAL = Event.Type.SELECTABLE_FINAL
-
-def pn_collector():
- return Proton.collector()
-
-def pn_connection_collect(conn, coll):
- conn.impl.collect(coll)
-
-class pn_event:
-
- def __init__(self, impl):
- self.impl = impl
-
- def copy(self):
- return pn_event(self.impl.copy())
-
-def pn_collector_peek(coll):
- ev = coll.peek()
- if ev:
- return pn_event(ev.copy())
- else:
- return None
-
-def pn_collector_pop(coll):
- coll.pop()
-
-def pn_collector_free(coll):
- pass
-
-def pn_event_reactor(event):
- return event.impl.getReactor()
-
-def pn_event_connection(event):
- return wrap(event.impl.getConnection(), pn_connection_wrapper)
-
-def pn_event_session(event):
- return wrap(event.impl.getSession(), pn_session_wrapper)
-
-def pn_event_link(event):
- return wrap(event.impl.getLink(), pn_link_wrapper)
-
-def pn_event_delivery(event):
- return wrap(event.impl.getDelivery(), pn_delivery_wrapper)
-
-def pn_event_transport(event):
- return wrap(event.impl.getTransport(), pn_transport_wrapper)
-
-from org.apache.qpid.proton.engine.impl import ConnectionImpl, SessionImpl, \
- SenderImpl, ReceiverImpl, DeliveryImpl, TransportImpl
-from org.apache.qpid.proton.reactor.impl import TaskImpl, SelectableImpl
-
-J2C = {
- ConnectionImpl: "pn_connection",
- SessionImpl: "pn_session",
- SenderImpl: "pn_link",
- ReceiverImpl: "pn_link",
- DeliveryImpl: "pn_delivery",
- TransportImpl: "pn_transport",
- TaskImpl: "pn_task",
- SelectableImpl: "pn_selectable"
-}
-
-wrappers = {
- "pn_connection": lambda x: wrap(x, pn_connection_wrapper),
- "pn_session": lambda x: wrap(x, pn_session_wrapper),
- "pn_link": lambda x: wrap(x, pn_link_wrapper),
- "pn_delivery": lambda x: wrap(x, pn_delivery_wrapper),
- "pn_transport": lambda x: wrap(x, pn_transport_wrapper),
- "pn_task": lambda x: x,
- "pn_selectable": lambda x: x,
- "pn_void": lambda x: x
-}
-
-def pn_event_class(event):
- ctx = event.impl.getContext()
- return J2C.get(ctx.getClass(), "pn_void")
-
-def pn_event_context(event):
- return wrappers[pn_event_class(event)](event.impl.getContext())
-
-def pn_event_type(event):
- return event.impl.getEventType()
-
-def pn_event_root(event):
- return event.impl.getRootHandler()
-
-def pn_event_type_name(etype):
- return str(etype)
-
-def pn_event_category(event):
- return event.impl.getCategory()
-
-def pn_event_attachments(event):
- return event.impl.attachments()
-
-def pn_event_copy(event):
- return event.copy()
-
-class TypeExtender:
- def __init__(self, number):
- pass
- def next(self):
- class CustomEvent(EventType):
- def isValid(self):
- return True
- return CustomEvent()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/cerror.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/cerror.py b/tests/java/shim/cerror.py
deleted file mode 100644
index c87681c..0000000
--- a/tests/java/shim/cerror.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# from proton/error.h
-PN_EOS = -1
-PN_ERR = -2
-PN_OVERFLOW = -3
-PN_UNDERFLOW = -4
-PN_STATE_ERR = -5
-PN_ARG_ERR = -6
-PN_TIMEOUT =-7
-PN_INTR = -8
-PN_INPROGRESS =-9
-
-class pn_error:
-
- def __init__(self, code, text):
- self.code = code
- self.text = text
-
- def set(self, code, text):
- self.code = code
- self.text = text
- return self.code
-
-def pn_error_code(err):
- return err.code
-
-def pn_error_text(err):
- return err.text
-
-from unittest import SkipTest as Skipped
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/chandlers.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/chandlers.py b/tests/java/shim/chandlers.py
deleted file mode 100644
index 272990f..0000000
--- a/tests/java/shim/chandlers.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-import sys
-from cerror import Skipped
-from org.apache.qpid.proton.reactor import FlowController, Handshaker
-from org.apache.qpid.proton.engine import BaseHandler, HandlerException
-
-# from proton/handlers.h
-def pn_flowcontroller(window):
- return FlowController(window)
-
-def pn_handshaker():
- return Handshaker()
-
-def pn_iohandler():
- raise Skipped()
-
-from cengine import pn_event, pn_event_type
-
-class pn_pyhandler(BaseHandler):
-
- def __init__(self, pyobj):
- self.pyobj = pyobj
-
- def onUnhandled(self, event):
- ev = pn_event(event)
- try:
- self.pyobj.dispatch(ev, pn_event_type(ev))
- except HandlerException:
- ex = sys.exc_info();
- cause = ex[1].cause
- if hasattr(cause, "value"):
- cause = cause.value
- t = type(cause)
- self.pyobj.exception(t, cause, ex[2])
- except:
- ex = sys.exc_info()
- self.pyobj.exception(*ex)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/cmessage.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/cmessage.py b/tests/java/shim/cmessage.py
deleted file mode 100644
index d406bea..0000000
--- a/tests/java/shim/cmessage.py
+++ /dev/null
@@ -1,250 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-from org.apache.qpid.proton import Proton
-from org.apache.qpid.proton.amqp.messaging import AmqpValue, AmqpSequence, \
- Data as DataSection, ApplicationProperties, MessageAnnotations, DeliveryAnnotations
-
-from ccodec import *
-from cerror import *
-from org.apache.qpid.proton.amqp import Binary
-
-# from proton/message.h
-PN_DATA = 0
-PN_TEXT = 1
-PN_AMQP = 2
-PN_JSON = 3
-
-PN_DEFAULT_PRIORITY = 4
-
-class pn_message_wrapper:
-
- def __init__(self):
- self.inferred = False
- self.impl = Proton.message()
- self.id = pn_data(0)
- self.correlation_id = pn_data(0)
- self.instructions = pn_data(0)
- self.annotations = pn_data(0)
- self.properties = pn_data(0)
- self.body = pn_data(0)
-
- def decode(self, impl):
- self.impl = impl
- self.post_decode()
-
- def post_decode(self):
- obj2dat(self.impl.getMessageId(), self.id)
- self.id.next()
- obj2dat(self.impl.getCorrelationId(), self.correlation_id)
- self.correlation_id.next()
- def peel(x):
- if x is not None:
- return x.getValue()
- return None
- obj2dat(peel(self.impl.getDeliveryAnnotations()), self.instructions)
- obj2dat(peel(self.impl.getMessageAnnotations()), self.annotations)
- obj2dat(peel(self.impl.getApplicationProperties()), self.properties)
- bod = self.impl.getBody()
- if bod is not None: bod = bod.getValue()
- obj2dat(bod, self.body)
-
- def pre_encode(self):
- self.impl.setMessageId(dat2obj(self.id))
- self.impl.setCorrelationId(dat2obj(self.correlation_id))
- def wrap(x, wrapper):
- if x is not None:
- return wrapper(x)
- return None
- self.impl.setDeliveryAnnotations(wrap(dat2obj(self.instructions), DeliveryAnnotations))
- self.impl.setMessageAnnotations(wrap(dat2obj(self.annotations), MessageAnnotations))
- self.impl.setApplicationProperties(wrap(dat2obj(self.properties), ApplicationProperties))
- bod = dat2obj(self.body)
- if self.inferred:
- if isinstance(bod, bytes):
- bod = DataSection(Binary(array(bod, 'b')))
- elif isinstance(bod, list):
- bod = AmqpSequence(bod)
- else:
- bod = AmqpValue(bod)
- else:
- bod = AmqpValue(bod)
- self.impl.setBody(bod)
-
- def __repr__(self):
- return self.impl.toString()
-
-def pn_message():
- return pn_message_wrapper()
-
-def pn_message_id(msg):
- return msg.id
-
-def pn_message_correlation_id(msg):
- return msg.correlation_id
-
-def pn_message_get_address(msg):
- return msg.impl.getAddress()
-
-def pn_message_set_address(msg, address):
- msg.impl.setAddress(address)
- return 0
-
-def pn_message_get_reply_to(msg):
- return msg.impl.getReplyTo()
-
-def pn_message_set_reply_to(msg, address):
- msg.impl.setReplyTo(address)
- return 0
-
-def pn_message_get_reply_to_group_id(msg):
- return msg.impl.getReplyToGroupId()
-
-def pn_message_set_reply_to_group_id(msg, id):
- msg.impl.setReplyToGroupId(id)
- return 0
-
-def pn_message_get_group_sequence(msg):
- return msg.impl.getGroupSequence()
-
-def pn_message_set_group_sequence(msg, seq):
- msg.impl.setGroupSequence(seq)
- return 0
-
-def pn_message_get_group_id(msg):
- return msg.impl.getGroupId()
-
-def pn_message_set_group_id(msg, id):
- msg.impl.setGroupId(id)
- return 0
-
-def pn_message_is_first_acquirer(msg):
- return msg.impl.isFirstAcquirer()
-
-def pn_message_set_first_acquirer(msg, b):
- msg.impl.setFirstAcquirer(b)
- return 0
-
-def pn_message_is_durable(msg):
- return msg.impl.isDurable()
-
-def pn_message_set_durable(msg, b):
- msg.impl.setDurable(b)
- return 0
-
-def pn_message_get_delivery_count(msg):
- return msg.impl.getDeliveryCount()
-
-def pn_message_set_delivery_count(msg, c):
- msg.impl.setDeliveryCount(c)
- return 0
-
-def pn_message_get_creation_time(msg):
- return msg.impl.getCreationTime()
-
-def pn_message_set_creation_time(msg, t):
- msg.impl.setCreationTime(t)
- return 0
-
-def pn_message_get_expiry_time(msg):
- return msg.impl.getExpiryTime()
-
-def pn_message_set_expiry_time(msg, t):
- msg.impl.setExpiryTime(t)
- return 0
-
-def pn_message_get_content_type(msg):
- return msg.impl.getContentType()
-
-def pn_message_set_content_type(msg, ct):
- msg.impl.setContentType(ct)
- return 0
-
-def pn_message_get_content_encoding(msg):
- return msg.impl.getContentEncoding()
-
-def pn_message_set_content_encoding(msg, ct):
- msg.impl.setContentEncoding(ct)
- return 0
-
-def pn_message_get_subject(msg):
- return msg.impl.getSubject()
-
-def pn_message_set_subject(msg, value):
- msg.impl.setSubject(value)
- return 0
-
-def pn_message_get_priority(msg):
- return msg.impl.getPriority()
-
-def pn_message_set_priority(msg, p):
- msg.impl.setPriority(p)
- return 0
-
-def pn_message_get_ttl(msg):
- return msg.impl.getTtl()
-
-def pn_message_set_ttl(msg, ttl):
- msg.impl.setTtl(ttl)
- return 0
-
-def pn_message_get_user_id(msg):
- uid = msg.impl.getUserId()
- if uid is None:
- return ""
- else:
- return uid.tostring()
-
-def pn_message_set_user_id(msg, uid):
- msg.impl.setUserId(uid)
- return 0
-
-def pn_message_instructions(msg):
- return msg.instructions
-
-def pn_message_annotations(msg):
- return msg.annotations
-
-def pn_message_properties(msg):
- return msg.properties
-
-def pn_message_body(msg):
- return msg.body
-
-def pn_message_decode(msg, data):
- n = msg.impl.decode(array(data, 'b'), 0, len(data))
- msg.post_decode()
- return n
-
-from java.nio import BufferOverflowException
-
-def pn_message_encode(msg, size):
- msg.pre_encode()
- ba = zeros(size, 'b')
- # XXX: shouldn't have to use the try/catch
- try:
- n = msg.impl.encode(ba, 0, size)
- if n >= 0:
- return n, ba[:n].tostring()
- else:
- return n
- except BufferOverflowException, e:
- return PN_OVERFLOW, None
-
-def pn_message_clear(msg):
- msg.impl.clear()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/cmessenger.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/cmessenger.py b/tests/java/shim/cmessenger.py
deleted file mode 100644
index 249e0dc..0000000
--- a/tests/java/shim/cmessenger.py
+++ /dev/null
@@ -1,225 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-from org.apache.qpid.proton import Proton
-from org.apache.qpid.proton.messenger import Messenger, Status
-from org.apache.qpid.proton import InterruptException, TimeoutException
-
-from cerror import *
-
-# from proton/messenger.h
-PN_STATUS_UNKNOWN = 0
-PN_STATUS_PENDING = 1
-PN_STATUS_ACCEPTED = 2
-PN_STATUS_REJECTED = 3
-PN_STATUS_RELEASED = 4
-PN_STATUS_MODIFIED = 5
-PN_STATUS_ABORTED = 6
-PN_STATUS_SETTLED = 7
-
-PN_CUMULATIVE = 1
-
-class pn_messenger_wrapper:
-
- def __init__(self, impl):
- self.impl = impl
- self.error = pn_error(0, None)
-
-def pn_messenger(name):
- if name is None:
- return pn_messenger_wrapper(Proton.messenger())
- else:
- return pn_messenger_wrapper(Proton.messenger(name))
-
-def pn_messenger_error(m):
- return m.error
-
-def pn_messenger_set_timeout(m, t):
- m.impl.setTimeout(t)
- return 0
-
-def pn_messenger_set_blocking(m, b):
- m.impl.setBlocking(b)
- return 0
-
-def pn_messenger_set_certificate(m, c):
- m.impl.setCertificate(c)
- return 0
-
-def pn_messenger_set_private_key(m, p):
- m.impl.setPrivateKey(p)
- return 0
-
-def pn_messenger_set_password(m, p):
- m.impl.setPassword(p)
- return 0
-
-def pn_messenger_set_trusted_certificates(m, t):
- m.impl.setTrustedCertificates(t)
- return 0
-
-def pn_messenger_set_incoming_window(m, w):
- m.impl.setIncomingWindow(w)
- return 0
-
-def pn_messenger_set_outgoing_window(m, w):
- m.impl.setOutgoingWindow(w)
- return 0
-
-def pn_messenger_start(m):
- m.impl.start()
- return 0
-
-# XXX: ???
-def pn_messenger_work(m, t):
- try:
- if m.impl.work(t):
- return 1
- else:
- return PN_TIMEOUT
- except InterruptException, e:
- return PN_INTR
-
-class pn_subscription:
-
- def __init__(self):
- pass
-
-def pn_messenger_subscribe(m, source):
- m.impl.subscribe(source)
- return pn_subscription()
-
-def pn_messenger_route(m, pattern, address):
- m.impl.route(pattern, address)
- return 0
-
-def pn_messenger_rewrite(m, pattern, address):
- m.impl.rewrite(pattern, address)
- return 0
-
-def pn_messenger_interrupt(m):
- m.impl.interrupt()
- return 0
-
-def pn_messenger_buffered(m, t):
- raise Skipped()
-
-from org.apache.qpid.proton.engine import TransportException
-
-def pn_messenger_stop(m):
- m.impl.stop()
- return 0
-
-def pn_messenger_stopped(m):
- return m.impl.stopped()
-
-def pn_messenger_put(m, msg):
- msg.pre_encode()
- m.impl.put(msg.impl)
- return 0
-
-def pn_messenger_outgoing_tracker(m):
- return m.impl.outgoingTracker()
-
-def pn_messenger_send(m, n):
- try:
- m.impl.send(n)
- return 0
- except InterruptException, e:
- return PN_INTR
- except TimeoutException, e:
- return PN_TIMEOUT
-
-def pn_messenger_recv(m, n):
- try:
- m.impl.recv(n)
- return 0
- except InterruptException, e:
- return PN_INTR
- except TimeoutException, e:
- return PN_TIMEOUT
-
-def pn_messenger_receiving(m):
- return m.impl.receiving()
-
-def pn_messenger_incoming(m):
- return m.impl.incoming()
-
-def pn_messenger_outgoing(m):
- return m.impl.outgoing()
-
-def pn_messenger_get(m, msg):
- mimpl = m.impl.get()
- if msg:
- msg.decode(mimpl)
- return 0
-
-def pn_messenger_incoming_tracker(m):
- return m.impl.incomingTracker()
-
-def pn_messenger_accept(m, tracker, flags):
- if flags:
- m.impl.accept(tracker, Messenger.CUMULATIVE)
- else:
- m.impl.accept(tracker, 0)
- return 0
-
-def pn_messenger_reject(m, tracker, flags):
- if flags:
- m.impl.reject(tracker, Messenger.CUMULATIVE)
- else:
- m.impl.reject(tracker, 0)
- return 0
-
-def pn_messenger_settle(m, tracker, flags):
- if flags:
- m.impl.settle(tracker, Messenger.CUMULATIVE)
- else:
- m.impl.settle(tracker, 0)
- return 0
-
-STATUS_P2J = {
- PN_STATUS_UNKNOWN: Status.UNKNOWN,
- PN_STATUS_PENDING: Status.PENDING,
- PN_STATUS_ACCEPTED: Status.ACCEPTED,
- PN_STATUS_REJECTED: Status.REJECTED,
- PN_STATUS_RELEASED: Status.RELEASED,
- PN_STATUS_MODIFIED: Status.MODIFIED,
- PN_STATUS_ABORTED: Status.ABORTED,
- PN_STATUS_SETTLED: Status.SETTLED
-}
-
-STATUS_J2P = {
- Status.UNKNOWN: PN_STATUS_UNKNOWN,
- Status.PENDING: PN_STATUS_PENDING,
- Status.ACCEPTED: PN_STATUS_ACCEPTED,
- Status.REJECTED: PN_STATUS_REJECTED,
- Status.RELEASED: PN_STATUS_RELEASED,
- Status.MODIFIED: PN_STATUS_MODIFIED,
- Status.ABORTED: PN_STATUS_ABORTED,
- Status.SETTLED: PN_STATUS_SETTLED
-}
-
-def pn_messenger_status(m, tracker):
- return STATUS_J2P[m.impl.getStatus(tracker)]
-
-def pn_messenger_set_passive(m, passive):
- raise Skipped()
-
-def pn_messenger_selectable(m):
- raise Skipped()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/cobject.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/cobject.py b/tests/java/shim/cobject.py
deleted file mode 100644
index 33ab438..0000000
--- a/tests/java/shim/cobject.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-def pn_class_name(cls):
- return cls
-
-def pn_void2py(obj):
- return obj
-
-def pn_py2void(obj):
- return obj
-
-def pn_cast_pn_connection(obj):
- return obj
-
-def pn_cast_pn_session(obj):
- return obj
-
-def pn_cast_pn_link(obj):
- return obj
-
-def pn_cast_pn_delivery(obj):
- return obj
-
-def pn_cast_pn_transport(obj):
- return obj
-
-def pn_cast_pn_reactor(obj):
- return obj
-
-def pn_cast_pn_task(obj):
- return obj
-
-def pn_cast_pn_selectable(obj):
- return obj
-
-PN_PYREF = None
-
-def pn_record_def(record, key, clazz):
- pass
-
-from java.lang import Object
-
-def pn_record_get(record, key):
- return record.get(key, Object)
-
-def pn_record_set(record, key, value):
- record.set(key, Object, value)
-
-def pn_incref(obj):
- pass
-
-def pn_decref(obj):
- pass
-
-def pn_free(obj):
- pass
-
-from java.lang import StringBuilder
-
-def pn_string(st):
- sb = StringBuilder()
- if st:
- sb.append(st)
- return sb
-
-def pn_string_get(sb):
- return sb.toString()
-
-def pn_inspect(obj, st):
- if obj is None:
- st.append("null")
- else:
- st.append(repr(obj))
- return 0
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/compat.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/compat.py b/tests/java/shim/compat.py
deleted file mode 100644
index 7bff3ba..0000000
--- a/tests/java/shim/compat.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-import sys
-from jarray import zeros, array as _array
-
-if (sys.version_info[0] == 2 and sys.version_info[1] == 5):
- array = _array
-else:
- def array(obj, code):
- return obj
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/cproton.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/cproton.py b/tests/java/shim/cproton.py
deleted file mode 100644
index d5ed574..0000000
--- a/tests/java/shim/cproton.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-"""
-The cproton module defines a java implementation of the C interface as
-exposed to python via swig. This allows tests defined in python to run
-against both the C and Java protocol implementations.
-"""
-
-# @todo(kgiusti) dynamically set these via filters in the pom.xml file
-PN_VERSION_MAJOR = 0
-PN_VERSION_MINOR = 0
-PN_VERSION_POINT = 0
-
-from ctypes import *
-from cobject import *
-from cerror import *
-from ccodec import *
-from cengine import *
-from csasl import *
-from cssl import *
-from cmessenger import *
-from cmessage import *
-from curl import *
-from creactor import *
-from chandlers import *
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[33/34] qpid-proton git commit: NO-JIRA: go: note C dependency
prominently on entry-point docs.
Posted by ac...@apache.org.
NO-JIRA: go: note C dependency prominently on entry-point docs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/951dcb4e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/951dcb4e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/951dcb4e
Branch: refs/heads/go1
Commit: 951dcb4e130613f16cab6bd7c24093423dc552d8
Parents: cac0fc4
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Jan 9 10:16:20 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Jan 9 10:20:53 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/go/src/qpid.apache.org/README.md | 5 +++++
proton-c/bindings/go/src/qpid.apache.org/amqp/doc.go | 2 ++
proton-c/bindings/go/src/qpid.apache.org/electron/doc.go | 2 ++
proton-c/bindings/go/src/qpid.apache.org/proton/doc.go | 2 ++
4 files changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/951dcb4e/proton-c/bindings/go/src/qpid.apache.org/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/README.md b/proton-c/bindings/go/src/qpid.apache.org/README.md
index ffd67f8..7415929 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/README.md
+++ b/proton-c/bindings/go/src/qpid.apache.org/README.md
@@ -4,6 +4,11 @@ These packages provide [Go](http://golang.org) support for sending and receiving
AMQP messages in client or server applications. Reference documentation is
available at: <http://godoc.org/?q=qpid.apache.org>
+They require the [proton-C library](http://qpid.apache.org/proton) to be installed.
+On many platforms it is avaialable pre-packaged, for example on Fedora
+
+ yum install qpid-proton-c-devel
+
There are 3 packages:
[qpid.apache.org/amqp](http://godoc.org/qpid.apache.org/amqp) provides functions
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/951dcb4e/proton-c/bindings/go/src/qpid.apache.org/amqp/doc.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/doc.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/doc.go
index 97051a5..701af55 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/doc.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/doc.go
@@ -24,6 +24,8 @@ It follows the standard 'encoding' libraries pattern. The mapping between AMQP
and Go types is described in the documentation of the Marshal and Unmarshal
functions.
+This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
+
Package 'electron' is a full AMQP 1.0 client/server toolkit using this package.
AMQP 1.0 is an open standard for inter-operable message exchange, see <http://www.amqp.org/>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/951dcb4e/proton-c/bindings/go/src/qpid.apache.org/electron/doc.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/doc.go b/proton-c/bindings/go/src/qpid.apache.org/electron/doc.go
index bc2c589..f4baa31 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/doc.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/doc.go
@@ -20,6 +20,8 @@ under the License.
/*
Package electron lets you write concurrent AMQP 1.0 messaging clients and servers.
+This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
+
Start by creating a Container with NewContainer. An AMQP Container represents a
single AMQP "application" and can contain client and server connections.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/951dcb4e/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go b/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go
index 083f701..1049e71 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go
@@ -21,6 +21,8 @@ under the License.
Package proton wraps Proton-C, an event-driven, concurrent-unsafe AMQP 1.0
C library (package 'electron' is more "Go-like" and concurrent-safe)
+This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
+
Consult the C API documentation at http://qpid.apache.org/proton for more
information about the types here. There is a 1-1 correspondence between C type
pn_foo_t and Go type proton.Foo, and between C function
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[03/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/creactor.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/creactor.py b/tests/java/shim/creactor.py
deleted file mode 100644
index b61c1df..0000000
--- a/tests/java/shim/creactor.py
+++ /dev/null
@@ -1,118 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-import sys
-from proton import _compat
-from cerror import Skipped
-from cengine import wrap, pn_connection_wrapper
-
-from org.apache.qpid.proton.reactor import Reactor
-from org.apache.qpid.proton.engine import BaseHandler, HandlerException
-
-# from proton/reactor.h
-def pn_reactor():
- return Reactor.Factory.create()
-def pn_reactor_attachments(r):
- return r.attachments()
-def pn_reactor_get_global_handler(r):
- return r.getGlobalHandler()
-def pn_reactor_set_global_handler(r, h):
- r.setGlobalHandler(h)
-def pn_reactor_get_handler(r):
- return r.getHandler()
-def pn_reactor_set_handler(r, h):
- r.setHandler(h)
-def pn_reactor_set_timeout(r, t):
- r.setTimeout(t)
-def pn_reactor_get_timeout(r):
- return r.getTimeout()
-def pn_reactor_schedule(r, t, h):
- return r.schedule(t, h)
-def pn_reactor_yield(r):
- getattr(r, "yield")()
-def pn_reactor_start(r):
- r.start()
-def pn_reactor_process(r):
- return peel_handler_exception(r.process)
-def pn_reactor_stop(r):
- return peel_handler_exception(r.stop)
-def pn_reactor_selectable(r):
- return r.selectable()
-def pn_reactor_connection(r, h):
- return wrap(r.connection(h), pn_connection_wrapper)
-def pn_reactor_connection_to_host(r, host, port, h):
- return wrap(r.connectionToHost(host, int(port), h),
- pn_connection_wrapper)
-def pn_reactor_get_connection_address(r, c):
- return r.getConnectionAddress(c.impl)
-def pn_reactor_set_connection_host(r, c, h, p):
- r.setConnectionHost(c.impl, h, int(p))
-def pn_reactor_acceptor(r, host, port, handler):
- return r.acceptor(host, int(port), handler)
-def pn_reactor_mark(r):
- return r.mark()
-def pn_reactor_wakeup(r):
- return r.wakeup()
-
-def peel_handler_exception(meth):
- try:
- return meth()
- except HandlerException, he:
- cause = he.cause
- t = getattr(cause, "type", cause.__class__)
- info = sys.exc_info()
- _compat.raise_(t, cause, info[2])
-
-def pn_handler_add(h, c):
- h.add(c)
-def pn_handler_dispatch(h, ev, et):
- if et != None and et != ev.impl.type:
- ev.impl.redispatch(et, h)
- else:
- ev.impl.dispatch(h)
-def pn_record_set_handler(r, h):
- BaseHandler.setHandler(r, h)
-def pn_record_get_handler(r):
- return BaseHandler.getHandler(r)
-
-def pn_task_attachments(t):
- return t.attachments()
-
-def pn_selectable_attachments(s):
- return s.attachments()
-
-def pn_selectable_set_fd(s, fd):
- s.setChannel(fd.getChannel())
-
-def pn_acceptor_close(a):
- a.close()
-
-def pn_task_cancel(t):
- t.cancel()
-
-def pn_object_reactor(o):
- if hasattr(o, "impl"):
- if hasattr(o.impl, "getSession"):
- return o.impl.getSession().getConnection().getReactor()
- elif hasattr(o.impl, "getConnection"):
- return o.impl.getConnection().getReactor()
- else:
- return o.impl.getReactor()
- else:
- return o.getReactor()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/csasl.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/csasl.py b/tests/java/shim/csasl.py
deleted file mode 100644
index b540f82..0000000
--- a/tests/java/shim/csasl.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-from org.apache.qpid.proton.engine import Sasl
-
-from compat import array, zeros
-
-from cerror import *
-
-# from proton/sasl.h
-PN_SASL_NONE=-1
-PN_SASL_OK=0
-PN_SASL_AUTH=1
-PN_SASL_SYS=2
-PN_SASL_PERM=3
-PN_SASL_TEMP=4
-
-def pn_sasl_extended():
- return False
-
-def pn_sasl(tp):
- sasl = tp.impl.sasl()
- if tp.server:
- sasl.server()
- else:
- sasl.client()
- return sasl
-
-SASL_OUTCOMES_P2J = {
- PN_SASL_NONE: Sasl.PN_SASL_NONE,
- PN_SASL_OK: Sasl.PN_SASL_OK,
- PN_SASL_AUTH: Sasl.PN_SASL_AUTH,
- PN_SASL_SYS: Sasl.PN_SASL_SYS,
- PN_SASL_PERM: Sasl.PN_SASL_PERM,
- PN_SASL_TEMP: Sasl.PN_SASL_TEMP,
-}
-
-SASL_OUTCOMES_J2P = {
- Sasl.PN_SASL_NONE: PN_SASL_NONE,
- Sasl.PN_SASL_OK: PN_SASL_OK,
- Sasl.PN_SASL_AUTH: PN_SASL_AUTH,
- Sasl.PN_SASL_SYS: PN_SASL_SYS,
- Sasl.PN_SASL_PERM: PN_SASL_PERM,
- Sasl.PN_SASL_TEMP: PN_SASL_TEMP,
-}
-
-def pn_transport_require_auth(transport, require):
- raise Skipped('Not supported in Proton-J')
-
-# TODO: Placeholders
-def pn_transport_is_authenticated(transport):
- raise Skipped('Not supported in Proton-J')
-
-def pn_transport_is_encrypted(transport):
- raise Skipped('Not supported in Proton-J')
-
-def pn_transport_get_user(transport):
- raise Skipped('Not supported in Proton-J')
-
-def pn_connection_set_user(connection, user):
- pass
-
-def pn_connection_set_password(connection, password):
- pass
-
-def pn_sasl_allowed_mechs(sasl, mechs):
- sasl.setMechanisms(*mechs.split())
-
-def pn_sasl_set_allow_insecure_mechs(sasl, insecure):
- pass
-
-def pn_sasl_done(sasl, outcome):
- sasl.done(SASL_OUTCOMES_P2J[outcome])
-
-def pn_sasl_outcome(sasl):
- return SASL_OUTCOMES_J2P[sasl.getOutcome()]
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/cssl.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/cssl.py b/tests/java/shim/cssl.py
deleted file mode 100644
index d389984..0000000
--- a/tests/java/shim/cssl.py
+++ /dev/null
@@ -1,126 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-from org.apache.qpid.proton import Proton
-from org.apache.qpid.proton.engine import SslDomain
-
-from cerror import *
-
-# from proton/ssl.h
-PN_SSL_MODE_CLIENT = 1
-PN_SSL_MODE_SERVER = 2
-
-PN_SSL_RESUME_UNKNOWN = 0
-PN_SSL_RESUME_NEW = 1
-PN_SSL_RESUME_REUSED = 2
-
-PN_SSL_VERIFY_NULL=0
-PN_SSL_VERIFY_PEER=1
-PN_SSL_ANONYMOUS_PEER=2
-PN_SSL_VERIFY_PEER_NAME=3
-
-PN_SSL_SHA1=0
-PN_SSL_SHA256=1
-PN_SSL_SHA512=2
-PN_SSL_MD5=3
-
-PN_SSL_CERT_SUBJECT_COUNTRY_NAME=0
-PN_SSL_CERT_SUBJECT_STATE_OR_PROVINCE=1
-PN_SSL_CERT_SUBJECT_CITY_OR_LOCALITY=2
-PN_SSL_CERT_SUBJECT_ORGANIZATION_NAME=3
-PN_SSL_CERT_SUBJECT_ORGANIZATION_UNIT=4
-PN_SSL_CERT_SUBJECT_COMMON_NAME=5
-
-PN_SSL_MODE_J2P = {
- SslDomain.Mode.CLIENT: PN_SSL_MODE_CLIENT,
- SslDomain.Mode.SERVER: PN_SSL_MODE_SERVER
-}
-
-PN_SSL_MODE_P2J = {
- PN_SSL_MODE_CLIENT: SslDomain.Mode.CLIENT,
- PN_SSL_MODE_SERVER: SslDomain.Mode.SERVER
-}
-
-def pn_ssl_present():
- return True
-
-def pn_ssl_domain(mode):
- domain = Proton.sslDomain()
- domain.init(PN_SSL_MODE_P2J[mode])
- return domain
-
-def pn_ssl_domain_set_credentials(domain, certificate_file, private_key_file, password):
- domain.setCredentials(certificate_file, private_key_file, password)
- return 0
-
-def pn_ssl_domain_set_trusted_ca_db(domain, trusted_db):
- domain.setTrustedCaDb(trusted_db)
- return 0
-
-PN_VERIFY_MODE_J2P = {
- None: PN_SSL_VERIFY_NULL,
- SslDomain.VerifyMode.VERIFY_PEER: PN_SSL_VERIFY_PEER,
- SslDomain.VerifyMode.VERIFY_PEER_NAME: PN_SSL_VERIFY_PEER_NAME,
- SslDomain.VerifyMode.ANONYMOUS_PEER: PN_SSL_ANONYMOUS_PEER
-}
-
-PN_VERIFY_MODE_P2J = {
- PN_SSL_VERIFY_NULL: None,
- PN_SSL_VERIFY_PEER: SslDomain.VerifyMode.VERIFY_PEER,
- PN_SSL_VERIFY_PEER_NAME: SslDomain.VerifyMode.VERIFY_PEER_NAME,
- PN_SSL_ANONYMOUS_PEER: SslDomain.VerifyMode.ANONYMOUS_PEER
-}
-
-def pn_ssl_domain_set_peer_authentication(domain, mode, trusted=None):
- domain.setPeerAuthentication(PN_VERIFY_MODE_P2J[mode])
- if trusted:
- domain.setTrustedCaDb(trusted)
- return 0
-
-def pn_ssl_domain_allow_unsecured_client(domain):
- domain.allowUnsecuredClient(True)
- return 0
-
-class pn_ssl_wrapper:
-
- def __init__(self, transport):
- self.impl = None
- self.transport = transport
-
-def pn_ssl(transport):
- if getattr(transport, "ssl", None) is not None:
- return transport.ssl
- else:
- transport.ssl = pn_ssl_wrapper(transport)
- return transport.ssl
-
-def pn_ssl_init(ssl, domain, session_id):
- # XXX: session_id
- ssl.impl = ssl.transport.impl.ssl(domain, None)
-
-def pn_ssl_resume_status(ssl):
- raise Skipped()
-
-def pn_ssl_get_cipher_name(ssl, size):
- name = ssl.impl.getCipherName()
- return (bool(name), name)
-
-def pn_ssl_get_protocol_name(ssl, size):
- name = ssl.impl.getProtocolName()
- return (bool(name), name)
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/ctypes.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/ctypes.py b/tests/java/shim/ctypes.py
deleted file mode 100644
index bd88b17..0000000
--- a/tests/java/shim/ctypes.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# from proton/types.h
-PN_MILLIS_MAX = 4294967295
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/java/shim/curl.py
----------------------------------------------------------------------
diff --git a/tests/java/shim/curl.py b/tests/java/shim/curl.py
deleted file mode 100644
index d4d3d37..0000000
--- a/tests/java/shim/curl.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License
-#
-
-from org.apache.qpid.proton.messenger.impl import Address
-
-def pn_url():
- return Address()
-
-def pn_url_parse(urlstr):
- return Address(urlstr)
-
-def pn_url_free(url): pass
-
-def pn_url_clear(url):
- url.clear();
-
-def pn_url_str(url): return url.toString()
-
-def pn_url_get_scheme(url): return url.getScheme()
-def pn_url_get_username(url): return url.getUser()
-def pn_url_get_password(url): return url.getPass()
-def pn_url_get_host(url): return url.getHost() or None
-def pn_url_get_port(url): return url.getPort()
-def pn_url_get_path(url): return url.getName()
-
-def pn_url_set_scheme(url, value): url.setScheme(value)
-def pn_url_set_username(url, value): url.setUser(value)
-def pn_url_set_password(url, value): url.setPass(value)
-def pn_url_set_host(url, value): url.setHost(value)
-def pn_url_set_port(url, value): url.setPort(value)
-def pn_url_set_path(url, value): url.setName(value)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/pom.xml b/tests/pom.xml
deleted file mode 100644
index c01089f..0000000
--- a/tests/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- -
- - Licensed to the Apache Software Foundation (ASF) under one
- - or more contributor license agreements. See the NOTICE file
- - distributed with this work for additional information
- - regarding copyright ownership. The ASF licenses this file
- - to you under the Apache License, Version 2.0 (the
- - "License"); you may not use this file except in compliance
- - with the License. You may obtain a copy of the License at
- -
- - http://www.apache.org/licenses/LICENSE-2.0
- -
- - Unless required by applicable law or agreed to in writing,
- - software distributed under the License is distributed on an
- - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- - KIND, either express or implied. See the License for the
- - specific language governing permissions and limitations
- - under the License.
- -
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>proton-tests</artifactId>
- <name>proton-tests</name>
-
- <parent>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-project</artifactId>
- <version>0.17.0-SNAPSHOT</version>
- </parent>
-
- <description>The Proton python system tests execute against the Java or C implementation, using Maven (via this pom) and CMake/CTest respectively.
-
-To run the tests against proton-j, execute:
-
-mvn test
-
-Example of advanced usage (all of the -D flags are optional):
-
-mvn test \
--Dproton.pythontest.pattern='proton_tests.transport.ClientTransportTest.*' \
--Dproton.pythontest.invocations=20 \
--Dproton.pythontest.always_colorize=true
- </description>
-
- <scm>
- <url>http://svn.apache.org/viewvc/qpid/proton/</url>
- </scm>
-
- <properties>
- <testReportOutputDirectory>${basedir}/target/surefire-reports</testReportOutputDirectory>
- </properties>
-
- <build>
- <!-- System tests are arranged by language, hence the non-default location of the JUnit tests. -->
- <testSourceDirectory>java</testSourceDirectory>
- <resources>
- <resource><directory>resources</directory></resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <protonJythonIgnoreFile>${basedir}/java/pythonTests.ignore</protonJythonIgnoreFile>
- <protonJythonTestRoot>${basedir}/python</protonJythonTestRoot>
- <protonJythonBinding>${basedir}/../proton-c/bindings/python</protonJythonBinding>
- <protonJythonShim>${basedir}/java/shim</protonJythonShim>
- <protonJythonTestScript>${basedir}/python/proton-test</protonJythonTestScript>
- <protonJythonTestXmlOutputDirectory>${testReportOutputDirectory}</protonJythonTestXmlOutputDirectory>
- <java.util.logging.config.file>${project.build.outputDirectory}/logging.properties</java.util.logging.config.file>
- </systemPropertyVariables>
- <reportsDirectory>${testReportOutputDirectory}</reportsDirectory>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-j</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcpkix-jdk15on</artifactId>
- <version>1.53</version>
- </dependency>
- <dependency>
- <groupId>org.python</groupId>
- <artifactId>jython-standalone</artifactId>
- <version>2.7.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/python/proton_tests/__init__.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/__init__.py b/tests/python/proton_tests/__init__.py
index 091fa49..66ce650 100644
--- a/tests/python/proton_tests/__init__.py
+++ b/tests/python/proton_tests/__init__.py
@@ -22,7 +22,6 @@ import proton_tests.engine
import proton_tests.message
import proton_tests.handler
import proton_tests.reactor
-import proton_tests.reactor_interop
import proton_tests.messenger
import proton_tests.sasl
import proton_tests.transport
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index a25dc2f..424570d 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -267,144 +267,6 @@ class ExceptionTest(Test):
assert False, "expected barf to be cancelled"
-class HandlerDerivationTest(Test):
- def setUp(self):
- import platform
- if platform.python_implementation() != "Jython":
- # Exception propagation does not work currently for CPython
- raise SkipTest()
- self.reactor = Reactor()
-
- def wrong_exception(self):
- import sys
- ex = sys.exc_info()
- assert False, " Unexpected exception " + str(ex[1])
-
- def test_reactor_final_derived(self):
- h = BarfOnFinalDerived()
- self.reactor.global_handler = h
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except Barf:
- pass
- except:
- self.wrong_exception()
-
- def test_reactor_final_py_child_py(self):
- class APoorExcuseForAHandler:
- def __init__(self):
- self.handlers = [BarfOnFinal()]
- self.reactor.global_handler = APoorExcuseForAHandler()
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except Barf:
- pass
- except:
- self.wrong_exception()
-
- def test_reactor_final_py_child_derived(self):
- class APoorExcuseForAHandler:
- def __init__(self):
- self.handlers = [BarfOnFinalDerived()]
- self.reactor.global_handler = APoorExcuseForAHandler()
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except Barf:
- pass
- except:
- self.wrong_exception()
-
- def test_reactor_final_derived_child_derived(self):
- class APoorExcuseForAHandler(CHandshaker):
- def __init__(self):
- CHandshaker.__init__(self)
- self.handlers = [BarfOnFinalDerived()]
- self.reactor.global_handler = APoorExcuseForAHandler()
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except Barf:
- pass
- except:
- self.wrong_exception()
-
- def test_reactor_final_derived_child_py(self):
- class APoorExcuseForAHandler(CHandshaker):
- def __init__(self):
- CHandshaker.__init__(self)
- self.handlers = [BarfOnFinal()]
- self.reactor.global_handler = APoorExcuseForAHandler()
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except Barf:
- pass
- except:
- self.wrong_exception()
-
- def test_reactor_init_derived(self):
- h = BarfOnFinalDerived()
- self.reactor.global_handler = h
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except:
- assert h.init, "excpected the init"
-
- def test_reactor_init_py_child_py(self):
- h = BarfOnFinal()
- class APoorExcuseForAHandler:
- def __init__(self):
- self.handlers = [h]
- self.reactor.global_handler = APoorExcuseForAHandler()
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except:
- assert h.init, "excpected the init"
-
- def test_reactor_init_py_child_derived(self):
- h = BarfOnFinalDerived()
- class APoorExcuseForAHandler:
- def __init__(self):
- self.handlers = [h]
- self.reactor.global_handler = APoorExcuseForAHandler()
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except:
- assert h.init, "excpected the init"
-
- def test_reactor_init_derived_child_derived(self):
- h = BarfOnFinalDerived()
- class APoorExcuseForAHandler(CHandshaker):
- def __init__(self):
- CHandshaker.__init__(self)
- self.handlers = [h]
- self.reactor.global_handler = APoorExcuseForAHandler()
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except:
- assert h.init, "excpected the init"
-
- def test_reactor_init_derived_child_py(self):
- h = BarfOnFinal()
- class APoorExcuseForAHandler(CHandshaker):
- def __init__(self):
- CHandshaker.__init__(self)
- self.handlers = [h]
- self.reactor.global_handler = APoorExcuseForAHandler()
- try:
- self.reactor.run()
- assert False, "expected to barf"
- except:
- assert h.init, "excpected the init"
-
-
class ApplicationEventTest(Test):
"""Test application defined events and handlers."""
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/python/proton_tests/reactor_interop.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor_interop.py b/tests/python/proton_tests/reactor_interop.py
deleted file mode 100644
index 801a417..0000000
--- a/tests/python/proton_tests/reactor_interop.py
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-from __future__ import absolute_import
-
-from .common import Test, free_tcp_port, Skipped
-from proton import Message
-from proton.handlers import CHandshaker, CFlowController
-from proton.reactor import Reactor
-
-import os
-import subprocess
-from threading import Thread
-import time
-
-class JavaThread(Thread):
- def __init__(self, operation, port, count):
- Thread.__init__(self)
- self.operation = operation
- self.port = str(port)
- self.count = str(count)
- self.result = 1
-
- def run(self):
- self.result = subprocess.call(['java',
- 'org.apache.qpid.proton.ProtonJInterop',
- self.operation, self.port, self.count])
-
-class ReceiveHandler:
- def __init__(self, count):
- self.count = count
- self.handlers = [CHandshaker(), CFlowController()]
- self.messages = []
-
- def on_reactor_init(self, event):
- port = free_tcp_port()
- self.acceptor = event.reactor.acceptor("127.0.0.1", port)
- self.java_thread = JavaThread("send", port, self.count)
- self.java_thread.start()
-
- def on_delivery(self, event):
- rcv = event.receiver
- msg = Message()
- if rcv and msg.recv(rcv):
- event.delivery.settle()
- self.messages += [msg.body]
- self.count -= 1
- if (self.count == 0):
- self.acceptor.close()
-
-class SendHandler:
- def __init__(self, host, num_msgs):
- self.host = host
- self.num_msgs = num_msgs
- self.count = 0
- self.handlers = [CHandshaker()]
-
- def on_connection_init(self, event):
- conn = event.connection
- conn.hostname = self.host
- ssn = conn.session()
- snd = ssn.sender("sender")
- conn.open()
- ssn.open()
- snd.open()
-
- def on_link_flow(self, event):
- snd = event.sender
- if snd.credit > 0 and self.count < self.num_msgs:
- self.count += 1
- msg = Message("message-" + str(self.count))
- dlv = snd.send(msg)
- dlv.settle()
- if (self.count == self.num_msgs):
- snd.close()
- snd.session.close()
- snd.connection.close()
-
- def on_reactor_init(self, event):
- event.reactor.connection(self)
-
-class ReactorInteropTest(Test):
-
- def setUp(self):
- classpath = ""
- if ('CLASSPATH' in os.environ):
- classpath = os.environ['CLASSPATH']
- entries = classpath.split(os.pathsep)
- self.proton_j_available = False
- for entry in entries:
- self.proton_j_available |= entry != "" and os.path.exists(entry)
-
- def protonc_to_protonj(self, count):
- if (not self.proton_j_available):
- raise Skipped("ProtonJ not found")
-
- port = free_tcp_port()
- java_thread = JavaThread("recv", port, count)
- java_thread.start()
- # Give the Java thread time to spin up a JVM and start listening
- # XXX: would be better to parse the stdout output for a message
- time.sleep(1)
-
- sh = SendHandler('127.0.0.1:' + str(port), count)
- r = Reactor(sh)
- r.run()
-
- java_thread.join()
- assert(java_thread.result == 0)
-
- def protonj_to_protonc(self, count):
- if (not self.proton_j_available):
- raise Skipped("ProtonJ not found")
-
- rh = ReceiveHandler(count)
- r = Reactor(rh)
- r.run()
-
- rh.java_thread.join()
- assert(rh.java_thread.result == 0)
-
- for i in range(1, count):
- assert(rh.messages[i-1] == ("message-" + str(i)))
-
- def test_protonc_to_protonj_1(self):
- self.protonc_to_protonj(1)
-
- def test_protonc_to_protonj_5(self):
- self.protonc_to_protonj(5)
-
- def test_protonc_to_protonj_500(self):
- self.protonc_to_protonj(500)
-
- def test_protonc_to_protonj_5000(self):
- self.protonc_to_protonj(5000)
-
- def test_protonj_to_protonc_1(self):
- self.protonj_to_protonc(1)
-
- def test_protonj_to_protonc_5(self):
- self.protonj_to_protonc(5)
-
- def test_protonj_to_protonc_500(self):
- self.protonj_to_protonc(500)
-
- def test_protonj_to_protonc_5000(self):
- self.protonj_to_protonc(5000)
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tests/resources/logging.properties
----------------------------------------------------------------------
diff --git a/tests/resources/logging.properties b/tests/resources/logging.properties
deleted file mode 100644
index 311654f..0000000
--- a/tests/resources/logging.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-handlers = java.util.logging.ConsoleHandler
-
-java.util.logging.ConsoleHandler.level = ALL
-java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
-
-# Note: the following line forces log statements to appear on a single line
-# when running on JDK 1.7 and later
-java.util.logging.SimpleFormatter.format = %1$tF %1$tT.%tL %4$s %5$s%n
-
-.level = INFO
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tools/cmake/Modules/FindJava.cmake
----------------------------------------------------------------------
diff --git a/tools/cmake/Modules/FindJava.cmake b/tools/cmake/Modules/FindJava.cmake
deleted file mode 100644
index 1664fe1..0000000
--- a/tools/cmake/Modules/FindJava.cmake
+++ /dev/null
@@ -1,214 +0,0 @@
-# - Find Java
-# This module finds if Java is installed and determines where the
-# include files and libraries are. This code sets the following
-# variables:
-#
-# Java_JAVA_EXECUTABLE = the full path to the Java runtime
-# Java_JAVAC_EXECUTABLE = the full path to the Java compiler
-# Java_JAVAH_EXECUTABLE = the full path to the Java header generator
-# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator
-# Java_JAR_EXECUTABLE = the full path to the Java archiver
-# Java_VERSION_STRING = Version of the package found (java version), eg. 1.6.0_12
-# Java_VERSION_MAJOR = The major version of the package found.
-# Java_VERSION_MINOR = The minor version of the package found.
-# Java_VERSION_PATCH = The patch version of the package found.
-# Java_VERSION_TWEAK = The tweak version of the package found (after '_')
-# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak)
-#
-# The minimum required version of Java can be specified using the
-# standard CMake syntax, e.g. find_package(Java 1.5)
-#
-# NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to be
-# identical. For example some java version may return:
-# Java_VERSION_STRING = 1.5.0_17
-# and
-# Java_VERSION = 1.5.0.17
-#
-# another example is the Java OEM, with:
-# Java_VERSION_STRING = 1.6.0-oem
-# and
-# Java_VERSION = 1.6.0
-#
-# For these components the following variables are set:
-#
-# Java_FOUND - TRUE if all components are found.
-# Java_INCLUDE_DIRS - Full paths to all include dirs.
-# Java_LIBRARIES - Full paths to all libraries.
-# Java_<component>_FOUND - TRUE if <component> is found.
-#
-# Example Usages:
-# find_package(Java)
-# find_package(Java COMPONENTS Runtime)
-# find_package(Java COMPONENTS Development)
-#
-
-#=============================================================================
-# Copyright 2002-2009 Kitware, Inc.
-# Copyright 2009-2011 Mathieu Malaterre <ma...@gmail.com>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-
-# The HINTS option should only be used for values computed from the system.
-set(_JAVA_HINTS
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin"
- $ENV{JAVA_HOME}/bin
- )
-# Hard-coded guesses should still go in PATHS. This ensures that the user
-# environment can always override hard guesses.
-set(_JAVA_PATHS
- /usr/lib/java/bin
- /usr/share/java/bin
- /usr/local/java/bin
- /usr/local/java/share/bin
- /usr/java/j2sdk1.4.2_04
- /usr/lib/j2sdk1.4-sun/bin
- /usr/java/j2sdk1.4.2_09/bin
- /usr/lib/j2sdk1.5-sun/bin
- /opt/sun-jdk-1.5.0.04/bin
- )
-find_program(Java_JAVA_EXECUTABLE
- NAMES java
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
-)
-
-if(Java_JAVA_EXECUTABLE)
- execute_process(COMMAND ${Java_JAVA_EXECUTABLE} -version
- RESULT_VARIABLE res
- OUTPUT_VARIABLE var
- ERROR_VARIABLE var # sun-java output to stderr
- OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_STRIP_TRAILING_WHITESPACE)
- if( res )
- if(${Java_FIND_REQUIRED})
- message( FATAL_ERROR "Error executing java -version" )
- else()
- message( STATUS "Warning, could not run java --version")
- endif()
- else()
- # extract major/minor version and patch level from "java -version" output
- # Tested on linux using
- # 1. Sun / Sun OEM
- # 2. OpenJDK 1.6
- # 3. GCJ 1.5
- # 4. Kaffe 1.4.2
- if(var MATCHES "(java|openjdk) version \"[0-9]+\\.[0-9]+\\.[0-9_.]+.*\".*")
- # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer
- string( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\".*"
- "\\1" Java_VERSION_STRING "${var}" )
- elseif(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*")
- # Kaffe style
- string( REGEX REPLACE "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+).*"
- "\\1" Java_VERSION_STRING "${var}" )
- else()
- if(NOT Java_FIND_QUIETLY)
- message(WARNING "regex not supported: ${var}. Please report")
- endif()
- endif()
- string( REGEX REPLACE "([0-9]+).*" "\\1" Java_VERSION_MAJOR "${Java_VERSION_STRING}" )
- string( REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_MINOR "${Java_VERSION_STRING}" )
- string( REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_PATCH "${Java_VERSION_STRING}" )
- # warning tweak version can be empty:
- string( REGEX REPLACE "[0-9]+\\.[0-9]+\\.[0-9]+[_\\.]?([0-9]*).*$" "\\1" Java_VERSION_TWEAK "${Java_VERSION_STRING}" )
- if( Java_VERSION_TWEAK STREQUAL "" ) # check case where tweak is not defined
- set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH})
- else()
- set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH}.${Java_VERSION_TWEAK})
- endif()
- endif()
-
-endif()
-
-
-find_program(Java_JAR_EXECUTABLE
- NAMES jar
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
-)
-
-find_program(Java_JAVAC_EXECUTABLE
- NAMES javac
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
-)
-
-find_program(Java_JAVAH_EXECUTABLE
- NAMES javah
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
-)
-
-find_program(Java_JAVADOC_EXECUTABLE
- NAMES javadoc
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
-)
-
-#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-include(FindPackageHandleStandardArgs)
-if(Java_FIND_COMPONENTS)
-
- # Apache Qpid Proton doesn't support this because of find_package_handle_standard_args
- # differences (see comment below)
- message(FATAL_ERROR "Apache Qpid Proton FindJava does not support Java_FIND_COMPONENTS")
-
- foreach(component ${Java_FIND_COMPONENTS})
- # User just want to execute some Java byte-compiled
- if(component STREQUAL "Runtime")
- find_package_handle_standard_args(Java
- REQUIRED_VARS Java_JAVA_EXECUTABLE
- VERSION_VAR Java_VERSION
- )
- elseif(component STREQUAL "Development")
- find_package_handle_standard_args(Java
- REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
- Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
- VERSION_VAR Java_VERSION
- )
- else()
- message(FATAL_ERROR "Comp: ${component} is not handled")
- endif()
- set(Java_${component}_FOUND TRUE)
- endforeach()
-else()
- # Check for everything
-
- # Apache Qpid Proton local change: the line below has been tweaked because
- # the signature of find_package_handle_standard_args in cmake 2.6 lacks the
- # REQUIRED_VARS and VERSION_VAR parameters, and specifies the error message differently.
-
- find_package_handle_standard_args(Java DEFAULT_MSG
- Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
- Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
- )
-endif()
-
-
-mark_as_advanced(
- Java_JAVA_EXECUTABLE
- Java_JAR_EXECUTABLE
- Java_JAVAC_EXECUTABLE
- Java_JAVAH_EXECUTABLE
- Java_JAVADOC_EXECUTABLE
- )
-
-# LEGACY
-set(JAVA_RUNTIME ${Java_JAVA_EXECUTABLE})
-set(JAVA_ARCHIVE ${Java_JAR_EXECUTABLE})
-set(JAVA_COMPILE ${Java_JAVAC_EXECUTABLE})
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tools/cmake/Modules/ProtonUseJava.cmake
----------------------------------------------------------------------
diff --git a/tools/cmake/Modules/ProtonUseJava.cmake b/tools/cmake/Modules/ProtonUseJava.cmake
deleted file mode 100644
index 4b011ef..0000000
--- a/tools/cmake/Modules/ProtonUseJava.cmake
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# Adds a custom command to rebuild the JAR to include resources and the
-# directory entries that are missed by add_jar()
-
-function (rebuild_jar upstream_target jar_name)
- add_custom_command(TARGET ${upstream_target} POST_BUILD
- COMMAND ${Java_JAR_EXECUTABLE} cf ${jar_name}
- -C ${CMAKE_CURRENT_SOURCE_DIR}/src/main/resources .
- -C ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${upstream_target}.dir/ org
- COMMENT "Rebuilding ${jar_name} to include missing resources")
-endfunction ()
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tools/cmake/Modules/ProtonUseJavaSourceFileList.cmake
----------------------------------------------------------------------
diff --git a/tools/cmake/Modules/ProtonUseJavaSourceFileList.cmake b/tools/cmake/Modules/ProtonUseJavaSourceFileList.cmake
deleted file mode 100644
index f1c106d..0000000
--- a/tools/cmake/Modules/ProtonUseJavaSourceFileList.cmake
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# Produces a text file containing a list of java source files from one
-# or more java source directories. Produces output suitable for use
-# with javac's @ source file argument.
-#
-# JAVA_SOURCE_DIR_PATHS - colon (:) separated string of java source directories
-# JAVA_SOURCE_FILE_LIST - name of text file to write
-#
-
-if (JAVA_SOURCE_DIR_PATHS)
- string(REPLACE ":" ";" JAVA_SOURCE_DIR_PATHS_LIST ${JAVA_SOURCE_DIR_PATHS})
- message(STATUS "Java source paths: ${JAVA_SOURCE_DIR_PATHS}")
-
- set(_JAVA_GLOBBED_FILES)
- foreach(JAVA_SOURCE_DIR_PATH ${JAVA_SOURCE_DIR_PATHS_LIST})
- if (EXISTS "${JAVA_SOURCE_DIR_PATH}")
- file(GLOB_RECURSE _JAVA_GLOBBED_TMP_FILES "${JAVA_SOURCE_DIR_PATH}/*.java")
- if (_JAVA_GLOBBED_TMP_FILES)
- list(APPEND _JAVA_GLOBBED_FILES ${_JAVA_GLOBBED_TMP_FILES})
- endif ()
- else ()
- message(SEND_ERROR "FATAL: Java source path ${JAVA_SOURCE_DIR_PATH} doesn't exist")
- endif ()
- endforeach()
-
- set (_CHECK_STALE OFF)
- set(_GENERATE_FILE_LIST ON)
- if (EXISTS ${JAVA_SOURCE_FILE_LIST})
- set (_CHECK_STALE ON)
- set(_GENERATE_FILE_LIST OFF)
- endif ()
-
- set(_JAVA_SOURCE_FILES_SEPARATED)
- foreach(_JAVA_GLOBBED_FILE ${_JAVA_GLOBBED_FILES})
- if (_CHECK_STALE)
- if (${_JAVA_GLOBBED_FILE} IS_NEWER_THAN ${JAVA_SOURCE_FILE_LIST})
- set(_GENERATE_FILE_LIST ON)
- endif()
- endif()
- set(_JAVA_SOURCE_FILES_SEPARATED ${_JAVA_SOURCE_FILES_SEPARATED}${_JAVA_GLOBBED_FILE}\n)
- endforeach()
-
- if (_GENERATE_FILE_LIST)
- message(STATUS "Writing Java source file list to ${JAVA_SOURCE_FILE_LIST}")
- file(WRITE ${JAVA_SOURCE_FILE_LIST} ${_JAVA_SOURCE_FILES_SEPARATED})
- endif()
-else ()
- message(SEND_ERROR "FATAL: Can't find JAVA_SOURCE_DIR_PATHS")
-endif ()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tools/cmake/Modules/README
----------------------------------------------------------------------
diff --git a/tools/cmake/Modules/README b/tools/cmake/Modules/README
deleted file mode 100644
index 1c679c0..0000000
--- a/tools/cmake/Modules/README
+++ /dev/null
@@ -1,14 +0,0 @@
-CMake Modules
-=============
-
-Contents:
-
-UseJava, UseJavaSymLinks, UseJavaClassFilelist:
-
-These are Andreas Schneider's CMake Java Support. We have our own local copy as all versions of
-CMake < 2.8.9 have defects in their Java support that affect us. Local modifications are commented
-with "Apache Qpid Proton...".
-
-UseProtonJava:
-
-Custom support functions for the Proton Java modules
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tools/cmake/Modules/UseJava.cmake
----------------------------------------------------------------------
diff --git a/tools/cmake/Modules/UseJava.cmake b/tools/cmake/Modules/UseJava.cmake
deleted file mode 100644
index 444343e..0000000
--- a/tools/cmake/Modules/UseJava.cmake
+++ /dev/null
@@ -1,1015 +0,0 @@
-# - Use Module for Java
-# This file provides functions for Java. It is assumed that FindJava.cmake
-# has already been loaded. See FindJava.cmake for information on how to
-# load Java into your CMake project.
-#
-# add_jar(TARGET_NAME SRC1 SRC2 .. SRCN RCS1 RCS2 .. RCSN)
-#
-# This command creates a <TARGET_NAME>.jar. It compiles the given source
-# files (SRC) and adds the given resource files (RCS) to the jar file.
-# If only resource files are given then just a jar file is created.
-#
-# Additional instructions:
-# To add compile flags to the target you can set these flags with
-# the following variable:
-#
-# set(CMAKE_JAVA_COMPILE_FLAGS -nowarn)
-#
-# To add a path or a jar file to the class path you can do this
-# with the CMAKE_JAVA_INCLUDE_PATH variable.
-#
-# set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar)
-#
-# To use a different output name for the target you can set it with:
-#
-# set(CMAKE_JAVA_TARGET_OUTPUT_NAME shibboleet.jar)
-# add_jar(foobar foobar.java)
-#
-# To use a different output directory than CMAKE_CURRENT_BINARY_DIR
-# you can set it with:
-#
-# set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin)
-#
-# To define an entry point in your jar you can set it with:
-#
-# set(CMAKE_JAVA_JAR_ENTRY_POINT com/examples/MyProject/Main)
-#
-# To add a VERSION to the target output name you can set it using
-# CMAKE_JAVA_TARGET_VERSION. This will create a jar file with the name
-# shibboleet-1.0.0.jar and will create a symlink shibboleet.jar
-# pointing to the jar with the version information.
-#
-# set(CMAKE_JAVA_TARGET_VERSION 1.2.0)
-# add_jar(shibboleet shibbotleet.java)
-#
-# If the target is a JNI library, utilize the following commands to
-# create a JNI symbolic link:
-#
-# set(CMAKE_JNI_TARGET TRUE)
-# set(CMAKE_JAVA_TARGET_VERSION 1.2.0)
-# add_jar(shibboleet shibbotleet.java)
-# install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet)
-# install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR})
-#
-# If a single target needs to produce more than one jar from its
-# java source code, to prevent the accumulation of duplicate class
-# files in subsequent jars, set/reset CMAKE_JAR_CLASSES_PREFIX prior
-# to calling the add_jar() function:
-#
-# set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo)
-# add_jar(foo foo.java)
-#
-# set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar)
-# add_jar(bar bar.java)
-#
-# Target Properties:
-# The add_jar() functions sets some target properties. You can get these
-# properties with the
-# get_property(TARGET <target_name> PROPERTY <propery_name>)
-# command.
-#
-# INSTALL_FILES The files which should be installed. This is used by
-# install_jar().
-# JNI_SYMLINK The JNI symlink which should be installed.
-# This is used by install_jni_symlink().
-# JAR_FILE The location of the jar file so that you can include
-# it.
-# CLASS_DIR The directory where the class files can be found. For
-# example to use them with javah.
-#
-# find_jar(<VAR>
-# name | NAMES name1 [name2 ...]
-# [PATHS path1 [path2 ... ENV var]]
-# [VERSIONS version1 [version2]]
-# [DOC "cache documentation string"]
-# )
-#
-# This command is used to find a full path to the named jar. A cache
-# entry named by <VAR> is created to stor the result of this command. If
-# the full path to a jar is found the result is stored in the variable
-# and the search will not repeated unless the variable is cleared. If
-# nothing is found, the result will be <VAR>-NOTFOUND, and the search
-# will be attempted again next time find_jar is invoked with the same
-# variable.
-# The name of the full path to a file that is searched for is specified
-# by the names listed after NAMES argument. Additional search locations
-# can be specified after the PATHS argument. If you require special a
-# version of a jar file you can specify it with the VERSIONS argument.
-# The argument after DOC will be used for the documentation string in
-# the cache.
-#
-# install_jar(TARGET_NAME DESTINATION)
-#
-# This command installs the TARGET_NAME files to the given DESTINATION.
-# It should be called in the same scope as add_jar() or it will fail.
-#
-# install_jni_symlink(TARGET_NAME DESTINATION)
-#
-# This command installs the TARGET_NAME JNI symlinks to the given
-# DESTINATION. It should be called in the same scope as add_jar()
-# or it will fail.
-#
-# create_javadoc(<VAR>
-# PACKAGES pkg1 [pkg2 ...]
-# [SOURCEPATH <sourcepath>]
-# [CLASSPATH <classpath>]
-# [INSTALLPATH <install path>]
-# [DOCTITLE "the documentation title"]
-# [WINDOWTITLE "the title of the document"]
-# [AUTHOR TRUE|FALSE]
-# [USE TRUE|FALSE]
-# [VERSION TRUE|FALSE]
-# )
-#
-# Create java documentation based on files or packages. For more
-# details please read the javadoc manpage.
-#
-# There are two main signatures for create_javadoc. The first
-# signature works with package names on a path with source files:
-#
-# Example:
-# create_javadoc(my_example_doc
-# PACKAGES com.exmaple.foo com.example.bar
-# SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}"
-# CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
-# WINDOWTITLE "My example"
-# DOCTITLE "<h1>My example</h1>"
-# AUTHOR TRUE
-# USE TRUE
-# VERSION TRUE
-# )
-#
-# The second signature for create_javadoc works on a given list of
-# files.
-#
-# create_javadoc(<VAR>
-# FILES file1 [file2 ...]
-# [CLASSPATH <classpath>]
-# [INSTALLPATH <install path>]
-# [DOCTITLE "the documentation title"]
-# [WINDOWTITLE "the title of the document"]
-# [AUTHOR TRUE|FALSE]
-# [USE TRUE|FALSE]
-# [VERSION TRUE|FALSE]
-# )
-#
-# Example:
-# create_javadoc(my_example_doc
-# FILES ${example_SRCS}
-# CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
-# WINDOWTITLE "My example"
-# DOCTITLE "<h1>My example</h1>"
-# AUTHOR TRUE
-# USE TRUE
-# VERSION TRUE
-# )
-#
-# Both signatures share most of the options. These options are the
-# same as what you can find in the javadoc manpage. Please look at
-# the manpage for CLASSPATH, DOCTITLE, WINDOWTITLE, AUTHOR, USE and
-# VERSION.
-#
-# The documentation will be by default installed to
-#
-# ${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR>
-#
-# if you don't set the INSTALLPATH.
-#
-
-#=============================================================================
-# Copyright 2010-2011 Andreas schneider <as...@redhat.com>
-# Copyright 2010 Ben Boeckel <be...@kitware.com>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-
-function (__java_copy_file src dest comment)
- add_custom_command(
- OUTPUT ${dest}
- COMMAND cmake -E copy_if_different
- ARGS ${src}
- ${dest}
- DEPENDS ${src}
- COMMENT ${comment})
-endfunction ()
-
-# define helper scripts
-#set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.cmake)
-#set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake)
-set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_MODULE_PATH}/UseJavaClassFilelist.cmake)
-set(_JAVA_SYMLINK_SCRIPT ${CMAKE_MODULE_PATH}/UseJavaSymlinks.cmake)
-
-# Apache Qpid Proton: changed to write a source file list to avoid hitting
-# command line limits when processing many source files.
-function(add_jar _TARGET_NAME)
- set(_JAVA_SOURCE_FILES ${ARGN})
-
- if (NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
- set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
- endif()
-
- if (CMAKE_JAVA_JAR_ENTRY_POINT)
- set(_ENTRY_POINT_OPTION e)
- set(_ENTRY_POINT_VALUE ${CMAKE_JAVA_JAR_ENTRY_POINT})
- endif ()
-
- if (LIBRARY_OUTPUT_PATH)
- set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
- else ()
- set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR})
- endif ()
-
- set(CMAKE_JAVA_INCLUDE_PATH
- ${CMAKE_JAVA_INCLUDE_PATH}
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_JAVA_OBJECT_OUTPUT_PATH}
- ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH}
- )
-
- if (WIN32 AND NOT CYGWIN)
- set(CMAKE_JAVA_INCLUDE_FLAG_SEP ";")
- else ()
- set(CMAKE_JAVA_INCLUDE_FLAG_SEP ":")
- endif()
-
- foreach (JAVA_INCLUDE_DIR ${CMAKE_JAVA_INCLUDE_PATH})
- set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}")
- endforeach()
-
- set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_JAVA_TARGET_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
-
- set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
- if (CMAKE_JAVA_TARGET_OUTPUT_NAME AND CMAKE_JAVA_TARGET_VERSION)
- set(_JAVA_TARGET_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}-${CMAKE_JAVA_TARGET_VERSION}.jar")
- set(_JAVA_TARGET_OUTPUT_LINK "${CMAKE_JAVA_TARGET_OUTPUT_NAME}.jar")
- elseif (CMAKE_JAVA_TARGET_VERSION)
- set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}-${CMAKE_JAVA_TARGET_VERSION}.jar")
- set(_JAVA_TARGET_OUTPUT_LINK "${_TARGET_NAME}.jar")
- elseif (CMAKE_JAVA_TARGET_OUTPUT_NAME)
- set(_JAVA_TARGET_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}.jar")
- endif ()
- # reset
- set(CMAKE_JAVA_TARGET_OUTPUT_NAME)
-
- set(_JAVA_CLASS_FILES)
- set(_JAVA_COMPILE_FILES)
- set(_JAVA_DEPENDS)
- set(_JAVA_RESOURCE_FILES)
- foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES})
- get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
- get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE)
- get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
- get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
-
- file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR} ${_JAVA_FULL})
- file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
- string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
- string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
- if (${_BIN_LEN} LESS ${_SRC_LEN})
- set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH})
- else ()
- set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH})
- endif ()
- get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH)
-
- if (_JAVA_EXT MATCHES ".java")
- list(APPEND _JAVA_COMPILE_FILES ${_JAVA_SOURCE_FILE})
- set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class")
- set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE})
-
- elseif (_JAVA_EXT MATCHES ".jar"
- OR _JAVA_EXT MATCHES ".war"
- OR _JAVA_EXT MATCHES ".ear"
- OR _JAVA_EXT MATCHES ".sar")
- list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_SOURCE_FILE})
-
- elseif (_JAVA_EXT STREQUAL "")
- list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH})
- list(APPEND _JAVA_DEPENDS ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}})
-
- else ()
- __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE}
- ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}
- "Copying ${_JAVA_SOURCE_FILE} to the build directory")
- list(APPEND _JAVA_RESOURCE_FILES ${_JAVA_SOURCE_FILE})
- endif ()
- endforeach()
-
- set(CMAKE_JAVA_SOURCE_FILE_LIST ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_source_filelist)
- string(REPLACE ";" "\n" _JAVA_COMPILE_FILES_NEWLINE_SEPARATED "${_JAVA_COMPILE_FILES}")
- file(WRITE ${CMAKE_JAVA_SOURCE_FILE_LIST} "${_JAVA_COMPILE_FILES_NEWLINE_SEPARATED}")
-
- # create an empty java_class_filelist
- if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
- file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")
- endif()
-
- if (_JAVA_COMPILE_FILES)
- # Compile the java files and create a list of class files
- add_custom_command(
- # NOTE: this command generates an artificial dependency file
- OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
- COMMAND ${Java_JAVAC_EXECUTABLE}
- ${CMAKE_JAVA_COMPILE_FLAGS}
- -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
- -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- @${CMAKE_JAVA_SOURCE_FILE_LIST}
- COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
- DEPENDS ${_JAVA_COMPILE_FILES}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
- )
- add_custom_command(
- OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
- COMMAND ${CMAKE_COMMAND}
- -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}"
- -P ${_JAVA_CLASS_FILELIST_SCRIPT}
- DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- endif ()
-
- # create the jar file
- set(_JAVA_JAR_OUTPUT_PATH
- ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
- if (CMAKE_JNI_TARGET)
- add_custom_command(
- OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
- COMMAND ${Java_JAR_EXECUTABLE}
- -cf${_ENTRY_POINT_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE}
- ${_JAVA_RESOURCE_FILES} @java_class_filelist
- COMMAND ${CMAKE_COMMAND}
- -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
- -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
- -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
- -P ${_JAVA_SYMLINK_SCRIPT}
- COMMAND ${CMAKE_COMMAND}
- -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
- -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_JAR_OUTPUT_PATH}
- -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
- -P ${_JAVA_SYMLINK_SCRIPT}
- DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
- WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
- )
- else ()
- add_custom_command(
- OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
- COMMAND ${Java_JAR_EXECUTABLE}
- -cf${_ENTRY_POINT_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE}
- ${_JAVA_RESOURCE_FILES} @java_class_filelist
- COMMAND ${CMAKE_COMMAND}
- -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
- -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
- -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
- -P ${_JAVA_SYMLINK_SCRIPT}
- WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
- COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
- )
- endif ()
-
- # Add the target and make sure we have the latest resource files.
- add_custom_target(${_TARGET_NAME} ALL DEPENDS ${_JAVA_JAR_OUTPUT_PATH})
-
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- INSTALL_FILES
- ${_JAVA_JAR_OUTPUT_PATH}
- )
-
- if (_JAVA_TARGET_OUTPUT_LINK)
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- INSTALL_FILES
- ${_JAVA_JAR_OUTPUT_PATH}
- ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
- )
-
- if (CMAKE_JNI_TARGET)
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- JNI_SYMLINK
- ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
- )
- endif ()
- endif ()
-
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- JAR_FILE
- ${_JAVA_JAR_OUTPUT_PATH}
- )
-
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- CLASSDIR
- ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- )
-
-endfunction()
-
-# Apache Qpid Proton: new function that accepts a file containing the Java source
-# files. This is useful when the set of source files is only discovered at make-time,
-# and avoids passing a wildcard argument to javac (which fails on some platforms)
-function(add_jar_from_filelist _TARGET_NAME CMAKE_JAVA_SOURCE_FILE_LIST)
-
- if (NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
- set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
- endif()
-
- set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_JAVA_TARGET_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
-
- set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
- if (CMAKE_JAVA_TARGET_OUTPUT_NAME AND CMAKE_JAVA_TARGET_VERSION)
- set(_JAVA_TARGET_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}-${CMAKE_JAVA_TARGET_VERSION}.jar")
- set(_JAVA_TARGET_OUTPUT_LINK "${CMAKE_JAVA_TARGET_OUTPUT_NAME}.jar")
- elseif (CMAKE_JAVA_TARGET_VERSION)
- set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}-${CMAKE_JAVA_TARGET_VERSION}.jar")
- set(_JAVA_TARGET_OUTPUT_LINK "${_TARGET_NAME}.jar")
- elseif (CMAKE_JAVA_TARGET_OUTPUT_NAME)
- set(_JAVA_TARGET_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}.jar")
- endif ()
- # reset
- set(CMAKE_JAVA_TARGET_OUTPUT_NAME)
-
- foreach (JAVA_INCLUDE_DIR ${CMAKE_JAVA_INCLUDE_PATH})
- set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}")
- endforeach()
-
- # create an empty java_class_filelist
- if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
- file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")
- endif ()
-
- # Compile the java files and create a list of class files
- add_custom_command(
- # NOTE: this command generates an artificial dependency file
- OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
- COMMAND ${Java_JAVAC_EXECUTABLE}
- ${CMAKE_JAVA_COMPILE_FLAGS}
- -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
- -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- @${CMAKE_JAVA_SOURCE_FILE_LIST}
- COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
- DEPENDS ${CMAKE_JAVA_SOURCE_FILE_LIST}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
- )
- add_custom_command(
- OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
- COMMAND ${CMAKE_COMMAND}
- -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}"
- -P ${_JAVA_CLASS_FILELIST_SCRIPT}
- DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
-
- # create the jar file
- set(_JAVA_JAR_OUTPUT_PATH
- ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
- add_custom_command(
- OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
- COMMAND ${Java_JAR_EXECUTABLE}
- -cf ${_JAVA_JAR_OUTPUT_PATH}
- ${_JAVA_RESOURCE_FILES} @java_class_filelist
- COMMAND ${CMAKE_COMMAND}
- -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
- -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
- -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
- -P ${_JAVA_SYMLINK_SCRIPT}
- WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
- COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
- )
- # Add the target and make sure we have the latest resource files.
- add_custom_target(${_TARGET_NAME} ALL DEPENDS ${_JAVA_JAR_OUTPUT_PATH})
-
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- INSTALL_FILES
- ${_JAVA_JAR_OUTPUT_PATH}
- )
-
- if (_JAVA_TARGET_OUTPUT_LINK)
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- INSTALL_FILES
- ${_JAVA_JAR_OUTPUT_PATH}
- ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
- )
-
- if (CMAKE_JNI_TARGET)
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- JNI_SYMLINK
- ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
- )
- endif ()
- endif ()
-
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- JAR_FILE
- ${_JAVA_JAR_OUTPUT_PATH}
- )
-
- set_property(
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- CLASSDIR
- ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- )
-
-endfunction()
-
-# Apache Qpid Proton: make the install files optional so as not to error if there is no symlink
-function(INSTALL_JAR _TARGET_NAME _DESTINATION)
- get_property(__FILES
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- INSTALL_FILES
- )
-
- if (__FILES)
- install(
- FILES
- ${__FILES}
- DESTINATION
- ${_DESTINATION}
- OPTIONAL
- )
- else ()
- message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.")
- endif ()
-endfunction()
-
-function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION)
- get_property(__SYMLINK
- TARGET
- ${_TARGET_NAME}
- PROPERTY
- JNI_SYMLINK
- )
-
- if (__SYMLINK)
- install(
- FILES
- ${__SYMLINK}
- DESTINATION
- ${_DESTINATION}
- )
- else ()
- message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.")
- endif ()
-endfunction()
-
-function (find_jar VARIABLE)
- set(_jar_names)
- set(_jar_files)
- set(_jar_versions)
- set(_jar_paths
- /usr/share/java/
- /usr/local/share/java/
- ${Java_JAR_PATHS})
- set(_jar_doc "NOTSET")
-
- set(_state "name")
-
- foreach (arg ${ARGN})
- if (${_state} STREQUAL "name")
- if (${arg} STREQUAL "VERSIONS")
- set(_state "versions")
- elseif (${arg} STREQUAL "NAMES")
- set(_state "names")
- elseif (${arg} STREQUAL "PATHS")
- set(_state "paths")
- elseif (${arg} STREQUAL "DOC")
- set(_state "doc")
- else ()
- set(_jar_names ${arg})
- if (_jar_doc STREQUAL "NOTSET")
- set(_jar_doc "Finding ${arg} jar")
- endif ()
- endif ()
- elseif (${_state} STREQUAL "versions")
- if (${arg} STREQUAL "NAMES")
- set(_state "names")
- elseif (${arg} STREQUAL "PATHS")
- set(_state "paths")
- elseif (${arg} STREQUAL "DOC")
- set(_state "doc")
- else ()
- set(_jar_versions ${_jar_versions} ${arg})
- endif ()
- elseif (${_state} STREQUAL "names")
- if (${arg} STREQUAL "VERSIONS")
- set(_state "versions")
- elseif (${arg} STREQUAL "PATHS")
- set(_state "paths")
- elseif (${arg} STREQUAL "DOC")
- set(_state "doc")
- else ()
- set(_jar_names ${_jar_names} ${arg})
- if (_jar_doc STREQUAL "NOTSET")
- set(_jar_doc "Finding ${arg} jar")
- endif ()
- endif ()
- elseif (${_state} STREQUAL "paths")
- if (${arg} STREQUAL "VERSIONS")
- set(_state "versions")
- elseif (${arg} STREQUAL "NAMES")
- set(_state "names")
- elseif (${arg} STREQUAL "DOC")
- set(_state "doc")
- else ()
- set(_jar_paths ${_jar_paths} ${arg})
- endif ()
- elseif (${_state} STREQUAL "doc")
- if (${arg} STREQUAL "VERSIONS")
- set(_state "versions")
- elseif (${arg} STREQUAL "NAMES")
- set(_state "names")
- elseif (${arg} STREQUAL "PATHS")
- set(_state "paths")
- else ()
- set(_jar_doc ${arg})
- endif ()
- endif ()
- endforeach ()
-
- if (NOT _jar_names)
- message(FATAL_ERROR "find_jar: No name to search for given")
- endif ()
-
- foreach (jar_name ${_jar_names})
- foreach (version ${_jar_versions})
- set(_jar_files ${_jar_files} ${jar_name}-${version}.jar)
- endforeach ()
- set(_jar_files ${_jar_files} ${jar_name}.jar)
- endforeach ()
-
- find_file(${VARIABLE}
- NAMES ${_jar_files}
- PATHS ${_jar_paths}
- DOC ${_jar_doc}
- NO_DEFAULT_PATH)
-endfunction ()
-
-function(create_javadoc _target)
- set(_javadoc_packages)
- set(_javadoc_files)
- set(_javadoc_sourcepath)
- set(_javadoc_classpath)
- set(_javadoc_installpath "${CMAKE_INSTALL_PREFIX}/share/javadoc")
- set(_javadoc_doctitle)
- set(_javadoc_windowtitle)
- set(_javadoc_author FALSE)
- set(_javadoc_version FALSE)
- set(_javadoc_use FALSE)
-
- set(_state "package")
-
- foreach (arg ${ARGN})
- if (${_state} STREQUAL "package")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- set(_javadoc_packages ${arg})
- set(_state "packages")
- endif ()
- elseif (${_state} STREQUAL "packages")
- if (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- list(APPEND _javadoc_packages ${arg})
- endif ()
- elseif (${_state} STREQUAL "files")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- list(APPEND _javadoc_files ${arg})
- endif ()
- elseif (${_state} STREQUAL "sourcepath")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- list(APPEND _javadoc_sourcepath ${arg})
- endif ()
- elseif (${_state} STREQUAL "classpath")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- list(APPEND _javadoc_classpath ${arg})
- endif ()
- elseif (${_state} STREQUAL "installpath")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- set(_javadoc_installpath ${arg})
- endif ()
- elseif (${_state} STREQUAL "doctitle")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- set(_javadoc_doctitle ${arg})
- endif ()
- elseif (${_state} STREQUAL "windowtitle")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- set(_javadoc_windowtitle ${arg})
- endif ()
- elseif (${_state} STREQUAL "author")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- set(_javadoc_author ${arg})
- endif ()
- elseif (${_state} STREQUAL "use")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- set(_javadoc_use ${arg})
- endif ()
- elseif (${_state} STREQUAL "version")
- if (${arg} STREQUAL "PACKAGES")
- set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
- set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
- set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
- set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
- set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
- set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
- set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
- set(_state "author")
- elseif (${arg} STREQUAL "USE")
- set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
- set(_state "version")
- else ()
- set(_javadoc_version ${arg})
- endif ()
- endif ()
- endforeach ()
-
- set(_javadoc_builddir ${CMAKE_CURRENT_BINARY_DIR}/javadoc/${_target})
- set(_javadoc_options -d ${_javadoc_builddir})
-
- if (_javadoc_sourcepath)
- set(_start TRUE)
- foreach(_path ${_javadoc_sourcepath})
- if (_start)
- set(_sourcepath ${_path})
- set(_start FALSE)
- else ()
- set(_sourcepath ${_sourcepath}:${_path})
- endif ()
- endforeach()
- set(_javadoc_options ${_javadoc_options} -sourcepath ${_sourcepath})
- endif ()
-
- if (_javadoc_classpath)
- set(_start TRUE)
- foreach(_path ${_javadoc_classpath})
- if (_start)
- set(_classpath ${_path})
- set(_start FALSE)
- else ()
- set(_classpath ${_classpath}:${_path})
- endif ()
- endforeach()
- set(_javadoc_options ${_javadoc_options} -classpath "${_classpath}")
- endif ()
-
- if (_javadoc_doctitle)
- set(_javadoc_options ${_javadoc_options} -doctitle '${_javadoc_doctitle}')
- endif ()
-
- if (_javadoc_windowtitle)
- set(_javadoc_options ${_javadoc_options} -windowtitle '${_javadoc_windowtitle}')
- endif ()
-
- if (_javadoc_author)
- set(_javadoc_options ${_javadoc_options} -author)
- endif ()
-
- if (_javadoc_use)
- set(_javadoc_options ${_javadoc_options} -use)
- endif ()
-
- if (_javadoc_version)
- set(_javadoc_options ${_javadoc_options} -version)
- endif ()
-
- add_custom_target(${_target}_javadoc ALL
- COMMAND ${Java_JAVADOC_EXECUTABLE} ${_javadoc_options}
- ${_javadoc_files}
- ${_javadoc_packages}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
-
- install(
- DIRECTORY ${_javadoc_builddir}
- DESTINATION ${_javadoc_installpath}
- )
-endfunction()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tools/cmake/Modules/UseJavaClassFilelist.cmake
----------------------------------------------------------------------
diff --git a/tools/cmake/Modules/UseJavaClassFilelist.cmake b/tools/cmake/Modules/UseJavaClassFilelist.cmake
deleted file mode 100644
index 6f3a4e7..0000000
--- a/tools/cmake/Modules/UseJavaClassFilelist.cmake
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# This script create a list of compiled Java class files to be added to a
-# jar file. This avoids including cmake files which get created in the
-# binary directory.
-#
-
-#=============================================================================
-# Copyright 2010-2011 Andreas schneider <as...@redhat.com>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-
-if (CMAKE_JAVA_CLASS_OUTPUT_PATH)
- if (EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}")
-
- set(_JAVA_GLOBBED_FILES)
- if (CMAKE_JAR_CLASSES_PREFIX)
- foreach(JAR_CLASS_PREFIX ${CMAKE_JAR_CLASSES_PREFIX})
- message(STATUS "JAR_CLASS_PREFIX: ${JAR_CLASS_PREFIX}")
-
- file(GLOB_RECURSE _JAVA_GLOBBED_TMP_FILES "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${JAR_CLASS_PREFIX}/*.class")
- if (_JAVA_GLOBBED_TMP_FILES)
- list(APPEND _JAVA_GLOBBED_FILES ${_JAVA_GLOBBED_TMP_FILES})
- endif ()
- endforeach()
- else()
- file(GLOB_RECURSE _JAVA_GLOBBED_FILES "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/*.class")
- endif ()
-
- set(_JAVA_CLASS_FILES)
- # file(GLOB_RECURSE foo RELATIVE) is broken so we need this.
- foreach(_JAVA_GLOBBED_FILE ${_JAVA_GLOBBED_FILES})
- file(RELATIVE_PATH _JAVA_CLASS_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH} ${_JAVA_GLOBBED_FILE})
- set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES}${_JAVA_CLASS_FILE}\n)
- endforeach()
-
- # write to file
- file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist ${_JAVA_CLASS_FILES})
-
- else ()
- message(SEND_ERROR "FATAL: Java class output path doesn't exist")
- endif ()
-else ()
- message(SEND_ERROR "FATAL: Can't find CMAKE_JAVA_CLASS_OUTPUT_PATH")
-endif ()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/tools/cmake/Modules/UseJavaSymlinks.cmake
----------------------------------------------------------------------
diff --git a/tools/cmake/Modules/UseJavaSymlinks.cmake b/tools/cmake/Modules/UseJavaSymlinks.cmake
deleted file mode 100644
index 88dd768..0000000
--- a/tools/cmake/Modules/UseJavaSymlinks.cmake
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Helper script for UseJava.cmake
-#
-
-#=============================================================================
-# Copyright 2010-2011 Andreas schneider <as...@redhat.com>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-
-if (UNIX AND _JAVA_TARGET_OUTPUT_LINK)
- if (_JAVA_TARGET_OUTPUT_NAME)
- find_program(LN_EXECUTABLE
- NAMES
- ln
- )
-
- execute_process(
- COMMAND ${LN_EXECUTABLE} -sf "${_JAVA_TARGET_OUTPUT_NAME}" "${_JAVA_TARGET_OUTPUT_LINK}"
- WORKING_DIRECTORY ${_JAVA_TARGET_DIR}
- )
- else ()
- message(SEND_ERROR "FATAL: Can't find _JAVA_TARGET_OUTPUT_NAME")
- endif ()
-endif ()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[19/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/RejectedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/RejectedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/RejectedType.java
deleted file mode 100644
index 3b7d87e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/RejectedType.java
+++ /dev/null
@@ -1,127 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Rejected;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-
-
-public class RejectedType extends AbstractDescribedType<Rejected,List> implements DescribedTypeConstructor<Rejected>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000025L), Symbol.valueOf("amqp:rejected:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000025L);
-
- private RejectedType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Rejected val)
- {
- return new RejectedWrapper(val);
- }
-
-
- private static final class RejectedWrapper extends AbstractList
- {
- private final Rejected _impl;
-
- private RejectedWrapper(Rejected impl)
- {
- _impl = impl;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _impl.getError();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _impl.getError() != null
- ? 1
- : 0;
-
- }
- }
-
- public Rejected newInstance(Object described)
- {
- List l = (List) described;
-
- Rejected o = new Rejected();
-
- switch(1 - l.size())
- {
- case 0:
- o.setError( (ErrorCondition) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Rejected> getTypeClass()
- {
- return Rejected.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- RejectedType type = new RejectedType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ReleasedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ReleasedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ReleasedType.java
deleted file mode 100644
index 1e34ca4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/ReleasedType.java
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Released;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class ReleasedType extends AbstractDescribedType<Released,List> implements DescribedTypeConstructor<Released>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000026L), Symbol.valueOf("amqp:released:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000026L);
-
- public ReleasedType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Released val)
- {
- return Collections.EMPTY_LIST;
- }
-
-
- public Released newInstance(Object described)
- {
- return Released.getInstance();
- }
-
- public Class<Released> getTypeClass()
- {
- return Released.class;
- }
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- ReleasedType type = new ReleasedType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/SourceType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/SourceType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/SourceType.java
deleted file mode 100644
index 0239e6e..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/SourceType.java
+++ /dev/null
@@ -1,217 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Outcome;
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.amqp.messaging.TerminusDurability;
-import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy;
-
-
-public class SourceType extends AbstractDescribedType<Source,List> implements DescribedTypeConstructor<Source>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000028L), Symbol.valueOf("amqp:source:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000028L);
-
- public SourceType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Source val)
- {
- return new SourceWrapper(val);
- }
-
-
- private static final class SourceWrapper extends AbstractList
- {
- private final Source _impl;
-
- public SourceWrapper(Source impl)
- {
- _impl = impl;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _impl.getAddress();
- case 1:
- return _impl.getDurable().getValue();
- case 2:
- return _impl.getExpiryPolicy().getPolicy();
- case 3:
- return _impl.getTimeout();
- case 4:
- return _impl.getDynamic();
- case 5:
- return _impl.getDynamicNodeProperties();
- case 6:
- return _impl.getDistributionMode();
- case 7:
- return _impl.getFilter();
- case 8:
- return _impl.getDefaultOutcome();
- case 9:
- return _impl.getOutcomes();
- case 10:
- return _impl.getCapabilities();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _impl.getCapabilities() != null
- ? 11
- : _impl.getOutcomes() != null
- ? 10
- : _impl.getDefaultOutcome() != null
- ? 9
- : _impl.getFilter() != null
- ? 8
- : _impl.getDistributionMode() != null
- ? 7
- : _impl.getDynamicNodeProperties() != null
- ? 6
- : _impl.getDynamic()
- ? 5
- : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO))
- ? 4
- : _impl.getExpiryPolicy() != TerminusExpiryPolicy.SESSION_END
- ? 3
- : _impl.getDurable() != TerminusDurability.NONE
- ? 2
- : _impl.getAddress() != null
- ? 1
- : 0;
-
- }
-
- }
-
- public Source newInstance(Object described)
- {
- List l = (List) described;
-
- Source o = new Source();
-
-
- switch(11 - l.size())
- {
-
- case 0:
- Object val0 = l.get( 10 );
- if( val0 == null || val0.getClass().isArray() )
- {
- o.setCapabilities( (Symbol[]) val0 );
- }
- else
- {
- o.setCapabilities( (Symbol) val0 );
- }
- case 1:
- Object val1 = l.get( 9 );
- if( val1 == null || val1.getClass().isArray() )
- {
- o.setOutcomes( (Symbol[]) val1 );
- }
- else
- {
- o.setOutcomes( (Symbol) val1 );
- }
- case 2:
- o.setDefaultOutcome( (Outcome) l.get( 8 ) );
- case 3:
- o.setFilter( (Map) l.get( 7 ) );
- case 4:
- o.setDistributionMode( (Symbol) l.get( 6 ) );
- case 5:
- o.setDynamicNodeProperties( (Map) l.get( 5 ) );
- case 6:
- Boolean dynamic = (Boolean) l.get(4);
- o.setDynamic(dynamic == null ? false : dynamic);
- case 7:
- UnsignedInteger timeout = (UnsignedInteger) l.get(3);
- o.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
- case 8:
- Symbol expiryPolicy = (Symbol) l.get(2);
- o.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy.valueOf(expiryPolicy));
- case 9:
- UnsignedInteger durable = (UnsignedInteger) l.get(1);
- o.setDurable(durable == null ? TerminusDurability.NONE : TerminusDurability.get(durable));
- case 10:
- o.setAddress( (String) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Source> getTypeClass()
- {
- return Source.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- SourceType type = new SourceType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/TargetType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/TargetType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/TargetType.java
deleted file mode 100644
index d8ab043..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/TargetType.java
+++ /dev/null
@@ -1,182 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.messaging;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Target;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-import org.apache.qpid.proton.amqp.messaging.TerminusDurability;
-import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy;
-
-
-public class TargetType extends AbstractDescribedType<Target,List> implements DescribedTypeConstructor<Target>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000029L), Symbol.valueOf("amqp:target:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000029L);
-
- public TargetType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Target val)
- {
- return new TargetWrapper(val);
- }
-
-
- private static final class TargetWrapper extends AbstractList
- {
- private final Target _impl;
-
- public TargetWrapper(Target impl)
- {
- _impl = impl;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _impl.getAddress();
- case 1:
- return _impl.getDurable().getValue();
- case 2:
- return _impl.getExpiryPolicy().getPolicy();
- case 3:
- return _impl.getTimeout();
- case 4:
- return _impl.getDynamic();
- case 5:
- return _impl.getDynamicNodeProperties();
- case 6:
- return _impl.getCapabilities();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _impl.getCapabilities() != null
- ? 7
- : _impl.getDynamicNodeProperties() != null
- ? 6
- : _impl.getDynamic()
- ? 5
- : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO))
- ? 4
- : !_impl.getExpiryPolicy().equals(TerminusExpiryPolicy.SESSION_END)
- ? 3
- : !_impl.getDurable().equals(TerminusDurability.NONE)
- ? 2
- : _impl.getAddress() != null
- ? 1
- : 0;
-
- }
- }
-
- public Target newInstance(Object described)
- {
- List l = (List) described;
-
- Target o = new Target();
-
-
- switch(7 - l.size())
- {
-
- case 0:
- Object val0 = l.get( 6 );
- if( val0 == null || val0.getClass().isArray() )
- {
- o.setCapabilities( (Symbol[]) val0 );
- }
- else
- {
- o.setCapabilities( (Symbol) val0 );
- }
- case 1:
- o.setDynamicNodeProperties( (Map) l.get( 5 ) );
- case 2:
- Boolean dynamic = (Boolean) l.get(4);
- o.setDynamic(dynamic == null ? false : dynamic);
- case 3:
- UnsignedInteger timeout = (UnsignedInteger) l.get(3);
- o.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
- case 4:
- Symbol expiryPolicy = (Symbol) l.get(2);
- o.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy.valueOf(expiryPolicy));
- case 5:
- UnsignedInteger durable = (UnsignedInteger) l.get(1);
- o.setDurable(durable == null ? TerminusDurability.NONE : TerminusDurability.get(durable));
- case 6:
- o.setAddress( (String) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Target> getTypeClass()
- {
- return Target.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- TargetType type = new TargetType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslChallengeType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslChallengeType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslChallengeType.java
deleted file mode 100644
index 9c2c74f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslChallengeType.java
+++ /dev/null
@@ -1,102 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.security;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.security.SaslChallenge;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public class SaslChallengeType extends AbstractDescribedType<SaslChallenge,List> implements DescribedTypeConstructor<SaslChallenge>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000042L), Symbol.valueOf("amqp:sasl-challenge:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000042L);
-
- private SaslChallengeType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(SaslChallenge val)
- {
- return Collections.singletonList(val.getChallenge());
- }
-
-
-
- public SaslChallenge newInstance(Object described)
- {
- List l = (List) described;
-
- SaslChallenge o = new SaslChallenge();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The challenge field cannot be omitted");
- }
-
- o.setChallenge( (Binary) l.get( 0 ) );
-
-
-
- return o;
- }
-
- public Class<SaslChallenge> getTypeClass()
- {
- return SaslChallenge.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- SaslChallengeType type = new SaslChallengeType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslInitType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslInitType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslInitType.java
deleted file mode 100644
index 345b875..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslInitType.java
+++ /dev/null
@@ -1,145 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.security;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.security.SaslInit;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public class SaslInitType extends AbstractDescribedType<SaslInit,List> implements DescribedTypeConstructor<SaslInit>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000041L), Symbol.valueOf("amqp:sasl-init:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000041L);
-
- private SaslInitType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(SaslInit val)
- {
- return new SaslInitWrapper(val);
- }
-
-
- public static class SaslInitWrapper extends AbstractList
- {
-
- private SaslInit _saslInit;
-
- public SaslInitWrapper(SaslInit saslInit)
- {
- _saslInit = saslInit;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _saslInit.getMechanism();
- case 1:
- return _saslInit.getInitialResponse();
- case 2:
- return _saslInit.getHostname();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _saslInit.getHostname() != null
- ? 3
- : _saslInit.getInitialResponse() != null
- ? 2
- : 1;
-
- }
- }
-
- public SaslInit newInstance(Object described)
- {
- List l = (List) described;
-
- SaslInit o = new SaslInit();
-
- if(l.size() <= 0)
- {
- throw new DecodeException("The mechanism field cannot be omitted");
- }
-
- switch(3 - l.size())
- {
-
- case 0:
- o.setHostname( (String) l.get( 2 ) );
- case 1:
- o.setInitialResponse( (Binary) l.get( 1 ) );
- case 2:
- o.setMechanism( (Symbol) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<SaslInit> getTypeClass()
- {
- return SaslInit.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- SaslInitType type = new SaslInitType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslMechanismsType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslMechanismsType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslMechanismsType.java
deleted file mode 100644
index d964792..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslMechanismsType.java
+++ /dev/null
@@ -1,105 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.security;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.security.SaslMechanisms;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public class SaslMechanismsType extends AbstractDescribedType<SaslMechanisms,List> implements DescribedTypeConstructor<SaslMechanisms>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000040L), Symbol.valueOf("amqp:sasl-mechanisms:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000040L);
-
- private SaslMechanismsType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(SaslMechanisms val)
- {
- return Collections.singletonList(val.getSaslServerMechanisms());
- }
-
- public SaslMechanisms newInstance(Object described)
- {
- List l = (List) described;
-
- SaslMechanisms o = new SaslMechanisms();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The sasl-server-mechanisms field cannot be omitted");
- }
-
- Object val0 = l.get( 0 );
- if( val0 == null || val0.getClass().isArray() )
- {
- o.setSaslServerMechanisms( (Symbol[]) val0 );
- }
- else
- {
- o.setSaslServerMechanisms( (Symbol) val0 );
- }
-
- return o;
- }
-
- public Class<SaslMechanisms> getTypeClass()
- {
- return SaslMechanisms.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- SaslMechanismsType type = new SaslMechanismsType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslOutcomeType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslOutcomeType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslOutcomeType.java
deleted file mode 100644
index 3c7d906..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslOutcomeType.java
+++ /dev/null
@@ -1,140 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.security;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.security.SaslCode;
-import org.apache.qpid.proton.amqp.security.SaslOutcome;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public class SaslOutcomeType extends AbstractDescribedType<SaslOutcome,List> implements DescribedTypeConstructor<SaslOutcome>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000044L), Symbol.valueOf("amqp:sasl-outcome:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000044L);
-
- private SaslOutcomeType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(SaslOutcome val)
- {
- return new SaslOutcomeWrapper(val);
- }
-
-
- public static final class SaslOutcomeWrapper extends AbstractList
- {
- private final SaslOutcome _impl;
-
- public SaslOutcomeWrapper(SaslOutcome impl)
- {
- _impl = impl;
- }
-
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _impl.getCode().getValue();
- case 1:
- return _impl.getAdditionalData();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _impl.getAdditionalData() != null
- ? 2
- : 1;
- }
- }
-
- public SaslOutcome newInstance(Object described)
- {
- List l = (List) described;
-
- SaslOutcome o = new SaslOutcome();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The code field cannot be omitted");
- }
-
- switch(2 - l.size())
- {
-
- case 0:
- o.setAdditionalData( (Binary) l.get( 1 ) );
- case 1:
- o.setCode(SaslCode.valueOf((UnsignedByte) l.get(0)));
- }
-
-
- return o;
- }
-
- public Class<SaslOutcome> getTypeClass()
- {
- return SaslOutcome.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- SaslOutcomeType type = new SaslOutcomeType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslResponseType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslResponseType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslResponseType.java
deleted file mode 100644
index cd2d61f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/security/SaslResponseType.java
+++ /dev/null
@@ -1,103 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.security;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.security.SaslResponse;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public class SaslResponseType extends AbstractDescribedType<SaslResponse,List> implements DescribedTypeConstructor<SaslResponse>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000043L), Symbol.valueOf("amqp:sasl-response:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000043L);
-
- private SaslResponseType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(SaslResponse val)
- {
- return Collections.singletonList(val.getResponse());
- }
-
-
- public SaslResponse newInstance(Object described)
- {
- List l = (List) described;
-
- SaslResponse o = new SaslResponse();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The response field cannot be omitted");
- }
-
- switch(1 - l.size())
- {
-
- case 0:
- o.setResponse( (Binary) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<SaslResponse> getTypeClass()
- {
- return SaslResponse.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- SaslResponseType type = new SaslResponseType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/CoordinatorType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/CoordinatorType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/CoordinatorType.java
deleted file mode 100644
index 47321ef..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/CoordinatorType.java
+++ /dev/null
@@ -1,109 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transaction;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transaction.Coordinator;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class CoordinatorType extends AbstractDescribedType<Coordinator,List> implements DescribedTypeConstructor<Coordinator>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000030L), Symbol.valueOf("amqp:coordinator:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000030L);
-
- private CoordinatorType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Coordinator val)
- {
- Symbol[] capabilities = val.getCapabilities();
- return capabilities == null || capabilities.length == 0
- ? Collections.EMPTY_LIST
- : Collections.singletonList(capabilities);
- }
-
-
- public Coordinator newInstance(Object described)
- {
- List l = (List) described;
-
- Coordinator o = new Coordinator();
-
-
- switch(1 - l.size())
- {
-
- case 0:
- Object val0 = l.get( 0 );
- if( val0 == null || val0.getClass().isArray() )
- {
- o.setCapabilities( (Symbol[]) val0 );
- }
- else
- {
- o.setCapabilities( (Symbol) val0 );
- }
- }
-
-
- return o;
- }
-
- public Class<Coordinator> getTypeClass()
- {
- return Coordinator.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- CoordinatorType type = new CoordinatorType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DeclareType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DeclareType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DeclareType.java
deleted file mode 100644
index 45130e0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DeclareType.java
+++ /dev/null
@@ -1,95 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transaction;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transaction.Declare;
-import org.apache.qpid.proton.amqp.transaction.GlobalTxId;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public class DeclareType extends AbstractDescribedType<Declare,List> implements DescribedTypeConstructor<Declare>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000031L), Symbol.valueOf("amqp:declare:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000031L);
-
- private DeclareType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Declare val)
- {
- GlobalTxId globalId = val.getGlobalId();
- return globalId == null ? Collections.EMPTY_LIST : Collections.singletonList(globalId);
- }
-
- public Declare newInstance(Object described)
- {
- List l = (List) described;
-
- Declare o = new Declare();
-
- if(!l.isEmpty())
- {
- o.setGlobalId( (GlobalTxId) l.get( 0 ) );
- }
-
- return o;
- }
-
- public Class<Declare> getTypeClass()
- {
- return Declare.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DeclareType type = new DeclareType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DeclaredType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DeclaredType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DeclaredType.java
deleted file mode 100644
index ccba51a..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DeclaredType.java
+++ /dev/null
@@ -1,99 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transaction;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transaction.Declared;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public class DeclaredType extends AbstractDescribedType<Declared,List> implements DescribedTypeConstructor<Declared>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000033L), Symbol.valueOf("amqp:declared:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000033L);
-
- private DeclaredType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Declared val)
- {
- return Collections.singletonList(val.getTxnId());
- }
-
- public Declared newInstance(Object described)
- {
- List l = (List) described;
-
- Declared o = new Declared();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The txn-id field cannot be omitted");
- }
-
- o.setTxnId( (Binary) l.get( 0 ) );
-
-
-
- return o;
- }
-
- public Class<Declared> getTypeClass()
- {
- return Declared.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DeclaredType type = new DeclaredType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DischargeType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DischargeType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DischargeType.java
deleted file mode 100644
index 8ec382f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/DischargeType.java
+++ /dev/null
@@ -1,141 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transaction;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transaction.Discharge;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public class DischargeType extends AbstractDescribedType<Discharge,List> implements DescribedTypeConstructor<Discharge>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000032L), Symbol.valueOf("amqp:discharge:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000032L);
-
- private DischargeType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Discharge val)
- {
- return new DischargeWrapper(val);
- }
-
-
- public static class DischargeWrapper extends AbstractList
- {
-
- private Discharge _discharge;
-
- public DischargeWrapper(Discharge discharge)
- {
- _discharge = discharge;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _discharge.getTxnId();
- case 1:
- return _discharge.getFail();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _discharge.getFail() != null
- ? 2
- : 1;
-
- }
-
- }
-
- public Discharge newInstance(Object described)
- {
- List l = (List) described;
-
- Discharge o = new Discharge();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The txn-id field cannot be omitted");
- }
-
- switch(2 - l.size())
- {
-
- case 0:
- o.setFail( (Boolean) l.get( 1 ) );
- case 1:
- o.setTxnId( (Binary) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Discharge> getTypeClass()
- {
- return Discharge.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DischargeType type = new DischargeType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/TransactionalStateType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/TransactionalStateType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/TransactionalStateType.java
deleted file mode 100644
index 74731ef..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transaction/TransactionalStateType.java
+++ /dev/null
@@ -1,141 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transaction;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.messaging.Outcome;
-import org.apache.qpid.proton.amqp.transaction.TransactionalState;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-public class TransactionalStateType extends AbstractDescribedType<TransactionalState,List> implements DescribedTypeConstructor<TransactionalState>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000034L), Symbol.valueOf("amqp:transactional-state:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000034L);
-
- private TransactionalStateType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(TransactionalState val)
- {
- return new TransactionalStateWrapper(val);
- }
-
- public static class TransactionalStateWrapper extends AbstractList
- {
-
- private TransactionalState _transactionalState;
-
- public TransactionalStateWrapper(TransactionalState transactionalState)
- {
- _transactionalState = transactionalState;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _transactionalState.getTxnId();
- case 1:
- return _transactionalState.getOutcome();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _transactionalState.getOutcome() != null
- ? 2
- : 1;
-
- }
-
-
- }
-
- public TransactionalState newInstance(Object described)
- {
- List l = (List) described;
-
- TransactionalState o = new TransactionalState();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The txn-id field cannot be omitted");
- }
-
- switch(2 - l.size())
- {
-
- case 0:
- o.setOutcome( (Outcome) l.get( 1 ) );
- case 1:
- o.setTxnId( (Binary) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<TransactionalState> getTypeClass()
- {
- return TransactionalState.class;
- }
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- TransactionalStateType type = new TransactionalStateType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/AttachType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/AttachType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/AttachType.java
deleted file mode 100644
index 533dbc8..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/AttachType.java
+++ /dev/null
@@ -1,233 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.Attach;
-import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
-import org.apache.qpid.proton.amqp.transport.Role;
-import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
-import org.apache.qpid.proton.amqp.transport.Source;
-import org.apache.qpid.proton.amqp.transport.Target;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public final class AttachType extends AbstractDescribedType<Attach,List> implements DescribedTypeConstructor<Attach>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000012L), Symbol.valueOf("amqp:attach:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000012L);
-
- private AttachType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Attach val)
- {
- return new AttachWrapper(val);
- }
-
-
- public static class AttachWrapper extends AbstractList
- {
-
- private Attach _attach;
-
- public AttachWrapper(Attach attach)
- {
- _attach = attach;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _attach.getName();
- case 1:
- return _attach.getHandle();
- case 2:
- return _attach.getRole().getValue();
- case 3:
- return _attach.getSndSettleMode().getValue();
- case 4:
- return _attach.getRcvSettleMode().getValue();
- case 5:
- return _attach.getSource();
- case 6:
- return _attach.getTarget();
- case 7:
- return _attach.getUnsettled();
- case 8:
- return _attach.getIncompleteUnsettled();
- case 9:
- return _attach.getInitialDeliveryCount();
- case 10:
- return _attach.getMaxMessageSize();
- case 11:
- return _attach.getOfferedCapabilities();
- case 12:
- return _attach.getDesiredCapabilities();
- case 13:
- return _attach.getProperties();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _attach.getProperties() != null
- ? 14
- : _attach.getDesiredCapabilities() != null
- ? 13
- : _attach.getOfferedCapabilities() != null
- ? 12
- : _attach.getMaxMessageSize() != null
- ? 11
- : _attach.getInitialDeliveryCount() != null
- ? 10
- : _attach.getIncompleteUnsettled()
- ? 9
- : _attach.getUnsettled() != null
- ? 8
- : _attach.getTarget() != null
- ? 7
- : _attach.getSource() != null
- ? 6
- : (_attach.getRcvSettleMode() != null && !_attach.getRcvSettleMode().equals(ReceiverSettleMode.FIRST))
- ? 5
- : (_attach.getSndSettleMode() != null && !_attach.getSndSettleMode().equals(SenderSettleMode.MIXED))
- ? 4
- : 3;
-
- }
-
- }
-
- public Attach newInstance(Object described)
- {
- List l = (List) described;
-
- Attach o = new Attach();
-
- if(l.size() <= 2)
- {
- throw new DecodeException("The role field cannot be omitted");
- }
-
- switch(14 - l.size())
- {
-
- case 0:
- o.setProperties( (Map) l.get( 13 ) );
- case 1:
- Object val1 = l.get( 12 );
- if( val1 == null || val1.getClass().isArray() )
- {
- o.setDesiredCapabilities( (Symbol[]) val1 );
- }
- else
- {
- o.setDesiredCapabilities( (Symbol) val1 );
- }
- case 2:
- Object val2 = l.get( 11 );
- if( val2 == null || val2.getClass().isArray() )
- {
- o.setOfferedCapabilities( (Symbol[]) val2 );
- }
- else
- {
- o.setOfferedCapabilities( (Symbol) val2 );
- }
- case 3:
- o.setMaxMessageSize( (UnsignedLong) l.get( 10 ) );
- case 4:
- o.setInitialDeliveryCount( (UnsignedInteger) l.get( 9 ) );
- case 5:
- Boolean incompleteUnsettled = (Boolean) l.get(8);
- o.setIncompleteUnsettled(incompleteUnsettled == null ? false : incompleteUnsettled);
- case 6:
- o.setUnsettled( (Map) l.get( 7 ) );
- case 7:
- o.setTarget( (Target) l.get( 6 ) );
- case 8:
- o.setSource( (Source) l.get( 5 ) );
- case 9:
- UnsignedByte rcvSettleMode = (UnsignedByte) l.get(4);
- o.setRcvSettleMode(rcvSettleMode == null ? ReceiverSettleMode.FIRST : ReceiverSettleMode.values()[rcvSettleMode.intValue()]);
- case 10:
- UnsignedByte sndSettleMode = (UnsignedByte) l.get(3);
- o.setSndSettleMode(sndSettleMode == null ? SenderSettleMode.MIXED : SenderSettleMode.values()[sndSettleMode.intValue()]);
- case 11:
- o.setRole( Boolean.TRUE.equals( l.get( 2 ) ) ? Role.RECEIVER : Role.SENDER);
- case 12:
- o.setHandle( (UnsignedInteger) l.get( 1 ) );
- case 13:
- o.setName( (String) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Attach> getTypeClass()
- {
- return Attach.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- AttachType type = new AttachType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/BeginType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/BeginType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/BeginType.java
deleted file mode 100644
index a01ad51..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/BeginType.java
+++ /dev/null
@@ -1,188 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.AbstractList;
-import java.util.List;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-import org.apache.qpid.proton.amqp.transport.Begin;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public final class BeginType extends AbstractDescribedType<Begin,List> implements DescribedTypeConstructor<Begin>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000011L), Symbol.valueOf("amqp:begin:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000011L);
-
- private BeginType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Begin val)
- {
- return new BeginWrapper(val);
- }
-
- private static class BeginWrapper extends AbstractList
- {
-
- private Begin _begin;
-
- public BeginWrapper(Begin begin)
- {
- _begin = begin;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _begin.getRemoteChannel();
- case 1:
- return _begin.getNextOutgoingId();
- case 2:
- return _begin.getIncomingWindow();
- case 3:
- return _begin.getOutgoingWindow();
- case 4:
- return _begin.getHandleMax();
- case 5:
- return _begin.getOfferedCapabilities();
- case 6:
- return _begin.getDesiredCapabilities();
- case 7:
- return _begin.getProperties();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _begin.getProperties() != null
- ? 8
- : _begin.getDesiredCapabilities() != null
- ? 7
- : _begin.getOfferedCapabilities() != null
- ? 6
- : (_begin.getHandleMax() != null && !_begin.getHandleMax().equals(UnsignedInteger.MAX_VALUE))
- ? 5
- : 4;
-
- }
- }
-
- public Begin newInstance(Object described)
- {
- List l = (List) described;
-
- Begin o = new Begin();
-
- if(l.size() <= 3)
- {
- throw new DecodeException("The outgoing-window field cannot be omitted");
- }
-
- switch(8 - l.size())
- {
-
- case 0:
- o.setProperties( (Map) l.get( 7 ) );
- case 1:
- Object val1 = l.get( 6 );
- if( val1 == null || val1.getClass().isArray() )
- {
- o.setDesiredCapabilities( (Symbol[]) val1 );
- }
- else
- {
- o.setDesiredCapabilities( (Symbol) val1 );
- }
- case 2:
- Object val2 = l.get( 5 );
- if( val2 == null || val2.getClass().isArray() )
- {
- o.setOfferedCapabilities( (Symbol[]) val2 );
- }
- else
- {
- o.setOfferedCapabilities( (Symbol) val2 );
- }
- case 3:
- UnsignedInteger handleMax = (UnsignedInteger) l.get(4);
- o.setHandleMax(handleMax == null ? UnsignedInteger.MAX_VALUE : handleMax);
- case 4:
- o.setOutgoingWindow( (UnsignedInteger) l.get( 3 ) );
- case 5:
- o.setIncomingWindow( (UnsignedInteger) l.get( 2 ) );
- case 6:
- o.setNextOutgoingId( (UnsignedInteger) l.get( 1 ) );
- case 7:
- o.setRemoteChannel( (UnsignedShort) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Begin> getTypeClass()
- {
- return Begin.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- BeginType type = new BeginType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/CloseType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/CloseType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/CloseType.java
deleted file mode 100644
index 832ea6b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/CloseType.java
+++ /dev/null
@@ -1,94 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.Close;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-
-public final class CloseType extends AbstractDescribedType<Close,List> implements DescribedTypeConstructor<Close>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000018L), Symbol.valueOf("amqp:close:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000018L);
-
- private CloseType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Close val)
- {
- ErrorCondition error = val.getError();
- return error == null ? Collections.EMPTY_LIST : Collections.singletonList(error);
- }
-
- public Close newInstance(Object described)
- {
- List l = (List) described;
-
- Close o = new Close();
-
- if(!l.isEmpty())
- {
- o.setError( (ErrorCondition) l.get( 0 ) );
- }
-
- return o;
- }
-
- public Class<Close> getTypeClass()
- {
- return Close.class;
- }
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- CloseType type = new CloseType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DetachType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DetachType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DetachType.java
deleted file mode 100644
index 62dd068..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DetachType.java
+++ /dev/null
@@ -1,147 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.Detach;
-import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public final class DetachType extends AbstractDescribedType<Detach,List> implements DescribedTypeConstructor<Detach>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000016L), Symbol.valueOf("amqp:detach:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000016L);
-
- private DetachType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Detach val)
- {
- return new DetachWrapper(val);
- }
-
- public static class DetachWrapper extends AbstractList
- {
-
- private Detach _detach;
-
- public DetachWrapper(Detach detach)
- {
- _detach = detach;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _detach.getHandle();
- case 1:
- return _detach.getClosed();
- case 2:
- return _detach.getError();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _detach.getError() != null
- ? 3
- : _detach.getClosed()
- ? 2
- : 1;
-
- }
- }
-
- public Detach newInstance(Object described)
- {
- List l = (List) described;
-
- Detach o = new Detach();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The handle field cannot be omitted");
- }
-
- switch(3 - l.size())
- {
-
- case 0:
- o.setError( (ErrorCondition) l.get( 2 ) );
- case 1:
- Boolean closed = (Boolean) l.get(1);
- o.setClosed(closed == null ? false : closed);
- case 2:
- o.setHandle( (UnsignedInteger) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Detach> getTypeClass()
- {
- return Detach.class;
- }
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DetachType type = new DetachType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java
deleted file mode 100644
index b833613..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java
+++ /dev/null
@@ -1,168 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec.transport;
-
-import java.util.AbstractList;
-import java.util.List;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.transport.DeliveryState;
-import org.apache.qpid.proton.amqp.transport.Disposition;
-import org.apache.qpid.proton.amqp.transport.Role;
-import org.apache.qpid.proton.codec.AbstractDescribedType;
-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.codec.EncoderImpl;
-
-
-public final class DispositionType extends AbstractDescribedType<Disposition,List> implements DescribedTypeConstructor<Disposition>
-{
- private static final Object[] DESCRIPTORS =
- {
- UnsignedLong.valueOf(0x0000000000000015L), Symbol.valueOf("amqp:disposition:list"),
- };
-
- private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000015L);
-
- private DispositionType(EncoderImpl encoder)
- {
- super(encoder);
- }
-
- public UnsignedLong getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- @Override
- protected List wrap(Disposition val)
- {
- return new DispositionWrapper(val);
- }
-
-
- private static final class DispositionWrapper extends AbstractList
- {
-
- private Disposition _disposition;
-
- public DispositionWrapper(Disposition disposition)
- {
- _disposition = disposition;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _disposition.getRole().getValue();
- case 1:
- return _disposition.getFirst();
- case 2:
- return _disposition.getLast();
- case 3:
- return _disposition.getSettled();
- case 4:
- return _disposition.getState();
- case 5:
- return _disposition.getBatchable();
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _disposition.getBatchable()
- ? 6
- : _disposition.getState() != null
- ? 5
- : _disposition.getSettled()
- ? 4
- : _disposition.getLast() != null
- ? 3
- : 2;
-
- }
- }
-
- public Disposition newInstance(Object described)
- {
- List l = (List) described;
-
- Disposition o = new Disposition();
-
- if(l.isEmpty())
- {
- throw new DecodeException("The first field cannot be omitted");
- }
-
- switch(6 - l.size())
- {
-
- case 0:
- Boolean batchable = (Boolean) l.get(5);
- o.setBatchable(batchable == null ? false : batchable);
- case 1:
- o.setState( (DeliveryState) l.get( 4 ) );
- case 2:
- Boolean settled = (Boolean) l.get(3);
- o.setSettled(settled == null ? false : settled);
- case 3:
- o.setLast( (UnsignedInteger) l.get( 2 ) );
- case 4:
- o.setFirst( (UnsignedInteger) l.get( 1 ) );
- case 5:
- o.setRole( Boolean.TRUE.equals(l.get( 0 )) ? Role.RECEIVER : Role.SENDER );
- }
-
-
- return o;
- }
-
- public Class<Disposition> getTypeClass()
- {
- return Disposition.class;
- }
-
-
-
-
- public static void register(Decoder decoder, EncoderImpl encoder)
- {
- DispositionType type = new DispositionType(encoder);
- for(Object descriptor : DESCRIPTORS)
- {
- decoder.register(descriptor, type);
- }
- encoder.register(type);
- }
-
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[29/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/LICENSE
----------------------------------------------------------------------
diff --git a/examples/engine/java/LICENSE b/examples/engine/java/LICENSE
deleted file mode 100644
index ad410e1..0000000
--- a/examples/engine/java/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
-Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed 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.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/drain
----------------------------------------------------------------------
diff --git a/examples/engine/java/drain b/examples/engine/java/drain
deleted file mode 100755
index a277ced..0000000
--- a/examples/engine/java/drain
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Drain -Dexec.args="$*"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/pom.xml
----------------------------------------------------------------------
diff --git a/examples/engine/java/pom.xml b/examples/engine/java/pom.xml
deleted file mode 100644
index bf334b0..0000000
--- a/examples/engine/java/pom.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-project</artifactId>
- <version>0.17.0-SNAPSHOT</version>
- <relativePath>../../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>proton-j-engine-demo</artifactId>
- <name>proton-j-engine-demo</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-j</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/server
----------------------------------------------------------------------
diff --git a/examples/engine/java/server b/examples/engine/java/server
deleted file mode 100755
index 84a167c..0000000
--- a/examples/engine/java/server
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Server -Dexec.args="$*"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/spout
----------------------------------------------------------------------
diff --git a/examples/engine/java/spout b/examples/engine/java/spout
deleted file mode 100755
index 42cd0c7..0000000
--- a/examples/engine/java/spout
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Spout -Dexec.args="$*"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Drain.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Drain.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Drain.java
deleted file mode 100644
index 8b93886..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Drain.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Receiver;
-
-public class Drain extends BaseHandler {
-
- private int count;
- private boolean block;
- private int received;
- private boolean quiet;
-
- public Drain(int count, boolean block, boolean quiet) {
- this.count = count;
- this.block = block;
- this.quiet = quiet;
- }
-
- @Override
- public void onLinkLocalOpen(Event evt) {
- Link link = evt.getLink();
- if (link instanceof Receiver) {
- Receiver receiver = (Receiver) link;
-
- if (block) {
- receiver.flow(count);
- } else {
- receiver.drain(count);
- }
- }
- }
-
- @Override
- public void onLinkFlow(Event evt) {
- Link link = evt.getLink();
- if (link instanceof Receiver) {
- Receiver receiver = (Receiver) link;
-
- if (!receiver.draining()) {
- receiver.getSession().getConnection().close();
- }
- }
- }
-
- @Override
- public void onDelivery(Event evt) {
- Delivery dlv = evt.getDelivery();
- if (dlv.getLink() instanceof Receiver) {
- Receiver receiver = (Receiver) dlv.getLink();
-
- if (!dlv.isPartial()) {
- byte[] bytes = new byte[dlv.pending()];
- receiver.recv(bytes, 0, bytes.length);
- Message msg = new Message(bytes);
-
- if (!quiet) {
- System.out.println(String.format("Got message: %s", msg));
- }
- received++;
- dlv.settle();
- }
-
- if ((received >= count) || (!block && !receiver.draining())) {
- receiver.getSession().getConnection().close();
- }
- }
- }
-
- @Override
- public void onConnectionRemoteClose(Event evt) {
- System.out.println(String.format("Got %s messages", received));
- }
-
- public static void main(String[] argv) throws Exception {
- List<String> switches = new ArrayList<String>();
- List<String> args = new ArrayList<String>();
- for (String s : argv) {
- if (s.startsWith("-")) {
- switches.add(s);
- } else {
- args.add(s);
- }
- }
-
- boolean quiet = switches.contains("-q");
- String address = args.isEmpty() || !args.get(0).startsWith("/") ? "//localhost" : args.remove(0);
- int count = args.isEmpty() ? 1 : Integer.parseInt(args.remove(0));
- boolean block = switches.contains("-b");
-
- Collector collector = Collector.Factory.create();
-
- Drain drain = new Drain(count, block, quiet);
- Driver driver = new Driver(collector, drain);
-
- Pool pool = new Pool(collector);
- pool.incoming(address, null);
-
- driver.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Driver.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Driver.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Driver.java
deleted file mode 100644
index 7412dc6..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Driver.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Handler;
-import org.apache.qpid.proton.engine.Sasl;
-import org.apache.qpid.proton.engine.Transport;
-import org.apache.qpid.proton.engine.TransportException;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.StandardSocketOptions;
-import java.nio.ByteBuffer;
-import java.nio.channels.Selector;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.util.UUID;
-
-
-/**
- * Driver
- *
- */
-
-public class Driver extends BaseHandler
-{
-
- final private Collector collector;
- final private Handler[] handlers;
- final private Selector selector;
-
- public Driver(Collector collector, Handler ... handlers) throws IOException {
- this.collector = collector;
- this.handlers = handlers;
- this.selector = Selector.open();
- }
-
- public void listen(String host, int port) throws IOException {
- new Acceptor(host, port);
- }
-
- public void run() throws IOException {
- while (true) {
- processEvents();
-
- // I don't know if there is a better way to do this, but
- // the only way canceled selection keys are removed from
- // the key set is via a select operation, so we do this
- // first to figure out whether we should exit. Without
- // this we would block indefinitely when there are only
- // cancelled keys remaining.
- selector.selectNow();
- if (selector.keys().isEmpty()) {
- selector.close();
- return;
- }
-
- selector.selectedKeys().clear();
- selector.select();
-
- for (SelectionKey key : selector.selectedKeys()) {
- Selectable selectable = (Selectable) key.attachment();
- selectable.selected();
- }
- }
- }
-
- public void processEvents() {
- while (true) {
- Event ev = collector.peek();
- if (ev == null) break;
- ev.dispatch(this);
- for (Handler h : handlers) {
- ev.dispatch(h);
- }
- collector.pop();
- }
- }
-
- @Override
- public void onTransport(Event evt) {
- Transport transport = evt.getTransport();
- ChannelHandler ch = (ChannelHandler) transport.getContext();
- ch.selected();
- }
-
- @Override
- public void onConnectionLocalOpen(Event evt) {
- Connection conn = evt.getConnection();
- if (conn.getRemoteState() == EndpointState.UNINITIALIZED) {
- // Give the connection a [random] container-id
- conn.setContainer(UUID.randomUUID().toString());
- try {
- new Connector(conn);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- private interface Selectable {
- void selected() throws IOException;
- }
-
- private class Acceptor implements Selectable {
-
- final private ServerSocketChannel socket;
- final private SelectionKey key;
-
- Acceptor(String host, int port) throws IOException {
- socket = ServerSocketChannel.open();
- socket.configureBlocking(false);
- socket.bind(new InetSocketAddress(host, port));
- socket.setOption(StandardSocketOptions.SO_REUSEADDR, true);
- key = socket.register(selector, SelectionKey.OP_ACCEPT, this);
- }
-
- public void selected() throws IOException {
- SocketChannel sock = socket.accept();
- System.out.println("ACCEPTED: " + sock);
- Connection conn = Connection.Factory.create();
- conn.collect(collector);
- Transport transport = Transport.Factory.create();
- Sasl sasl = transport.sasl();
- sasl.setMechanisms("ANONYMOUS");
- sasl.server();
- sasl.done(Sasl.PN_SASL_OK);
- transport.bind(conn);
- new ChannelHandler(sock, SelectionKey.OP_READ, transport);
- }
- }
-
- private class ChannelHandler implements Selectable {
-
- final SocketChannel socket;
- final SelectionKey key;
- final Transport transport;
-
- ChannelHandler(SocketChannel socket, int ops, Transport transport) throws IOException {
- this.socket = socket;
- socket.configureBlocking(false);
- key = socket.register(selector, ops, this);
- this.transport = transport;
- transport.setContext(this);
- }
-
- boolean update() {
- if (socket.isConnected()) {
- int c = transport.capacity();
- int p = transport.pending();
- if (key.isValid()) {
- key.interestOps((c != 0 ? SelectionKey.OP_READ : 0) |
- (p > 0 ? SelectionKey.OP_WRITE : 0));
- }
- if (c < 0 && p < 0) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
-
- public void selected() {
- if (!key.isValid()) { return; }
-
- try {
- if (key.isConnectable()) {
- System.out.println("CONNECTED: " + socket);
- socket.finishConnect();
- }
-
- if (key.isReadable()) {
- int c = transport.capacity();
- if (c > 0) {
- ByteBuffer tail = transport.tail();
- int n = socket.read(tail);
- if (n > 0) {
- try {
- transport.process();
- } catch (TransportException e) {
- e.printStackTrace();
- }
- } else if (n < 0) {
- transport.close_tail();
- }
- }
- }
-
- if (key.isWritable()) {
- int p = transport.pending();
- if (p > 0) {
- ByteBuffer head = transport.head();
- int n = socket.write(head);
- if (n > 0) {
- transport.pop(n);
- } else if (n < 0) {
- transport.close_head();
- }
- }
- }
-
- if (update()) {
- transport.unbind();
- System.out.println("CLOSING: " + socket);
- socket.close();
- }
- } catch (IOException e) {
- transport.unbind();
- System.out.println(String.format("CLOSING(%s): %s", e, socket));
- try {
- socket.close();
- } catch (IOException e2) {
- throw new RuntimeException(e2);
- }
- }
-
- }
-
- }
-
- private static Transport makeTransport(Connection conn) {
- Transport transport = Transport.Factory.create();
- Sasl sasl = transport.sasl();
- sasl.setMechanisms("ANONYMOUS");
- sasl.client();
- transport.bind(conn);
- return transport;
- }
-
- private class Connector extends ChannelHandler {
-
- Connector(Connection conn) throws IOException {
- super(SocketChannel.open(), SelectionKey.OP_CONNECT, makeTransport(conn));
- System.out.println("CONNECTING: " + conn.getHostname());
- socket.connect(new InetSocketAddress(conn.getHostname(), 5672));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/FlowController.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/FlowController.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/FlowController.java
deleted file mode 100644
index d22a637..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/FlowController.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Receiver;
-
-/**
- * FlowController
- *
- */
-
-public class FlowController extends BaseHandler
-{
-
- final private int window;
-
- public FlowController(int window) {
- this.window = window;
- }
-
- private void topUp(Receiver rcv) {
- int delta = window - rcv.getCredit();
- rcv.flow(delta);
- }
-
- @Override
- public void onLinkLocalOpen(Event evt) {
- Link link = evt.getLink();
- if (link instanceof Receiver) {
- topUp((Receiver) link);
- }
- }
-
- @Override
- public void onLinkRemoteOpen(Event evt) {
- Link link = evt.getLink();
- if (link instanceof Receiver) {
- topUp((Receiver) link);
- }
- }
-
- @Override
- public void onLinkFlow(Event evt) {
- Link link = evt.getLink();
- if (link instanceof Receiver) {
- topUp((Receiver) link);
- }
- }
-
- @Override
- public void onDelivery(Event evt) {
- Link link = evt.getLink();
- if (link instanceof Receiver) {
- topUp((Receiver) link);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Handshaker.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Handshaker.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Handshaker.java
deleted file mode 100644
index c53d0f8..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Handshaker.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.EndpointState;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Session;
-
-/**
- * Handshaker
- *
- */
-
-public class Handshaker extends BaseHandler
-{
-
- @Override
- public void onConnectionRemoteOpen(Event evt) {
- Connection conn = evt.getConnection();
- if (conn.getLocalState() == EndpointState.UNINITIALIZED) {
- conn.open();
- }
- }
-
- @Override
- public void onSessionRemoteOpen(Event evt) {
- Session ssn = evt.getSession();
- if (ssn.getLocalState() == EndpointState.UNINITIALIZED) {
- ssn.open();
- }
- }
-
- @Override
- public void onLinkRemoteOpen(Event evt) {
- Link link = evt.getLink();
- if (link.getLocalState() == EndpointState.UNINITIALIZED) {
- link.setSource(link.getRemoteSource());
- link.setTarget(link.getRemoteTarget());
- link.open();
- }
- }
-
- @Override
- public void onConnectionRemoteClose(Event evt) {
- Connection conn = evt.getConnection();
- if (conn.getLocalState() != EndpointState.CLOSED) {
- conn.close();
- }
- }
-
- @Override
- public void onSessionRemoteClose(Event evt) {
- Session ssn = evt.getSession();
- if (ssn.getLocalState() != EndpointState.CLOSED) {
- ssn.close();
- }
- }
-
- @Override
- public void onLinkRemoteClose(Event evt) {
- Link link = evt.getLink();
- if (link.getLocalState() != EndpointState.CLOSED) {
- link.close();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Message.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Message.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Message.java
deleted file mode 100644
index b439f69..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Message.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-
-/**
- * Message
- *
- */
-
-public class Message
-{
- private final byte[] bytes;
-
- /**
- * These bytes are expected to be AMQP encoded.
- */
- public Message(byte[] bytes) {
- this.bytes = bytes;
- }
-
- private static final byte[] PREFIX = {(byte)0x00, (byte)0x53, (byte)0x77, (byte)0xb1};
-
- private static byte[] encodeString(String string) {
- byte[] utf8 = string.getBytes();
- byte[] result = new byte[PREFIX.length + 4 + utf8.length];
- ByteBuffer bbuf = ByteBuffer.wrap(result);
- bbuf.put(PREFIX);
- bbuf.putInt(utf8.length);
- bbuf.put(utf8);
- return result;
- }
-
- public Message(String string) {
- // XXX: special case string encoding for now
- this(encodeString(string));
- }
-
- public byte[] getBytes() {
- return bytes;
- }
-
- public String toString() {
- StringBuilder bld = new StringBuilder();
- bld.append("Message(");
- for (byte b : bytes) {
- if (b >= 32 && b < 127) {
- bld.append((char) b);
- } else {
- bld.append("\\x");
- String hex = Integer.toHexString(0xFF & b);
- if (hex.length() < 2) {
- bld.append("0");
- }
- bld.append(hex);
- }
- }
- bld.append(')');
- return bld.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Pool.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Pool.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Pool.java
deleted file mode 100644
index bb5bf86..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Pool.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Session;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Sender;
-import org.apache.qpid.proton.engine.Receiver;
-
-import org.apache.qpid.proton.amqp.messaging.Source;
-import org.apache.qpid.proton.amqp.messaging.Target;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Pool
- *
- */
-
-public class Pool
-{
-
- final private Collector collector;
- final private Map<String,Connection> connections;
-
- final private LinkConstructor<Sender> outgoingConstructor = new LinkConstructor<Sender> () {
- public Sender create(Session ssn, String remote, String local) {
- return newOutgoing(ssn, remote, local);
- }
- };
- final private LinkConstructor<Receiver> incomingConstructor = new LinkConstructor<Receiver> () {
- public Receiver create(Session ssn, String remote, String local) {
- return newIncoming(ssn, remote, local);
- }
- };
-
- final private LinkResolver<Sender> outgoingResolver;
- final private LinkResolver<Receiver> incomingResolver;
-
- public Pool(Collector collector, final Router router) {
- this.collector = collector;
- connections = new HashMap<String,Connection>();
-
- if (router != null) {
- outgoingResolver = new LinkResolver<Sender>() {
- public Sender resolve(String address) {
- return router.getOutgoing(address).choose();
- }
- };
- incomingResolver = new LinkResolver<Receiver>() {
- public Receiver resolve(String address) {
- return router.getIncoming(address).choose();
- }
- };
- } else {
- outgoingResolver = new LinkResolver<Sender>() {
- public Sender resolve(String address) { return null; }
- };
- incomingResolver = new LinkResolver<Receiver>() {
- public Receiver resolve(String address) { return null; }
- };
- }
- }
-
- public Pool(Collector collector) {
- this(collector, null);
- }
-
- private <T extends Link> T resolve(String remote, String local,
- LinkResolver<T> resolver,
- LinkConstructor<T> constructor) {
- String host = remote.substring(2).split("/", 2)[0];
- T link = resolver.resolve(remote);
- if (link == null) {
- Connection conn = connections.get(host);
- if (conn == null) {
- conn = Connection.Factory.create();
- conn.collect(collector);
- conn.setHostname(host);
- conn.open();
- connections.put(host, conn);
- }
-
- Session ssn = conn.session();
- ssn.open();
-
- link = constructor.create(ssn, remote, local);
- link.open();
- }
- return link;
- }
-
- public Sender outgoing(String target, String source) {
- return resolve(target, source, outgoingResolver, outgoingConstructor);
- }
-
- public Receiver incoming(String source, String target) {
- return resolve(source, target, incomingResolver, incomingConstructor);
- }
-
- public Sender newOutgoing(Session ssn, String remote, String local) {
- Sender snd = ssn.sender(String.format("%s-%s", local, remote));
- Source src = new Source();
- src.setAddress(local);
- snd.setSource(src);
- Target tgt = new Target();
- tgt.setAddress(remote);
- snd.setTarget(tgt);
- return snd;
- }
-
- public Receiver newIncoming(Session ssn, String remote, String local) {
- Receiver rcv = ssn.receiver(String.format("%s-%s", remote, local));
- Source src = new Source();
- src.setAddress(remote);
- rcv.setSource(src);
- Target tgt = new Target();
- tgt.setAddress(remote);
- rcv.setTarget(tgt);
- return rcv;
- }
-
- public static interface LinkConstructor<T extends Link> {
- T create(Session session, String remote, String local);
- }
-
- public static interface LinkResolver<T extends Link> {
- T resolve(String remote);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Router.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Router.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Router.java
deleted file mode 100644
index 873f16c..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Router.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import org.apache.qpid.proton.amqp.transport.Source;
-import org.apache.qpid.proton.amqp.transport.Target;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Receiver;
-import org.apache.qpid.proton.engine.Sender;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-
-
-/**
- * Router
- *
- */
-
-public class Router extends BaseHandler
-{
-
- public static class Routes<T extends Link> {
-
- List<T> routes = new ArrayList<T>();
-
- void add(T route) {
- routes.add(route);
- }
-
- void remove(T route) {
- routes.remove(route);
- }
-
- int size() {
- return routes.size();
- }
-
- public T choose() {
- if (routes.isEmpty()) { return null; }
- ThreadLocalRandom rand = ThreadLocalRandom.current();
- int idx = rand.nextInt(0, routes.size());
- return routes.get(idx);
- }
-
- }
-
- private static final Routes<Sender> EMPTY_OUT = new Routes<Sender>();
- private static final Routes<Receiver> EMPTY_IN = new Routes<Receiver>();
-
- final private Map<String,Routes<Sender>> outgoing = new HashMap<String,Routes<Sender>>();
- final private Map<String,Routes<Receiver>> incoming = new HashMap<String,Routes<Receiver>>();
-
- public Router() {}
-
- private String getAddress(Source source) {
- if (source == null) {
- return null;
- } else {
- return source.getAddress();
- }
- }
-
- private String getAddress(Target target) {
- if (target == null) {
- return null;
- } else {
- return target.getAddress();
- }
- }
-
- public String getAddress(Sender snd) {
- String source = getAddress(snd.getSource());
- String target = getAddress(snd.getTarget());
- return source != null ? source : target;
- }
-
- public String getAddress(Receiver rcv) {
- return getAddress(rcv.getTarget());
- }
-
- public Routes<Sender> getOutgoing(String address) {
- Routes<Sender> routes = outgoing.get(address);
- if (routes == null) { return EMPTY_OUT; }
- return routes;
- }
-
- public Routes<Receiver> getIncoming(String address) {
- Routes<Receiver> routes = incoming.get(address);
- if (routes == null) { return EMPTY_IN; }
- return routes;
- }
-
- private void add(Sender snd) {
- String address = getAddress(snd);
- Routes<Sender> routes = outgoing.get(address);
- if (routes == null) {
- routes = new Routes<Sender>();
- outgoing.put(address, routes);
- }
- routes.add(snd);
- }
-
- private void remove(Sender snd) {
- String address = getAddress(snd);
- Routes<Sender> routes = outgoing.get(address);
- if (routes != null) {
- routes.remove(snd);
- if (routes.size() == 0) {
- outgoing.remove(address);
- }
- }
- }
-
- private void add(Receiver rcv) {
- String address = getAddress(rcv);
- Routes<Receiver> routes = incoming.get(address);
- if (routes == null) {
- routes = new Routes<Receiver>();
- incoming.put(address, routes);
- }
- routes.add(rcv);
- }
-
- private void remove(Receiver rcv) {
- String address = getAddress(rcv);
- Routes<Receiver> routes = incoming.get(address);
- if (routes != null) {
- routes.remove(rcv);
- if (routes.size() == 0) {
- incoming.remove(address);
- }
- }
- }
-
- private void add(Link link) {
- if (link instanceof Sender) {
- add((Sender) link);
- } else {
- add((Receiver) link);
- }
- }
-
- private void remove(Link link) {
- if (link instanceof Sender) {
- remove((Sender) link);
- } else {
- remove((Receiver) link);
- }
- }
-
- @Override
- public void onLinkLocalOpen(Event evt) {
- add(evt.getLink());
- }
-
- @Override
- public void onLinkLocalClose(Event evt) {
- remove(evt.getLink());
- }
-
- @Override
- public void onLinkFinal(Event evt) {
- remove(evt.getLink());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Server.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Server.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Server.java
deleted file mode 100644
index 3e00bd5..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Server.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import org.apache.qpid.proton.amqp.messaging.Accepted;
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Receiver;
-import org.apache.qpid.proton.engine.Sender;
-
-import java.io.IOException;
-
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Server
- *
- */
-
-public class Server extends BaseHandler
-{
-
- private class MessageStore {
-
- Map<String,Deque<Message>> messages = new HashMap<String,Deque<Message>>();
-
- void put(String address, Message message) {
- Deque<Message> queue = messages.get(address);
- if (queue == null) {
- queue = new ArrayDeque<Message>();
- messages.put(address, queue);
- }
- queue.add(message);
- }
-
- Message get(String address) {
- Deque<Message> queue = messages.get(address);
- if (queue == null) { return null; }
- Message msg = queue.remove();
- if (queue.isEmpty()) {
- messages.remove(address);
- }
- return msg;
- }
-
- }
-
- final private MessageStore messages = new MessageStore();
- final private Router router;
- private boolean quiet;
- private int tag = 0;
-
- public Server(Router router, boolean quiet) {
- this.router = router;
- this.quiet = quiet;
- }
-
- private byte[] nextTag() {
- return String.format("%s", tag++).getBytes();
- }
-
- private int send(String address) {
- return send(address, null);
- }
-
- private int send(String address, Sender snd) {
- if (snd == null) {
- Router.Routes<Sender> routes = router.getOutgoing(address);
- snd = routes.choose();
- if (snd == null) {
- return 0;
- }
- }
-
- int count = 0;
- while (snd.getCredit() > 0 && snd.getQueued() < 1024) {
- Message msg = messages.get(address);
- if (msg == null) {
- snd.drained();
- return count;
- }
- Delivery dlv = snd.delivery(nextTag());
- byte[] bytes = msg.getBytes();
- snd.send(bytes, 0, bytes.length);
- dlv.settle();
- count++;
- if (!quiet) {
- System.out.println(String.format("Sent message(%s): %s", address, msg));
- }
- }
-
- return count;
- }
-
- @Override
- public void onLinkFlow(Event evt) {
- Link link = evt.getLink();
- if (link instanceof Sender) {
- Sender snd = (Sender) link;
- send(router.getAddress(snd), snd);
- }
- }
-
- @Override
- public void onDelivery(Event evt) {
- Delivery dlv = evt.getDelivery();
- Link link = dlv.getLink();
- if (link instanceof Sender) {
- dlv.settle();
- } else {
- Receiver rcv = (Receiver) link;
- if (!dlv.isPartial()) {
- byte[] bytes = new byte[dlv.pending()];
- rcv.recv(bytes, 0, bytes.length);
- String address = router.getAddress(rcv);
- Message message = new Message(bytes);
- messages.put(address, message);
- dlv.disposition(Accepted.getInstance());
- dlv.settle();
- if (!quiet) {
- System.out.println(String.format("Got message(%s): %s", address, message));
- }
- send(address);
- }
- }
- }
-
- public static final void main(String[] argv) throws IOException {
- List<String> switches = new ArrayList<String>();
- List<String> args = new ArrayList<String>();
- for (String s : argv) {
- if (s.startsWith("-")) {
- switches.add(s);
- } else {
- args.add(s);
- }
- }
-
- boolean quiet = switches.contains("-q");
- String host = !args.isEmpty() && !Character.isDigit(args.get(0).charAt(0)) ?
- args.remove(0) : "localhost";
- int port = !args.isEmpty() ? Integer.parseInt(args.remove(0)) : 5672;
-
- Collector collector = Collector.Factory.create();
- Router router = new Router();
- Driver driver = new Driver(collector, new Handshaker(),
- new FlowController(1024), router,
- new Server(router, quiet));
- driver.listen(host, port);
- driver.run();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Spout.java
----------------------------------------------------------------------
diff --git a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Spout.java b/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Spout.java
deleted file mode 100644
index 1d70aca..0000000
--- a/examples/engine/java/src/main/java/org/apache/qpid/proton/examples/Spout.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.examples;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.qpid.proton.engine.BaseHandler;
-import org.apache.qpid.proton.engine.Collector;
-import org.apache.qpid.proton.engine.Connection;
-import org.apache.qpid.proton.engine.Delivery;
-import org.apache.qpid.proton.engine.Event;
-import org.apache.qpid.proton.engine.Link;
-import org.apache.qpid.proton.engine.Sender;
-
-public class Spout extends BaseHandler
-{
- private int count;
- private int sent;
- private int settled;
- private boolean quiet;
-
- public Spout(int count, boolean quiet) {
- this.count = count;
- this.quiet = quiet;
- }
-
- @Override
- public void onLinkFlow(Event evt) {
- Link link = evt.getLink();
- if (link instanceof Sender) {
- Sender sender = (Sender) link;
- while ((sent < count) && sender.getCredit() > 0) {
- Delivery dlv = sender.delivery(String.format("spout-%s", sent).getBytes());
-
- Message msg = new Message(String.format("Hello World! [%s]", sent));
- byte[] bytes = msg.getBytes();
- sender.send(bytes, 0, bytes.length);
- sender.advance();
-
- if (!quiet) {
- System.out.println(String.format("Sent %s to %s: %s", new String(dlv.getTag()),
- sender.getTarget().getAddress(), msg));
- }
- sent++;
- }
- }
- }
-
- @Override
- public void onDelivery(Event evt) {
- Delivery dlv = evt.getDelivery();
- if (dlv.remotelySettled()) {
- if (!quiet) {
- System.out.println(String.format("Settled %s: %s", new String(dlv.getTag()), dlv.getRemoteState()));
- }
- dlv.settle();
- settled++;
- }
-
- if (settled >= count) {
- dlv.getLink().getSession().getConnection().close();
- }
- }
-
- @Override
- public void onConnectionRemoteClose(Event evt) {
- System.out.println("settled: " + settled);
- }
-
- public static void main(String[] argv) throws Exception {
- List<String> switches = new ArrayList<String>();
- List<String> args = new ArrayList<String>();
- for (String s : argv) {
- if (s.startsWith("-")) {
- switches.add(s);
- } else {
- args.add(s);
- }
- }
-
- boolean quiet = switches.contains("-q");
- String address = !args.isEmpty() && args.get(0).startsWith("/") ?
- args.remove(0) : "//localhost";
- int count = !args.isEmpty() ? Integer.parseInt(args.remove(0)) : 1;
-
- Collector collector = Collector.Factory.create();
-
- Spout spout = new Spout(count, quiet);
-
- Driver driver = new Driver(collector, spout);
-
- Pool pool = new Pool(collector);
- pool.outgoing(address, null);
-
- driver.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/messenger/README.txt
----------------------------------------------------------------------
diff --git a/examples/java/messenger/README.txt b/examples/java/messenger/README.txt
deleted file mode 100644
index 20d3788..0000000
--- a/examples/java/messenger/README.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-This directory contains java examples that use the messenger API.
-Based on the python examples in ../py
-
- Send.java - a simple example of using the messenger API to send messages
- Recv.java - a simple example of using the messenger API to receive messages
-
-Note that depending on the address passed into these scripts, you can
-use them in either a peer to peer or a brokered scenario.
-
-For brokered usage:
- java Recv.class amqp://<broker>/<queue>
- java Send.class -a amqp://<broker>/<queue> msg_1 ... msg_n
-
-For peer to peer usage:
- # execute on <host> to receive messages from all local network interfaces
- java Recv.class amqp://~0.0.0.0
- java Send.class -a amqp://<host> msg_1 ... msg_n
-
-Or, use the shell scripts "recv" and "send" to run the java programs:
-recv [-v] [-n MAXMESSAGES] [-a ADDRESS] ... [-a ADDRESS]
-send [-a ADDRESS] [-s SUBJECT] MESSAGE ... MESSAGE
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/messenger/pom.xml
----------------------------------------------------------------------
diff --git a/examples/java/messenger/pom.xml b/examples/java/messenger/pom.xml
deleted file mode 100644
index a23a4a3..0000000
--- a/examples/java/messenger/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-project</artifactId>
- <version>0.17.0-SNAPSHOT</version>
- <relativePath>../../..</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>proton-j-messenger-example</artifactId>
- <name>proton-j-messenger-example</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-j</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- </dependencies>
-
- <scm>
- <url>http://svn.apache.org/viewvc/qpid/proton/</url>
- </scm>
-</project>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/messenger/recv
----------------------------------------------------------------------
diff --git a/examples/java/messenger/recv b/examples/java/messenger/recv
deleted file mode 100755
index 862700c..0000000
--- a/examples/java/messenger/recv
+++ /dev/null
@@ -1,31 +0,0 @@
-#! /bin/bash
-#
-# 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.
-#
-
-# Usage: recv [-v] [-n MAXMESSAGES] [-a ADDRESS]*"
-# Subscribes to the given amqp addresses (by default, to amqp://localhost/test),
-# and prints messages received, upt to MAXMESSAGES.
-# Prints message headers and body; -v means print all message properties.
-
-HERE=$(cd $(dirname $0); pwd)
-TOP=$(cd $(dirname $0); cd ../../..; pwd)
-LIBS=$HERE/target/classes:$TOP/proton-j/target/classes
-JFLAGS="-Djava.util.logging.config.file=$HERE/recv.trace.props -cp $LIBS"
-java -cp $LIBS org.apache.qpid.proton.example.Recv "$@"
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/messenger/send
----------------------------------------------------------------------
diff --git a/examples/java/messenger/send b/examples/java/messenger/send
deleted file mode 100755
index e7b4b67..0000000
--- a/examples/java/messenger/send
+++ /dev/null
@@ -1,29 +0,0 @@
-#! /bin/bash
-#
-# 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.
-#
-
-# Usage: send [-a ADDRESS] [-s SUBJECT] MESSAGE ... MESSAGE
-# sends each arg as a text-message to the given adress (by default, to amqp://localhost/test)
-
-HERE=$(cd $(dirname $0); pwd)
-TOP=$(cd $(dirname $0); cd ../../..; pwd)
-LIBS=$HERE/target/classes:$TOP/proton-j/target/classes
-JFLAGS="-Djava.util.logging.config.file=$HERE/send.trace.props -cp $LIBS"
-java -cp $LIBS org.apache.qpid.proton.example.Send "$@"
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/messenger/src/main/java/org/apache/qpid/proton/example/Recv.java
----------------------------------------------------------------------
diff --git a/examples/java/messenger/src/main/java/org/apache/qpid/proton/example/Recv.java b/examples/java/messenger/src/main/java/org/apache/qpid/proton/example/Recv.java
deleted file mode 100644
index 3934cff..0000000
--- a/examples/java/messenger/src/main/java/org/apache/qpid/proton/example/Recv.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.example;
-
-import org.apache.qpid.proton.message.Message;
-import org.apache.qpid.proton.messenger.Messenger;
-import org.apache.qpid.proton.messenger.impl.MessengerImpl;
-import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Example/test of the java Messenger/Message API.
- * Based closely qpid src/proton/examples/messenger/py/recv.py
- * @author mberkowitz@sf.org
- * @since 8/4/2013
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public class Recv {
- private static Logger tracer = Logger.getLogger("proton.example");
- private boolean verbose = false;
- private int maxct = 0;
- private List<String> addrs = new ArrayList<String>();
-
- private static void usage() {
- System.err.println("Usage: recv [-v] [-n MAXCT] [-a ADDRESS]*");
- System.exit(2);
- }
-
- private Recv(String args[]) {
- int i = 0;
- while (i < args.length) {
- String arg = args[i++];
- if (arg.startsWith("-")) {
- if ("-v".equals(arg)) {
- verbose = true;
- } else if ("-a".equals(arg)) {
- addrs.add(args[i++]);
- } else if ("-n".equals(arg)) {
- maxct = Integer.valueOf(args[i++]);
- } else {
- System.err.println("unknown option " + arg);
- usage();
- }
- } else {
- usage();
- }
- }
- if (addrs.size() == 0) {
- addrs.add("amqp://~0.0.0.0");
- }
- }
-
- private static String safe(Object o) {
- return String.valueOf(o);
- }
-
- private void print(int i, Message msg) {
- StringBuilder b = new StringBuilder("message: ");
- b.append(i).append("\n");
- b.append("Address: ").append(msg.getAddress()).append("\n");
- b.append("Subject: ").append(msg.getSubject()).append("\n");
- if (verbose) {
- b.append("Props: ").append(msg.getProperties()).append("\n");
- b.append("App Props: ").append(msg.getApplicationProperties()).append("\n");
- b.append("Msg Anno: ").append(msg.getMessageAnnotations()).append("\n");
- b.append("Del Anno: ").append(msg.getDeliveryAnnotations()).append("\n");
- } else {
- ApplicationProperties p = msg.getApplicationProperties();
- String s = (p == null) ? "null" : safe(p.getValue());
- b.append("Headers: ").append(s).append("\n");
- }
- b.append(msg.getBody()).append("\n");
- b.append("END").append("\n");
- System.out.println(b.toString());
- }
-
- private void run() {
- try {
- Messenger mng = new MessengerImpl();
- mng.start();
- for (String a : addrs) {
- mng.subscribe(a);
- }
- int ct = 0;
- boolean done = false;
- while (!done) {
- mng.recv();
- while (mng.incoming() > 0) {
- Message msg = mng.get();
- ++ct;
- print(ct, msg);
- if (maxct > 0 && ct >= maxct) {
- done = true;
- break;
- }
- }
- }
- mng.stop();
- } catch (Exception e) {
- tracer.log(Level.SEVERE, "proton error", e);
- }
- }
-
- public static void main(String args[]) {
- Recv o = new Recv(args);
- o.run();
- }
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/messenger/src/main/java/org/apache/qpid/proton/example/Send.java
----------------------------------------------------------------------
diff --git a/examples/java/messenger/src/main/java/org/apache/qpid/proton/example/Send.java b/examples/java/messenger/src/main/java/org/apache/qpid/proton/example/Send.java
deleted file mode 100644
index 6f4a919..0000000
--- a/examples/java/messenger/src/main/java/org/apache/qpid/proton/example/Send.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.example;
-
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
-import org.apache.qpid.proton.message.Message;
-import org.apache.qpid.proton.message.impl.MessageImpl;
-import org.apache.qpid.proton.messenger.Messenger;
-import org.apache.qpid.proton.messenger.impl.MessengerImpl;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Example/test of the java Messenger/Message API.
- * Based closely qpid src/proton/examples/messenger/py/send.py
- * @author mberkowitz@sf.org
- * @since 8/4/2013
- * @deprecated Messenger will be removed from upcoming proton-j releases.
- */
-@Deprecated
-public class Send {
-
- private static Logger tracer = Logger.getLogger("proton.example");
- private String address = "amqp://0.0.0.0";
- private String subject;
- private String[] bodies = new String[]{"Hello World!"};
-
- private static void usage() {
- System.err.println("Usage: send [-a ADDRESS] [-s SUBJECT] MSG+");
- System.exit(2);
- }
-
- private Send(String args[]) {
- int i = 0;
- while (i < args.length) {
- String arg = args[i++];
- if (arg.startsWith("-")) {
- if ("-a".equals(arg)) {
- address = args[i++];
- } else if ("-s".equals(arg)) {
- subject = args[i++];
- } else {
- System.err.println("unknown option " + arg);
- usage();
- }
- } else {
- --i;
- break;
- }
- }
-
- if(i != args.length)
- {
- bodies = Arrays.copyOfRange(args, i, args.length);
- }
- }
-
- private void run() {
- try {
- Messenger mng = new MessengerImpl();
- mng.start();
- Message msg = new MessageImpl();
- msg.setAddress(address);
- if (subject != null) msg.setSubject(subject);
- for (String body : bodies) {
- msg.setBody(new AmqpValue(body));
- mng.put(msg);
- }
- mng.send();
- mng.stop();
- } catch (Exception e) {
- tracer.log(Level.SEVERE, "proton error", e);
- }
- }
-
- public static void main(String args[]) {
- Send o = new Send(args);
- o.run();
- }
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/.gitignore
----------------------------------------------------------------------
diff --git a/examples/java/reactor/.gitignore b/examples/java/reactor/.gitignore
deleted file mode 100644
index 5e56e04..0000000
--- a/examples/java/reactor/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/bin
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/README.md
----------------------------------------------------------------------
diff --git a/examples/java/reactor/README.md b/examples/java/reactor/README.md
deleted file mode 100644
index c6b532f..0000000
--- a/examples/java/reactor/README.md
+++ /dev/null
@@ -1,55 +0,0 @@
-The Reactor API provides a means to dispatch events occurring across
-one or more connections. It can be used purely as a dispatch tool
-alongside your own I/O mechanism, however by default it is configured
-with a handler that provides I/O for you.
-
-When programming with the reactor it is important to understand the
-dispatch model used to process events. Every event is associated with
-a context object, i.e. the *target* object upon which the event
-occurred. These objects are contained either directly or indirectly
-within the Reactor:
-
- Delivery --> Link --> Session --> Connection --+
- |
- Task --+--> Reactor
- |
- Selectable --+
-
-
-Each event is dispatched first to a target-specific handler, and
-second to a global handler. The target-specific handler for an event
-is located by searching from the event context up through the
-hierarchy (terminating with the Reactor) and retrieving the most
-specific handler found.
-
-This means that any handler set on the Reactor could receive events
-targeting any object. For example if no handlers are associated with a
-Connection or any of its child objects, then the Reactor's handler
-will receive all the events for that Connection.
-
-Putting a handler on any child, e.g. a Connection or Session or Link
-will prevent any handlers set on the ancestors of that object from
-seeing any events targeted for that object or its children unless that
-handler specifically chooses to delegate those events up to the
-parent, e.g. by overriding onUnhandled and delegating.
-
-The global handler (used to dispatch all events after the
-target-specific handler is invoked) can be accessed and modified using
-Reactor.set/getGlobalHandler. This can be useful for a number of
-reasons, e.g. you could log all events by doing this:
-
- reactor.getGlobalHandler().add(new LoggerHandler());
-
-Where LoggerHandler does this:
-
- public void onUnhandled(Event evt) {
- System.out.println(evt);
- }
-
-The above trick is particularly useful for debugging.
-
-Handlers themselves can have child handlers which will automatically
-delegate the event to those children *after* dispatching the event to
-itself. The default global handler is what provides the default I/O
-behavior of the reactor. To use the reactor as a pure dispatch
-mechanism you can simply set the global handler to null.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/pom.xml
----------------------------------------------------------------------
diff --git a/examples/java/reactor/pom.xml b/examples/java/reactor/pom.xml
deleted file mode 100644
index 3ca3ec3..0000000
--- a/examples/java/reactor/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-project</artifactId>
- <version>0.17.0-SNAPSHOT</version>
- <relativePath>../../..</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>proton-j-reactor-examples</artifactId>
- <name>proton-j-reactor-examples</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>proton-j</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- </dependencies>
-
- <scm>
- <url>http://svn.apache.org/viewvc/qpid/proton/</url>
- </scm>
-</project>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/run
----------------------------------------------------------------------
diff --git a/examples/java/reactor/run b/examples/java/reactor/run
deleted file mode 100755
index 51bd155..0000000
--- a/examples/java/reactor/run
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-CLASS=$1
-shift
-mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.example.reactor.${CLASS} -Dexec.args="$*"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[25/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Open.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Open.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Open.java
deleted file mode 100644
index e4ec98b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Open.java
+++ /dev/null
@@ -1,175 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-import java.util.Arrays;
-import java.util.Map;
-
-
-public final class Open implements FrameBody
-{
- 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 <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleOpen(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "Open{" +
- " containerId='" + _containerId + '\'' +
- ", hostname='" + _hostname + '\'' +
- ", maxFrameSize=" + _maxFrameSize +
- ", channelMax=" + _channelMax +
- ", idleTimeOut=" + _idleTimeOut +
- ", outgoingLocales=" + (_outgoingLocales == null ? null : Arrays.asList(_outgoingLocales)) +
- ", incomingLocales=" + (_incomingLocales == null ? null : Arrays.asList(_incomingLocales)) +
- ", offeredCapabilities=" + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities)) +
- ", desiredCapabilities=" + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) +
- ", properties=" + _properties +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
deleted file mode 100644
index c2621e6..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
+++ /dev/null
@@ -1,54 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-
-public enum ReceiverSettleMode
-{
- FIRST(0),
- SECOND(1);
-
- private UnsignedByte value;
-
- private ReceiverSettleMode(int value) {
- this.value = UnsignedByte.valueOf((byte)value);
- }
-
- public static ReceiverSettleMode valueOf(UnsignedByte value) {
-
- switch (value.intValue()) {
- case 0:
- return ReceiverSettleMode.FIRST;
- case 1:
- return ReceiverSettleMode.SECOND;
- default:
- throw new IllegalArgumentException("The value can be only 0 (for FIRST) and 1 (for SECOND)");
- }
- }
-
- public UnsignedByte getValue() {
- return this.value;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Role.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Role.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Role.java
deleted file mode 100644
index f40effb..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Role.java
+++ /dev/null
@@ -1,34 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-public enum Role
-{
- SENDER, RECEIVER;
-
- public boolean getValue()
- {
- return this == RECEIVER;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
deleted file mode 100644
index 6dae3f4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
+++ /dev/null
@@ -1,58 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-
-public enum SenderSettleMode
-{
- UNSETTLED(0),
- SETTLED(1),
- MIXED(2);
-
- private UnsignedByte value;
-
- private SenderSettleMode(int value) {
- this.value = UnsignedByte.valueOf((byte)value);
- }
-
- public static SenderSettleMode valueOf(UnsignedByte value) {
-
- switch (value.intValue()) {
-
- case 0:
- return SenderSettleMode.UNSETTLED;
- case 1:
- return SenderSettleMode.SETTLED;
- case 2:
- return SenderSettleMode.MIXED;
- default:
- throw new IllegalArgumentException("The value can be only 0 (for UNSETTLED), 1 (for SETTLED) and 2 (for MIXED)");
- }
- }
-
- public UnsignedByte getValue() {
- return this.value;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SessionError.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SessionError.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SessionError.java
deleted file mode 100644
index e029cfb..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SessionError.java
+++ /dev/null
@@ -1,38 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-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");
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Source.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Source.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Source.java
deleted file mode 100644
index 2d6f3b2..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Source.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.amqp.transport;
-
-public interface Source
-{
- public String getAddress();
-
- public Source copy();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Target.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Target.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Target.java
deleted file mode 100644
index c972c02..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Target.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.apache.qpid.proton.amqp.transport;
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-public interface Target
-{
- public String getAddress();
-
- public Target copy();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Transfer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Transfer.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Transfer.java
deleted file mode 100644
index 35c421c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Transfer.java
+++ /dev/null
@@ -1,181 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-public final class Transfer implements FrameBody
-{
- private UnsignedInteger _handle;
- private UnsignedInteger _deliveryId;
- private Binary _deliveryTag;
- private UnsignedInteger _messageFormat;
- private Boolean _settled;
- private boolean _more;
- private ReceiverSettleMode _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 ReceiverSettleMode getRcvSettleMode()
- {
- return _rcvSettleMode;
- }
-
- public void setRcvSettleMode(ReceiverSettleMode rcvSettleMode)
- {
- _rcvSettleMode = rcvSettleMode;
- }
-
- public DeliveryState getState()
- {
- return _state;
- }
-
- public void setState(DeliveryState state)
- {
- _state = state;
- }
-
- public boolean getResume()
- {
- return _resume;
- }
-
- public void setResume(boolean resume)
- {
- _resume = resume;
- }
-
- public boolean getAborted()
- {
- return _aborted;
- }
-
- public void setAborted(boolean aborted)
- {
- _aborted = aborted;
- }
-
- public boolean getBatchable()
- {
- return _batchable;
- }
-
- public void setBatchable(boolean batchable)
- {
- _batchable = batchable;
- }
-
- public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleTransfer(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "Transfer{" +
- "handle=" + _handle +
- ", deliveryId=" + _deliveryId +
- ", deliveryTag=" + _deliveryTag +
- ", messageFormat=" + _messageFormat +
- ", settled=" + _settled +
- ", more=" + _more +
- ", rcvSettleMode=" + _rcvSettleMode +
- ", state=" + _state +
- ", resume=" + _resume +
- ", aborted=" + _aborted +
- ", batchable=" + _batchable +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPDefinedTypes.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPDefinedTypes.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPDefinedTypes.java
deleted file mode 100644
index 2e2f9e0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPDefinedTypes.java
+++ /dev/null
@@ -1,107 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.transport.Attach;
-import org.apache.qpid.proton.amqp.transport.Begin;
-import org.apache.qpid.proton.amqp.transport.Close;
-import org.apache.qpid.proton.amqp.transport.Detach;
-import org.apache.qpid.proton.amqp.transport.Disposition;
-import org.apache.qpid.proton.amqp.transport.End;
-import org.apache.qpid.proton.amqp.transport.Flow;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.amqp.transport.Transfer;
-import org.apache.qpid.proton.codec.messaging.*;
-import org.apache.qpid.proton.codec.security.*;
-import org.apache.qpid.proton.codec.transaction.*;
-import org.apache.qpid.proton.codec.transport.*;
-
-public class AMQPDefinedTypes
-{
- public static void registerAllTypes(Decoder decoder, EncoderImpl encoder)
- {
- registerTransportTypes(decoder, encoder);
- registerMessagingTypes(decoder, encoder);
- registerTransactionTypes(decoder, encoder);
- registerSecurityTypes(decoder, encoder);
- }
-
-
- public static void registerTransportTypes(Decoder decoder, EncoderImpl encoder)
- {
- OpenType.register(decoder, encoder);
- BeginType.register(decoder, encoder);
- AttachType.register(decoder, encoder);
- FlowType.register(decoder, encoder);
- TransferType.register(decoder, encoder);
- DispositionType.register(decoder, encoder);
- DetachType.register(decoder, encoder);
- EndType.register(decoder, encoder);
- CloseType.register(decoder, encoder);
- ErrorConditionType.register(decoder, encoder);
- }
-
- public static void registerMessagingTypes(Decoder decoder, EncoderImpl encoder)
- {
- HeaderType.register(decoder, encoder);
- DeliveryAnnotationsType.register(decoder, encoder);
- MessageAnnotationsType.register(decoder, encoder);
- PropertiesType.register( decoder, encoder );
- ApplicationPropertiesType.register(decoder, encoder);
- DataType.register(decoder, encoder);
- AmqpSequenceType.register(decoder, encoder);
- AmqpValueType.register(decoder, encoder);
- FooterType.register(decoder, encoder);
- ReceivedType.register(decoder, encoder);
- AcceptedType.register(decoder , encoder);
- RejectedType.register(decoder, encoder);
- ReleasedType.register(decoder, encoder);
- ModifiedType.register(decoder, encoder);
- SourceType.register(decoder, encoder);
- TargetType.register(decoder, encoder);
- DeleteOnCloseType.register(decoder, encoder);
- DeleteOnNoLinksType.register(decoder, encoder);
- DeleteOnNoMessagesType.register(decoder, encoder);
- DeleteOnNoLinksOrMessagesType.register(decoder, encoder);
- }
-
- public static void registerTransactionTypes(Decoder decoder, EncoderImpl encoder)
- {
- CoordinatorType.register(decoder, encoder);
- DeclareType.register(decoder, encoder);
- DischargeType.register(decoder, encoder);
- DeclaredType.register(decoder, encoder);
- TransactionalStateType.register(decoder, encoder);
- }
-
- public static void registerSecurityTypes(Decoder decoder, EncoderImpl encoder)
- {
- SaslMechanismsType.register(decoder, encoder);
- SaslInitType.register(decoder, encoder);
- SaslChallengeType.register(decoder, encoder);
- SaslResponseType.register(decoder, encoder);
- SaslOutcomeType.register(decoder, encoder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPType.java
deleted file mode 100644
index 4796b3f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPType.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-
-public interface AMQPType<V>
-{
- Class<V> getTypeClass();
-
- TypeEncoding<V> getEncoding(V val);
-
- TypeEncoding<V> getCanonicalEncoding();
-
- Collection<? extends TypeEncoding<V>> getAllEncodings();
-
- void write(V val);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractDescribedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractDescribedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractDescribedType.java
deleted file mode 100644
index d31ac40..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractDescribedType.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-
-abstract public class AbstractDescribedType<T,M> implements AMQPType<T>
-{
-
- private final EncoderImpl _encoder;
- private final Map<TypeEncoding<M>, TypeEncoding<T>> _encodings = new HashMap<TypeEncoding<M>, TypeEncoding<T>>();
-
- public AbstractDescribedType(EncoderImpl encoder)
- {
- _encoder = encoder;
- }
-
- abstract protected UnsignedLong getDescriptor();
-
-
- public TypeEncoding<T> getEncoding(final T val)
- {
- M asUnderlying = wrap(val);
- TypeEncoding<M> underlyingEncoding = _encoder.getType(asUnderlying).getEncoding(asUnderlying);
- TypeEncoding<T> encoding = _encodings.get(underlyingEncoding);
- if(encoding == null)
- {
- encoding = new DynamicDescribedTypeEncoding(underlyingEncoding);
- _encodings.put(underlyingEncoding, encoding);
- }
-
- return encoding;
- }
-
- abstract protected M wrap(T val);
-
- public TypeEncoding<T> getCanonicalEncoding()
- {
- return null;
- }
-
- public Collection<TypeEncoding<T>> getAllEncodings()
- {
- Collection values = _encodings.values();
- Collection unmodifiable = Collections.unmodifiableCollection(values);
- return (Collection<TypeEncoding<T>>) unmodifiable;
- }
-
- public void write(final T val)
- {
- TypeEncoding<T> encoding = getEncoding(val);
- encoding.writeConstructor();
- encoding.writeValue(val);
- }
-
- private class DynamicDescribedTypeEncoding implements TypeEncoding<T>
- {
- private final TypeEncoding<M> _underlyingEncoding;
- private final TypeEncoding<UnsignedLong> _descriptorType;
- private final int _constructorSize;
-
-
- public DynamicDescribedTypeEncoding(final TypeEncoding<M> underlyingEncoding)
- {
- _underlyingEncoding = underlyingEncoding;
- _descriptorType = _encoder.getType(getDescriptor()).getEncoding(getDescriptor());
- _constructorSize = 1 + _descriptorType.getConstructorSize()
- + _descriptorType.getValueSize(getDescriptor())
- + _underlyingEncoding.getConstructorSize();
- }
-
- public AMQPType<T> getType()
- {
- return AbstractDescribedType.this;
- }
-
- public void writeConstructor()
- {
- _encoder.writeRaw(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
- _descriptorType.writeConstructor();
- _descriptorType.writeValue(getDescriptor());
- _underlyingEncoding.writeConstructor();
- }
-
- public int getConstructorSize()
- {
- return _constructorSize;
- }
-
- public void writeValue(final T val)
- {
- _underlyingEncoding.writeValue(wrap(val));
- }
-
- public int getValueSize(final T val)
- {
- return _underlyingEncoding.getValueSize(wrap(val));
- }
-
- public boolean isFixedSizeVal()
- {
- return _underlyingEncoding.isFixedSizeVal();
- }
-
- public boolean encodesSuperset(final TypeEncoding<T> encoding)
- {
- return (getType() == encoding.getType())
- && (_underlyingEncoding.encodesSuperset(((DynamicDescribedTypeEncoding)encoding)
- ._underlyingEncoding));
- }
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return false;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveType.java
deleted file mode 100644
index 9a8c9c4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveType.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-abstract class AbstractPrimitiveType<T> implements PrimitiveType<T>
-{
- public final void write(T val)
- {
- final TypeEncoding<T> encoding = getEncoding(val);
- encoding.writeConstructor();
- encoding.writeValue(val);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveTypeEncoding.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveTypeEncoding.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveTypeEncoding.java
deleted file mode 100644
index 56079ee..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveTypeEncoding.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-abstract class AbstractPrimitiveTypeEncoding<T> implements PrimitiveTypeEncoding<T>
-{
- private final EncoderImpl _encoder;
- private final DecoderImpl _decoder;
-
- AbstractPrimitiveTypeEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _encoder = encoder;
- _decoder = decoder;
- }
-
- public final void writeConstructor()
- {
- _encoder.writeRaw(getEncodingCode());
- }
-
- public int getConstructorSize()
- {
- return 1;
- }
-
- public abstract byte getEncodingCode();
-
- protected EncoderImpl getEncoder()
- {
- return _encoder;
- }
-
- public Class<T> getTypeClass()
- {
- return getType().getTypeClass();
- }
-
- protected DecoderImpl getDecoder()
- {
- return _decoder;
- }
-
-
- public boolean encodesJavaPrimitive()
- {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/ArrayType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ArrayType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ArrayType.java
deleted file mode 100644
index 45b8dd5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ArrayType.java
+++ /dev/null
@@ -1,1150 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.lang.reflect.Array;
-import java.util.Arrays;
-import java.util.Collection;
-
-public class ArrayType implements PrimitiveType<Object[]>
-{
- private final EncoderImpl _encoder;
- private final BooleanType _booleanType;
- private final ByteType _byteType;
- private final ShortType _shortType;
- private final IntegerType _integerType;
- private final LongType _longType;
- private final FloatType _floatType;
- private final DoubleType _doubleType;
- private final CharacterType _characterType;
-
- public static interface ArrayEncoding extends PrimitiveTypeEncoding<Object[]>
- {
- void writeValue(boolean[] a);
- void writeValue(byte[] a);
- void writeValue(short[] a);
- void writeValue(int[] a);
- void writeValue(long[] a);
- void writeValue(float[] a);
- void writeValue(double[] a);
- void writeValue(char[] a);
-
- void setValue(Object[] val, TypeEncoding encoder, int size);
-
- int getSizeBytes();
-
- Object readValueArray();
- }
-
- private final ArrayEncoding _shortArrayEncoding;
- private final ArrayEncoding _arrayEncoding;
-
- public ArrayType(EncoderImpl encoder,
- final DecoderImpl decoder, BooleanType boolType,
- ByteType byteType,
- ShortType shortType,
- IntegerType intType,
- LongType longType,
- FloatType floatType,
- DoubleType doubleType,
- CharacterType characterType)
- {
- _encoder = encoder;
- _booleanType = boolType;
- _byteType = byteType;
- _shortType = shortType;
- _integerType = intType;
- _longType = longType;
- _floatType = floatType;
- _doubleType = doubleType;
- _characterType = characterType;
-
- _arrayEncoding = new AllArrayEncoding(encoder, decoder);
- _shortArrayEncoding = new ShortArrayEncoding(encoder, decoder);
-
- encoder.register(Object[].class, this);
- decoder.register(this);
- }
-
- public Class<Object[]> getTypeClass()
- {
- return Object[].class;
- }
-
- public ArrayEncoding getEncoding(final Object[] val)
- {
- TypeEncoding encoder = calculateEncoder(val,_encoder);
- int size = calculateSize(val, encoder);
- ArrayEncoding arrayEncoding = (val.length > 255 || size > 254)
- ? _arrayEncoding
- : _shortArrayEncoding;
- arrayEncoding.setValue(val, encoder, size);
- return arrayEncoding;
- }
-
- private static TypeEncoding calculateEncoder(final Object[] val, final EncoderImpl encoder)
- {
-
- if(val.length == 0)
- {
- AMQPType underlyingType = encoder.getTypeFromClass(val.getClass().getComponentType());
- return underlyingType.getCanonicalEncoding();
- }
- else
- {
- AMQPType underlyingType = encoder.getTypeFromClass(val.getClass().getComponentType());
- boolean checkTypes = false;
-
- if(val[0].getClass().isArray() && val[0].getClass().getComponentType().isPrimitive())
- {
- Class componentType = val[0].getClass().getComponentType();
- if(componentType == Boolean.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((boolean[])val[0]);
- }
- else if(componentType == Byte.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((byte[])val[0]);
- }
- else if(componentType == Short.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((short[])val[0]);
- }
- else if(componentType == Integer.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((int[])val[0]);
- }
- else if(componentType == Long.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((long[])val[0]);
- }
- else if(componentType == Float.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((float[])val[0]);
- }
- else if(componentType == Double.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((double[])val[0]);
- }
- else if(componentType == Character.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((char[])val[0]);
- }
- else
- {
- throw new IllegalArgumentException("Cannot encode arrays of type " + componentType.getName());
- }
- }
- else
- {
-
- if(underlyingType == null)
- {
- checkTypes = true;
- underlyingType = encoder.getType(val[0]);
- }
- TypeEncoding underlyingEncoding = underlyingType.getEncoding(val[0]);
- TypeEncoding canonicalEncoding = underlyingType.getCanonicalEncoding();
-
- for(int i = 0; i < val.length && (checkTypes || underlyingEncoding != canonicalEncoding); i++)
- {
- if(checkTypes && encoder.getType(val[i]) != underlyingType)
- {
- throw new IllegalArgumentException("Non matching types " + underlyingType + " and " + encoder
- .getType(val[i]) + " in array");
- }
-
-
- TypeEncoding elementEncoding = underlyingType.getEncoding(val[i]);
- if(elementEncoding != underlyingEncoding && !underlyingEncoding.encodesSuperset(elementEncoding))
- {
- if(elementEncoding.encodesSuperset(underlyingEncoding))
- {
- underlyingEncoding = elementEncoding;
- }
- else
- {
- underlyingEncoding = canonicalEncoding;
- }
- }
-
- }
-
- return underlyingEncoding;
- }
- }
- }
-
- private static int calculateSize(final Object[] val, final TypeEncoding encoder)
- {
- int size = encoder.getConstructorSize();
- if(encoder.isFixedSizeVal())
- {
- size += val.length * encoder.getValueSize(null);
- }
- else
- {
- for(Object o : val)
- {
- if(o.getClass().isArray() && o.getClass().getComponentType().isPrimitive())
- {
- ArrayEncoding arrayEncoding = (ArrayEncoding) encoder;
- ArrayType arrayType = (ArrayType) arrayEncoding.getType();
-
- Class componentType = o.getClass().getComponentType();
-
- size += 2 * arrayEncoding.getSizeBytes();
-
- TypeEncoding componentEncoding;
- int componentCount;
-
- if(componentType == Boolean.TYPE)
- {
- boolean[] componentArray = (boolean[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Byte.TYPE)
- {
- byte[] componentArray = (byte[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Short.TYPE)
- {
- short[] componentArray = (short[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Integer.TYPE)
- {
- int[] componentArray = (int[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Long.TYPE)
- {
- long[] componentArray = (long[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Float.TYPE)
- {
- float[] componentArray = (float[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Double.TYPE)
- {
- double[] componentArray = (double[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Character.TYPE)
- {
- char[] componentArray = (char[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else
- {
- throw new IllegalArgumentException("Cannot encode arrays of type " + componentType.getName());
- }
-
- size += componentEncoding.getConstructorSize()
- + componentEncoding.getValueSize(null) * componentCount;
-
- }
- else
- {
- size += encoder.getValueSize(o);
- }
- }
- }
-
- return size;
- }
-
- public ArrayEncoding getCanonicalEncoding()
- {
- return _arrayEncoding;
- }
-
- public Collection<ArrayEncoding> getAllEncodings()
- {
- return Arrays.asList(_shortArrayEncoding, _arrayEncoding);
- }
-
- public void write(final Object[] val)
- {
- ArrayEncoding encoding = getEncoding(val);
- encoding.writeConstructor();
- encoding.writeValue(val);
- }
-
- public void write(boolean[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final boolean[] a)
- {
- return a.length < 254 || a.length <= 255 && allSameValue(a) ? _shortArrayEncoding : _arrayEncoding;
- }
-
- private boolean allSameValue(final boolean[] a)
- {
- boolean val = a[0];
- for(int i = 1; i < a.length; i++)
- {
- if(val != a[i])
- {
- return false;
- }
- }
- return true;
- }
-
- public void write(byte[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final byte[] a)
- {
- return a.length < 254 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- public void write(short[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final short[] a)
- {
- return a.length < 127 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- public void write(int[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final int[] a)
- {
- return a.length < 63 || (a.length < 254 && allSmallInts(a)) ? _shortArrayEncoding : _arrayEncoding;
- }
-
- private boolean allSmallInts(final int[] a)
- {
- for(int i = 0; i < a.length; i++)
- {
- if(a[i] < -128 || a[i] > 127)
- {
- return false;
- }
- }
- return true;
- }
-
- public void write(long[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final long[] a)
- {
- return a.length < 31 || (a.length < 254 && allSmallLongs(a)) ? _shortArrayEncoding : _arrayEncoding;
- }
-
- private boolean allSmallLongs(final long[] a)
- {
- for(int i = 0; i < a.length; i++)
- {
- if(a[i] < -128L || a[i] > 127L)
- {
- return false;
- }
- }
- return true;
- }
-
- public void write(float[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final float[] a)
- {
- return a.length < 63 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- public void write(double[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final double[] a)
- {
- return a.length < 31 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- public void write(char[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final char[] a)
- {
- return a.length < 63 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- private class AllArrayEncoding
- extends LargeFloatingSizePrimitiveTypeEncoding<Object[]>
- implements ArrayEncoding
- {
-
- private Object[] _val;
- private TypeEncoding _underlyingEncoder;
- private int _size;
-
- AllArrayEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- public void writeValue(final boolean[] a)
- {
- BooleanType.BooleanEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(boolean b : a)
- {
- underlyingEncoder.writeValue(b);
- }
-
- }
-
- public void writeValue(final byte[] a)
- {
- ByteType.ByteEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(byte b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final short[] a)
- {
- ShortType.ShortEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(short b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final int[] a)
- {
-
- IntegerType.IntegerEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(int b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final long[] a)
- {
-
- LongType.LongEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(long b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final float[] a)
- {
-
- FloatType.FloatEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(float b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final double[] a)
- {
-
- DoubleType.DoubleEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(double b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final char[] a)
- {
-
- CharacterType.CharacterEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(char b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void setValue(final Object[] val, final TypeEncoding encoder, final int size)
- {
- _val = val;
- _underlyingEncoder = encoder;
- _size = size;
- }
-
- @Override
- protected void writeEncodedValue(final Object[] val)
- {
- TypeEncoding underlyingEncoder;
-
- if(_val != val)
- {
- _val = val;
- _underlyingEncoder = underlyingEncoder = calculateEncoder(val, getEncoder());
- _size = calculateSize(val, underlyingEncoder);
- }
- else
- {
- underlyingEncoder = _underlyingEncoder;
- }
- getEncoder().writeRaw(val.length);
- underlyingEncoder.writeConstructor();
- for(Object o : val)
- {
- underlyingEncoder.writeValue(o);
- }
- }
-
- @Override
- protected int getEncodedValueSize(final Object[] val)
- {
- if(_val != val)
- {
- _val = val;
- _underlyingEncoder = calculateEncoder(val, getEncoder());
- _size = calculateSize(val, _underlyingEncoder);
- }
- return 4 + _size;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.ARRAY32;
- }
-
- public ArrayType getType()
- {
- return ArrayType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Object[]> encoding)
- {
- return getType() == encoding.getType();
- }
-
- public Object[] readValue()
- {
- DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- int count = decoder.readRawInt();
- return decodeArray(decoder, count);
- }
-
- public Object readValueArray()
- {
- DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- int count = decoder.readRawInt();
- return decodeArrayAsObject(decoder, count);
- }
-
-
-
- }
-
-
-
- private class ShortArrayEncoding
- extends SmallFloatingSizePrimitiveTypeEncoding<Object[]>
- implements ArrayEncoding
- {
-
- private Object[] _val;
- private TypeEncoding _underlyingEncoder;
- private int _size;
-
- ShortArrayEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- public void writeValue(final boolean[] a)
- {
- BooleanType.BooleanEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(boolean b : a)
- {
- underlyingEncoder.writeValue(b);
- }
-
- }
-
- public void writeValue(final byte[] a)
- {
- ByteType.ByteEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(byte b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final short[] a)
- {
- ShortType.ShortEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(short b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final int[] a)
- {
-
- IntegerType.IntegerEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(int b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final long[] a)
- {
-
- LongType.LongEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(long b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final float[] a)
- {
-
- FloatType.FloatEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(float b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final double[] a)
- {
-
- DoubleType.DoubleEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(double b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final char[] a)
- {
-
- CharacterType.CharacterEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(char b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void setValue(final Object[] val, final TypeEncoding encoder, final int size)
- {
- _val = val;
- _underlyingEncoder = encoder;
- _size = size;
- }
-
- @Override
- protected void writeEncodedValue(final Object[] val)
- {
- TypeEncoding underlyingEncoder;
-
- if(_val != val)
- {
- _val = val;
- _underlyingEncoder = underlyingEncoder = calculateEncoder(val, getEncoder());
- _size = calculateSize(val, underlyingEncoder);
- }
- else
- {
- underlyingEncoder = _underlyingEncoder;
- }
- getEncoder().writeRaw((byte)val.length);
- underlyingEncoder.writeConstructor();
- for(Object o : val)
- {
- if(o.getClass().isArray() && o.getClass().getComponentType().isPrimitive())
- {
- ArrayEncoding arrayEncoding = (ArrayEncoding) underlyingEncoder;
- ArrayType arrayType = (ArrayType) arrayEncoding.getType();
-
- Class componentType = o.getClass().getComponentType();
-
- if(componentType == Boolean.TYPE)
- {
- boolean[] componentArray = (boolean[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Byte.TYPE)
- {
- byte[] componentArray = (byte[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Short.TYPE)
- {
- short[] componentArray = (short[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Integer.TYPE)
- {
- int[] componentArray = (int[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Long.TYPE)
- {
- long[] componentArray = (long[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Float.TYPE)
- {
- float[] componentArray = (float[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Double.TYPE)
- {
- double[] componentArray = (double[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Character.TYPE)
- {
- char[] componentArray = (char[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else
- {
- throw new IllegalArgumentException("Cannot encode arrays of type " + componentType.getName());
- }
-
- }
- else
- {
- underlyingEncoder.writeValue(o);
- }
- }
- }
-
- @Override
- protected int getEncodedValueSize(final Object[] val)
- {
- if(_val != val)
- {
- _val = val;
- _underlyingEncoder = calculateEncoder(val, getEncoder());
- _size = calculateSize(val, _underlyingEncoder);
- }
- return 1 + _size;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.ARRAY8;
- }
-
- public ArrayType getType()
- {
- return ArrayType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Object[]> encoding)
- {
- return getType() == encoding.getType();
- }
-
- public Object[] readValue()
- {
- DecoderImpl decoder = getDecoder();
- int size = ((int)decoder.readRawByte()) & 0xFF;
- int count = ((int)decoder.readRawByte()) & 0xFF;
- return decodeArray(decoder, count);
- }
-
- public Object readValueArray()
- {
- DecoderImpl decoder = getDecoder();
- int size = ((int)decoder.readRawByte()) & 0xFF;
- int count = ((int)decoder.readRawByte()) & 0xFF;
- return decodeArrayAsObject(decoder, count);
- }
-
- }
-
- private BooleanType.BooleanEncoding getUnderlyingEncoding(final boolean[] a)
- {
- if(a.length == 0)
- {
- return _booleanType.getCanonicalEncoding();
- }
- else
- {
- boolean val = a[0];
- for(int i = 1; i < a.length; i++)
- {
- if(val != a[i])
- {
- return _booleanType.getCanonicalEncoding();
- }
- }
- return _booleanType.getEncoding(val);
- }
- }
-
-
- private ByteType.ByteEncoding getUnderlyingEncoding(final byte[] a)
- {
- return _byteType.getCanonicalEncoding();
- }
-
-
- private ShortType.ShortEncoding getUnderlyingEncoding(final short[] a)
- {
- return _shortType.getCanonicalEncoding();
- }
-
- private IntegerType.IntegerEncoding getUnderlyingEncoding(final int[] a)
- {
- if(a.length == 0 || !allSmallInts(a))
- {
- return _integerType.getCanonicalEncoding();
- }
- else
- {
- return _integerType.getEncoding(a[0]);
- }
- }
-
- private LongType.LongEncoding getUnderlyingEncoding(final long[] a)
- {
- if(a.length == 0 || !allSmallLongs(a))
- {
- return _longType.getCanonicalEncoding();
- }
- else
- {
- return _longType.getEncoding(a[0]);
- }
- }
-
-
- private FloatType.FloatEncoding getUnderlyingEncoding(final float[] a)
- {
- return _floatType.getCanonicalEncoding();
- }
-
-
- private DoubleType.DoubleEncoding getUnderlyingEncoding(final double[] a)
- {
- return _doubleType.getCanonicalEncoding();
- }
-
-
- private CharacterType.CharacterEncoding getUnderlyingEncoding(final char[] a)
- {
- return _characterType.getCanonicalEncoding();
- }
-
- private static Object[] decodeArray(final DecoderImpl decoder, final int count)
- {
- TypeConstructor constructor = decoder.readConstructor();
- return decodeNonPrimitive(decoder, constructor, count);
- }
-
- private static Object[] decodeNonPrimitive(final DecoderImpl decoder,
- final TypeConstructor constructor,
- final int count)
- {
- if (count > decoder.getByteBufferRemaining()) {
- throw new IllegalArgumentException("Array element count "+count+" is specified to be greater than the amount of data available ("+
- decoder.getByteBufferRemaining()+")");
- }
-
- if(constructor instanceof ArrayEncoding)
- {
- ArrayEncoding arrayEncoding = (ArrayEncoding) constructor;
-
- Object[] array = new Object[count];
- for(int i = 0; i < count; i++)
- {
- array[i] = arrayEncoding.readValueArray();
- }
-
- return array;
- }
- else
- {
- Object[] array = (Object[]) Array.newInstance(constructor.getTypeClass(), count);
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readValue();
- }
-
- return array;
- }
- }
-
- private static Object decodeArrayAsObject(final DecoderImpl decoder, final int count)
- {
- TypeConstructor constructor = decoder.readConstructor();
- if(constructor.encodesJavaPrimitive())
- {
- if (count > decoder.getByteBufferRemaining()) {
- throw new IllegalArgumentException("Array element count "+count+" is specified to be greater than the amount of data available ("+
- decoder.getByteBufferRemaining()+")");
- }
-
- if(constructor instanceof BooleanType.BooleanEncoding)
- {
- return decodeBooleanArray((BooleanType.BooleanEncoding) constructor, count);
- }
- else if(constructor instanceof ByteType.ByteEncoding)
- {
- return decodeByteArray((ByteType.ByteEncoding)constructor, count);
- }
- else if(constructor instanceof ShortType.ShortEncoding)
- {
- return decodeShortArray((ShortType.ShortEncoding)constructor, count);
- }
- else if(constructor instanceof IntegerType.IntegerEncoding)
- {
- return decodeIntArray((IntegerType.IntegerEncoding)constructor, count);
- }
- else if(constructor instanceof LongType.LongEncoding)
- {
- return decodeLongArray((LongType.LongEncoding) constructor, count);
- }
- else if(constructor instanceof FloatType.FloatEncoding)
- {
- return decodeFloatArray((FloatType.FloatEncoding) constructor, count);
- }
- else if(constructor instanceof DoubleType.DoubleEncoding)
- {
- return decodeDoubleArray((DoubleType.DoubleEncoding)constructor, count);
- }
- else
- {
- throw new ClassCastException("Unexpected class " + constructor.getClass().getName());
- }
-
- }
- else
- {
- return decodeNonPrimitive(decoder, constructor, count);
- }
-
- }
-
- private static boolean[] decodeBooleanArray(BooleanType.BooleanEncoding constructor, final int count)
- {
- boolean[] array = new boolean[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static byte[] decodeByteArray(ByteType.ByteEncoding constructor , final int count)
- {
- byte[] array = new byte[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static short[] decodeShortArray(ShortType.ShortEncoding constructor, final int count)
- {
- short[] array = new short[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static int[] decodeIntArray(IntegerType.IntegerEncoding constructor, final int count)
- {
- int[] array = new int[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
-
- private static long[] decodeLongArray(LongType.LongEncoding constructor, final int count)
- {
- long[] array = new long[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static float[] decodeFloatArray(FloatType.FloatEncoding constructor, final int count)
- {
- float[] array = new float[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static double[] decodeDoubleArray(DoubleType.DoubleEncoding constructor, final int count)
- {
- double[] array = new double[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
-
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/BigIntegerType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/BigIntegerType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/BigIntegerType.java
deleted file mode 100644
index f74e80b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/BigIntegerType.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collection;
-
-public class BigIntegerType extends AbstractPrimitiveType<BigInteger> {
-
- public static interface BigIntegerEncoding extends PrimitiveTypeEncoding<BigInteger>
- {
- void write(BigInteger l);
- void writeValue(BigInteger l);
- public BigInteger readPrimitiveValue();
- }
-
- private static final BigInteger BIG_BYTE_MIN = BigInteger.valueOf(Byte.MIN_VALUE);
- private static final BigInteger BIG_BYTE_MAX = BigInteger.valueOf(Byte.MAX_VALUE);
- private static final BigInteger BIG_LONG_MIN = BigInteger.valueOf(Long.MIN_VALUE);;
- private static final BigInteger BIG_LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);;
-
- private BigIntegerEncoding _BigIntegerEncoding;
- private BigIntegerEncoding _smallBigIntegerEncoding;
-
- BigIntegerType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _BigIntegerEncoding = new AllBigIntegerEncoding(encoder, decoder);
- _smallBigIntegerEncoding = new SmallBigIntegerEncoding(encoder, decoder);
- encoder.register(BigInteger.class, this);
- }
-
- public Class<BigInteger> getTypeClass()
- {
- return BigInteger.class;
- }
-
- public BigIntegerEncoding getEncoding(final BigInteger l)
- {
- return (l.compareTo(BIG_BYTE_MIN) >= 0 && l.compareTo(BIG_BYTE_MAX) <= 0) ? _smallBigIntegerEncoding : _BigIntegerEncoding;
- }
-
-
- public BigIntegerEncoding getCanonicalEncoding()
- {
- return _BigIntegerEncoding;
- }
-
- public Collection<BigIntegerEncoding> getAllEncodings()
- {
- return Arrays.asList(_smallBigIntegerEncoding, _BigIntegerEncoding);
- }
-
- private long longValueExact(final BigInteger val) {
- if (val.compareTo(BIG_LONG_MIN) < 0 || val.compareTo(BIG_LONG_MAX) > 0) {
- throw new ArithmeticException("cannot encode BigInteger not representable as long");
- }
- return val.longValue();
- }
-
- private class AllBigIntegerEncoding extends FixedSizePrimitiveTypeEncoding<BigInteger> implements BigIntegerEncoding
- {
-
- public AllBigIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 8;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.LONG;
- }
-
- public BigIntegerType getType()
- {
- return BigIntegerType.this;
- }
-
- public void writeValue(final BigInteger val)
- {
- getEncoder().writeRaw(longValueExact(val));
- }
-
- public void write(final BigInteger l)
- {
- writeConstructor();
- getEncoder().writeRaw(longValueExact(l));
-
- }
-
- public boolean encodesSuperset(final TypeEncoding<BigInteger> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public BigInteger readValue()
- {
- return readPrimitiveValue();
- }
-
- public BigInteger readPrimitiveValue()
- {
- return BigInteger.valueOf(getDecoder().readLong());
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-
- private class SmallBigIntegerEncoding extends FixedSizePrimitiveTypeEncoding<BigInteger> implements BigIntegerEncoding
- {
- public SmallBigIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SMALLLONG;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
- public void write(final BigInteger l)
- {
- writeConstructor();
- getEncoder().writeRaw(l.byteValue());
- }
-
- public BigInteger readPrimitiveValue()
- {
- return BigInteger.valueOf(getDecoder().readRawByte());
- }
-
- public BigIntegerType getType()
- {
- return BigIntegerType.this;
- }
-
- public void writeValue(final BigInteger val)
- {
- getEncoder().writeRaw(val.byteValue());
- }
-
- public boolean encodesSuperset(final TypeEncoding<BigInteger> encoder)
- {
- return encoder == this;
- }
-
- public BigInteger readValue()
- {
- return readPrimitiveValue();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/BinaryType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/BinaryType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/BinaryType.java
deleted file mode 100644
index 88c204f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/BinaryType.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public class BinaryType extends AbstractPrimitiveType<Binary>
-{
- private final BinaryEncoding _binaryEncoding;
- private final BinaryEncoding _shortBinaryEncoding;
-
- private static interface BinaryEncoding extends PrimitiveTypeEncoding<Binary>
- {
-
- }
-
- BinaryType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _binaryEncoding = new LongBinaryEncoding(encoder, decoder);
- _shortBinaryEncoding = new ShortBinaryEncoding(encoder, decoder);
- encoder.register(Binary.class, this);
- decoder.register(this);
- }
-
- public Class<Binary> getTypeClass()
- {
- return Binary.class;
- }
-
- public BinaryEncoding getEncoding(final Binary val)
- {
- return val.getLength() <= 255 ? _shortBinaryEncoding : _binaryEncoding;
- }
-
-
- public BinaryEncoding getCanonicalEncoding()
- {
- return _binaryEncoding;
- }
-
- public Collection<BinaryEncoding> getAllEncodings()
- {
- return Arrays.asList(_shortBinaryEncoding, _binaryEncoding);
- }
-
- private class LongBinaryEncoding
- extends LargeFloatingSizePrimitiveTypeEncoding<Binary>
- implements BinaryEncoding
- {
-
- public LongBinaryEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final Binary val)
- {
- getEncoder().writeRaw(val.getArray(), val.getArrayOffset(), val.getLength());
- }
-
- @Override
- protected int getEncodedValueSize(final Binary val)
- {
- return val.getLength();
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.VBIN32;
- }
-
- public BinaryType getType()
- {
- return BinaryType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Binary> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Binary readValue()
- {
- final DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- if (size > decoder.getByteBufferRemaining()) {
- throw new IllegalArgumentException("Binary data size "+size+" is specified to be greater than the amount of data available ("+
- decoder.getByteBufferRemaining()+")");
- }
- byte[] data = new byte[size];
- decoder.readRaw(data, 0, size);
- return new Binary(data);
- }
- }
-
- private class ShortBinaryEncoding
- extends SmallFloatingSizePrimitiveTypeEncoding<Binary>
- implements BinaryEncoding
- {
-
- public ShortBinaryEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final Binary val)
- {
- getEncoder().writeRaw(val.getArray(), val.getArrayOffset(), val.getLength());
- }
-
- @Override
- protected int getEncodedValueSize(final Binary val)
- {
- return val.getLength();
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.VBIN8;
- }
-
- public BinaryType getType()
- {
- return BinaryType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Binary> encoder)
- {
- return encoder == this;
- }
-
- public Binary readValue()
- {
- int size = ((int)getDecoder().readRawByte()) & 0xff;
- byte[] data = new byte[size];
- getDecoder().readRaw(data, 0, size);
- return new Binary(data);
- }
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org