Added @Override annotations which were disallowed in Java 5 but not anymore in Java 6.
This commit is contained in:
parent
d3fb52e11d
commit
0dbdbcdb96
@ -318,6 +318,7 @@ public class Bootstrap implements ExternalResourceReleasable {
|
||||
* {@inheritDoc} This method simply delegates the call to
|
||||
* {@link ChannelFactory#releaseExternalResources()}.
|
||||
*/
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
ChannelFactory factory = this.factory;
|
||||
if (factory != null) {
|
||||
|
@ -39,10 +39,12 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
private int markedReaderIndex;
|
||||
private int markedWriterIndex;
|
||||
|
||||
@Override
|
||||
public int readerIndex() {
|
||||
return readerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readerIndex(int readerIndex) {
|
||||
if (readerIndex < 0 || readerIndex > writerIndex) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -50,10 +52,12 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
this.readerIndex = readerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writerIndex() {
|
||||
return writerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writerIndex(int writerIndex) {
|
||||
if (writerIndex < readerIndex || writerIndex > capacity()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -61,6 +65,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
this.writerIndex = writerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIndex(int readerIndex, int writerIndex) {
|
||||
if (readerIndex < 0 || readerIndex > writerIndex || writerIndex > capacity()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -69,42 +74,52 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
this.writerIndex = writerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
readerIndex = writerIndex = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readable() {
|
||||
return readableBytes() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean writable() {
|
||||
return writableBytes() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readableBytes() {
|
||||
return writerIndex - readerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writableBytes() {
|
||||
return capacity() - writerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markReaderIndex() {
|
||||
markedReaderIndex = readerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetReaderIndex() {
|
||||
readerIndex(markedReaderIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markWriterIndex() {
|
||||
markedWriterIndex = writerIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetWriterIndex() {
|
||||
writerIndex = markedWriterIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discardReadBytes() {
|
||||
if (readerIndex == 0) {
|
||||
return;
|
||||
@ -116,20 +131,24 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
readerIndex = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ensureWritableBytes(int writableBytes) {
|
||||
if (writableBytes > writableBytes()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getUnsignedByte(int index) {
|
||||
return (short) (getByte(index) & 0xFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedShort(int index) {
|
||||
return getShort(index) & 0xFFFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMedium(int index) {
|
||||
int value = getUnsignedMedium(index);
|
||||
if ((value & 0x800000) != 0) {
|
||||
@ -138,30 +157,37 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUnsignedInt(int index) {
|
||||
return getInt(index) & 0xFFFFFFFFL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getChar(int index) {
|
||||
return (char) getShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(int index) {
|
||||
return Float.intBitsToFloat(getInt(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(int index) {
|
||||
return Double.longBitsToDouble(getLong(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst) {
|
||||
getBytes(index, dst, 0, dst.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst) {
|
||||
getBytes(index, dst, dst.writableBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int length) {
|
||||
if (length > dst.writableBytes()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -170,26 +196,32 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
dst.writerIndex(dst.writerIndex() + length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChar(int index, int value) {
|
||||
setShort(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloat(int index, float value) {
|
||||
setInt(index, Float.floatToRawIntBits(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(int index, double value) {
|
||||
setLong(index, Double.doubleToRawLongBits(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src) {
|
||||
setBytes(index, src, 0, src.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src) {
|
||||
setBytes(index, src, src.readableBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int length) {
|
||||
if (length > src.readableBytes()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -198,6 +230,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
src.readerIndex(src.readerIndex() + length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZero(int index, int length) {
|
||||
if (length == 0) {
|
||||
return;
|
||||
@ -230,6 +263,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte readByte() {
|
||||
if (readerIndex == writerIndex) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -237,10 +271,12 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return getByte(readerIndex ++);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short readUnsignedByte() {
|
||||
return (short) (readByte() & 0xFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short readShort() {
|
||||
checkReadableBytes(2);
|
||||
short v = getShort(readerIndex);
|
||||
@ -248,10 +284,12 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUnsignedShort() {
|
||||
return readShort() & 0xFFFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readMedium() {
|
||||
int value = readUnsignedMedium();
|
||||
if ((value & 0x800000) != 0) {
|
||||
@ -260,6 +298,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUnsignedMedium() {
|
||||
checkReadableBytes(3);
|
||||
int v = getUnsignedMedium(readerIndex);
|
||||
@ -267,6 +306,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readInt() {
|
||||
checkReadableBytes(4);
|
||||
int v = getInt(readerIndex);
|
||||
@ -274,10 +314,12 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readUnsignedInt() {
|
||||
return readInt() & 0xFFFFFFFFL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readLong() {
|
||||
checkReadableBytes(8);
|
||||
long v = getLong(readerIndex);
|
||||
@ -285,18 +327,22 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char readChar() {
|
||||
return (char) readShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float readFloat() {
|
||||
return Float.intBitsToFloat(readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double readDouble() {
|
||||
return Double.longBitsToDouble(readLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer readBytes(int length) {
|
||||
checkReadableBytes(length);
|
||||
if (length == 0) {
|
||||
@ -308,26 +354,31 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer readSlice(int length) {
|
||||
ChannelBuffer slice = slice(readerIndex, length);
|
||||
readerIndex += length;
|
||||
return slice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(byte[] dst, int dstIndex, int length) {
|
||||
checkReadableBytes(length);
|
||||
getBytes(readerIndex, dst, dstIndex, length);
|
||||
readerIndex += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(byte[] dst) {
|
||||
readBytes(dst, 0, dst.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(ChannelBuffer dst) {
|
||||
readBytes(dst, dst.writableBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(ChannelBuffer dst, int length) {
|
||||
if (length > dst.writableBytes()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -336,12 +387,14 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
dst.writerIndex(dst.writerIndex() + length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(ChannelBuffer dst, int dstIndex, int length) {
|
||||
checkReadableBytes(length);
|
||||
getBytes(readerIndex, dst, dstIndex, length);
|
||||
readerIndex += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(ByteBuffer dst) {
|
||||
int length = dst.remaining();
|
||||
checkReadableBytes(length);
|
||||
@ -349,6 +402,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
readerIndex += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readBytes(GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
checkReadableBytes(length);
|
||||
@ -357,12 +411,14 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(OutputStream out, int length) throws IOException {
|
||||
checkReadableBytes(length);
|
||||
getBytes(readerIndex, out, length);
|
||||
readerIndex += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skipBytes(int length) {
|
||||
int newReaderIndex = readerIndex + length;
|
||||
if (newReaderIndex > writerIndex) {
|
||||
@ -371,55 +427,67 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
readerIndex = newReaderIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByte(int value) {
|
||||
setByte(writerIndex ++, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeShort(int value) {
|
||||
setShort(writerIndex, value);
|
||||
writerIndex += 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMedium(int value) {
|
||||
setMedium(writerIndex, value);
|
||||
writerIndex += 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInt(int value) {
|
||||
setInt(writerIndex, value);
|
||||
writerIndex += 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLong(long value) {
|
||||
setLong(writerIndex, value);
|
||||
writerIndex += 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChar(int value) {
|
||||
writeShort(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFloat(float value) {
|
||||
writeInt(Float.floatToRawIntBits(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDouble(double value) {
|
||||
writeLong(Double.doubleToRawLongBits(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(byte[] src, int srcIndex, int length) {
|
||||
setBytes(writerIndex, src, srcIndex, length);
|
||||
writerIndex += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(byte[] src) {
|
||||
writeBytes(src, 0, src.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(ChannelBuffer src) {
|
||||
writeBytes(src, src.readableBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(ChannelBuffer src, int length) {
|
||||
if (length > src.readableBytes()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -428,17 +496,20 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
src.readerIndex(src.readerIndex() + length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(ChannelBuffer src, int srcIndex, int length) {
|
||||
setBytes(writerIndex, src, srcIndex, length);
|
||||
writerIndex += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(ByteBuffer src) {
|
||||
int length = src.remaining();
|
||||
setBytes(writerIndex, src);
|
||||
writerIndex += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writeBytes(InputStream in, int length)
|
||||
throws IOException {
|
||||
int writtenBytes = setBytes(writerIndex, in, length);
|
||||
@ -448,6 +519,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return writtenBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writeBytes(ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
int writtenBytes = setBytes(writerIndex, in, length);
|
||||
@ -457,6 +529,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return writtenBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeZero(int length) {
|
||||
if (length == 0) {
|
||||
return;
|
||||
@ -484,30 +557,37 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy() {
|
||||
return copy(readerIndex, readableBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice() {
|
||||
return slice(readerIndex, readableBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer() {
|
||||
return toByteBuffer(readerIndex, readableBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer[] toByteBuffers() {
|
||||
return toByteBuffers(readerIndex, readableBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer[] toByteBuffers(int index, int length) {
|
||||
return new ByteBuffer[] { toByteBuffer(index, length) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Charset charset) {
|
||||
return toString(readerIndex, readableBytes(), charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(int index, int length, Charset charset) {
|
||||
if (length == 0) {
|
||||
return "";
|
||||
@ -517,32 +597,39 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
toByteBuffer(index, length), charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(int fromIndex, int toIndex, byte value) {
|
||||
return ChannelBuffers.indexOf(this, fromIndex, toIndex, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder) {
|
||||
return ChannelBuffers.indexOf(this, fromIndex, toIndex, indexFinder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bytesBefore(byte value) {
|
||||
return bytesBefore(readerIndex(), readableBytes(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bytesBefore(ChannelBufferIndexFinder indexFinder) {
|
||||
return bytesBefore(readerIndex(), readableBytes(), indexFinder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bytesBefore(int length, byte value) {
|
||||
checkReadableBytes(length);
|
||||
return bytesBefore(readerIndex(), length, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bytesBefore(int length, ChannelBufferIndexFinder indexFinder) {
|
||||
checkReadableBytes(length);
|
||||
return bytesBefore(readerIndex(), length, indexFinder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bytesBefore(int index, int length, byte value) {
|
||||
int endIndex = indexOf(index, index + length, value);
|
||||
if (endIndex < 0) {
|
||||
@ -551,6 +638,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return endIndex - index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bytesBefore(int index, int length,
|
||||
ChannelBufferIndexFinder indexFinder) {
|
||||
int endIndex = indexOf(index, index + length, indexFinder);
|
||||
@ -573,6 +661,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
return ChannelBuffers.equals(this, (ChannelBuffer) o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ChannelBuffer that) {
|
||||
return ChannelBuffers.compare(this, that);
|
||||
}
|
||||
|
@ -49,14 +49,17 @@ public abstract class AbstractChannelBufferFactory implements ChannelBufferFacto
|
||||
this.defaultOrder = defaultOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer getBuffer(int capacity) {
|
||||
return getBuffer(getDefaultOrder(), capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer getBuffer(byte[] array, int offset, int length) {
|
||||
return getBuffer(getDefaultOrder(), array, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder getDefaultOrder() {
|
||||
return defaultOrder;
|
||||
}
|
||||
|
@ -52,24 +52,29 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
super(array, readerIndex, writerIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
return HeapChannelBufferFactory.getInstance(ByteOrder.BIG_ENDIAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
return (short) (array[index] << 8 | array[index+1] & 0xFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
return (array[index] & 0xff) << 16 |
|
||||
(array[index+1] & 0xff) << 8 |
|
||||
(array[index+2] & 0xff) << 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
return (array[index] & 0xff) << 24 |
|
||||
(array[index+1] & 0xff) << 16 |
|
||||
@ -77,6 +82,7 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
(array[index+3] & 0xff) << 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
return ((long) array[index] & 0xff) << 56 |
|
||||
((long) array[index+1] & 0xff) << 48 |
|
||||
@ -88,17 +94,20 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
((long) array[index+7] & 0xff) << 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
array[index ] = (byte) (value >>> 8);
|
||||
array[index+1] = (byte) (value >>> 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
array[index ] = (byte) (value >>> 16);
|
||||
array[index+1] = (byte) (value >>> 8);
|
||||
array[index+2] = (byte) (value >>> 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
array[index ] = (byte) (value >>> 24);
|
||||
array[index+1] = (byte) (value >>> 16);
|
||||
@ -106,6 +115,7 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
array[index+3] = (byte) (value >>> 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
array[index ] = (byte) (value >>> 56);
|
||||
array[index+1] = (byte) (value >>> 48);
|
||||
@ -117,10 +127,12 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
array[index+7] = (byte) (value >>> 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
return new BigEndianHeapChannelBuffer(array, readerIndex(), writerIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
if (index < 0 || length < 0 || index + length > array.length) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
|
@ -62,6 +62,7 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
setIndex(buffer.readerIndex(), buffer.writerIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
if (buffer.isDirect()) {
|
||||
return DirectChannelBufferFactory.getInstance(order());
|
||||
@ -70,52 +71,64 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return buffer.isDirect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return buffer.hasArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
return buffer.arrayOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
return buffer.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
return buffer.getShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
return (getByte(index) & 0xff) << 16 |
|
||||
(getByte(index+1) & 0xff) << 8 |
|
||||
(getByte(index+2) & 0xff) << 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
return buffer.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
return buffer.getLong(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
|
||||
if (dst instanceof ByteBufferBackedChannelBuffer) {
|
||||
ByteBufferBackedChannelBuffer bbdst = (ByteBufferBackedChannelBuffer) dst;
|
||||
@ -130,6 +143,7 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
ByteBuffer data = buffer.duplicate();
|
||||
try {
|
||||
@ -140,6 +154,7 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
data.get(dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ByteBuffer dst) {
|
||||
ByteBuffer data = buffer.duplicate();
|
||||
int bytesToCopy = Math.min(capacity() - index, dst.remaining());
|
||||
@ -151,28 +166,34 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
dst.put(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int index, int value) {
|
||||
buffer.put(index, (byte) value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
buffer.putShort(index, (short) value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
setByte(index, (byte) (value >>> 16));
|
||||
setByte(index+1, (byte) (value >>> 8));
|
||||
setByte(index+2, (byte) (value >>> 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
buffer.putInt(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
buffer.putLong(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
if (src instanceof ByteBufferBackedChannelBuffer) {
|
||||
ByteBufferBackedChannelBuffer bbsrc = (ByteBufferBackedChannelBuffer) src;
|
||||
@ -187,18 +208,21 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src, int srcIndex, int length) {
|
||||
ByteBuffer data = buffer.duplicate();
|
||||
data.limit(index + length).position(index);
|
||||
data.put(src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ByteBuffer src) {
|
||||
ByteBuffer data = buffer.duplicate();
|
||||
data.limit(index + src.remaining()).position(index);
|
||||
data.put(src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, OutputStream out, int length) throws IOException {
|
||||
if (length == 0) {
|
||||
return;
|
||||
@ -216,6 +240,7 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int index, GatheringByteChannel out, int length) throws IOException {
|
||||
if (length == 0) {
|
||||
return 0;
|
||||
@ -224,6 +249,7 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
return out.write((ByteBuffer) buffer.duplicate().position(index).limit(index + length));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, InputStream in, int length)
|
||||
throws IOException {
|
||||
|
||||
@ -265,6 +291,7 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
|
||||
@ -293,6 +320,7 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
if (index == 0 && length == capacity()) {
|
||||
return buffer.duplicate().order(order());
|
||||
@ -302,6 +330,7 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice(int index, int length) {
|
||||
if (index == 0 && length == capacity()) {
|
||||
ChannelBuffer slice = duplicate();
|
||||
@ -317,10 +346,12 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
return new ByteBufferBackedChannelBuffer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
ByteBuffer src;
|
||||
try {
|
||||
|
@ -1705,6 +1705,7 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
* {@linkplain #equals(Object) equal to} this array, both arrays should
|
||||
* return the same value.
|
||||
*/
|
||||
@Override
|
||||
int hashCode();
|
||||
|
||||
/**
|
||||
@ -1719,6 +1720,7 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
* {@code null} and an object which is not an instance of
|
||||
* {@link ChannelBuffer} type.
|
||||
*/
|
||||
@Override
|
||||
boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
@ -1727,6 +1729,7 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
* comparison functions of various languages such as {@code strcmp},
|
||||
* {@code memcmp} and {@link String#compareTo(String)}.
|
||||
*/
|
||||
@Override
|
||||
int compareTo(ChannelBuffer buffer);
|
||||
|
||||
/**
|
||||
@ -1735,5 +1738,6 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
* the values of the key properties such as {@link #readerIndex()},
|
||||
* {@link #writerIndex()} and {@link #capacity()}.
|
||||
*/
|
||||
@Override
|
||||
String toString();
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a {@code NUL (0x00)} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NUL = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) == 0;
|
||||
}
|
||||
@ -57,6 +58,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a non-{@code NUL (0x00)} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_NUL = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) != 0;
|
||||
}
|
||||
@ -66,6 +68,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a {@code CR ('\r')} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder CR = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) == '\r';
|
||||
}
|
||||
@ -75,6 +78,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a non-{@code CR ('\r')} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_CR = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) != '\r';
|
||||
}
|
||||
@ -84,6 +88,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a {@code LF ('\n')} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder LF = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) == '\n';
|
||||
}
|
||||
@ -93,6 +98,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a non-{@code LF ('\n')} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_LF = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) != '\n';
|
||||
}
|
||||
@ -102,6 +108,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a {@code CR ('\r')} or {@code LF ('\n')}.
|
||||
*/
|
||||
static ChannelBufferIndexFinder CRLF = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
byte b = buffer.getByte(guessedIndex);
|
||||
return b == '\r' || b == '\n';
|
||||
@ -113,6 +120,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* nor a {@code LF ('\n')}.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_CRLF = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
byte b = buffer.getByte(guessedIndex);
|
||||
return b != '\r' && b != '\n';
|
||||
@ -124,6 +132,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* ({@code ' '} and {@code '\t'}).
|
||||
*/
|
||||
static ChannelBufferIndexFinder LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
byte b = buffer.getByte(guessedIndex);
|
||||
return b == ' ' || b == '\t';
|
||||
@ -135,6 +144,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* (neither {@code ' '} nor {@code '\t'}).
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
||||
@Override
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
byte b = buffer.getByte(guessedIndex);
|
||||
return b != ' ' && b != '\t';
|
||||
|
@ -137,11 +137,13 @@ public class ChannelBufferInputStream extends InputStream implements DataInput {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readBoolean() throws IOException {
|
||||
checkAvailable(1);
|
||||
return read() != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte readByte() throws IOException {
|
||||
if (!buffer.readable()) {
|
||||
throw new EOFException();
|
||||
@ -149,27 +151,33 @@ public class ChannelBufferInputStream extends InputStream implements DataInput {
|
||||
return buffer.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char readChar() throws IOException {
|
||||
return (char) readShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double readDouble() throws IOException {
|
||||
return Double.longBitsToDouble(readLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float readFloat() throws IOException {
|
||||
return Float.intBitsToFloat(readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFully(byte[] b) throws IOException {
|
||||
readFully(b, 0, b.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFully(byte[] b, int off, int len) throws IOException {
|
||||
checkAvailable(len);
|
||||
buffer.readBytes(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readInt() throws IOException {
|
||||
checkAvailable(4);
|
||||
return buffer.readInt();
|
||||
@ -177,6 +185,7 @@ public class ChannelBufferInputStream extends InputStream implements DataInput {
|
||||
|
||||
private final StringBuilder lineBuf = new StringBuilder();
|
||||
|
||||
@Override
|
||||
public String readLine() throws IOException {
|
||||
lineBuf.setLength(0);
|
||||
for (;;) {
|
||||
@ -195,28 +204,34 @@ public class ChannelBufferInputStream extends InputStream implements DataInput {
|
||||
return lineBuf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readLong() throws IOException {
|
||||
checkAvailable(8);
|
||||
return buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short readShort() throws IOException {
|
||||
checkAvailable(2);
|
||||
return buffer.readShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readUTF() throws IOException {
|
||||
return DataInputStream.readUTF(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUnsignedByte() throws IOException {
|
||||
return readByte() & 0xff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUnsignedShort() throws IOException {
|
||||
return readShort() & 0xffff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int skipBytes(int n) throws IOException {
|
||||
int nBytes = Math.min(available(), n);
|
||||
buffer.skipBytes(nBytes);
|
||||
|
@ -82,14 +82,17 @@ public class ChannelBufferOutputStream extends OutputStream implements DataOutpu
|
||||
buffer.writeByte((byte) b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBoolean(boolean v) throws IOException {
|
||||
write(v? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByte(int v) throws IOException {
|
||||
write(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(String s) throws IOException {
|
||||
int len = s.length();
|
||||
for (int i = 0; i < len; i ++) {
|
||||
@ -97,10 +100,12 @@ public class ChannelBufferOutputStream extends OutputStream implements DataOutpu
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChar(int v) throws IOException {
|
||||
writeShort((short) v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChars(String s) throws IOException {
|
||||
int len = s.length();
|
||||
for (int i = 0 ; i < len ; i ++) {
|
||||
@ -108,26 +113,32 @@ public class ChannelBufferOutputStream extends OutputStream implements DataOutpu
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDouble(double v) throws IOException {
|
||||
writeLong(Double.doubleToLongBits(v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFloat(float v) throws IOException {
|
||||
writeInt(Float.floatToIntBits(v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInt(int v) throws IOException {
|
||||
buffer.writeInt(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLong(long v) throws IOException {
|
||||
buffer.writeLong(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeShort(int v) throws IOException {
|
||||
buffer.writeShort((short) v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeUTF(String s) throws IOException {
|
||||
utf8out.writeUTF(s);
|
||||
}
|
||||
|
@ -140,39 +140,48 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
setIndex(buffer.readerIndex(), buffer.writerIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
return HeapChannelBufferFactory.getInstance(order());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return indices[components.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
int componentId = componentId(index);
|
||||
return components[componentId].getByte(index - indices[componentId]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 2 <= indices[componentId + 1]) {
|
||||
@ -184,6 +193,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 3 <= indices[componentId + 1]) {
|
||||
@ -195,6 +205,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 4 <= indices[componentId + 1]) {
|
||||
@ -206,6 +217,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 8 <= indices[componentId + 1]) {
|
||||
@ -217,6 +229,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
int componentId = componentId(index);
|
||||
if (index > capacity() - length || dstIndex > dst.length - length) {
|
||||
@ -236,6 +249,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ByteBuffer dst) {
|
||||
int componentId = componentId(index);
|
||||
int limit = dst.limit();
|
||||
@ -261,6 +275,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
|
||||
int componentId = componentId(index);
|
||||
if (index > capacity() - length || dstIndex > dst.capacity() - length) {
|
||||
@ -280,6 +295,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int index, GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
// XXX Gathering write is not supported because of a known issue.
|
||||
@ -288,6 +304,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
return out.write(toByteBuffer(index, length));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, OutputStream out, int length)
|
||||
throws IOException {
|
||||
int componentId = componentId(index);
|
||||
@ -307,11 +324,13 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int index, int value) {
|
||||
int componentId = componentId(index);
|
||||
components[componentId].setByte(index - indices[componentId], value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 2 <= indices[componentId + 1]) {
|
||||
@ -325,6 +344,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 3 <= indices[componentId + 1]) {
|
||||
@ -338,6 +358,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 4 <= indices[componentId + 1]) {
|
||||
@ -351,6 +372,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
int componentId = componentId(index);
|
||||
if (index + 8 <= indices[componentId + 1]) {
|
||||
@ -364,6 +386,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src, int srcIndex, int length) {
|
||||
int componentId = componentId(index);
|
||||
if (index > capacity() - length || srcIndex > src.length - length) {
|
||||
@ -383,6 +406,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ByteBuffer src) {
|
||||
int componentId = componentId(index);
|
||||
int limit = src.limit();
|
||||
@ -408,6 +432,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
int componentId = componentId(index);
|
||||
if (index > capacity() - length || srcIndex > src.capacity() - length) {
|
||||
@ -427,6 +452,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, InputStream in, int length)
|
||||
throws IOException {
|
||||
int componentId = componentId(index);
|
||||
@ -465,6 +491,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
int componentId = componentId(index);
|
||||
@ -495,12 +522,14 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
ChannelBuffer duplicate = new CompositeChannelBuffer(this);
|
||||
duplicate.setIndex(readerIndex(), writerIndex());
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
int componentId = componentId(index);
|
||||
if (index > capacity() - length) {
|
||||
@ -530,6 +559,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
dst.writerIndex(dst.capacity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice(int index, int length) {
|
||||
if (index == 0) {
|
||||
if (length == 0) {
|
||||
@ -552,6 +582,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
if (components.length == 1) {
|
||||
return components[0].toByteBuffer(index, length);
|
||||
|
@ -106,6 +106,7 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
|
||||
this.preallocatedBufferCapacity = preallocatedBufferCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer getBuffer(ByteOrder order, int capacity) {
|
||||
if (order == null) {
|
||||
throw new NullPointerException("order");
|
||||
@ -130,6 +131,7 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
|
||||
return slice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer getBuffer(ByteOrder order, byte[] array, int offset, int length) {
|
||||
if (array == null) {
|
||||
throw new NullPointerException("array");
|
||||
@ -149,6 +151,7 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer getBuffer(ByteBuffer nioBuffer) {
|
||||
if (!nioBuffer.isReadOnly() && nioBuffer.isDirect()) {
|
||||
return ChannelBuffers.wrappedBuffer(nioBuffer);
|
||||
|
@ -52,134 +52,166 @@ public class DuplicatedChannelBuffer extends AbstractChannelBuffer implements Wr
|
||||
setIndex(buffer.readerIndex(), buffer.writerIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer unwrap() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
return buffer.factory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return buffer.order();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return buffer.isDirect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return buffer.capacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return buffer.hasArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
return buffer.arrayOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
return buffer.getByte(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
return buffer.getShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
return buffer.getUnsignedMedium(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
return buffer.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
return buffer.getLong(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
return new DuplicatedChannelBuffer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
return buffer.copy(index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice(int index, int length) {
|
||||
return buffer.slice(index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
|
||||
buffer.getBytes(index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
buffer.getBytes(index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ByteBuffer dst) {
|
||||
buffer.getBytes(index, dst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int index, int value) {
|
||||
buffer.setByte(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
buffer.setShort(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
buffer.setMedium(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
buffer.setInt(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
buffer.setLong(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src, int srcIndex, int length) {
|
||||
buffer.setBytes(index, src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
buffer.setBytes(index, src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ByteBuffer src) {
|
||||
buffer.setBytes(index, src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, OutputStream out, int length)
|
||||
throws IOException {
|
||||
buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int index, GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
return buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, InputStream in, int length)
|
||||
throws IOException {
|
||||
return buffer.setBytes(index, in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
return buffer.setBytes(index, in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
return buffer.toByteBuffer(index, length);
|
||||
}
|
||||
|
@ -86,113 +86,140 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||
buffer = newBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return endianness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return buffer.isDirect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return buffer.capacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return buffer.hasArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
return buffer.arrayOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
return buffer.getByte(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
return buffer.getShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
return buffer.getUnsignedMedium(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
return buffer.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
return buffer.getLong(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
buffer.getBytes(index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
|
||||
buffer.getBytes(index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ByteBuffer dst) {
|
||||
buffer.getBytes(index, dst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int index, GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
return buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, OutputStream out, int length)
|
||||
throws IOException {
|
||||
buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int index, int value) {
|
||||
buffer.setByte(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
buffer.setShort(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
buffer.setMedium(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
buffer.setInt(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
buffer.setLong(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src, int srcIndex, int length) {
|
||||
buffer.setBytes(index, src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
buffer.setBytes(index, src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ByteBuffer src) {
|
||||
buffer.setBytes(index, src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, InputStream in, int length)
|
||||
throws IOException {
|
||||
return buffer.setBytes(index, in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
return buffer.setBytes(index, in, length);
|
||||
@ -265,10 +292,12 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||
super.writeZero(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
return new DuplicatedChannelBuffer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
DynamicChannelBuffer copiedBuffer = new DynamicChannelBuffer(order(), Math.max(length, 64), factory());
|
||||
copiedBuffer.buffer = buffer.copy(index, length);
|
||||
@ -276,6 +305,7 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||
return copiedBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice(int index, int length) {
|
||||
if (index == 0) {
|
||||
if (length == 0) {
|
||||
@ -290,6 +320,7 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
return buffer.toByteBuffer(index, length);
|
||||
}
|
||||
|
@ -71,30 +71,37 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
setIndex(readerIndex, writerIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return array.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
return array;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
return array[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
|
||||
if (dst instanceof HeapChannelBuffer) {
|
||||
getBytes(index, ((HeapChannelBuffer) dst).array, dstIndex, length);
|
||||
@ -103,28 +110,34 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
System.arraycopy(array, index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ByteBuffer dst) {
|
||||
dst.put(array, index, Math.min(capacity() - index, dst.remaining()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, OutputStream out, int length)
|
||||
throws IOException {
|
||||
out.write(array, index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int index, GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
return out.write(ByteBuffer.wrap(array, index, length));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int index, int value) {
|
||||
array[index] = (byte) value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
if (src instanceof HeapChannelBuffer) {
|
||||
setBytes(index, ((HeapChannelBuffer) src).array, srcIndex, length);
|
||||
@ -133,14 +146,17 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src, int srcIndex, int length) {
|
||||
System.arraycopy(src, srcIndex, array, index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ByteBuffer src) {
|
||||
src.get(array, index, src.remaining());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, InputStream in, int length) throws IOException {
|
||||
int readBytes = 0;
|
||||
do {
|
||||
@ -160,6 +176,7 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException {
|
||||
ByteBuffer buf = ByteBuffer.wrap(array, index, length);
|
||||
int readBytes = 0;
|
||||
@ -186,6 +203,7 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice(int index, int length) {
|
||||
if (index == 0) {
|
||||
if (length == 0) {
|
||||
@ -206,6 +224,7 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
return ByteBuffer.wrap(array, index, length).order(order());
|
||||
}
|
||||
|
@ -69,14 +69,17 @@ public class HeapChannelBufferFactory extends AbstractChannelBufferFactory {
|
||||
super(defaultOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer getBuffer(ByteOrder order, int capacity) {
|
||||
return ChannelBuffers.buffer(order, capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer getBuffer(ByteOrder order, byte[] array, int offset, int length) {
|
||||
return ChannelBuffers.wrappedBuffer(order, array, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer getBuffer(ByteBuffer nioBuffer) {
|
||||
if (nioBuffer.hasArray()) {
|
||||
return ChannelBuffers.wrappedBuffer(nioBuffer);
|
||||
|
@ -52,24 +52,29 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
super(array, readerIndex, writerIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
return HeapChannelBufferFactory.getInstance(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
return (short) (array[index] & 0xFF | array[index+1] << 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
return (array[index ] & 0xff) << 0 |
|
||||
(array[index+1] & 0xff) << 8 |
|
||||
(array[index+2] & 0xff) << 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
return (array[index ] & 0xff) << 0 |
|
||||
(array[index+1] & 0xff) << 8 |
|
||||
@ -77,6 +82,7 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
(array[index+3] & 0xff) << 24;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
return ((long) array[index] & 0xff) << 0 |
|
||||
((long) array[index+1] & 0xff) << 8 |
|
||||
@ -88,17 +94,20 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
((long) array[index+7] & 0xff) << 56;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
array[index ] = (byte) (value >>> 0);
|
||||
array[index+1] = (byte) (value >>> 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
array[index ] = (byte) (value >>> 0);
|
||||
array[index+1] = (byte) (value >>> 8);
|
||||
array[index+2] = (byte) (value >>> 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
array[index ] = (byte) (value >>> 0);
|
||||
array[index+1] = (byte) (value >>> 8);
|
||||
@ -106,6 +115,7 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
array[index+3] = (byte) (value >>> 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
array[index ] = (byte) (value >>> 0);
|
||||
array[index+1] = (byte) (value >>> 8);
|
||||
@ -117,10 +127,12 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
array[index+7] = (byte) (value >>> 56);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
return new LittleEndianHeapChannelBuffer(array, readerIndex(), writerIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
if (index < 0 || length < 0 || index + length > array.length) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
|
@ -52,30 +52,37 @@ public class ReadOnlyChannelBuffer extends AbstractChannelBuffer implements Wrap
|
||||
setIndex(buffer.readerIndex(), buffer.writerIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer unwrap() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
return buffer.factory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return buffer.order();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return buffer.isDirect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
@ -85,102 +92,126 @@ public class ReadOnlyChannelBuffer extends AbstractChannelBuffer implements Wrap
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int index, int value) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src, int srcIndex, int length) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ByteBuffer src) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, InputStream in, int length)
|
||||
throws IOException {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int index, GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
return buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, OutputStream out, int length)
|
||||
throws IOException {
|
||||
buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
buffer.getBytes(index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
|
||||
buffer.getBytes(index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ByteBuffer dst) {
|
||||
buffer.getBytes(index, dst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
return new ReadOnlyChannelBuffer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
return buffer.copy(index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice(int index, int length) {
|
||||
return new ReadOnlyChannelBuffer(buffer.slice(index, length));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
return buffer.getByte(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
return buffer.getShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
return buffer.getUnsignedMedium(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
return buffer.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
return buffer.getLong(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
return buffer.toByteBuffer(index, length).asReadOnlyBuffer();
|
||||
}
|
||||
@ -194,6 +225,7 @@ public class ReadOnlyChannelBuffer extends AbstractChannelBuffer implements Wrap
|
||||
return bufs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return buffer.capacity();
|
||||
}
|
||||
|
@ -57,74 +57,90 @@ public class SlicedChannelBuffer extends AbstractChannelBuffer implements Wrappe
|
||||
writerIndex(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer unwrap() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
return buffer.factory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return buffer.order();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return buffer.isDirect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return buffer.hasArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
return buffer.arrayOffset() + adjustment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
checkIndex(index);
|
||||
return buffer.getByte(index + adjustment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
checkIndex(index, 2);
|
||||
return buffer.getShort(index + adjustment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
checkIndex(index, 3);
|
||||
return buffer.getUnsignedMedium(index + adjustment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
checkIndex(index, 4);
|
||||
return buffer.getInt(index + adjustment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
checkIndex(index, 8);
|
||||
return buffer.getLong(index + adjustment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
ChannelBuffer duplicate = new SlicedChannelBuffer(buffer, adjustment, length);
|
||||
duplicate.setIndex(readerIndex(), writerIndex());
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
checkIndex(index, length);
|
||||
return buffer.copy(index + adjustment, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice(int index, int length) {
|
||||
checkIndex(index, length);
|
||||
if (length == 0) {
|
||||
@ -133,85 +149,101 @@ public class SlicedChannelBuffer extends AbstractChannelBuffer implements Wrappe
|
||||
return new SlicedChannelBuffer(buffer, index + adjustment, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
buffer.getBytes(index + adjustment, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
buffer.getBytes(index + adjustment, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ByteBuffer dst) {
|
||||
checkIndex(index, dst.remaining());
|
||||
buffer.getBytes(index + adjustment, dst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int index, int value) {
|
||||
checkIndex(index);
|
||||
buffer.setByte(index + adjustment, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
checkIndex(index, 2);
|
||||
buffer.setShort(index + adjustment, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
checkIndex(index, 3);
|
||||
buffer.setMedium(index + adjustment, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
checkIndex(index, 4);
|
||||
buffer.setInt(index + adjustment, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
checkIndex(index, 8);
|
||||
buffer.setLong(index + adjustment, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src, int srcIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
buffer.setBytes(index + adjustment, src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
buffer.setBytes(index + adjustment, src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ByteBuffer src) {
|
||||
checkIndex(index, src.remaining());
|
||||
buffer.setBytes(index + adjustment, src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, OutputStream out, int length)
|
||||
throws IOException {
|
||||
checkIndex(index, length);
|
||||
buffer.getBytes(index + adjustment, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int index, GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
checkIndex(index, length);
|
||||
return buffer.getBytes(index + adjustment, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, InputStream in, int length)
|
||||
throws IOException {
|
||||
checkIndex(index, length);
|
||||
return buffer.setBytes(index + adjustment, in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
checkIndex(index, length);
|
||||
return buffer.setBytes(index + adjustment, in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
checkIndex(index, length);
|
||||
return buffer.toByteBuffer(index + adjustment, length);
|
||||
|
@ -51,74 +51,90 @@ public class TruncatedChannelBuffer extends AbstractChannelBuffer implements Wra
|
||||
writerIndex(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer unwrap() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory factory() {
|
||||
return buffer.factory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteOrder order() {
|
||||
return buffer.order();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return buffer.isDirect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return buffer.hasArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
return buffer.arrayOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int index) {
|
||||
checkIndex(index);
|
||||
return buffer.getByte(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
checkIndex(index, 2);
|
||||
return buffer.getShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int index) {
|
||||
checkIndex(index, 3);
|
||||
return buffer.getUnsignedMedium(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
checkIndex(index, 4);
|
||||
return buffer.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
checkIndex(index, 8);
|
||||
return buffer.getLong(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer duplicate() {
|
||||
ChannelBuffer duplicate = new TruncatedChannelBuffer(buffer, length);
|
||||
duplicate.setIndex(readerIndex(), writerIndex());
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer copy(int index, int length) {
|
||||
checkIndex(index, length);
|
||||
return buffer.copy(index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer slice(int index, int length) {
|
||||
checkIndex(index, length);
|
||||
if (length == 0) {
|
||||
@ -127,85 +143,101 @@ public class TruncatedChannelBuffer extends AbstractChannelBuffer implements Wra
|
||||
return buffer.slice(index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
buffer.getBytes(index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
buffer.getBytes(index, dst, dstIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, ByteBuffer dst) {
|
||||
checkIndex(index, dst.remaining());
|
||||
buffer.getBytes(index, dst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setByte(int index, int value) {
|
||||
checkIndex(index);
|
||||
buffer.setByte(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, int value) {
|
||||
checkIndex(index, 2);
|
||||
buffer.setShort(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMedium(int index, int value) {
|
||||
checkIndex(index, 3);
|
||||
buffer.setMedium(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
checkIndex(index, 4);
|
||||
buffer.setInt(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
checkIndex(index, 8);
|
||||
buffer.setLong(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, byte[] src, int srcIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
buffer.setBytes(index, src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
buffer.setBytes(index, src, srcIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytes(int index, ByteBuffer src) {
|
||||
checkIndex(index, src.remaining());
|
||||
buffer.setBytes(index, src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBytes(int index, OutputStream out, int length)
|
||||
throws IOException {
|
||||
checkIndex(index, length);
|
||||
buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int index, GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
checkIndex(index, length);
|
||||
return buffer.getBytes(index, out, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, InputStream in, int length)
|
||||
throws IOException {
|
||||
checkIndex(index, length);
|
||||
return buffer.setBytes(index, in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int index, ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
checkIndex(index, length);
|
||||
return buffer.setBytes(index, in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer(int index, int length) {
|
||||
checkIndex(index, length);
|
||||
return buffer.toByteBuffer(index, length);
|
||||
|
@ -54,6 +54,7 @@ public abstract class AbstractChannel implements Channel {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
allChannels.remove(future.getChannel().getId());
|
||||
}
|
||||
@ -124,18 +125,22 @@ public abstract class AbstractChannel implements Channel {
|
||||
pipeline.attach(this, sink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFactory getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPipeline getPipeline() {
|
||||
return pipeline;
|
||||
}
|
||||
@ -176,10 +181,12 @@ public abstract class AbstractChannel implements Channel {
|
||||
/**
|
||||
* Compares the {@linkplain #getId() ID} of the two channels.
|
||||
*/
|
||||
@Override
|
||||
public final int compareTo(Channel o) {
|
||||
return getId().compareTo(o.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return !closeFuture.isDone();
|
||||
}
|
||||
@ -196,36 +203,44 @@ public abstract class AbstractChannel implements Channel {
|
||||
return closeFuture.setClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture bind(SocketAddress localAddress) {
|
||||
return Channels.bind(this, localAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture unbind() {
|
||||
return Channels.unbind(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture close() {
|
||||
ChannelFuture returnedCloseFuture = Channels.close(this);
|
||||
assert closeFuture == returnedCloseFuture;
|
||||
return closeFuture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture getCloseFuture() {
|
||||
return closeFuture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture connect(SocketAddress remoteAddress) {
|
||||
return Channels.connect(this, remoteAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture disconnect() {
|
||||
return Channels.disconnect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInterestOps() {
|
||||
return interestOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture setInterestOps(int interestOps) {
|
||||
return Channels.setInterestOps(this, interestOps);
|
||||
}
|
||||
@ -239,14 +254,17 @@ public abstract class AbstractChannel implements Channel {
|
||||
this.interestOps = interestOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadable() {
|
||||
return (getInterestOps() & OP_READ) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return (getInterestOps() & OP_WRITE) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture setReadable(boolean readable) {
|
||||
if (readable) {
|
||||
return setInterestOps(getInterestOps() | OP_READ);
|
||||
@ -255,10 +273,12 @@ public abstract class AbstractChannel implements Channel {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture write(Object message) {
|
||||
return Channels.write(this, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture write(Object message, SocketAddress remoteAddress) {
|
||||
return Channels.write(this, message, remoteAddress);
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public abstract class AbstractChannelSink implements ChannelSink {
|
||||
* {@link ChannelHandler} to raise an exception
|
||||
* @param cause the exception raised by a {@link ChannelHandler}
|
||||
*/
|
||||
@Override
|
||||
public void exceptionCaught(ChannelPipeline pipeline,
|
||||
ChannelEvent event, ChannelPipelineException cause) throws Exception {
|
||||
Throwable actualCause = cause.getCause();
|
||||
|
@ -91,6 +91,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S
|
||||
return getUnsupportedOperationFuture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return false;
|
||||
}
|
||||
|
@ -149,10 +149,12 @@ public class AdaptiveReceiveBufferSizePredictor implements
|
||||
nextReceiveBufferSize = SIZE_TABLE[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextReceiveBufferSize() {
|
||||
return nextReceiveBufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void previousReceiveBufferSize(int previousReceiveBufferSize) {
|
||||
if (previousReceiveBufferSize <= SIZE_TABLE[Math.max(0, index - INDEX_DECREMENT - 1)]) {
|
||||
if (decreaseNow) {
|
||||
|
@ -66,6 +66,7 @@ public class AdaptiveReceiveBufferSizePredictorFactory implements
|
||||
this.maximum = maximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReceiveBufferSizePredictor getPredictor() throws Exception {
|
||||
return new AdaptiveReceiveBufferSizePredictor(minimum, initial, maximum);
|
||||
}
|
||||
|
@ -82,5 +82,6 @@ public interface ChannelFactory extends ExternalResourceReleasable {
|
||||
* behavior will be resulted in if the resources are released when there's
|
||||
* an open channel which is managed by this factory.
|
||||
*/
|
||||
@Override
|
||||
void releaseExternalResources();
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public interface ChannelFutureListener extends EventListener {
|
||||
* associated with the specified {@link ChannelFuture}.
|
||||
*/
|
||||
static ChannelFutureListener CLOSE = new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) {
|
||||
future.getChannel().close();
|
||||
}
|
||||
@ -52,6 +53,7 @@ public interface ChannelFutureListener extends EventListener {
|
||||
* operation ended up with a failure or cancellation rather than a success.
|
||||
*/
|
||||
static ChannelFutureListener CLOSE_ON_FAILURE = new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) {
|
||||
if (!future.isSuccess()) {
|
||||
future.getChannel().close();
|
||||
|
@ -111,6 +111,7 @@ public class Channels {
|
||||
public static ChannelPipelineFactory pipelineFactory(
|
||||
final ChannelPipeline pipeline) {
|
||||
return new ChannelPipelineFactory() {
|
||||
@Override
|
||||
public ChannelPipeline getPipeline() {
|
||||
return pipeline(pipeline);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public interface ChildChannelStateEvent extends ChannelEvent {
|
||||
* with this event. Please note that you should use {@link #getChildChannel()}
|
||||
* to get the {@link Channel} created or accepted by the parent {@link Channel}.
|
||||
*/
|
||||
@Override
|
||||
Channel getChannel();
|
||||
|
||||
/**
|
||||
|
@ -48,6 +48,7 @@ public abstract class CompleteChannelFuture implements ChannelFuture {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(ChannelFutureListener listener) {
|
||||
try {
|
||||
listener.operationComplete(this);
|
||||
@ -58,10 +59,12 @@ public abstract class CompleteChannelFuture implements ChannelFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ChannelFutureListener listener) {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture await() throws InterruptedException {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
@ -69,6 +72,7 @@ public abstract class CompleteChannelFuture implements ChannelFuture {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
@ -76,6 +80,7 @@ public abstract class CompleteChannelFuture implements ChannelFuture {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean await(long timeoutMillis) throws InterruptedException {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
@ -83,42 +88,52 @@ public abstract class CompleteChannelFuture implements ChannelFuture {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture awaitUninterruptibly() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awaitUninterruptibly(long timeoutMillis) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setProgress(long amount, long current, long total) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFailure(Throwable cause) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSuccess() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return false;
|
||||
}
|
||||
|
@ -44,12 +44,14 @@ public class DefaultChannelConfig implements ChannelConfig {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptions(Map<String, Object> options) {
|
||||
for (Entry<String, Object> e: options.entrySet()) {
|
||||
setOption(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setOption(String key, Object value) {
|
||||
if (key.equals("pipelineFactory")) {
|
||||
setPipelineFactory((ChannelPipelineFactory) value);
|
||||
@ -63,14 +65,17 @@ public class DefaultChannelConfig implements ChannelConfig {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConnectTimeoutMillis() {
|
||||
return connectTimeoutMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
if (bufferFactory == null) {
|
||||
throw new NullPointerException("bufferFactory");
|
||||
@ -78,10 +83,12 @@ public class DefaultChannelConfig implements ChannelConfig {
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPipelineFactory getPipelineFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
|
||||
if (connectTimeoutMillis < 0) {
|
||||
throw new IllegalArgumentException("connectTimeoutMillis: " + connectTimeoutMillis);
|
||||
@ -89,6 +96,7 @@ public class DefaultChannelConfig implements ChannelConfig {
|
||||
this.connectTimeoutMillis = connectTimeoutMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
||||
// Unused
|
||||
}
|
||||
|
@ -92,18 +92,22 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
this.cancellable = cancellable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isDone() {
|
||||
return done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isSuccess() {
|
||||
return done && cause == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Throwable getCause() {
|
||||
if (cause != CANCELLED) {
|
||||
return cause;
|
||||
@ -112,10 +116,12 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isCancelled() {
|
||||
return cause == CANCELLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(ChannelFutureListener listener) {
|
||||
if (listener == null) {
|
||||
throw new NullPointerException("listener");
|
||||
@ -149,6 +155,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ChannelFutureListener listener) {
|
||||
if (listener == null) {
|
||||
throw new NullPointerException("listener");
|
||||
@ -173,6 +180,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture await() throws InterruptedException {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
@ -192,15 +200,18 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean await(long timeout, TimeUnit unit)
|
||||
throws InterruptedException {
|
||||
return await0(unit.toNanos(timeout), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean await(long timeoutMillis) throws InterruptedException {
|
||||
return await0(MILLISECONDS.toNanos(timeoutMillis), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture awaitUninterruptibly() {
|
||||
boolean interrupted = false;
|
||||
synchronized (this) {
|
||||
@ -224,6 +235,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
|
||||
try {
|
||||
return await0(unit.toNanos(timeout), false);
|
||||
@ -232,6 +244,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awaitUninterruptibly(long timeoutMillis) {
|
||||
try {
|
||||
return await0(MILLISECONDS.toNanos(timeoutMillis), false);
|
||||
@ -300,6 +313,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSuccess() {
|
||||
synchronized (this) {
|
||||
// Allow only once.
|
||||
@ -317,6 +331,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFailure(Throwable cause) {
|
||||
synchronized (this) {
|
||||
// Allow only once.
|
||||
@ -335,6 +350,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
if (!cancellable) {
|
||||
return false;
|
||||
@ -386,6 +402,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setProgress(long amount, long current, long total) {
|
||||
ChannelFutureProgressListener[] plisteners;
|
||||
synchronized (this) {
|
||||
|
@ -53,10 +53,12 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelSink getSink() {
|
||||
ChannelSink sink = this.sink;
|
||||
if (sink == null) {
|
||||
@ -65,6 +67,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return sink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(Channel channel, ChannelSink sink) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
@ -79,10 +82,12 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
this.sink = sink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAttached() {
|
||||
return sink != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addFirst(String name, ChannelHandler handler) {
|
||||
if (name2ctx.isEmpty()) {
|
||||
init(name, handler);
|
||||
@ -101,6 +106,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addLast(String name, ChannelHandler handler) {
|
||||
if (name2ctx.isEmpty()) {
|
||||
init(name, handler);
|
||||
@ -119,6 +125,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addBefore(String baseName, String name, ChannelHandler handler) {
|
||||
DefaultChannelHandlerContext ctx = getContextOrDie(baseName);
|
||||
if (ctx == head) {
|
||||
@ -137,6 +144,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addAfter(String baseName, String name, ChannelHandler handler) {
|
||||
DefaultChannelHandlerContext ctx = getContextOrDie(baseName);
|
||||
if (ctx == tail) {
|
||||
@ -155,14 +163,17 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void remove(ChannelHandler handler) {
|
||||
remove(getContextOrDie(handler));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandler remove(String name) {
|
||||
return remove(getContextOrDie(name)).getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized <T extends ChannelHandler> T remove(Class<T> handlerType) {
|
||||
return (T) remove(getContextOrDie(handlerType)).getHandler();
|
||||
@ -190,6 +201,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandler removeFirst() {
|
||||
if (name2ctx.isEmpty()) {
|
||||
throw new NoSuchElementException();
|
||||
@ -216,6 +228,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return oldHead.getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandler removeLast() {
|
||||
if (name2ctx.isEmpty()) {
|
||||
throw new NoSuchElementException();
|
||||
@ -242,14 +255,17 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return oldTail.getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler) {
|
||||
replace(getContextOrDie(oldHandler), newName, newHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandler replace(String oldName, String newName, ChannelHandler newHandler) {
|
||||
return replace(getContextOrDie(oldName), newName, newHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized <T extends ChannelHandler> T replace(
|
||||
Class<T> oldHandlerType, String newName, ChannelHandler newHandler) {
|
||||
@ -401,6 +417,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandler getFirst() {
|
||||
DefaultChannelHandlerContext head = this.head;
|
||||
if (head == null) {
|
||||
@ -409,6 +426,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return head.getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandler getLast() {
|
||||
DefaultChannelHandlerContext tail = this.tail;
|
||||
if (tail == null) {
|
||||
@ -417,6 +435,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return tail.getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandler get(String name) {
|
||||
DefaultChannelHandlerContext ctx = name2ctx.get(name);
|
||||
if (ctx == null) {
|
||||
@ -426,6 +445,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized <T extends ChannelHandler> T get(Class<T> handlerType) {
|
||||
ChannelHandlerContext ctx = getContext(handlerType);
|
||||
@ -436,6 +456,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandlerContext getContext(String name) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name");
|
||||
@ -443,6 +464,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return name2ctx.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandlerContext getContext(ChannelHandler handler) {
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("handler");
|
||||
@ -464,6 +486,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ChannelHandlerContext getContext(
|
||||
Class<? extends ChannelHandler> handlerType) {
|
||||
if (handlerType == null) {
|
||||
@ -487,6 +510,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ChannelHandler> toMap() {
|
||||
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
|
||||
if (name2ctx.isEmpty()) {
|
||||
@ -529,6 +553,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUpstream(ChannelEvent e) {
|
||||
DefaultChannelHandlerContext head = getActualUpstreamContext(this.head);
|
||||
if (head == null) {
|
||||
@ -548,6 +573,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDownstream(ChannelEvent e) {
|
||||
DefaultChannelHandlerContext tail = getActualDownstreamContext(this.tail);
|
||||
if (tail == null) {
|
||||
@ -703,38 +729,47 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return getPipeline().getChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPipeline getPipeline() {
|
||||
return DefaultChannelPipeline.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandleDownstream() {
|
||||
return canHandleDownstream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandleUpstream() {
|
||||
return canHandleUpstream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttachment() {
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttachment(Object attachment) {
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDownstream(ChannelEvent e) {
|
||||
DefaultChannelHandlerContext prev = getActualDownstreamContext(this.prev);
|
||||
if (prev == null) {
|
||||
@ -748,6 +783,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUpstream(ChannelEvent e) {
|
||||
DefaultChannelHandlerContext next = getActualUpstreamContext(this.next);
|
||||
if (next != null) {
|
||||
@ -761,10 +797,12 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) {
|
||||
logger.warn("Not attached yet; discarding: " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelPipeline pipeline,
|
||||
ChannelEvent e, ChannelPipelineException cause) throws Exception {
|
||||
throw cause;
|
||||
|
@ -45,14 +45,17 @@ public class DefaultChildChannelStateEvent implements ChildChannelStateEvent {
|
||||
this.childChannel = childChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return parentChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture getFuture() {
|
||||
return succeededFuture(getChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChildChannel() {
|
||||
return childChannel;
|
||||
}
|
||||
|
@ -48,14 +48,17 @@ public class DefaultExceptionEvent implements ExceptionEvent {
|
||||
StackTraceSimplifier.simplify(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture getFuture() {
|
||||
return succeededFuture(getChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
@ -21,14 +21,17 @@ public class DefaultFileRegion implements FileRegion {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferTo(WritableByteChannel target, long position) throws IOException {
|
||||
long count = this.count - position;
|
||||
if (count < 0 || position < 0) {
|
||||
@ -43,6 +46,7 @@ public class DefaultFileRegion implements FileRegion {
|
||||
return file.transferTo(this.position + position, count, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
try {
|
||||
file.close();
|
||||
|
@ -42,6 +42,7 @@ public class DefaultServerChannelConfig implements ChannelConfig {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptions(Map<String, Object> options) {
|
||||
for (Entry<String, Object> e: options.entrySet()) {
|
||||
setOption(e.getKey(), e.getValue());
|
||||
@ -52,6 +53,7 @@ public class DefaultServerChannelConfig implements ChannelConfig {
|
||||
* Sets an individual option. You can override this method to support
|
||||
* additional configuration parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean setOption(String key, Object value) {
|
||||
if (key.equals("pipelineFactory")) {
|
||||
setPipelineFactory((ChannelPipelineFactory) value);
|
||||
@ -63,10 +65,12 @@ public class DefaultServerChannelConfig implements ChannelConfig {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPipelineFactory getPipelineFactory() {
|
||||
return pipelineFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
||||
if (pipelineFactory == null) {
|
||||
throw new NullPointerException("pipelineFactory");
|
||||
@ -74,10 +78,12 @@ public class DefaultServerChannelConfig implements ChannelConfig {
|
||||
this.pipelineFactory = pipelineFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
if (bufferFactory == null) {
|
||||
throw new NullPointerException("bufferFactory");
|
||||
@ -86,10 +92,12 @@ public class DefaultServerChannelConfig implements ChannelConfig {
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConnectTimeoutMillis() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
|
||||
// Unused
|
||||
}
|
||||
|
@ -46,14 +46,17 @@ public class DefaultWriteCompletionEvent implements WriteCompletionEvent {
|
||||
this.writtenAmount = writtenAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture getFuture() {
|
||||
return succeededFuture(getChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWrittenAmount() {
|
||||
return writtenAmount;
|
||||
}
|
||||
|
@ -53,18 +53,22 @@ public class DownstreamChannelStateEvent implements ChannelStateEvent {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture getFuture() {
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
@ -61,18 +61,22 @@ public class DownstreamMessageEvent implements MessageEvent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture getFuture() {
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
}
|
||||
|
@ -43,10 +43,12 @@ public class FailedChannelFuture extends CompleteChannelFuture {
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuccess() {
|
||||
return false;
|
||||
}
|
||||
|
@ -42,10 +42,12 @@ public class FixedReceiveBufferSizePredictor implements
|
||||
this.bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextReceiveBufferSize() {
|
||||
return bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void previousReceiveBufferSize(int previousReceiveBufferSize) {
|
||||
// Ignore
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public class FixedReceiveBufferSizePredictorFactory implements
|
||||
predictor = new FixedReceiveBufferSizePredictor(bufferSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReceiveBufferSizePredictor getPredictor() throws Exception {
|
||||
return predictor;
|
||||
}
|
||||
|
@ -26,5 +26,6 @@ package org.jboss.netty.channel;
|
||||
* @apiviz.has org.jboss.netty.channel.ServerChannel oneway - - creates
|
||||
*/
|
||||
public interface ServerChannelFactory extends ChannelFactory {
|
||||
@Override
|
||||
ServerChannel newChannel(ChannelPipeline pipeline);
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ public class SimpleChannelDownstreamHandler implements ChannelDownstreamHandler
|
||||
* meaningful sub-type event and calls an appropriate handler method with
|
||||
* the down-casted event.
|
||||
*/
|
||||
@Override
|
||||
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)
|
||||
throws Exception {
|
||||
|
||||
|
@ -93,6 +93,7 @@ public class SimpleChannelHandler implements ChannelUpstreamHandler, ChannelDown
|
||||
* meaningful sub-type event and calls an appropriate handler method with
|
||||
* the down-casted event.
|
||||
*/
|
||||
@Override
|
||||
public void handleUpstream(
|
||||
ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
|
||||
|
||||
@ -259,6 +260,7 @@ public class SimpleChannelHandler implements ChannelUpstreamHandler, ChannelDown
|
||||
* meaningful sub-type event and calls an appropriate handler method with
|
||||
* the down-casted event.
|
||||
*/
|
||||
@Override
|
||||
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)
|
||||
throws Exception {
|
||||
|
||||
|
@ -73,6 +73,7 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
|
||||
* meaningful sub-type event and calls an appropriate handler method with
|
||||
* the down-casted event.
|
||||
*/
|
||||
@Override
|
||||
public void handleUpstream(
|
||||
ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
|
||||
|
||||
|
@ -97,10 +97,12 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelSink getSink() {
|
||||
ChannelSink sink = this.sink;
|
||||
if (sink == null) {
|
||||
@ -109,6 +111,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
return sink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(Channel channel, ChannelSink sink) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
@ -123,54 +126,67 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
this.sink = sink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAttached() {
|
||||
return sink != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFirst(String name, ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLast(String name, ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBefore(String baseName, String name, ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAfter(String baseName, String name, ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler remove(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ChannelHandler> T remove(Class<T> handlerType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler removeFirst() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler removeLast() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler replace(String oldName, String newName, ChannelHandler newHandler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ChannelHandler> T replace(
|
||||
Class<T> oldHandlerType, String newName, ChannelHandler newHandler) {
|
||||
throw new UnsupportedOperationException();
|
||||
@ -259,14 +275,17 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler getFirst() {
|
||||
return contexts[0].getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler getLast() {
|
||||
return contexts[contexts.length - 1].getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler get(String name) {
|
||||
StaticChannelHandlerContext ctx = name2ctx.get(name);
|
||||
if (ctx == null) {
|
||||
@ -276,6 +295,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends ChannelHandler> T get(Class<T> handlerType) {
|
||||
ChannelHandlerContext ctx = getContext(handlerType);
|
||||
@ -286,6 +306,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandlerContext getContext(String name) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name");
|
||||
@ -293,6 +314,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
return name2ctx.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandlerContext getContext(ChannelHandler handler) {
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("handler");
|
||||
@ -305,6 +327,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandlerContext getContext(Class<? extends ChannelHandler> handlerType) {
|
||||
if (handlerType == null) {
|
||||
throw new NullPointerException("handlerType");
|
||||
@ -317,6 +340,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ChannelHandler> toMap() {
|
||||
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
@ -346,6 +370,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUpstream(ChannelEvent e) {
|
||||
StaticChannelHandlerContext head = getActualUpstreamContext(0);
|
||||
if (head == null) {
|
||||
@ -365,6 +390,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDownstream(ChannelEvent e) {
|
||||
StaticChannelHandlerContext tail = getActualDownstreamContext(lastIndex);
|
||||
if (tail == null) {
|
||||
@ -463,38 +489,47 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return getPipeline().getChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPipeline getPipeline() {
|
||||
return StaticChannelPipeline.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandleDownstream() {
|
||||
return canHandleDownstream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandleUpstream() {
|
||||
return canHandleUpstream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttachment() {
|
||||
return attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttachment(Object attachment) {
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDownstream(ChannelEvent e) {
|
||||
StaticChannelHandlerContext prev = getActualDownstreamContext(index - 1);
|
||||
if (prev == null) {
|
||||
@ -508,6 +543,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUpstream(ChannelEvent e) {
|
||||
StaticChannelHandlerContext next = getActualUpstreamContext(index + 1);
|
||||
if (next != null) {
|
||||
|
@ -36,10 +36,12 @@ public class SucceededChannelFuture extends CompleteChannelFuture {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Throwable getCause() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuccess() {
|
||||
return true;
|
||||
}
|
||||
|
@ -50,18 +50,22 @@ public class UpstreamChannelStateEvent implements ChannelStateEvent {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture getFuture() {
|
||||
return succeededFuture(getChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
@ -57,18 +57,22 @@ public class UpstreamMessageEvent implements MessageEvent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture getFuture() {
|
||||
return succeededFuture(getChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
}
|
||||
|
@ -253,5 +253,6 @@ public interface ChannelGroupFuture extends Iterable<ChannelFuture> {
|
||||
* {@link Iterator} is is unmodifiable, which means a {@link ChannelFuture}
|
||||
* cannot be removed from this future.
|
||||
*/
|
||||
@Override
|
||||
Iterator<ChannelFuture> iterator();
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ final class CombinedIterator<E> implements Iterator<E> {
|
||||
currentIterator = i1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
boolean hasNext = currentIterator.hasNext();
|
||||
if (hasNext) {
|
||||
@ -55,6 +56,7 @@ final class CombinedIterator<E> implements Iterator<E> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
try {
|
||||
E e = currentIterator.next();
|
||||
@ -69,6 +71,7 @@ final class CombinedIterator<E> implements Iterator<E> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
currentIterator.remove();
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
private final ConcurrentMap<Integer, Channel> serverChannels = new ConcurrentHashMap<Integer, Channel>();
|
||||
private final ConcurrentMap<Integer, Channel> nonServerChannels = new ConcurrentHashMap<Integer, Channel>();
|
||||
private final ChannelFutureListener remover = new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
remove(future.getChannel());
|
||||
}
|
||||
@ -73,6 +74,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -87,6 +89,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return nonServerChannels.size() + serverChannels.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel find(Integer id) {
|
||||
Channel c = nonServerChannels.get(id);
|
||||
if (c != null) {
|
||||
@ -178,6 +181,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return channels.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture close() {
|
||||
Map<Integer, ChannelFuture> futures =
|
||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
@ -192,6 +196,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return new DefaultChannelGroupFuture(this, futures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture disconnect() {
|
||||
Map<Integer, ChannelFuture> futures =
|
||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
@ -206,6 +211,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return new DefaultChannelGroupFuture(this, futures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture setInterestOps(int interestOps) {
|
||||
Map<Integer, ChannelFuture> futures =
|
||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
@ -220,6 +226,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return new DefaultChannelGroupFuture(this, futures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture setReadable(boolean readable) {
|
||||
Map<Integer, ChannelFuture> futures =
|
||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
@ -234,6 +241,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return new DefaultChannelGroupFuture(this, futures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture unbind() {
|
||||
Map<Integer, ChannelFuture> futures =
|
||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
@ -248,6 +256,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return new DefaultChannelGroupFuture(this, futures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture write(Object message) {
|
||||
Map<Integer, ChannelFuture> futures =
|
||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
@ -264,6 +273,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return new DefaultChannelGroupFuture(this, futures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture write(Object message, SocketAddress remoteAddress) {
|
||||
Map<Integer, ChannelFuture> futures =
|
||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
@ -290,6 +300,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
||||
return this == o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ChannelGroup o) {
|
||||
int v = getName().compareTo(o.getName());
|
||||
if (v != 0) {
|
||||
|
@ -56,6 +56,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
private int waiters;
|
||||
|
||||
private final ChannelFutureListener childListener = new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
boolean success = future.isSuccess();
|
||||
boolean callSetDone = false;
|
||||
@ -119,42 +120,52 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroup getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture find(Integer channelId) {
|
||||
return futures.get(channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture find(Channel channel) {
|
||||
return futures.get(channel.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ChannelFuture> iterator() {
|
||||
return futures.values().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isDone() {
|
||||
return done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isCompleteSuccess() {
|
||||
return successCount == futures.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isPartialSuccess() {
|
||||
return !futures.isEmpty() && successCount != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isPartialFailure() {
|
||||
return !futures.isEmpty() && failureCount != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isCompleteFailure() {
|
||||
return failureCount == futures.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(ChannelGroupFutureListener listener) {
|
||||
if (listener == null) {
|
||||
throw new NullPointerException("listener");
|
||||
@ -181,6 +192,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ChannelGroupFutureListener listener) {
|
||||
if (listener == null) {
|
||||
throw new NullPointerException("listener");
|
||||
@ -201,6 +213,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture await() throws InterruptedException {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
@ -220,15 +233,18 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean await(long timeout, TimeUnit unit)
|
||||
throws InterruptedException {
|
||||
return await0(unit.toNanos(timeout), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean await(long timeoutMillis) throws InterruptedException {
|
||||
return await0(MILLISECONDS.toNanos(timeoutMillis), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroupFuture awaitUninterruptibly() {
|
||||
boolean interrupted = false;
|
||||
synchronized (this) {
|
||||
@ -252,6 +268,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
|
||||
try {
|
||||
return await0(unit.toNanos(timeout), false);
|
||||
@ -260,6 +277,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awaitUninterruptibly(long timeoutMillis) {
|
||||
try {
|
||||
return await0(MILLISECONDS.toNanos(timeoutMillis), false);
|
||||
|
@ -57,22 +57,27 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return bound.get() && isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return pairedChannel != null && isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalAddress getLocalAddress() {
|
||||
return localAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalAddress getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ public class DefaultLocalClientChannelFactory implements LocalClientChannelFacto
|
||||
sink = new LocalClientChannelSink();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChannel newChannel(ChannelPipeline pipeline) {
|
||||
return new DefaultLocalChannel(null, this, pipeline, sink, null);
|
||||
}
|
||||
@ -47,6 +48,7 @@ public class DefaultLocalClientChannelFactory implements LocalClientChannelFacto
|
||||
* Does nothing because this implementation does not require any external
|
||||
* resources.
|
||||
*/
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
// No external resources.
|
||||
}
|
||||
|
@ -45,18 +45,22 @@ final class DefaultLocalServerChannel extends AbstractServerChannel
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig getConfig() {
|
||||
return channelConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return isOpen() && bound.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalAddress getLocalAddress() {
|
||||
return isBound()? localAddress : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalAddress getRemoteAddress() {
|
||||
return null;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ public class DefaultLocalServerChannelFactory implements LocalServerChannelFacto
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalServerChannel newChannel(ChannelPipeline pipeline) {
|
||||
return new DefaultLocalServerChannel(this, pipeline, sink);
|
||||
}
|
||||
@ -47,6 +48,7 @@ public class DefaultLocalServerChannelFactory implements LocalServerChannelFacto
|
||||
* Does nothing because this implementation does not require any external
|
||||
* resources.
|
||||
*/
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
// Unused
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ public final class LocalAddress extends SocketAddress implements Comparable<Loca
|
||||
// ephemeral ports, just like O/S does for port number 0. It will
|
||||
// break backward compatibility though.
|
||||
|
||||
@Override
|
||||
public int compareTo(LocalAddress o) {
|
||||
if (ephemeral) {
|
||||
if (o.ephemeral) {
|
||||
|
@ -26,6 +26,8 @@ import org.jboss.netty.channel.Channel;
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
public interface LocalChannel extends Channel {
|
||||
@Override
|
||||
LocalAddress getLocalAddress();
|
||||
@Override
|
||||
LocalAddress getRemoteAddress();
|
||||
}
|
||||
|
@ -26,5 +26,6 @@ import org.jboss.netty.channel.ChannelPipeline;
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
public interface LocalClientChannelFactory extends ChannelFactory {
|
||||
@Override
|
||||
LocalChannel newChannel(ChannelPipeline pipeline);
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ final class LocalClientChannelSink extends AbstractChannelSink {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||
if (e instanceof ChannelStateEvent) {
|
||||
ChannelStateEvent event = (ChannelStateEvent) e;
|
||||
|
@ -26,6 +26,8 @@ import org.jboss.netty.channel.ServerChannel;
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
public interface LocalServerChannel extends ServerChannel {
|
||||
@Override
|
||||
LocalAddress getLocalAddress();
|
||||
@Override
|
||||
LocalAddress getRemoteAddress();
|
||||
}
|
||||
|
@ -26,5 +26,6 @@ import org.jboss.netty.channel.ServerChannelFactory;
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
public interface LocalServerChannelFactory extends ServerChannelFactory {
|
||||
@Override
|
||||
LocalServerChannel newChannel(ChannelPipeline pipeline);
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ final class LocalServerChannelSink extends AbstractChannelSink {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||
Channel channel = e.getChannel();
|
||||
if (channel instanceof DefaultLocalServerChannel) {
|
||||
|
@ -29,5 +29,6 @@ import org.jboss.netty.channel.ChannelPipeline;
|
||||
* @apiviz.has org.jboss.netty.channel.socket.SocketChannel oneway - - creates
|
||||
*/
|
||||
public interface ClientSocketChannelFactory extends ChannelFactory {
|
||||
@Override
|
||||
SocketChannel newChannel(ChannelPipeline pipeline);
|
||||
}
|
||||
|
@ -33,8 +33,11 @@ import org.jboss.netty.channel.Channel;
|
||||
* @apiviz.composedOf org.jboss.netty.channel.socket.DatagramChannelConfig
|
||||
*/
|
||||
public interface DatagramChannel extends Channel {
|
||||
@Override
|
||||
DatagramChannelConfig getConfig();
|
||||
@Override
|
||||
InetSocketAddress getLocalAddress();
|
||||
@Override
|
||||
InetSocketAddress getRemoteAddress();
|
||||
|
||||
/**
|
||||
|
@ -29,5 +29,6 @@ import org.jboss.netty.channel.ChannelPipeline;
|
||||
* @apiviz.has org.jboss.netty.channel.socket.DatagramChannel oneway - - creates
|
||||
*/
|
||||
public interface DatagramChannelFactory extends ChannelFactory {
|
||||
@Override
|
||||
DatagramChannel newChannel(ChannelPipeline pipeline);
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBroadcast() {
|
||||
try {
|
||||
return socket.getBroadcast();
|
||||
@ -100,6 +101,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBroadcast(boolean broadcast) {
|
||||
try {
|
||||
socket.setBroadcast(broadcast);
|
||||
@ -108,6 +110,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetAddress getInterface() {
|
||||
if (socket instanceof MulticastSocket) {
|
||||
try {
|
||||
@ -120,6 +123,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterface(InetAddress interfaceAddress) {
|
||||
if (socket instanceof MulticastSocket) {
|
||||
try {
|
||||
@ -132,6 +136,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoopbackModeDisabled() {
|
||||
if (socket instanceof MulticastSocket) {
|
||||
try {
|
||||
@ -144,6 +149,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoopbackModeDisabled(boolean loopbackModeDisabled) {
|
||||
if (socket instanceof MulticastSocket) {
|
||||
try {
|
||||
@ -156,6 +162,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkInterface getNetworkInterface() {
|
||||
if (socket instanceof MulticastSocket) {
|
||||
try {
|
||||
@ -168,6 +175,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkInterface(NetworkInterface networkInterface) {
|
||||
if (socket instanceof MulticastSocket) {
|
||||
try {
|
||||
@ -180,6 +188,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReuseAddress() {
|
||||
try {
|
||||
return socket.getReuseAddress();
|
||||
@ -188,6 +197,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReuseAddress(boolean reuseAddress) {
|
||||
try {
|
||||
socket.setReuseAddress(reuseAddress);
|
||||
@ -196,6 +206,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReceiveBufferSize() {
|
||||
try {
|
||||
return socket.getReceiveBufferSize();
|
||||
@ -204,6 +215,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceiveBufferSize(int receiveBufferSize) {
|
||||
try {
|
||||
socket.setReceiveBufferSize(receiveBufferSize);
|
||||
@ -212,6 +224,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSendBufferSize() {
|
||||
try {
|
||||
return socket.getSendBufferSize();
|
||||
@ -220,6 +233,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSendBufferSize(int sendBufferSize) {
|
||||
try {
|
||||
socket.setSendBufferSize(sendBufferSize);
|
||||
@ -228,6 +242,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimeToLive() {
|
||||
if (socket instanceof MulticastSocket) {
|
||||
try {
|
||||
@ -240,6 +255,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeToLive(int ttl) {
|
||||
if (socket instanceof MulticastSocket) {
|
||||
try {
|
||||
@ -252,6 +268,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrafficClass() {
|
||||
try {
|
||||
return socket.getTrafficClass();
|
||||
@ -260,6 +277,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrafficClass(int trafficClass) {
|
||||
try {
|
||||
socket.setTrafficClass(trafficClass);
|
||||
@ -268,6 +286,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReceiveBufferSizePredictor getReceiveBufferSizePredictor() {
|
||||
ReceiveBufferSizePredictor predictor = this.predictor;
|
||||
if (predictor == null) {
|
||||
@ -283,6 +302,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
return predictor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceiveBufferSizePredictor(
|
||||
ReceiveBufferSizePredictor predictor) {
|
||||
if (predictor == null) {
|
||||
@ -291,10 +311,12 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig
|
||||
this.predictor = predictor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReceiveBufferSizePredictorFactory getReceiveBufferSizePredictorFactory() {
|
||||
return predictorFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory predictorFactory) {
|
||||
if (predictorFactory == null) {
|
||||
throw new NullPointerException("predictorFactory");
|
||||
|
@ -64,6 +64,7 @@ public class DefaultServerSocketChannelConfig extends DefaultServerChannelConfig
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReuseAddress() {
|
||||
try {
|
||||
return socket.getReuseAddress();
|
||||
@ -72,6 +73,7 @@ public class DefaultServerSocketChannelConfig extends DefaultServerChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReuseAddress(boolean reuseAddress) {
|
||||
try {
|
||||
socket.setReuseAddress(reuseAddress);
|
||||
@ -80,6 +82,7 @@ public class DefaultServerSocketChannelConfig extends DefaultServerChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReceiveBufferSize() {
|
||||
try {
|
||||
return socket.getReceiveBufferSize();
|
||||
@ -88,6 +91,7 @@ public class DefaultServerSocketChannelConfig extends DefaultServerChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceiveBufferSize(int receiveBufferSize) {
|
||||
try {
|
||||
socket.setReceiveBufferSize(receiveBufferSize);
|
||||
@ -96,14 +100,17 @@ public class DefaultServerSocketChannelConfig extends DefaultServerChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
|
||||
socket.setPerformancePreferences(connectionTime, latency, bandwidth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBacklog() {
|
||||
return backlog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBacklog(int backlog) {
|
||||
if (backlog < 0) {
|
||||
throw new IllegalArgumentException("backlog: " + backlog);
|
||||
|
@ -72,6 +72,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReceiveBufferSize() {
|
||||
try {
|
||||
return socket.getReceiveBufferSize();
|
||||
@ -80,6 +81,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSendBufferSize() {
|
||||
try {
|
||||
return socket.getSendBufferSize();
|
||||
@ -88,6 +90,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSoLinger() {
|
||||
try {
|
||||
return socket.getSoLinger();
|
||||
@ -96,6 +99,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrafficClass() {
|
||||
try {
|
||||
return socket.getTrafficClass();
|
||||
@ -104,6 +108,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeepAlive() {
|
||||
try {
|
||||
return socket.getKeepAlive();
|
||||
@ -112,6 +117,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReuseAddress() {
|
||||
try {
|
||||
return socket.getReuseAddress();
|
||||
@ -120,6 +126,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTcpNoDelay() {
|
||||
try {
|
||||
return socket.getTcpNoDelay();
|
||||
@ -128,6 +135,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeepAlive(boolean keepAlive) {
|
||||
try {
|
||||
socket.setKeepAlive(keepAlive);
|
||||
@ -136,11 +144,13 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPerformancePreferences(
|
||||
int connectionTime, int latency, int bandwidth) {
|
||||
socket.setPerformancePreferences(connectionTime, latency, bandwidth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceiveBufferSize(int receiveBufferSize) {
|
||||
try {
|
||||
socket.setReceiveBufferSize(receiveBufferSize);
|
||||
@ -149,6 +159,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReuseAddress(boolean reuseAddress) {
|
||||
try {
|
||||
socket.setReuseAddress(reuseAddress);
|
||||
@ -157,6 +168,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSendBufferSize(int sendBufferSize) {
|
||||
try {
|
||||
socket.setSendBufferSize(sendBufferSize);
|
||||
@ -165,6 +177,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSoLinger(int soLinger) {
|
||||
try {
|
||||
if (soLinger < 0) {
|
||||
@ -177,6 +190,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTcpNoDelay(boolean tcpNoDelay) {
|
||||
try {
|
||||
socket.setTcpNoDelay(tcpNoDelay);
|
||||
@ -185,6 +199,7 @@ public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrafficClass(int trafficClass) {
|
||||
try {
|
||||
socket.setTrafficClass(trafficClass);
|
||||
|
@ -31,7 +31,10 @@ import org.jboss.netty.channel.ServerChannel;
|
||||
* @apiviz.composedOf org.jboss.netty.channel.socket.ServerSocketChannelConfig
|
||||
*/
|
||||
public interface ServerSocketChannel extends ServerChannel {
|
||||
@Override
|
||||
ServerSocketChannelConfig getConfig();
|
||||
@Override
|
||||
InetSocketAddress getLocalAddress();
|
||||
@Override
|
||||
InetSocketAddress getRemoteAddress();
|
||||
}
|
||||
|
@ -30,5 +30,6 @@ import org.jboss.netty.channel.ServerChannelFactory;
|
||||
* @apiviz.has org.jboss.netty.channel.socket.ServerSocketChannel oneway - - creates
|
||||
*/
|
||||
public interface ServerSocketChannelFactory extends ServerChannelFactory {
|
||||
@Override
|
||||
ServerSocketChannel newChannel(ChannelPipeline pipeline);
|
||||
}
|
||||
|
@ -32,7 +32,10 @@ import org.jboss.netty.channel.Channel;
|
||||
* @apiviz.composedOf org.jboss.netty.channel.socket.SocketChannelConfig
|
||||
*/
|
||||
public interface SocketChannel extends Channel {
|
||||
@Override
|
||||
SocketChannelConfig getConfig();
|
||||
@Override
|
||||
InetSocketAddress getLocalAddress();
|
||||
@Override
|
||||
InetSocketAddress getRemoteAddress();
|
||||
}
|
||||
|
@ -90,22 +90,27 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpTunnelingSocketChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return realChannel.getLocalAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return realChannel.getRemoteAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return realChannel.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return realChannel.isConnected();
|
||||
}
|
||||
@ -137,6 +142,7 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
|
||||
void bindReal(final SocketAddress localAddress, final ChannelFuture future) {
|
||||
realChannel.bind(localAddress).addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
if (f.isSuccess()) {
|
||||
future.setSuccess();
|
||||
@ -150,6 +156,7 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
void connectReal(final SocketAddress remoteAddress, final ChannelFuture future) {
|
||||
final SocketChannel virtualChannel = this;
|
||||
realChannel.connect(remoteAddress).addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
final String serverName = config.getServerName();
|
||||
final int serverPort = ((InetSocketAddress) remoteAddress).getPort();
|
||||
@ -203,6 +210,7 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
fireChannelConnected(virtualChannel, remoteAddress);
|
||||
} else {
|
||||
sslHandshakeFuture.addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
if (f.isSuccess()) {
|
||||
realChannel.write(req);
|
||||
@ -239,6 +247,7 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
}
|
||||
|
||||
f.addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
if (f.isSuccess()) {
|
||||
future.setSuccess();
|
||||
@ -262,6 +271,7 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
|
||||
void setInterestOpsReal(final int interestOps, final ChannelFuture future) {
|
||||
realChannel.setInterestOps(interestOps).addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
if (f.isSuccess()) {
|
||||
future.setSuccess();
|
||||
@ -274,8 +284,10 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
|
||||
void disconnectReal(final ChannelFuture future) {
|
||||
writeLastChunk().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
realChannel.disconnect().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
if (f.isSuccess()) {
|
||||
future.setSuccess();
|
||||
@ -290,8 +302,10 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
|
||||
void unbindReal(final ChannelFuture future) {
|
||||
writeLastChunk().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
realChannel.unbind().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
if (f.isSuccess()) {
|
||||
future.setSuccess();
|
||||
@ -306,8 +320,10 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
|
||||
void closeReal(final ChannelFuture future) {
|
||||
writeLastChunk().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
realChannel.close().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f) {
|
||||
// Note: If 'future' refers to the closeFuture,
|
||||
// setSuccess() and setFailure() do nothing.
|
||||
|
@ -46,10 +46,12 @@ public class HttpTunnelingClientSocketChannelFactory implements ClientSocketChan
|
||||
this.clientSocketChannelFactory = clientSocketChannelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketChannel newChannel(ChannelPipeline pipeline) {
|
||||
return new HttpTunnelingClientSocketChannel(this, pipeline, sink, clientSocketChannelFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
clientSocketChannelFactory.releaseExternalResources();
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ final class HttpTunnelingClientSocketPipelineSink extends AbstractChannelSink {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventSunk(
|
||||
ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||
HttpTunnelingClientSocketChannel channel = (HttpTunnelingClientSocketChannel) e.getChannel();
|
||||
|
@ -206,12 +206,14 @@ public final class HttpTunnelingSocketChannelConfig implements SocketChannelConf
|
||||
enableSslSessionCreation = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptions(Map<String, Object> options) {
|
||||
for (Entry<String, Object> e: options.entrySet()) {
|
||||
setOption(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setOption(String key, Object value) {
|
||||
if (channel.realChannel.getConfig().setOption(key, value)) {
|
||||
return true;
|
||||
@ -236,88 +238,109 @@ public final class HttpTunnelingSocketChannelConfig implements SocketChannelConf
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReceiveBufferSize() {
|
||||
return channel.realChannel.getConfig().getReceiveBufferSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSendBufferSize() {
|
||||
return channel.realChannel.getConfig().getSendBufferSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSoLinger() {
|
||||
return channel.realChannel.getConfig().getSoLinger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrafficClass() {
|
||||
return channel.realChannel.getConfig().getTrafficClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeepAlive() {
|
||||
return channel.realChannel.getConfig().isKeepAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReuseAddress() {
|
||||
return channel.realChannel.getConfig().isReuseAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTcpNoDelay() {
|
||||
return channel.realChannel.getConfig().isTcpNoDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeepAlive(boolean keepAlive) {
|
||||
channel.realChannel.getConfig().setKeepAlive(keepAlive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPerformancePreferences(
|
||||
int connectionTime, int latency, int bandwidth) {
|
||||
channel.realChannel.getConfig().setPerformancePreferences(connectionTime, latency, bandwidth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceiveBufferSize(int receiveBufferSize) {
|
||||
channel.realChannel.getConfig().setReceiveBufferSize(receiveBufferSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReuseAddress(boolean reuseAddress) {
|
||||
channel.realChannel.getConfig().setReuseAddress(reuseAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSendBufferSize(int sendBufferSize) {
|
||||
channel.realChannel.getConfig().setSendBufferSize(sendBufferSize);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSoLinger(int soLinger) {
|
||||
channel.realChannel.getConfig().setSoLinger(soLinger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTcpNoDelay(boolean tcpNoDelay) {
|
||||
channel.realChannel.getConfig().setTcpNoDelay(tcpNoDelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrafficClass(int trafficClass) {
|
||||
channel.realChannel.getConfig().setTrafficClass(trafficClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return channel.realChannel.getConfig().getBufferFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConnectTimeoutMillis() {
|
||||
return channel.realChannel.getConfig().getConnectTimeoutMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPipelineFactory getPipelineFactory() {
|
||||
return channel.realChannel.getConfig().getPipelineFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
channel.realChannel.getConfig().setBufferFactory(bufferFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
|
||||
channel.realChannel.getConfig().setConnectTimeoutMillis(connectTimeoutMillis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
||||
channel.realChannel.getConfig().setPipelineFactory(pipelineFactory);
|
||||
}
|
||||
|
@ -79,10 +79,12 @@ class DefaultNioDatagramChannelConfig extends DefaultDatagramChannelConfig
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWriteBufferHighWaterMark() {
|
||||
return writeBufferHighWaterMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWriteBufferHighWaterMark(int writeBufferHighWaterMark) {
|
||||
if (writeBufferHighWaterMark < getWriteBufferLowWaterMark()) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -102,10 +104,12 @@ class DefaultNioDatagramChannelConfig extends DefaultDatagramChannelConfig
|
||||
this.writeBufferHighWaterMark = writeBufferHighWaterMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWriteBufferLowWaterMark() {
|
||||
return writeBufferLowWaterMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWriteBufferLowWaterMark(int writeBufferLowWaterMark) {
|
||||
if (writeBufferLowWaterMark > getWriteBufferHighWaterMark()) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -125,10 +129,12 @@ class DefaultNioDatagramChannelConfig extends DefaultDatagramChannelConfig
|
||||
this.writeBufferLowWaterMark = writeBufferLowWaterMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWriteSpinCount() {
|
||||
return writeSpinCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWriteSpinCount(int writeSpinCount) {
|
||||
if (writeSpinCount <= 0) {
|
||||
throw new IllegalArgumentException(
|
||||
|
@ -91,10 +91,12 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWriteBufferHighWaterMark() {
|
||||
return writeBufferHighWaterMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWriteBufferHighWaterMark(int writeBufferHighWaterMark) {
|
||||
if (writeBufferHighWaterMark < getWriteBufferLowWaterMark()) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -113,10 +115,12 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
|
||||
this.writeBufferHighWaterMark = writeBufferHighWaterMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWriteBufferLowWaterMark() {
|
||||
return writeBufferLowWaterMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWriteBufferLowWaterMark(int writeBufferLowWaterMark) {
|
||||
if (writeBufferLowWaterMark > getWriteBufferHighWaterMark()) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -135,10 +139,12 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
|
||||
this.writeBufferLowWaterMark = writeBufferLowWaterMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWriteSpinCount() {
|
||||
return writeSpinCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWriteSpinCount(int writeSpinCount) {
|
||||
if (writeSpinCount <= 0) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -147,6 +153,7 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
|
||||
this.writeSpinCount = writeSpinCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReceiveBufferSizePredictor getReceiveBufferSizePredictor() {
|
||||
ReceiveBufferSizePredictor predictor = this.predictor;
|
||||
if (predictor == null) {
|
||||
@ -162,6 +169,7 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
|
||||
return predictor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceiveBufferSizePredictor(
|
||||
ReceiveBufferSizePredictor predictor) {
|
||||
if (predictor == null) {
|
||||
@ -170,10 +178,12 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
|
||||
this.predictor = predictor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReceiveBufferSizePredictorFactory getReceiveBufferSizePredictorFactory() {
|
||||
return predictorFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory predictorFactory) {
|
||||
if (predictorFactory == null) {
|
||||
throw new NullPointerException("predictorFactory");
|
||||
|
@ -135,10 +135,12 @@ public class NioClientSocketChannelFactory implements ClientSocketChannelFactory
|
||||
sink = new NioClientSocketPipelineSink(bossExecutor, workerExecutor, workerCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketChannel newChannel(ChannelPipeline pipeline) {
|
||||
return new NioClientSocketChannel(this, pipeline, sink, sink.nextWorker());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
ExecutorUtil.terminate(bossExecutor, workerExecutor);
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventSunk(
|
||||
ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||
if (e instanceof ChannelStateEvent) {
|
||||
@ -141,6 +142,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
||||
channel.worker.register(channel, cf);
|
||||
} else {
|
||||
channel.getCloseFuture().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture f)
|
||||
throws Exception {
|
||||
if (!cf.isDone()) {
|
||||
@ -227,6 +229,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean shutdown = false;
|
||||
Selector selector = this.selector;
|
||||
@ -406,6 +409,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
channel.socket.register(
|
||||
|
@ -140,6 +140,7 @@ class NioDatagramChannel extends AbstractChannel
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
InetSocketAddress localAddress = this.localAddress;
|
||||
if (localAddress == null) {
|
||||
@ -154,6 +155,7 @@ class NioDatagramChannel extends AbstractChannel
|
||||
return localAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
InetSocketAddress remoteAddress = this.remoteAddress;
|
||||
if (remoteAddress == null) {
|
||||
@ -168,10 +170,12 @@ class NioDatagramChannel extends AbstractChannel
|
||||
return remoteAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return isOpen() && datagramChannel.socket().isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return datagramChannel.isConnected();
|
||||
}
|
||||
@ -181,6 +185,7 @@ class NioDatagramChannel extends AbstractChannel
|
||||
return super.setClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NioDatagramChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
@ -322,25 +327,30 @@ class NioDatagramChannel extends AbstractChannel
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
writeTaskInTaskQueue.set(false);
|
||||
worker.writeFromTaskLoop(NioDatagramChannel.this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinGroup(InetAddress multicastAddress) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinGroup(InetSocketAddress multicastAddress,
|
||||
NetworkInterface networkInterface) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveGroup(InetAddress multicastAddress) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveGroup(InetSocketAddress multicastAddress,
|
||||
NetworkInterface networkInterface) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -123,10 +123,12 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
|
||||
sink = new NioDatagramPipelineSink(workerExecutor, workerCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatagramChannel newChannel(final ChannelPipeline pipeline) {
|
||||
return new NioDatagramChannel(this, pipeline, sink, sink.nextWorker());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
ExecutorUtil.terminate(workerExecutor);
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ class NioDatagramPipelineSink extends AbstractChannelSink {
|
||||
* downstream event.
|
||||
* @param e The downstream event.
|
||||
*/
|
||||
@Override
|
||||
public void eventSunk(final ChannelPipeline pipeline, final ChannelEvent e)
|
||||
throws Exception {
|
||||
final NioDatagramChannel channel = (NioDatagramChannel) e.getChannel();
|
||||
|
@ -205,6 +205,7 @@ class NioDatagramWorker implements Runnable {
|
||||
/**
|
||||
* Selector loop.
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
// Store a ref to the current thread.
|
||||
thread = Thread.currentThread();
|
||||
@ -839,6 +840,7 @@ class NioDatagramWorker implements Runnable {
|
||||
* underlying DatagramChannels peer DatagramSocket register method.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
final SocketAddress localAddress = channel.getLocalAddress();
|
||||
if (localAddress == null) {
|
||||
|
@ -392,6 +392,7 @@ class NioProviderMetadata {
|
||||
selector = Selector.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!done) {
|
||||
synchronized (this) {
|
||||
|
@ -85,18 +85,22 @@ class NioServerSocketChannel extends AbstractServerChannel
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerSocketChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return (InetSocketAddress) socket.socket().getLocalSocketAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return isOpen() && socket.socket().isBound();
|
||||
}
|
||||
|
@ -138,10 +138,12 @@ public class NioServerSocketChannelFactory implements ServerSocketChannelFactory
|
||||
sink = new NioServerSocketPipelineSink(workerExecutor, workerCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerSocketChannel newChannel(ChannelPipeline pipeline) {
|
||||
return new NioServerSocketChannel(this, pipeline, sink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
ExecutorUtil.terminate(bossExecutor, workerExecutor);
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventSunk(
|
||||
ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||
Channel channel = e.getChannel();
|
||||
@ -230,6 +231,7 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
||||
channel.selector = selector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Thread currentThread = Thread.currentThread();
|
||||
|
||||
|
@ -84,10 +84,12 @@ class NioSocketChannel extends AbstractChannel
|
||||
config = new DefaultNioSocketChannelConfig(socket.socket());
|
||||
}
|
||||
|
||||
@Override
|
||||
public NioSocketChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
InetSocketAddress localAddress = this.localAddress;
|
||||
if (localAddress == null) {
|
||||
@ -102,6 +104,7 @@ class NioSocketChannel extends AbstractChannel
|
||||
return localAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
InetSocketAddress remoteAddress = this.remoteAddress;
|
||||
if (remoteAddress == null) {
|
||||
@ -121,10 +124,12 @@ class NioSocketChannel extends AbstractChannel
|
||||
return state >= ST_OPEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return state >= ST_BOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return state == ST_CONNECTED;
|
||||
}
|
||||
@ -263,6 +268,7 @@ class NioSocketChannel extends AbstractChannel
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
writeTaskInTaskQueue.set(false);
|
||||
worker.writeFromTaskLoop(NioSocketChannel.this);
|
||||
|
@ -143,6 +143,7 @@ class NioWorker implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
thread = Thread.currentThread();
|
||||
|
||||
@ -741,6 +742,7 @@ class NioWorker implements Runnable {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SocketAddress localAddress = channel.getLocalAddress();
|
||||
SocketAddress remoteAddress = channel.getRemoteAddress();
|
||||
|
@ -186,26 +186,32 @@ final class SocketSendBufferPool {
|
||||
initialPos = buffer.position();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean finished() {
|
||||
return !buffer.hasRemaining();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long writtenBytes() {
|
||||
return buffer.position() - initialPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long totalBytes() {
|
||||
return buffer.limit() - initialPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long transferTo(WritableByteChannel ch) throws IOException {
|
||||
return ch.write(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long transferTo(DatagramChannel ch, SocketAddress raddr) throws IOException {
|
||||
return ch.send(buffer, raddr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
// Unpooled.
|
||||
}
|
||||
@ -223,26 +229,32 @@ final class SocketSendBufferPool {
|
||||
initialPos = buffer.position();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finished() {
|
||||
return !buffer.hasRemaining();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long writtenBytes() {
|
||||
return buffer.position() - initialPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long totalBytes() {
|
||||
return buffer.limit() - initialPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferTo(WritableByteChannel ch) throws IOException {
|
||||
return ch.write(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferTo(DatagramChannel ch, SocketAddress raddr) throws IOException {
|
||||
return ch.send(buffer, raddr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
final Preallocation parent = this.parent;
|
||||
if (-- parent.refCnt == 0) {
|
||||
@ -264,29 +276,35 @@ final class SocketSendBufferPool {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finished() {
|
||||
return writtenBytes >= file.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long writtenBytes() {
|
||||
return writtenBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long totalBytes() {
|
||||
return file.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferTo(WritableByteChannel ch) throws IOException {
|
||||
long localWrittenBytes = file.transferTo(ch, writtenBytes);
|
||||
writtenBytes += localWrittenBytes;
|
||||
return localWrittenBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferTo(DatagramChannel ch, SocketAddress raddr)
|
||||
throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
// Unpooled.
|
||||
}
|
||||
@ -298,26 +316,32 @@ final class SocketSendBufferPool {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean finished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long writtenBytes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long totalBytes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long transferTo(WritableByteChannel ch) throws IOException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long transferTo(DatagramChannel ch, SocketAddress raddr) throws IOException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
// Unpooled.
|
||||
}
|
||||
|
@ -95,10 +95,12 @@ public class OioClientSocketChannelFactory implements ClientSocketChannelFactory
|
||||
sink = new OioClientSocketPipelineSink(workerExecutor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketChannel newChannel(ChannelPipeline pipeline) {
|
||||
return new OioClientSocketChannel(this, pipeline, sink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
ExecutorUtil.terminate(workerExecutor);
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ class OioClientSocketPipelineSink extends AbstractChannelSink {
|
||||
this.workerExecutor = workerExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventSunk(
|
||||
ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||
OioClientSocketChannel channel = (OioClientSocketChannel) e.getChannel();
|
||||
|
@ -78,10 +78,12 @@ final class OioDatagramChannel extends AbstractChannel
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatagramChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
InetSocketAddress localAddress = this.localAddress;
|
||||
if (localAddress == null) {
|
||||
@ -96,6 +98,7 @@ final class OioDatagramChannel extends AbstractChannel
|
||||
return localAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
InetSocketAddress remoteAddress = this.remoteAddress;
|
||||
if (remoteAddress == null) {
|
||||
@ -110,10 +113,12 @@ final class OioDatagramChannel extends AbstractChannel
|
||||
return remoteAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return isOpen() && socket.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return isOpen() && socket.isConnected();
|
||||
}
|
||||
@ -137,6 +142,7 @@ final class OioDatagramChannel extends AbstractChannel
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinGroup(InetAddress multicastAddress) {
|
||||
ensureBound();
|
||||
try {
|
||||
@ -146,6 +152,7 @@ final class OioDatagramChannel extends AbstractChannel
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinGroup(
|
||||
InetSocketAddress multicastAddress, NetworkInterface networkInterface) {
|
||||
ensureBound();
|
||||
@ -164,6 +171,7 @@ final class OioDatagramChannel extends AbstractChannel
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveGroup(InetAddress multicastAddress) {
|
||||
try {
|
||||
socket.leaveGroup(multicastAddress);
|
||||
@ -172,6 +180,7 @@ final class OioDatagramChannel extends AbstractChannel
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveGroup(
|
||||
InetSocketAddress multicastAddress, NetworkInterface networkInterface) {
|
||||
try {
|
||||
|
@ -98,10 +98,12 @@ public class OioDatagramChannelFactory implements DatagramChannelFactory {
|
||||
sink = new OioDatagramPipelineSink(id, workerExecutor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatagramChannel newChannel(ChannelPipeline pipeline) {
|
||||
return new OioDatagramChannel(this, pipeline, sink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseExternalResources() {
|
||||
ExecutorUtil.terminate(workerExecutor);
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ class OioDatagramPipelineSink extends AbstractChannelSink {
|
||||
this.workerExecutor = workerExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventSunk(
|
||||
ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||
OioDatagramChannel channel = (OioDatagramChannel) e.getChannel();
|
||||
|
@ -45,6 +45,7 @@ class OioDatagramWorker implements Runnable {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
channel.workerThread = Thread.currentThread();
|
||||
final MulticastSocket socket = channel.socket;
|
||||
|
@ -84,18 +84,22 @@ class OioServerSocketChannel extends AbstractServerChannel
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerSocketChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return (InetSocketAddress) socket.getLocalSocketAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return isOpen() && socket.isBound();
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user