diff --git a/src/main/java/org/jboss/netty/bootstrap/Bootstrap.java b/src/main/java/org/jboss/netty/bootstrap/Bootstrap.java index 6892a3dfb8..afb53a4e55 100644 --- a/src/main/java/org/jboss/netty/bootstrap/Bootstrap.java +++ b/src/main/java/org/jboss/netty/bootstrap/Bootstrap.java @@ -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) { diff --git a/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java index d96be7cb1a..f0d70fe919 100644 --- a/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/buffer/AbstractChannelBufferFactory.java b/src/main/java/org/jboss/netty/buffer/AbstractChannelBufferFactory.java index 2d9d8581dd..29ec759dcd 100644 --- a/src/main/java/org/jboss/netty/buffer/AbstractChannelBufferFactory.java +++ b/src/main/java/org/jboss/netty/buffer/AbstractChannelBufferFactory.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/buffer/BigEndianHeapChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/BigEndianHeapChannelBuffer.java index a545c013fd..aac2bb0c10 100644 --- a/src/main/java/org/jboss/netty/buffer/BigEndianHeapChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/BigEndianHeapChannelBuffer.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/buffer/ByteBufferBackedChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/ByteBufferBackedChannelBuffer.java index 5547117268..afdcd13ec0 100644 --- a/src/main/java/org/jboss/netty/buffer/ByteBufferBackedChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/ByteBufferBackedChannelBuffer.java @@ -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 { diff --git a/src/main/java/org/jboss/netty/buffer/ChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/ChannelBuffer.java index 943e7122eb..817708106c 100644 --- a/src/main/java/org/jboss/netty/buffer/ChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/ChannelBuffer.java @@ -1705,6 +1705,7 @@ public interface ChannelBuffer extends Comparable { * {@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 { * {@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 { * 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 { * the values of the key properties such as {@link #readerIndex()}, * {@link #writerIndex()} and {@link #capacity()}. */ + @Override String toString(); } diff --git a/src/main/java/org/jboss/netty/buffer/ChannelBufferIndexFinder.java b/src/main/java/org/jboss/netty/buffer/ChannelBufferIndexFinder.java index 9a6de34360..7f00e1eae9 100644 --- a/src/main/java/org/jboss/netty/buffer/ChannelBufferIndexFinder.java +++ b/src/main/java/org/jboss/netty/buffer/ChannelBufferIndexFinder.java @@ -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'; diff --git a/src/main/java/org/jboss/netty/buffer/ChannelBufferInputStream.java b/src/main/java/org/jboss/netty/buffer/ChannelBufferInputStream.java index faa2ac33d8..a040a97f0c 100644 --- a/src/main/java/org/jboss/netty/buffer/ChannelBufferInputStream.java +++ b/src/main/java/org/jboss/netty/buffer/ChannelBufferInputStream.java @@ -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); diff --git a/src/main/java/org/jboss/netty/buffer/ChannelBufferOutputStream.java b/src/main/java/org/jboss/netty/buffer/ChannelBufferOutputStream.java index b5f40f1414..776e826bf5 100644 --- a/src/main/java/org/jboss/netty/buffer/ChannelBufferOutputStream.java +++ b/src/main/java/org/jboss/netty/buffer/ChannelBufferOutputStream.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java index 8e54e79adf..6beb5b72be 100644 --- a/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java @@ -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); diff --git a/src/main/java/org/jboss/netty/buffer/DirectChannelBufferFactory.java b/src/main/java/org/jboss/netty/buffer/DirectChannelBufferFactory.java index 6cd3d7c548..e518f48c1f 100644 --- a/src/main/java/org/jboss/netty/buffer/DirectChannelBufferFactory.java +++ b/src/main/java/org/jboss/netty/buffer/DirectChannelBufferFactory.java @@ -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); diff --git a/src/main/java/org/jboss/netty/buffer/DuplicatedChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/DuplicatedChannelBuffer.java index c0f373b742..a7d24d8c3e 100644 --- a/src/main/java/org/jboss/netty/buffer/DuplicatedChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/DuplicatedChannelBuffer.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java index 0b6470cb31..5942d22b9a 100644 --- a/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/buffer/HeapChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/HeapChannelBuffer.java index 8bc888a1c6..f8d51d5b89 100644 --- a/src/main/java/org/jboss/netty/buffer/HeapChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/HeapChannelBuffer.java @@ -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()); } diff --git a/src/main/java/org/jboss/netty/buffer/HeapChannelBufferFactory.java b/src/main/java/org/jboss/netty/buffer/HeapChannelBufferFactory.java index 1a998bec99..92904a38e3 100644 --- a/src/main/java/org/jboss/netty/buffer/HeapChannelBufferFactory.java +++ b/src/main/java/org/jboss/netty/buffer/HeapChannelBufferFactory.java @@ -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); diff --git a/src/main/java/org/jboss/netty/buffer/LittleEndianHeapChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/LittleEndianHeapChannelBuffer.java index 9594c2553a..08727694a5 100644 --- a/src/main/java/org/jboss/netty/buffer/LittleEndianHeapChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/LittleEndianHeapChannelBuffer.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/buffer/ReadOnlyChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/ReadOnlyChannelBuffer.java index acbcdd5ada..c4556c9803 100644 --- a/src/main/java/org/jboss/netty/buffer/ReadOnlyChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/ReadOnlyChannelBuffer.java @@ -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(); } diff --git a/src/main/java/org/jboss/netty/buffer/SlicedChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/SlicedChannelBuffer.java index 6e7424c512..d91982b248 100644 --- a/src/main/java/org/jboss/netty/buffer/SlicedChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/SlicedChannelBuffer.java @@ -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); diff --git a/src/main/java/org/jboss/netty/buffer/TruncatedChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/TruncatedChannelBuffer.java index e882a280fe..27fccb43d6 100644 --- a/src/main/java/org/jboss/netty/buffer/TruncatedChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/TruncatedChannelBuffer.java @@ -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); diff --git a/src/main/java/org/jboss/netty/channel/AbstractChannel.java b/src/main/java/org/jboss/netty/channel/AbstractChannel.java index cbe4d16ae1..2776143b07 100644 --- a/src/main/java/org/jboss/netty/channel/AbstractChannel.java +++ b/src/main/java/org/jboss/netty/channel/AbstractChannel.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/channel/AbstractChannelSink.java b/src/main/java/org/jboss/netty/channel/AbstractChannelSink.java index f7cb0f12ac..79c421efbb 100644 --- a/src/main/java/org/jboss/netty/channel/AbstractChannelSink.java +++ b/src/main/java/org/jboss/netty/channel/AbstractChannelSink.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/AbstractServerChannel.java b/src/main/java/org/jboss/netty/channel/AbstractServerChannel.java index a6976bec10..bc9a7e0c15 100644 --- a/src/main/java/org/jboss/netty/channel/AbstractServerChannel.java +++ b/src/main/java/org/jboss/netty/channel/AbstractServerChannel.java @@ -91,6 +91,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S return getUnsupportedOperationFuture(); } + @Override public boolean isConnected() { return false; } diff --git a/src/main/java/org/jboss/netty/channel/AdaptiveReceiveBufferSizePredictor.java b/src/main/java/org/jboss/netty/channel/AdaptiveReceiveBufferSizePredictor.java index bf9c66d801..140e6351f6 100644 --- a/src/main/java/org/jboss/netty/channel/AdaptiveReceiveBufferSizePredictor.java +++ b/src/main/java/org/jboss/netty/channel/AdaptiveReceiveBufferSizePredictor.java @@ -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) { diff --git a/src/main/java/org/jboss/netty/channel/AdaptiveReceiveBufferSizePredictorFactory.java b/src/main/java/org/jboss/netty/channel/AdaptiveReceiveBufferSizePredictorFactory.java index 05fe59b6fb..053a36139c 100644 --- a/src/main/java/org/jboss/netty/channel/AdaptiveReceiveBufferSizePredictorFactory.java +++ b/src/main/java/org/jboss/netty/channel/AdaptiveReceiveBufferSizePredictorFactory.java @@ -66,6 +66,7 @@ public class AdaptiveReceiveBufferSizePredictorFactory implements this.maximum = maximum; } + @Override public ReceiveBufferSizePredictor getPredictor() throws Exception { return new AdaptiveReceiveBufferSizePredictor(minimum, initial, maximum); } diff --git a/src/main/java/org/jboss/netty/channel/ChannelFactory.java b/src/main/java/org/jboss/netty/channel/ChannelFactory.java index fdb44bfce2..bc4a0db737 100644 --- a/src/main/java/org/jboss/netty/channel/ChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/ChannelFactory.java @@ -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(); } diff --git a/src/main/java/org/jboss/netty/channel/ChannelFutureListener.java b/src/main/java/org/jboss/netty/channel/ChannelFutureListener.java index 0eb4b48ea6..904189db84 100644 --- a/src/main/java/org/jboss/netty/channel/ChannelFutureListener.java +++ b/src/main/java/org/jboss/netty/channel/ChannelFutureListener.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/Channels.java b/src/main/java/org/jboss/netty/channel/Channels.java index c5ee8584fc..a537b2c2c9 100644 --- a/src/main/java/org/jboss/netty/channel/Channels.java +++ b/src/main/java/org/jboss/netty/channel/Channels.java @@ -111,6 +111,7 @@ public class Channels { public static ChannelPipelineFactory pipelineFactory( final ChannelPipeline pipeline) { return new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() { return pipeline(pipeline); } diff --git a/src/main/java/org/jboss/netty/channel/ChildChannelStateEvent.java b/src/main/java/org/jboss/netty/channel/ChildChannelStateEvent.java index e5d5e34cd3..07772cc8d3 100644 --- a/src/main/java/org/jboss/netty/channel/ChildChannelStateEvent.java +++ b/src/main/java/org/jboss/netty/channel/ChildChannelStateEvent.java @@ -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(); /** diff --git a/src/main/java/org/jboss/netty/channel/CompleteChannelFuture.java b/src/main/java/org/jboss/netty/channel/CompleteChannelFuture.java index 75a2c34d72..c063be9230 100644 --- a/src/main/java/org/jboss/netty/channel/CompleteChannelFuture.java +++ b/src/main/java/org/jboss/netty/channel/CompleteChannelFuture.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/DefaultChannelConfig.java b/src/main/java/org/jboss/netty/channel/DefaultChannelConfig.java index 4b9ec6611b..3ec8079908 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultChannelConfig.java +++ b/src/main/java/org/jboss/netty/channel/DefaultChannelConfig.java @@ -44,12 +44,14 @@ public class DefaultChannelConfig implements ChannelConfig { super(); } + @Override public void setOptions(Map options) { for (Entry 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 } diff --git a/src/main/java/org/jboss/netty/channel/DefaultChannelFuture.java b/src/main/java/org/jboss/netty/channel/DefaultChannelFuture.java index 23936a9736..5eb5d15e3e 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultChannelFuture.java +++ b/src/main/java/org/jboss/netty/channel/DefaultChannelFuture.java @@ -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) { diff --git a/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java b/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java index 3bcc3ee231..f1de217c43 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java +++ b/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java @@ -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 remove(Class 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 replace( Class 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 get(Class 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 handlerType) { if (handlerType == null) { @@ -487,6 +510,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { return null; } + @Override public Map toMap() { Map map = new LinkedHashMap(); 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; diff --git a/src/main/java/org/jboss/netty/channel/DefaultChildChannelStateEvent.java b/src/main/java/org/jboss/netty/channel/DefaultChildChannelStateEvent.java index 7a55ad2e74..aa2e166003 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultChildChannelStateEvent.java +++ b/src/main/java/org/jboss/netty/channel/DefaultChildChannelStateEvent.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/DefaultExceptionEvent.java b/src/main/java/org/jboss/netty/channel/DefaultExceptionEvent.java index cfd78da20b..aa93c9a48e 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultExceptionEvent.java +++ b/src/main/java/org/jboss/netty/channel/DefaultExceptionEvent.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/DefaultFileRegion.java b/src/main/java/org/jboss/netty/channel/DefaultFileRegion.java index 4bc9419462..9a8bc100ee 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultFileRegion.java +++ b/src/main/java/org/jboss/netty/channel/DefaultFileRegion.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/DefaultServerChannelConfig.java b/src/main/java/org/jboss/netty/channel/DefaultServerChannelConfig.java index ebcde06b8f..ed1fe78a40 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultServerChannelConfig.java +++ b/src/main/java/org/jboss/netty/channel/DefaultServerChannelConfig.java @@ -42,6 +42,7 @@ public class DefaultServerChannelConfig implements ChannelConfig { super(); } + @Override public void setOptions(Map options) { for (Entry 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 } diff --git a/src/main/java/org/jboss/netty/channel/DefaultWriteCompletionEvent.java b/src/main/java/org/jboss/netty/channel/DefaultWriteCompletionEvent.java index 846e07f0f4..0809da673d 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultWriteCompletionEvent.java +++ b/src/main/java/org/jboss/netty/channel/DefaultWriteCompletionEvent.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/DownstreamChannelStateEvent.java b/src/main/java/org/jboss/netty/channel/DownstreamChannelStateEvent.java index db3d2853b5..76683b9b19 100644 --- a/src/main/java/org/jboss/netty/channel/DownstreamChannelStateEvent.java +++ b/src/main/java/org/jboss/netty/channel/DownstreamChannelStateEvent.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/DownstreamMessageEvent.java b/src/main/java/org/jboss/netty/channel/DownstreamMessageEvent.java index c69d9cdbff..a46cb441ff 100644 --- a/src/main/java/org/jboss/netty/channel/DownstreamMessageEvent.java +++ b/src/main/java/org/jboss/netty/channel/DownstreamMessageEvent.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/FailedChannelFuture.java b/src/main/java/org/jboss/netty/channel/FailedChannelFuture.java index 4610dc5bad..1482d44598 100644 --- a/src/main/java/org/jboss/netty/channel/FailedChannelFuture.java +++ b/src/main/java/org/jboss/netty/channel/FailedChannelFuture.java @@ -43,10 +43,12 @@ public class FailedChannelFuture extends CompleteChannelFuture { this.cause = cause; } + @Override public Throwable getCause() { return cause; } + @Override public boolean isSuccess() { return false; } diff --git a/src/main/java/org/jboss/netty/channel/FixedReceiveBufferSizePredictor.java b/src/main/java/org/jboss/netty/channel/FixedReceiveBufferSizePredictor.java index a5392f1ec2..2b04200df2 100644 --- a/src/main/java/org/jboss/netty/channel/FixedReceiveBufferSizePredictor.java +++ b/src/main/java/org/jboss/netty/channel/FixedReceiveBufferSizePredictor.java @@ -42,10 +42,12 @@ public class FixedReceiveBufferSizePredictor implements this.bufferSize = bufferSize; } + @Override public int nextReceiveBufferSize() { return bufferSize; } + @Override public void previousReceiveBufferSize(int previousReceiveBufferSize) { // Ignore } diff --git a/src/main/java/org/jboss/netty/channel/FixedReceiveBufferSizePredictorFactory.java b/src/main/java/org/jboss/netty/channel/FixedReceiveBufferSizePredictorFactory.java index c6439a99d7..5658d68999 100644 --- a/src/main/java/org/jboss/netty/channel/FixedReceiveBufferSizePredictorFactory.java +++ b/src/main/java/org/jboss/netty/channel/FixedReceiveBufferSizePredictorFactory.java @@ -38,6 +38,7 @@ public class FixedReceiveBufferSizePredictorFactory implements predictor = new FixedReceiveBufferSizePredictor(bufferSize); } + @Override public ReceiveBufferSizePredictor getPredictor() throws Exception { return predictor; } diff --git a/src/main/java/org/jboss/netty/channel/ServerChannelFactory.java b/src/main/java/org/jboss/netty/channel/ServerChannelFactory.java index 89a8f62d9f..bc80e76fcc 100644 --- a/src/main/java/org/jboss/netty/channel/ServerChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/ServerChannelFactory.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/channel/SimpleChannelDownstreamHandler.java b/src/main/java/org/jboss/netty/channel/SimpleChannelDownstreamHandler.java index ff02b1dd9a..42b5fadae3 100644 --- a/src/main/java/org/jboss/netty/channel/SimpleChannelDownstreamHandler.java +++ b/src/main/java/org/jboss/netty/channel/SimpleChannelDownstreamHandler.java @@ -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 { diff --git a/src/main/java/org/jboss/netty/channel/SimpleChannelHandler.java b/src/main/java/org/jboss/netty/channel/SimpleChannelHandler.java index 938e8da165..b81610cce6 100644 --- a/src/main/java/org/jboss/netty/channel/SimpleChannelHandler.java +++ b/src/main/java/org/jboss/netty/channel/SimpleChannelHandler.java @@ -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 { diff --git a/src/main/java/org/jboss/netty/channel/SimpleChannelUpstreamHandler.java b/src/main/java/org/jboss/netty/channel/SimpleChannelUpstreamHandler.java index 43b20e3234..189269c46f 100644 --- a/src/main/java/org/jboss/netty/channel/SimpleChannelUpstreamHandler.java +++ b/src/main/java/org/jboss/netty/channel/SimpleChannelUpstreamHandler.java @@ -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 { diff --git a/src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java b/src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java index 775b67df20..bd266653f8 100644 --- a/src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java +++ b/src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java @@ -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 remove(Class 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 replace( Class 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 get(Class 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 handlerType) { if (handlerType == null) { throw new NullPointerException("handlerType"); @@ -317,6 +340,7 @@ public class StaticChannelPipeline implements ChannelPipeline { return null; } + @Override public Map toMap() { Map map = new LinkedHashMap(); 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) { diff --git a/src/main/java/org/jboss/netty/channel/SucceededChannelFuture.java b/src/main/java/org/jboss/netty/channel/SucceededChannelFuture.java index 793edb15ab..8c60702489 100644 --- a/src/main/java/org/jboss/netty/channel/SucceededChannelFuture.java +++ b/src/main/java/org/jboss/netty/channel/SucceededChannelFuture.java @@ -36,10 +36,12 @@ public class SucceededChannelFuture extends CompleteChannelFuture { super(channel); } + @Override public Throwable getCause() { return null; } + @Override public boolean isSuccess() { return true; } diff --git a/src/main/java/org/jboss/netty/channel/UpstreamChannelStateEvent.java b/src/main/java/org/jboss/netty/channel/UpstreamChannelStateEvent.java index 084f59ebe0..cef3eeccc5 100644 --- a/src/main/java/org/jboss/netty/channel/UpstreamChannelStateEvent.java +++ b/src/main/java/org/jboss/netty/channel/UpstreamChannelStateEvent.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/UpstreamMessageEvent.java b/src/main/java/org/jboss/netty/channel/UpstreamMessageEvent.java index 06e73fec90..d588828b7d 100644 --- a/src/main/java/org/jboss/netty/channel/UpstreamMessageEvent.java +++ b/src/main/java/org/jboss/netty/channel/UpstreamMessageEvent.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/group/ChannelGroupFuture.java b/src/main/java/org/jboss/netty/channel/group/ChannelGroupFuture.java index 99cb85ce17..9237290d5d 100644 --- a/src/main/java/org/jboss/netty/channel/group/ChannelGroupFuture.java +++ b/src/main/java/org/jboss/netty/channel/group/ChannelGroupFuture.java @@ -253,5 +253,6 @@ public interface ChannelGroupFuture extends Iterable { * {@link Iterator} is is unmodifiable, which means a {@link ChannelFuture} * cannot be removed from this future. */ + @Override Iterator iterator(); } diff --git a/src/main/java/org/jboss/netty/channel/group/CombinedIterator.java b/src/main/java/org/jboss/netty/channel/group/CombinedIterator.java index 4dd8bbb8bd..82f589925d 100644 --- a/src/main/java/org/jboss/netty/channel/group/CombinedIterator.java +++ b/src/main/java/org/jboss/netty/channel/group/CombinedIterator.java @@ -41,6 +41,7 @@ final class CombinedIterator implements Iterator { currentIterator = i1; } + @Override public boolean hasNext() { boolean hasNext = currentIterator.hasNext(); if (hasNext) { @@ -55,6 +56,7 @@ final class CombinedIterator implements Iterator { } } + @Override public E next() { try { E e = currentIterator.next(); @@ -69,6 +71,7 @@ final class CombinedIterator implements Iterator { } } + @Override public void remove() { currentIterator.remove(); } diff --git a/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroup.java b/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroup.java index 52f7a80596..ac81627d24 100644 --- a/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroup.java +++ b/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroup.java @@ -49,6 +49,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel private final ConcurrentMap serverChannels = new ConcurrentHashMap(); private final ConcurrentMap nonServerChannels = new ConcurrentHashMap(); 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 implements Channel this.name = name; } + @Override public String getName() { return name; } @@ -87,6 +89,7 @@ public class DefaultChannelGroup extends AbstractSet 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 implements Channel return channels.toArray(a); } + @Override public ChannelGroupFuture close() { Map futures = new LinkedHashMap(size()); @@ -192,6 +196,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel return new DefaultChannelGroupFuture(this, futures); } + @Override public ChannelGroupFuture disconnect() { Map futures = new LinkedHashMap(size()); @@ -206,6 +211,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel return new DefaultChannelGroupFuture(this, futures); } + @Override public ChannelGroupFuture setInterestOps(int interestOps) { Map futures = new LinkedHashMap(size()); @@ -220,6 +226,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel return new DefaultChannelGroupFuture(this, futures); } + @Override public ChannelGroupFuture setReadable(boolean readable) { Map futures = new LinkedHashMap(size()); @@ -234,6 +241,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel return new DefaultChannelGroupFuture(this, futures); } + @Override public ChannelGroupFuture unbind() { Map futures = new LinkedHashMap(size()); @@ -248,6 +256,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel return new DefaultChannelGroupFuture(this, futures); } + @Override public ChannelGroupFuture write(Object message) { Map futures = new LinkedHashMap(size()); @@ -264,6 +273,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel return new DefaultChannelGroupFuture(this, futures); } + @Override public ChannelGroupFuture write(Object message, SocketAddress remoteAddress) { Map futures = new LinkedHashMap(size()); @@ -290,6 +300,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel return this == o; } + @Override public int compareTo(ChannelGroup o) { int v = getName().compareTo(o.getName()); if (v != 0) { diff --git a/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroupFuture.java b/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroupFuture.java index c9a893ddff..0850da1bbd 100644 --- a/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroupFuture.java +++ b/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroupFuture.java @@ -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 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); diff --git a/src/main/java/org/jboss/netty/channel/local/DefaultLocalChannel.java b/src/main/java/org/jboss/netty/channel/local/DefaultLocalChannel.java index 7cdd721659..2eda859f3b 100644 --- a/src/main/java/org/jboss/netty/channel/local/DefaultLocalChannel.java +++ b/src/main/java/org/jboss/netty/channel/local/DefaultLocalChannel.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/local/DefaultLocalClientChannelFactory.java b/src/main/java/org/jboss/netty/channel/local/DefaultLocalClientChannelFactory.java index 7648670d4b..8f80b8177f 100644 --- a/src/main/java/org/jboss/netty/channel/local/DefaultLocalClientChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/local/DefaultLocalClientChannelFactory.java @@ -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. } diff --git a/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannel.java b/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannel.java index 1e9726be43..f79858339b 100644 --- a/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannel.java +++ b/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannel.java @@ -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; } diff --git a/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannelFactory.java b/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannelFactory.java index 513b8db5ab..9379d472e9 100644 --- a/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannelFactory.java @@ -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 } diff --git a/src/main/java/org/jboss/netty/channel/local/LocalAddress.java b/src/main/java/org/jboss/netty/channel/local/LocalAddress.java index 4b5a8373a3..27c78cebdd 100644 --- a/src/main/java/org/jboss/netty/channel/local/LocalAddress.java +++ b/src/main/java/org/jboss/netty/channel/local/LocalAddress.java @@ -106,6 +106,7 @@ public final class LocalAddress extends SocketAddress implements Comparable options) { for (Entry 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); } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfig.java b/src/main/java/org/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfig.java index eeaa6fea02..3f97677e25 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfig.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfig.java @@ -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( diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/DefaultNioSocketChannelConfig.java b/src/main/java/org/jboss/netty/channel/socket/nio/DefaultNioSocketChannelConfig.java index d0af58aa83..1414df687b 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/DefaultNioSocketChannelConfig.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/DefaultNioSocketChannelConfig.java @@ -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"); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java index a9f59b963c..1733e2a89d 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink.java index f69cb4d7e6..5e04535dac 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink.java @@ -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( diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramChannel.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramChannel.java index 0b4c0fdc9b..734d193338 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramChannel.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramChannelFactory.java index b8879d76cd..f909a9d9ea 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramChannelFactory.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramPipelineSink.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramPipelineSink.java index 797a7ce1bb..8d243d9751 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramPipelineSink.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramPipelineSink.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java index b4358f2e7d..a77c27ad46 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java @@ -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) { diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioProviderMetadata.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioProviderMetadata.java index 921a4d229f..8d794db33e 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioProviderMetadata.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioProviderMetadata.java @@ -392,6 +392,7 @@ class NioProviderMetadata { selector = Selector.open(); } + @Override public void run() { while (!done) { synchronized (this) { diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannel.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannel.java index 72db301404..4cf7293adf 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannel.java @@ -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(); } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java index f05c99c2ef..f2be2fcd50 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketPipelineSink.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketPipelineSink.java index 9addd91166..918cfc2a0b 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketPipelineSink.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketPipelineSink.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioSocketChannel.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioSocketChannel.java index d4ff2b0114..a4031c7555 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioSocketChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioSocketChannel.java @@ -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); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java index 6e23d520e6..0938072ff5 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/SocketSendBufferPool.java b/src/main/java/org/jboss/netty/channel/socket/nio/SocketSendBufferPool.java index 70826d0300..ba1ab5de83 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/SocketSendBufferPool.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/SocketSendBufferPool.java @@ -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. } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketChannelFactory.java index d2976c4662..c63fe84802 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketChannelFactory.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketPipelineSink.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketPipelineSink.java index 3cc76f223e..7182ecfd3b 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketPipelineSink.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketPipelineSink.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannel.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannel.java index c7ce14eb97..9b905f5bc1 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannel.java @@ -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 { diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannelFactory.java index 75580c7960..5a74ba4267 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannelFactory.java @@ -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); } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramPipelineSink.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramPipelineSink.java index 1d50647248..ee16fe0298 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramPipelineSink.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramPipelineSink.java @@ -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(); diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java index 1e1d2d534f..d1368ee189 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java @@ -45,6 +45,7 @@ class OioDatagramWorker implements Runnable { this.channel = channel; } + @Override public void run() { channel.workerThread = Thread.currentThread(); final MulticastSocket socket = channel.socket; diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannel.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannel.java index bb66d65a80..77f6b9a570 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannel.java @@ -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(); } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannelFactory.java index d2b754dc4a..22114c08c4 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannelFactory.java @@ -115,10 +115,12 @@ public class OioServerSocketChannelFactory implements ServerSocketChannelFactory sink = new OioServerSocketPipelineSink(workerExecutor); } + @Override public ServerSocketChannel newChannel(ChannelPipeline pipeline) { return new OioServerSocketChannel(this, pipeline, sink); } + @Override public void releaseExternalResources() { ExecutorUtil.terminate(bossExecutor, workerExecutor); } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketPipelineSink.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketPipelineSink.java index 02c6fcff49..210dbf9608 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketPipelineSink.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketPipelineSink.java @@ -59,6 +59,7 @@ class OioServerSocketPipelineSink extends AbstractChannelSink { this.workerExecutor = workerExecutor; } + @Override public void eventSunk( ChannelPipeline pipeline, ChannelEvent e) throws Exception { Channel channel = e.getChannel(); @@ -199,6 +200,7 @@ class OioServerSocketPipelineSink extends AbstractChannelSink { this.channel = channel; } + @Override public void run() { channel.shutdownLock.lock(); try { diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioSocketChannel.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioSocketChannel.java index b53c83a192..2720e23b0a 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioSocketChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioSocketChannel.java @@ -62,10 +62,12 @@ abstract class OioSocketChannel extends AbstractChannel config = new DefaultSocketChannelConfig(socket); } + @Override public SocketChannelConfig getConfig() { return config; } + @Override public InetSocketAddress getLocalAddress() { InetSocketAddress localAddress = this.localAddress; if (localAddress == null) { @@ -80,6 +82,7 @@ abstract class OioSocketChannel extends AbstractChannel return localAddress; } + @Override public InetSocketAddress getRemoteAddress() { InetSocketAddress remoteAddress = this.remoteAddress; if (remoteAddress == null) { @@ -94,10 +97,12 @@ abstract class OioSocketChannel extends AbstractChannel return remoteAddress; } + @Override public boolean isBound() { return isOpen() && socket.isBound(); } + @Override public boolean isConnected() { return isOpen() && socket.isConnected(); } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java index 3124284b50..945927f178 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java @@ -46,6 +46,7 @@ class OioWorker implements Runnable { this.channel = channel; } + @Override public void run() { channel.workerThread = Thread.currentThread(); final PushbackInputStream in = channel.getInputStream(); diff --git a/src/main/java/org/jboss/netty/container/osgi/NettyBundleActivator.java b/src/main/java/org/jboss/netty/container/osgi/NettyBundleActivator.java index e7c78a3077..8d527635de 100644 --- a/src/main/java/org/jboss/netty/container/osgi/NettyBundleActivator.java +++ b/src/main/java/org/jboss/netty/container/osgi/NettyBundleActivator.java @@ -31,12 +31,14 @@ public class NettyBundleActivator implements BundleActivator { private OsgiLoggerFactory loggerFactory; + @Override public void start(BundleContext ctx) throws Exception { // Switch the internal logger to the OSGi LogService. loggerFactory = new OsgiLoggerFactory(ctx); InternalLoggerFactory.setDefaultFactory(loggerFactory); } + @Override public void stop(BundleContext ctx) throws Exception { if (loggerFactory != null) { InternalLoggerFactory.setDefaultFactory(loggerFactory.getFallback()); diff --git a/src/main/java/org/jboss/netty/example/discard/DiscardClient.java b/src/main/java/org/jboss/netty/example/discard/DiscardClient.java index 4cd7727891..1d6f51b0d9 100644 --- a/src/main/java/org/jboss/netty/example/discard/DiscardClient.java +++ b/src/main/java/org/jboss/netty/example/discard/DiscardClient.java @@ -62,6 +62,7 @@ public class DiscardClient { // Set up the pipeline factory. bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new DiscardClientHandler(firstMessageSize)); diff --git a/src/main/java/org/jboss/netty/example/discard/DiscardServer.java b/src/main/java/org/jboss/netty/example/discard/DiscardServer.java index b68a42cceb..a26aec3dda 100644 --- a/src/main/java/org/jboss/netty/example/discard/DiscardServer.java +++ b/src/main/java/org/jboss/netty/example/discard/DiscardServer.java @@ -43,6 +43,7 @@ public class DiscardServer { // Set up the pipeline factory. bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline(new DiscardServerHandler()); } diff --git a/src/main/java/org/jboss/netty/example/echo/EchoClient.java b/src/main/java/org/jboss/netty/example/echo/EchoClient.java index 24e3558fd1..4b5a6d7bec 100644 --- a/src/main/java/org/jboss/netty/example/echo/EchoClient.java +++ b/src/main/java/org/jboss/netty/example/echo/EchoClient.java @@ -66,6 +66,7 @@ public class EchoClient { // Set up the pipeline factory. bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new EchoClientHandler(firstMessageSize)); diff --git a/src/main/java/org/jboss/netty/example/echo/EchoServer.java b/src/main/java/org/jboss/netty/example/echo/EchoServer.java index a6a245f9a8..f45f42e2db 100644 --- a/src/main/java/org/jboss/netty/example/echo/EchoServer.java +++ b/src/main/java/org/jboss/netty/example/echo/EchoServer.java @@ -44,6 +44,7 @@ public class EchoServer { // Set up the pipeline factory. bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline(new EchoServerHandler()); } diff --git a/src/main/java/org/jboss/netty/example/factorial/FactorialClientHandler.java b/src/main/java/org/jboss/netty/example/factorial/FactorialClientHandler.java index 8c4d36e98c..fc4bc7daad 100644 --- a/src/main/java/org/jboss/netty/example/factorial/FactorialClientHandler.java +++ b/src/main/java/org/jboss/netty/example/factorial/FactorialClientHandler.java @@ -99,6 +99,7 @@ public class FactorialClientHandler extends SimpleChannelUpstreamHandler { if (receivedMessages == count) { // Offer the answer after closing the connection. e.getChannel().close().addListener(new ChannelFutureListener() { + @Override public void operationComplete(ChannelFuture future) { boolean offered = answer.offer((BigInteger) e.getMessage()); assert offered; diff --git a/src/main/java/org/jboss/netty/example/factorial/FactorialClientPipelineFactory.java b/src/main/java/org/jboss/netty/example/factorial/FactorialClientPipelineFactory.java index 9f743d08c6..a1df58bc56 100644 --- a/src/main/java/org/jboss/netty/example/factorial/FactorialClientPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/factorial/FactorialClientPipelineFactory.java @@ -40,6 +40,7 @@ public class FactorialClientPipelineFactory implements this.count = count; } + @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/factorial/FactorialServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/factorial/FactorialServerPipelineFactory.java index d2f2c96396..8f27842f22 100644 --- a/src/main/java/org/jboss/netty/example/factorial/FactorialServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/factorial/FactorialServerPipelineFactory.java @@ -35,6 +35,7 @@ import org.jboss.netty.handler.codec.compression.ZlibWrapper; public class FactorialServerPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerHandler.java b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerHandler.java index 2a72977695..6ac22fb395 100644 --- a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerHandler.java +++ b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerHandler.java @@ -105,10 +105,12 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler { new DefaultFileRegion(raf.getChannel(), 0, fileLength); writeFuture = ch.write(region); writeFuture.addListener(new ChannelFutureProgressListener() { + @Override public void operationComplete(ChannelFuture future) { region.releaseExternalResources(); } + @Override public void operationProgressed( ChannelFuture future, long amount, long current, long total) { System.out.printf("%s: %d / %d (+%d)%n", path, current, total, amount); diff --git a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerPipelineFactory.java index 838033f7ee..bedaf32ad7 100644 --- a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerPipelineFactory.java @@ -29,6 +29,7 @@ import org.jboss.netty.handler.stream.ChunkedWriteHandler; * @author Trustin Lee */ public class HttpStaticFileServerPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/http/snoop/HttpClientPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/snoop/HttpClientPipelineFactory.java index 69043aecc2..8902dbcbad 100644 --- a/src/main/java/org/jboss/netty/example/http/snoop/HttpClientPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/snoop/HttpClientPipelineFactory.java @@ -43,6 +43,7 @@ public class HttpClientPipelineFactory implements ChannelPipelineFactory { this.ssl = ssl; } + @Override public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/http/snoop/HttpServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/snoop/HttpServerPipelineFactory.java index 4eca247099..8960be7046 100644 --- a/src/main/java/org/jboss/netty/example/http/snoop/HttpServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/snoop/HttpServerPipelineFactory.java @@ -33,6 +33,7 @@ import org.jboss.netty.logging.InternalLogLevel; * @version $Rev$, $Date$ */ public class HttpServerPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/http/tunnel/HttpTunnelingClientExample.java b/src/main/java/org/jboss/netty/example/http/tunnel/HttpTunnelingClientExample.java index 3aba0935a5..0561a92dc6 100644 --- a/src/main/java/org/jboss/netty/example/http/tunnel/HttpTunnelingClientExample.java +++ b/src/main/java/org/jboss/netty/example/http/tunnel/HttpTunnelingClientExample.java @@ -66,6 +66,7 @@ public class HttpTunnelingClientExample { new OioClientSocketChannelFactory(Executors.newCachedThreadPool()))); b.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new StringDecoder(), diff --git a/src/main/java/org/jboss/netty/example/http/websocket/WebSocketServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/websocket/WebSocketServerPipelineFactory.java index 38116a0b61..d32d3494e6 100644 --- a/src/main/java/org/jboss/netty/example/http/websocket/WebSocketServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/websocket/WebSocketServerPipelineFactory.java @@ -30,6 +30,7 @@ import org.jboss.netty.handler.codec.http.HttpResponseEncoder; * @version $Rev$, $Date$ */ public class WebSocketServerPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/local/LocalExample.java b/src/main/java/org/jboss/netty/example/local/LocalExample.java index 8f2330e33e..41a67458ed 100644 --- a/src/main/java/org/jboss/netty/example/local/LocalExample.java +++ b/src/main/java/org/jboss/netty/example/local/LocalExample.java @@ -60,6 +60,7 @@ public class LocalExample { // Set up the client-side pipeline factory. cb.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new StringDecoder(), diff --git a/src/main/java/org/jboss/netty/example/local/LocalExampleMultthreaded.java b/src/main/java/org/jboss/netty/example/local/LocalExampleMultthreaded.java index 6eabfd890e..29736cba26 100644 --- a/src/main/java/org/jboss/netty/example/local/LocalExampleMultthreaded.java +++ b/src/main/java/org/jboss/netty/example/local/LocalExampleMultthreaded.java @@ -58,6 +58,7 @@ public class LocalExampleMultthreaded { new DefaultLocalClientChannelFactory()); cb.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new StringDecoder(), diff --git a/src/main/java/org/jboss/netty/example/local/LocalServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/local/LocalServerPipelineFactory.java index 9778024f0c..3e2ff9463e 100644 --- a/src/main/java/org/jboss/netty/example/local/LocalServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/local/LocalServerPipelineFactory.java @@ -43,6 +43,7 @@ public class LocalServerPipelineFactory implements ChannelPipelineFactory { executionHandler = new ExecutionHandler(eventExecutor); } + @Override public ChannelPipeline getPipeline() throws Exception { final ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", new StringDecoder()); @@ -53,6 +54,7 @@ public class LocalServerPipelineFactory implements ChannelPipelineFactory { } static class EchoCloseServerHandler implements ChannelUpstreamHandler, ChannelDownstreamHandler { + @Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { if (e instanceof MessageEvent) { @@ -66,6 +68,7 @@ public class LocalServerPipelineFactory implements ChannelPipelineFactory { ctx.sendUpstream(e); } + @Override public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) { if (e instanceof MessageEvent) { final MessageEvent evt = (MessageEvent) e; diff --git a/src/main/java/org/jboss/netty/example/localtime/LocalTimeClientPipelineFactory.java b/src/main/java/org/jboss/netty/example/localtime/LocalTimeClientPipelineFactory.java index 68beddf72e..1733ce32d9 100644 --- a/src/main/java/org/jboss/netty/example/localtime/LocalTimeClientPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/localtime/LocalTimeClientPipelineFactory.java @@ -31,6 +31,7 @@ import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepend */ public class LocalTimeClientPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline p = pipeline(); p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder()); diff --git a/src/main/java/org/jboss/netty/example/localtime/LocalTimeServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/localtime/LocalTimeServerPipelineFactory.java index a9caf230f5..dcb9cdb7fc 100644 --- a/src/main/java/org/jboss/netty/example/localtime/LocalTimeServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/localtime/LocalTimeServerPipelineFactory.java @@ -31,6 +31,7 @@ import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepend */ public class LocalTimeServerPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline p = pipeline(); p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder()); diff --git a/src/main/java/org/jboss/netty/example/objectecho/ObjectEchoClient.java b/src/main/java/org/jboss/netty/example/objectecho/ObjectEchoClient.java index a7c0ab3db7..aa3ceca0dd 100644 --- a/src/main/java/org/jboss/netty/example/objectecho/ObjectEchoClient.java +++ b/src/main/java/org/jboss/netty/example/objectecho/ObjectEchoClient.java @@ -65,6 +65,7 @@ public class ObjectEchoClient { // Set up the pipeline factory. bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new ObjectEncoder(), diff --git a/src/main/java/org/jboss/netty/example/objectecho/ObjectEchoServer.java b/src/main/java/org/jboss/netty/example/objectecho/ObjectEchoServer.java index 74a4a61e41..4b3ef60d91 100644 --- a/src/main/java/org/jboss/netty/example/objectecho/ObjectEchoServer.java +++ b/src/main/java/org/jboss/netty/example/objectecho/ObjectEchoServer.java @@ -46,6 +46,7 @@ public class ObjectEchoServer { // Set up the pipeline factory. bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new ObjectEncoder(), diff --git a/src/main/java/org/jboss/netty/example/portunification/PortUnificationServer.java b/src/main/java/org/jboss/netty/example/portunification/PortUnificationServer.java index 0c29ec0f47..6e1dafbc71 100644 --- a/src/main/java/org/jboss/netty/example/portunification/PortUnificationServer.java +++ b/src/main/java/org/jboss/netty/example/portunification/PortUnificationServer.java @@ -47,6 +47,7 @@ public class PortUnificationServer { // Set up the event pipeline factory. bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline(new PortUnificationServerHandler()); } diff --git a/src/main/java/org/jboss/netty/example/proxy/HexDumpProxyInboundHandler.java b/src/main/java/org/jboss/netty/example/proxy/HexDumpProxyInboundHandler.java index 7890914ebd..e7f1a83318 100644 --- a/src/main/java/org/jboss/netty/example/proxy/HexDumpProxyInboundHandler.java +++ b/src/main/java/org/jboss/netty/example/proxy/HexDumpProxyInboundHandler.java @@ -69,6 +69,7 @@ public class HexDumpProxyInboundHandler extends SimpleChannelUpstreamHandler { outboundChannel = f.getChannel(); f.addListener(new ChannelFutureListener() { + @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { // Connection attempt succeeded: diff --git a/src/main/java/org/jboss/netty/example/proxy/HexDumpProxyPipelineFactory.java b/src/main/java/org/jboss/netty/example/proxy/HexDumpProxyPipelineFactory.java index 80034c26df..71a1c769bf 100644 --- a/src/main/java/org/jboss/netty/example/proxy/HexDumpProxyPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/proxy/HexDumpProxyPipelineFactory.java @@ -39,6 +39,7 @@ public class HexDumpProxyPipelineFactory implements ChannelPipelineFactory { this.remotePort = remotePort; } + @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline p = pipeline(); // Note the static import. p.addLast("handler", new HexDumpProxyInboundHandler(cf, remoteHost, remotePort)); diff --git a/src/main/java/org/jboss/netty/example/qotm/QuoteOfTheMomentClient.java b/src/main/java/org/jboss/netty/example/qotm/QuoteOfTheMomentClient.java index 1c05e62727..5775cb9ac5 100644 --- a/src/main/java/org/jboss/netty/example/qotm/QuoteOfTheMomentClient.java +++ b/src/main/java/org/jboss/netty/example/qotm/QuoteOfTheMomentClient.java @@ -50,6 +50,7 @@ public class QuoteOfTheMomentClient { // Configure the pipeline factory. b.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new StringEncoder(CharsetUtil.ISO_8859_1), diff --git a/src/main/java/org/jboss/netty/example/qotm/QuoteOfTheMomentServer.java b/src/main/java/org/jboss/netty/example/qotm/QuoteOfTheMomentServer.java index 853152d5d1..23255aa8f1 100644 --- a/src/main/java/org/jboss/netty/example/qotm/QuoteOfTheMomentServer.java +++ b/src/main/java/org/jboss/netty/example/qotm/QuoteOfTheMomentServer.java @@ -49,6 +49,7 @@ public class QuoteOfTheMomentServer { // Configure the pipeline factory. b.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new StringEncoder(CharsetUtil.ISO_8859_1), diff --git a/src/main/java/org/jboss/netty/example/securechat/SecureChatClientPipelineFactory.java b/src/main/java/org/jboss/netty/example/securechat/SecureChatClientPipelineFactory.java index e3c3f3ee43..874f557a72 100644 --- a/src/main/java/org/jboss/netty/example/securechat/SecureChatClientPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/securechat/SecureChatClientPipelineFactory.java @@ -39,6 +39,7 @@ import org.jboss.netty.handler.ssl.SslHandler; public class SecureChatClientPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/securechat/SecureChatServerHandler.java b/src/main/java/org/jboss/netty/example/securechat/SecureChatServerHandler.java index fe94953554..876d88933f 100644 --- a/src/main/java/org/jboss/netty/example/securechat/SecureChatServerHandler.java +++ b/src/main/java/org/jboss/netty/example/securechat/SecureChatServerHandler.java @@ -123,6 +123,7 @@ public class SecureChatServerHandler extends SimpleChannelUpstreamHandler { this.sslHandler = sslHandler; } + @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { // Once session is secured, send a greeting. diff --git a/src/main/java/org/jboss/netty/example/securechat/SecureChatServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/securechat/SecureChatServerPipelineFactory.java index abfba18927..b4f6961e6f 100644 --- a/src/main/java/org/jboss/netty/example/securechat/SecureChatServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/securechat/SecureChatServerPipelineFactory.java @@ -39,6 +39,7 @@ import org.jboss.netty.handler.ssl.SslHandler; public class SecureChatServerPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/securechat/SecureChatTrustManagerFactory.java b/src/main/java/org/jboss/netty/example/securechat/SecureChatTrustManagerFactory.java index f1b2984c0e..d898703d8d 100644 --- a/src/main/java/org/jboss/netty/example/securechat/SecureChatTrustManagerFactory.java +++ b/src/main/java/org/jboss/netty/example/securechat/SecureChatTrustManagerFactory.java @@ -38,10 +38,12 @@ import javax.net.ssl.X509TrustManager; public class SecureChatTrustManagerFactory extends TrustManagerFactorySpi { private static final TrustManager DUMMY_TRUST_MANAGER = new X509TrustManager() { + @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } + @Override public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { // Always trust - it is an example. @@ -52,6 +54,7 @@ public class SecureChatTrustManagerFactory extends TrustManagerFactorySpi { "UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN()); } + @Override public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { // Always trust - it is an example. diff --git a/src/main/java/org/jboss/netty/example/telnet/TelnetClientPipelineFactory.java b/src/main/java/org/jboss/netty/example/telnet/TelnetClientPipelineFactory.java index b4c848a1bc..6a71227d47 100644 --- a/src/main/java/org/jboss/netty/example/telnet/TelnetClientPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/telnet/TelnetClientPipelineFactory.java @@ -36,6 +36,7 @@ import org.jboss.netty.handler.codec.string.StringEncoder; public class TelnetClientPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/telnet/TelnetServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/telnet/TelnetServerPipelineFactory.java index 3788d5d4d7..196be77773 100644 --- a/src/main/java/org/jboss/netty/example/telnet/TelnetServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/telnet/TelnetServerPipelineFactory.java @@ -36,6 +36,7 @@ import org.jboss.netty.handler.codec.string.StringEncoder; public class TelnetServerPipelineFactory implements ChannelPipelineFactory { + @Override public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); diff --git a/src/main/java/org/jboss/netty/example/uptime/UptimeClient.java b/src/main/java/org/jboss/netty/example/uptime/UptimeClient.java index 02707363f2..bded1dac5d 100644 --- a/src/main/java/org/jboss/netty/example/uptime/UptimeClient.java +++ b/src/main/java/org/jboss/netty/example/uptime/UptimeClient.java @@ -70,6 +70,7 @@ public class UptimeClient { // Configure the pipeline factory. bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline( new ReadTimeoutHandler(timer, READ_TIMEOUT), diff --git a/src/main/java/org/jboss/netty/example/uptime/UptimeClientHandler.java b/src/main/java/org/jboss/netty/example/uptime/UptimeClientHandler.java index a106cb6606..3532e1da85 100644 --- a/src/main/java/org/jboss/netty/example/uptime/UptimeClientHandler.java +++ b/src/main/java/org/jboss/netty/example/uptime/UptimeClientHandler.java @@ -61,6 +61,7 @@ public class UptimeClientHandler extends SimpleChannelUpstreamHandler { public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) { println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + "s"); timer.newTimeout(new TimerTask() { + @Override public void run(Timeout timeout) throws Exception { println("Reconnecting to: " + getRemoteAddress()); bootstrap.connect(); diff --git a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java index e8da93467a..e052feef14 100644 --- a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java @@ -303,6 +303,7 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne if (evt != null) { future.addListener(new ChannelFutureListener() { + @Override public void operationComplete(ChannelFuture future) throws Exception { ctx.sendDownstream(evt); } @@ -312,18 +313,22 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne return future; } + @Override public void beforeAdd(ChannelHandlerContext ctx) throws Exception { this.ctx = ctx; } + @Override public void afterAdd(ChannelHandlerContext ctx) throws Exception { // Unused } + @Override public void beforeRemove(ChannelHandlerContext ctx) throws Exception { // Unused } + @Override public void afterRemove(ChannelHandlerContext ctx) throws Exception { // Unused } diff --git a/src/main/java/org/jboss/netty/handler/codec/embedder/AbstractCodecEmbedder.java b/src/main/java/org/jboss/netty/handler/codec/embedder/AbstractCodecEmbedder.java index 9e5a277bf8..cecea08d1e 100644 --- a/src/main/java/org/jboss/netty/handler/codec/embedder/AbstractCodecEmbedder.java +++ b/src/main/java/org/jboss/netty/handler/codec/embedder/AbstractCodecEmbedder.java @@ -101,6 +101,7 @@ abstract class AbstractCodecEmbedder implements CodecEmbedder { pipeline.addLast("SINK", sink); } + @Override public boolean finish() { close(channel); fireChannelDisconnected(channel); @@ -125,16 +126,19 @@ abstract class AbstractCodecEmbedder implements CodecEmbedder { return productQueue.isEmpty(); } + @Override @SuppressWarnings("unchecked") public final E poll() { return (E) productQueue.poll(); } + @Override @SuppressWarnings("unchecked") public final E peek() { return (E) productQueue.peek(); } + @Override public final Object[] pollAll() { final int size = size(); Object[] a = new Object[size]; @@ -148,6 +152,7 @@ abstract class AbstractCodecEmbedder implements CodecEmbedder { return a; } + @Override @SuppressWarnings("unchecked") public final T[] pollAll(T[] a) { if (a == null) { @@ -177,6 +182,7 @@ abstract class AbstractCodecEmbedder implements CodecEmbedder { return a; } + @Override public final int size() { return productQueue.size(); } @@ -186,10 +192,12 @@ abstract class AbstractCodecEmbedder implements CodecEmbedder { super(); } + @Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) { handleEvent(e); } + @Override public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) { handleEvent(e); } @@ -205,6 +213,7 @@ abstract class AbstractCodecEmbedder implements CodecEmbedder { // Swallow otherwise. } + @Override public void exceptionCaught( ChannelPipeline pipeline, ChannelEvent e, ChannelPipelineException cause) throws Exception { diff --git a/src/main/java/org/jboss/netty/handler/codec/embedder/DecoderEmbedder.java b/src/main/java/org/jboss/netty/handler/codec/embedder/DecoderEmbedder.java index 504f70c0ab..1f895d05b8 100644 --- a/src/main/java/org/jboss/netty/handler/codec/embedder/DecoderEmbedder.java +++ b/src/main/java/org/jboss/netty/handler/codec/embedder/DecoderEmbedder.java @@ -71,6 +71,7 @@ public class DecoderEmbedder extends AbstractCodecEmbedder { super(bufferFactory, handlers); } + @Override public boolean offer(Object input) { fireMessageReceived(getChannel(), input); return !super.isEmpty(); diff --git a/src/main/java/org/jboss/netty/handler/codec/embedder/EmbeddedChannel.java b/src/main/java/org/jboss/netty/handler/codec/embedder/EmbeddedChannel.java index 4ae965e2fd..be9dce2136 100644 --- a/src/main/java/org/jboss/netty/handler/codec/embedder/EmbeddedChannel.java +++ b/src/main/java/org/jboss/netty/handler/codec/embedder/EmbeddedChannel.java @@ -44,22 +44,27 @@ class EmbeddedChannel extends AbstractChannel { config = new DefaultChannelConfig(); } + @Override public ChannelConfig getConfig() { return config; } + @Override public SocketAddress getLocalAddress() { return localAddress; } + @Override public SocketAddress getRemoteAddress() { return remoteAddress; } + @Override public boolean isBound() { return true; } + @Override public boolean isConnected() { return true; } diff --git a/src/main/java/org/jboss/netty/handler/codec/embedder/EmbeddedChannelFactory.java b/src/main/java/org/jboss/netty/handler/codec/embedder/EmbeddedChannelFactory.java index 2d689fc6d1..0bab97f296 100644 --- a/src/main/java/org/jboss/netty/handler/codec/embedder/EmbeddedChannelFactory.java +++ b/src/main/java/org/jboss/netty/handler/codec/embedder/EmbeddedChannelFactory.java @@ -32,10 +32,12 @@ class EmbeddedChannelFactory implements ChannelFactory { super(); } + @Override public Channel newChannel(ChannelPipeline pipeline) { throw new UnsupportedOperationException(); } + @Override public void releaseExternalResources() { // No external resources } diff --git a/src/main/java/org/jboss/netty/handler/codec/embedder/EncoderEmbedder.java b/src/main/java/org/jboss/netty/handler/codec/embedder/EncoderEmbedder.java index f5f80aa5a5..9b10dbf69c 100644 --- a/src/main/java/org/jboss/netty/handler/codec/embedder/EncoderEmbedder.java +++ b/src/main/java/org/jboss/netty/handler/codec/embedder/EncoderEmbedder.java @@ -71,6 +71,7 @@ public class EncoderEmbedder extends AbstractCodecEmbedder { super(bufferFactory, handlers); } + @Override public boolean offer(Object input) { write(getChannel(), input).setSuccess(); return !isEmpty(); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/CaseIgnoringComparator.java b/src/main/java/org/jboss/netty/handler/codec/http/CaseIgnoringComparator.java index 6812d07a91..9cc829b469 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/CaseIgnoringComparator.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/CaseIgnoringComparator.java @@ -34,6 +34,7 @@ final class CaseIgnoringComparator implements Comparator, Serializable { super(); } + @Override public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultCookie.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultCookie.java index 9cea2dad1f..90fdf70dfa 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultCookie.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultCookie.java @@ -98,14 +98,17 @@ public class DefaultCookie implements Cookie { setValue(value); } + @Override public String getName() { return name; } + @Override public String getValue() { return value; } + @Override public void setValue(String value) { if (value == null) { throw new NullPointerException("value"); @@ -113,46 +116,57 @@ public class DefaultCookie implements Cookie { this.value = value; } + @Override public String getDomain() { return domain; } + @Override public void setDomain(String domain) { this.domain = validateValue("domain", domain); } + @Override public String getPath() { return path; } + @Override public void setPath(String path) { this.path = validateValue("path", path); } + @Override public String getComment() { return comment; } + @Override public void setComment(String comment) { this.comment = validateValue("comment", comment); } + @Override public String getCommentUrl() { return commentUrl; } + @Override public void setCommentUrl(String commentUrl) { this.commentUrl = validateValue("commentUrl", commentUrl); } + @Override public boolean isDiscard() { return discard; } + @Override public void setDiscard(boolean discard) { this.discard = discard; } + @Override public Set getPorts() { if (unmodifiablePorts == null) { unmodifiablePorts = Collections.unmodifiableSet(ports); @@ -160,6 +174,7 @@ public class DefaultCookie implements Cookie { return unmodifiablePorts; } + @Override public void setPorts(int... ports) { if (ports == null) { throw new NullPointerException("ports"); @@ -181,6 +196,7 @@ public class DefaultCookie implements Cookie { } } + @Override public void setPorts(Iterable ports) { Set newPorts = new TreeSet(); for (int p: ports) { @@ -197,10 +213,12 @@ public class DefaultCookie implements Cookie { } } + @Override public int getMaxAge() { return maxAge; } + @Override public void setMaxAge(int maxAge) { if (maxAge < -1) { throw new IllegalArgumentException( @@ -210,26 +228,32 @@ public class DefaultCookie implements Cookie { this.maxAge = maxAge; } + @Override public int getVersion() { return version; } + @Override public void setVersion(int version) { this.version = version; } + @Override public boolean isSecure() { return secure; } + @Override public void setSecure(boolean secure) { this.secure = secure; } + @Override public boolean isHttpOnly() { return httpOnly; } + @Override public void setHttpOnly(boolean httpOnly) { this.httpOnly = httpOnly; } @@ -271,6 +295,7 @@ public class DefaultCookie implements Cookie { return true; } + @Override public int compareTo(Cookie c) { int v; v = getName().compareToIgnoreCase(c.getName()); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpChunk.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpChunk.java index 7637b0b562..f6c898bd4b 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpChunk.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpChunk.java @@ -37,10 +37,12 @@ public class DefaultHttpChunk implements HttpChunk { setContent(content); } + @Override public ChannelBuffer getContent() { return content; } + @Override public void setContent(ChannelBuffer content) { if (content == null) { throw new NullPointerException("content"); @@ -49,6 +51,7 @@ public class DefaultHttpChunk implements HttpChunk { this.content = content; } + @Override public boolean isLast() { return last; } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpChunkTrailer.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpChunkTrailer.java index 02ea94f149..c387081839 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpChunkTrailer.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpChunkTrailer.java @@ -44,54 +44,67 @@ public class DefaultHttpChunkTrailer implements HttpChunkTrailer { } }; + @Override public boolean isLast() { return true; } + @Override public void addHeader(final String name, final Object value) { headers.addHeader(name, value); } + @Override public void setHeader(final String name, final Object value) { headers.setHeader(name, value); } + @Override public void setHeader(final String name, final Iterable values) { headers.setHeader(name, values); } + @Override public void removeHeader(final String name) { headers.removeHeader(name); } + @Override public void clearHeaders() { headers.clearHeaders(); } + @Override public String getHeader(final String name) { return headers.getHeader(name); } + @Override public List getHeaders(final String name) { return headers.getHeaders(name); } + @Override public List> getHeaders() { return headers.getHeaders(); } + @Override public boolean containsHeader(final String name) { return headers.containsHeader(name); } + @Override public Set getHeaderNames() { return headers.getHeaderNames(); } + @Override public ChannelBuffer getContent() { return ChannelBuffers.EMPTY_BUFFER; } + @Override public void setContent(ChannelBuffer content) { throw new IllegalStateException("read-only"); } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java index 1640e83ba1..611e0ec9f2 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java @@ -45,22 +45,27 @@ public class DefaultHttpMessage implements HttpMessage { setProtocolVersion(version); } + @Override public void addHeader(final String name, final Object value) { headers.addHeader(name, value); } + @Override public void setHeader(final String name, final Object value) { headers.setHeader(name, value); } + @Override public void setHeader(final String name, final Iterable values) { headers.setHeader(name, values); } + @Override public void removeHeader(final String name) { headers.removeHeader(name); } + @Override public boolean isChunked() { if (chunked) { return true; @@ -69,6 +74,7 @@ public class DefaultHttpMessage implements HttpMessage { } } + @Override public void setChunked(boolean chunked) { this.chunked = chunked; if (chunked) { @@ -76,10 +82,12 @@ public class DefaultHttpMessage implements HttpMessage { } } + @Override public void clearHeaders() { headers.clearHeaders(); } + @Override public void setContent(ChannelBuffer content) { if (content == null) { content = ChannelBuffers.EMPTY_BUFFER; @@ -91,31 +99,38 @@ public class DefaultHttpMessage implements HttpMessage { this.content = content; } + @Override public String getHeader(final String name) { List values = getHeaders(name); return values.size() > 0 ? values.get(0) : null; } + @Override public List getHeaders(final String name) { return headers.getHeaders(name); } + @Override public List> getHeaders() { return headers.getHeaders(); } + @Override public boolean containsHeader(final String name) { return headers.containsHeader(name); } + @Override public Set getHeaderNames() { return headers.getHeaderNames(); } + @Override public HttpVersion getProtocolVersion() { return version; } + @Override public void setProtocolVersion(HttpVersion version) { if (version == null) { throw new NullPointerException("version"); @@ -123,6 +138,7 @@ public class DefaultHttpMessage implements HttpMessage { this.version = version; } + @Override public ChannelBuffer getContent() { return content; } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpRequest.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpRequest.java index 4017aa757b..63d084f27d 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpRequest.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpRequest.java @@ -43,10 +43,12 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques setUri(uri); } + @Override public HttpMethod getMethod() { return method; } + @Override public void setMethod(HttpMethod method) { if (method == null) { throw new NullPointerException("method"); @@ -54,10 +56,12 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques this.method = method; } + @Override public String getUri() { return uri; } + @Override public void setUri(String uri) { if (uri == null) { throw new NullPointerException("uri"); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpResponse.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpResponse.java index a14be4ec0d..9f4ddb2d81 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpResponse.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpResponse.java @@ -40,10 +40,12 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo setStatus(status); } + @Override public HttpResponseStatus getStatus() { return status; } + @Override public void setStatus(HttpResponseStatus status) { if (status == null) { throw new NullPointerException("status"); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpChunk.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpChunk.java index c14ccb350f..4c21347e48 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpChunk.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpChunk.java @@ -44,54 +44,67 @@ public interface HttpChunk { * The 'end of content' marker in chunked encoding. */ static HttpChunkTrailer LAST_CHUNK = new HttpChunkTrailer() { + @Override public ChannelBuffer getContent() { return ChannelBuffers.EMPTY_BUFFER; } + @Override public void setContent(ChannelBuffer content) { throw new IllegalStateException("read-only"); } + @Override public boolean isLast() { return true; } + @Override public void addHeader(String name, Object value) { throw new IllegalStateException("read-only"); } + @Override public void clearHeaders() { // NOOP } + @Override public boolean containsHeader(String name) { return false; } + @Override public String getHeader(String name) { return null; } + @Override public Set getHeaderNames() { return Collections.emptySet(); } + @Override public List getHeaders(String name) { return Collections.emptyList(); } + @Override public List> getHeaders() { return Collections.emptyList(); } + @Override public void removeHeader(String name) { // NOOP } + @Override public void setHeader(String name, Object value) { throw new IllegalStateException("read-only"); } + @Override public void setHeader(String name, Iterable values) { throw new IllegalStateException("read-only"); } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpChunkTrailer.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpChunkTrailer.java index 6765ce58c4..103aa7626c 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpChunkTrailer.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpChunkTrailer.java @@ -31,6 +31,7 @@ public interface HttpChunkTrailer extends HttpChunk { /** * Always returns {@code true}. */ + @Override boolean isLast(); /** diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpClientCodec.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpClientCodec.java index 992347c32d..f48926ffa5 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpClientCodec.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpClientCodec.java @@ -72,11 +72,13 @@ public class HttpClientCodec implements ChannelUpstreamHandler, decoder = new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize); } + @Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { decoder.handleUpstream(ctx, e); } + @Override public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { encoder.handleDownstream(ctx, e); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpHeaders.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpHeaders.java index 6513756550..7fd6d64047 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpHeaders.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpHeaders.java @@ -309,6 +309,11 @@ public class HttpHeaders { * @apiviz.stereotype static */ public static final class Values { + /** + * {@code "application/x-www-form-urlencoded"} + */ + public static final String APPLICATION_X_WWW_FORM_URLENCODED = + "application/x-www-form-urlencoded"; /** * {@code "base64"} */ @@ -317,6 +322,10 @@ public class HttpHeaders { * {@code "binary"} */ public static final String BINARY = "binary"; + /** + * {@code "boundary"} + */ + static final String BOUNDARY = "boundary"; /** * {@code "bytes"} */ @@ -369,6 +378,10 @@ public class HttpHeaders { * {@code "min-fresh"} */ public static final String MIN_FRESH = "min-fresh"; + /** + * {@code "multipart/form-data"} + */ + static final String MULTIPART_FORM_DATA = "multipart/form-data"; /** * {@code "must-revalidate"} */ @@ -991,14 +1004,17 @@ public class HttpHeaders { after.before = this; } + @Override public String getKey() { return key; } + @Override public String getValue() { return value; } + @Override public String setValue(String value) { if (value == null) { throw new NullPointerException("value"); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpMethod.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpMethod.java index a58e8c6946..7fd6d4f6da 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpMethod.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpMethod.java @@ -176,6 +176,7 @@ public class HttpMethod implements Comparable { return getName(); } + @Override public int compareTo(HttpMethod o) { return getName().compareTo(o.getName()); } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpResponseStatus.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpResponseStatus.java index f40ba80d35..b0d54d40ce 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpResponseStatus.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpResponseStatus.java @@ -470,6 +470,7 @@ public class HttpResponseStatus implements Comparable { return getCode() == ((HttpResponseStatus) o).getCode(); } + @Override public int compareTo(HttpResponseStatus o) { return getCode() - o.getCode(); } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpServerCodec.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpServerCodec.java index a133041faa..5e524a1f74 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpServerCodec.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpServerCodec.java @@ -56,11 +56,13 @@ public class HttpServerCodec implements ChannelUpstreamHandler, decoder = new HttpRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize); } + @Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { decoder.handleUpstream(ctx, e); } + @Override public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { encoder.handleDownstream(ctx, e); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpVersion.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpVersion.java index ffdc121b5b..b7e9c2e21d 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpVersion.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpVersion.java @@ -213,6 +213,7 @@ public class HttpVersion implements Comparable { getProtocolName().equals(that.getProtocolName()); } + @Override public int compareTo(HttpVersion o) { int v = getProtocolName().compareTo(o.getProtocolName()); if (v != 0) { diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocket/DefaultWebSocketFrame.java b/src/main/java/org/jboss/netty/handler/codec/http/websocket/DefaultWebSocketFrame.java index 54b08ad05b..a083473438 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocket/DefaultWebSocketFrame.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocket/DefaultWebSocketFrame.java @@ -62,26 +62,32 @@ public class DefaultWebSocketFrame implements WebSocketFrame { setData(type, binaryData); } + @Override public int getType() { return type; } + @Override public boolean isText() { return (getType() & 0x80) == 0; } + @Override public boolean isBinary() { return !isText(); } + @Override public ChannelBuffer getBinaryData() { return binaryData; } + @Override public String getTextData() { return getBinaryData().toString(CharsetUtil.UTF_8); } + @Override public void setData(int type, ChannelBuffer binaryData) { if (binaryData == null) { throw new NullPointerException("binaryData"); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocket/WebSocketFrame.java b/src/main/java/org/jboss/netty/handler/codec/http/websocket/WebSocketFrame.java index dc86d7ad20..0dc823e591 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocket/WebSocketFrame.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocket/WebSocketFrame.java @@ -82,5 +82,6 @@ public interface WebSocketFrame { * Returns the string representation of this frame. Please note that this * method is not identical to {@link #getTextData()}. */ + @Override String toString(); } diff --git a/src/main/java/org/jboss/netty/handler/codec/oneone/OneToOneDecoder.java b/src/main/java/org/jboss/netty/handler/codec/oneone/OneToOneDecoder.java index 6db1b04bfe..7f44b53fc4 100644 --- a/src/main/java/org/jboss/netty/handler/codec/oneone/OneToOneDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/oneone/OneToOneDecoder.java @@ -60,6 +60,7 @@ public abstract class OneToOneDecoder implements ChannelUpstreamHandler { super(); } + @Override public void handleUpstream( ChannelHandlerContext ctx, ChannelEvent evt) throws Exception { if (!(evt instanceof MessageEvent)) { diff --git a/src/main/java/org/jboss/netty/handler/codec/oneone/OneToOneEncoder.java b/src/main/java/org/jboss/netty/handler/codec/oneone/OneToOneEncoder.java index 5801eb5e34..b14af9779c 100644 --- a/src/main/java/org/jboss/netty/handler/codec/oneone/OneToOneEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/oneone/OneToOneEncoder.java @@ -54,6 +54,7 @@ public abstract class OneToOneEncoder implements ChannelDownstreamHandler { super(); } + @Override public void handleDownstream( ChannelHandlerContext ctx, ChannelEvent evt) throws Exception { if (!(evt instanceof MessageEvent)) { diff --git a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java index 8de04a2aef..2cae1b55b2 100644 --- a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java +++ b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java @@ -50,6 +50,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { terminated = true; } + @Override public int capacity() { if (terminated) { return buffer.capacity(); @@ -58,22 +59,27 @@ class ReplayingDecoderBuffer implements ChannelBuffer { } } + @Override public boolean isDirect() { return buffer.isDirect(); } + @Override public boolean hasArray() { return false; } + @Override public byte[] array() { throw new UnsupportedOperationException(); } + @Override public int arrayOffset() { throw new UnsupportedOperationException(); } + @Override public void clear() { throw new UnreplayableOperationException(); } @@ -83,123 +89,149 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return this == obj; } + @Override public int compareTo(ChannelBuffer buffer) { throw new UnreplayableOperationException(); } + @Override public ChannelBuffer copy() { throw new UnreplayableOperationException(); } + @Override public ChannelBuffer copy(int index, int length) { checkIndex(index, length); return buffer.copy(index, length); } + @Override public void discardReadBytes() { throw new UnreplayableOperationException(); } + @Override public void ensureWritableBytes(int writableBytes) { throw new UnreplayableOperationException(); } + @Override public ChannelBuffer duplicate() { throw new UnreplayableOperationException(); } + @Override public byte getByte(int index) { checkIndex(index); return buffer.getByte(index); } + @Override public short getUnsignedByte(int index) { checkIndex(index); return buffer.getUnsignedByte(index); } + @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, byte[] dst) { checkIndex(index, dst.length); buffer.getBytes(index, dst); } + @Override public void getBytes(int index, ByteBuffer dst) { throw new UnreplayableOperationException(); } + @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, ChannelBuffer dst, int length) { throw new UnreplayableOperationException(); } + @Override public void getBytes(int index, ChannelBuffer dst) { throw new UnreplayableOperationException(); } + @Override public int getBytes(int index, GatheringByteChannel out, int length) throws IOException { throw new UnreplayableOperationException(); } + @Override public void getBytes(int index, OutputStream out, int length) throws IOException { throw new UnreplayableOperationException(); } + @Override public int getInt(int index) { checkIndex(index, 4); return buffer.getInt(index); } + @Override public long getUnsignedInt(int index) { checkIndex(index, 4); return buffer.getUnsignedInt(index); } + @Override public long getLong(int index) { checkIndex(index, 8); return buffer.getLong(index); } + @Override public int getMedium(int index) { checkIndex(index, 3); return buffer.getMedium(index); } + @Override public int getUnsignedMedium(int index) { checkIndex(index, 3); return buffer.getUnsignedMedium(index); } + @Override public short getShort(int index) { checkIndex(index, 2); return buffer.getShort(index); } + @Override public int getUnsignedShort(int index) { checkIndex(index, 2); return buffer.getUnsignedShort(index); } + @Override public char getChar(int index) { checkIndex(index, 2); return buffer.getChar(index); } + @Override public float getFloat(int index) { checkIndex(index, 4); return buffer.getFloat(index); } + @Override public double getDouble(int index) { checkIndex(index, 8); return buffer.getDouble(index); @@ -210,6 +242,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { throw new UnreplayableOperationException(); } + @Override public int indexOf(int fromIndex, int toIndex, byte value) { int endIndex = buffer.indexOf(fromIndex, toIndex, value); if (endIndex < 0) { @@ -218,6 +251,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return endIndex; } + @Override public int indexOf(int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder) { int endIndex = buffer.indexOf(fromIndex, toIndex, indexFinder); @@ -227,6 +261,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return endIndex; } + @Override public int bytesBefore(byte value) { int bytes = buffer.bytesBefore(value); if (bytes < 0) { @@ -235,6 +270,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return bytes; } + @Override public int bytesBefore(ChannelBufferIndexFinder indexFinder) { int bytes = buffer.bytesBefore(indexFinder); if (bytes < 0) { @@ -243,6 +279,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return bytes; } + @Override public int bytesBefore(int length, byte value) { checkReadableBytes(length); int bytes = buffer.bytesBefore(length, value); @@ -252,6 +289,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return bytes; } + @Override public int bytesBefore(int length, ChannelBufferIndexFinder indexFinder) { checkReadableBytes(length); int bytes = buffer.bytesBefore(length, indexFinder); @@ -261,6 +299,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return bytes; } + @Override public int bytesBefore(int index, int length, byte value) { int bytes = buffer.bytesBefore(index, length, value); if (bytes < 0) { @@ -269,6 +308,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return bytes; } + @Override public int bytesBefore(int index, int length, ChannelBufferIndexFinder indexFinder) { int bytes = buffer.bytesBefore(index, length, indexFinder); @@ -278,26 +318,32 @@ class ReplayingDecoderBuffer implements ChannelBuffer { return bytes; } + @Override public void markReaderIndex() { buffer.markReaderIndex(); } + @Override public void markWriterIndex() { throw new UnreplayableOperationException(); } + @Override public ChannelBufferFactory factory() { return buffer.factory(); } + @Override public ByteOrder order() { return buffer.order(); } + @Override public boolean readable() { return terminated? buffer.readable() : true; } + @Override public int readableBytes() { if (terminated) { return buffer.readableBytes(); @@ -306,239 +352,292 @@ class ReplayingDecoderBuffer implements ChannelBuffer { } } + @Override public byte readByte() { checkReadableBytes(1); return buffer.readByte(); } + @Override public short readUnsignedByte() { checkReadableBytes(1); return buffer.readUnsignedByte(); } + @Override public void readBytes(byte[] dst, int dstIndex, int length) { checkReadableBytes(length); buffer.readBytes(dst, dstIndex, length); } + @Override public void readBytes(byte[] dst) { checkReadableBytes(dst.length); buffer.readBytes(dst); } + @Override public void readBytes(ByteBuffer dst) { throw new UnreplayableOperationException(); } + @Override public void readBytes(ChannelBuffer dst, int dstIndex, int length) { checkReadableBytes(length); buffer.readBytes(dst, dstIndex, length); } + @Override public void readBytes(ChannelBuffer dst, int length) { throw new UnreplayableOperationException(); } + @Override public void readBytes(ChannelBuffer dst) { throw new UnreplayableOperationException(); } + @Override public int readBytes(GatheringByteChannel out, int length) throws IOException { throw new UnreplayableOperationException(); } + @Override public ChannelBuffer readBytes(int length) { checkReadableBytes(length); return buffer.readBytes(length); } + @Override public ChannelBuffer readSlice(int length) { checkReadableBytes(length); return buffer.readSlice(length); } + @Override public void readBytes(OutputStream out, int length) throws IOException { throw new UnreplayableOperationException(); } + @Override public int readerIndex() { return buffer.readerIndex(); } + @Override public void readerIndex(int readerIndex) { buffer.readerIndex(readerIndex); } + @Override public int readInt() { checkReadableBytes(4); return buffer.readInt(); } + @Override public long readUnsignedInt() { checkReadableBytes(4); return buffer.readUnsignedInt(); } + @Override public long readLong() { checkReadableBytes(8); return buffer.readLong(); } + @Override public int readMedium() { checkReadableBytes(3); return buffer.readMedium(); } + @Override public int readUnsignedMedium() { checkReadableBytes(3); return buffer.readUnsignedMedium(); } + @Override public short readShort() { checkReadableBytes(2); return buffer.readShort(); } + @Override public int readUnsignedShort() { checkReadableBytes(2); return buffer.readUnsignedShort(); } + @Override public char readChar() { checkReadableBytes(2); return buffer.readChar(); } + @Override public float readFloat() { checkReadableBytes(4); return buffer.readFloat(); } + @Override public double readDouble() { checkReadableBytes(8); return buffer.readDouble(); } + @Override public void resetReaderIndex() { buffer.resetReaderIndex(); } + @Override public void resetWriterIndex() { throw new UnreplayableOperationException(); } + @Override public void setByte(int index, int value) { throw new UnreplayableOperationException(); } + @Override public void setBytes(int index, byte[] src, int srcIndex, int length) { throw new UnreplayableOperationException(); } + @Override public void setBytes(int index, byte[] src) { throw new UnreplayableOperationException(); } + @Override public void setBytes(int index, ByteBuffer src) { throw new UnreplayableOperationException(); } + @Override public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { throw new UnreplayableOperationException(); } + @Override public void setBytes(int index, ChannelBuffer src, int length) { throw new UnreplayableOperationException(); } + @Override public void setBytes(int index, ChannelBuffer src) { throw new UnreplayableOperationException(); } + @Override public int setBytes(int index, InputStream in, int length) throws IOException { throw new UnreplayableOperationException(); } + @Override public void setZero(int index, int length) { throw new UnreplayableOperationException(); } + @Override public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException { throw new UnreplayableOperationException(); } + @Override public void setIndex(int readerIndex, int writerIndex) { throw new UnreplayableOperationException(); } + @Override public void setInt(int index, int value) { throw new UnreplayableOperationException(); } + @Override public void setLong(int index, long value) { throw new UnreplayableOperationException(); } + @Override public void setMedium(int index, int value) { throw new UnreplayableOperationException(); } + @Override public void setShort(int index, int value) { throw new UnreplayableOperationException(); } + @Override public void setChar(int index, int value) { throw new UnreplayableOperationException(); } + @Override public void setFloat(int index, float value) { throw new UnreplayableOperationException(); } + @Override public void setDouble(int index, double value) { throw new UnreplayableOperationException(); } + @Override public void skipBytes(int length) { checkReadableBytes(length); buffer.skipBytes(length); } + @Override public ChannelBuffer slice() { throw new UnreplayableOperationException(); } + @Override public ChannelBuffer slice(int index, int length) { checkIndex(index, length); return buffer.slice(index, length); } + @Override public ByteBuffer toByteBuffer() { throw new UnreplayableOperationException(); } + @Override public ByteBuffer toByteBuffer(int index, int length) { checkIndex(index, length); return buffer.toByteBuffer(index, length); } + @Override public ByteBuffer[] toByteBuffers() { throw new UnreplayableOperationException(); } + @Override public ByteBuffer[] toByteBuffers(int index, int length) { checkIndex(index, length); return buffer.toByteBuffers(index, length); } + @Override public String toString(int index, int length, Charset charset) { checkIndex(index, length); return buffer.toString(index, length, charset); } + @Override public String toString(Charset charsetName) { throw new UnreplayableOperationException(); } @@ -554,87 +653,108 @@ class ReplayingDecoderBuffer implements ChannelBuffer { ')'; } + @Override public boolean writable() { return false; } + @Override public int writableBytes() { return 0; } + @Override public void writeByte(int value) { throw new UnreplayableOperationException(); } + @Override public void writeBytes(byte[] src, int srcIndex, int length) { throw new UnreplayableOperationException(); } + @Override public void writeBytes(byte[] src) { throw new UnreplayableOperationException(); } + @Override public void writeBytes(ByteBuffer src) { throw new UnreplayableOperationException(); } + @Override public void writeBytes(ChannelBuffer src, int srcIndex, int length) { throw new UnreplayableOperationException(); } + @Override public void writeBytes(ChannelBuffer src, int length) { throw new UnreplayableOperationException(); } + @Override public void writeBytes(ChannelBuffer src) { throw new UnreplayableOperationException(); } + @Override public int writeBytes(InputStream in, int length) throws IOException { throw new UnreplayableOperationException(); } + @Override public int writeBytes(ScatteringByteChannel in, int length) throws IOException { throw new UnreplayableOperationException(); } + @Override public void writeInt(int value) { throw new UnreplayableOperationException(); } + @Override public void writeLong(long value) { throw new UnreplayableOperationException(); } + @Override public void writeMedium(int value) { throw new UnreplayableOperationException(); } + @Override public void writeZero(int length) { throw new UnreplayableOperationException(); } + @Override public int writerIndex() { return buffer.writerIndex(); } + @Override public void writerIndex(int writerIndex) { throw new UnreplayableOperationException(); } + @Override public void writeShort(int value) { throw new UnreplayableOperationException(); } + @Override public void writeChar(int value) { throw new UnreplayableOperationException(); } + @Override public void writeFloat(float value) { throw new UnreplayableOperationException(); } + @Override public void writeDouble(double value) { throw new UnreplayableOperationException(); } diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java index f4c991e471..aa4aa439c0 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java @@ -108,6 +108,7 @@ public class ObjectDecoderInputStream extends InputStream implements this.maxObjectSize = maxObjectSize; } + @Override public Object readObject() throws ClassNotFoundException, IOException { int dataLen = readInt(); if (dataLen <= 0) { @@ -156,59 +157,73 @@ public class ObjectDecoderInputStream extends InputStream implements return in.read(b); } + @Override public final boolean readBoolean() throws IOException { return in.readBoolean(); } + @Override public final byte readByte() throws IOException { return in.readByte(); } + @Override public final char readChar() throws IOException { return in.readChar(); } + @Override public final double readDouble() throws IOException { return in.readDouble(); } + @Override public final float readFloat() throws IOException { return in.readFloat(); } + @Override public final void readFully(byte[] b, int off, int len) throws IOException { in.readFully(b, off, len); } + @Override public final void readFully(byte[] b) throws IOException { in.readFully(b); } + @Override public final int readInt() throws IOException { return in.readInt(); } + @Override @Deprecated public final String readLine() throws IOException { return in.readLine(); } + @Override public final long readLong() throws IOException { return in.readLong(); } + @Override public final short readShort() throws IOException { return in.readShort(); } + @Override public final int readUnsignedByte() throws IOException { return in.readUnsignedByte(); } + @Override public final int readUnsignedShort() throws IOException { return in.readUnsignedShort(); } + @Override public final String readUTF() throws IOException { return in.readUTF(); } @@ -223,6 +238,7 @@ public class ObjectDecoderInputStream extends InputStream implements return in.skip(n); } + @Override public final int skipBytes(int n) throws IOException { return in.skipBytes(n); } diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoderOutputStream.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoderOutputStream.java index e275f2dcc7..803b1bc778 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoderOutputStream.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoderOutputStream.java @@ -84,6 +84,7 @@ public class ObjectEncoderOutputStream extends OutputStream implements this.estimatedLength = estimatedLength; } + @Override public void writeObject(Object obj) throws IOException { ChannelBufferOutputStream bout = new ChannelBufferOutputStream( ChannelBuffers.dynamicBuffer(estimatedLength)); @@ -127,46 +128,57 @@ public class ObjectEncoderOutputStream extends OutputStream implements out.write(b); } + @Override public final void writeBoolean(boolean v) throws IOException { out.writeBoolean(v); } + @Override public final void writeByte(int v) throws IOException { out.writeByte(v); } + @Override public final void writeBytes(String s) throws IOException { out.writeBytes(s); } + @Override public final void writeChar(int v) throws IOException { out.writeChar(v); } + @Override public final void writeChars(String s) throws IOException { out.writeChars(s); } + @Override public final void writeDouble(double v) throws IOException { out.writeDouble(v); } + @Override public final void writeFloat(float v) throws IOException { out.writeFloat(v); } + @Override public final void writeInt(int v) throws IOException { out.writeInt(v); } + @Override public final void writeLong(long v) throws IOException { out.writeLong(v); } + @Override public final void writeShort(int v) throws IOException { out.writeShort(v); } + @Override public final void writeUTF(String str) throws IOException { out.writeUTF(str); } diff --git a/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java b/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java index 956033d2f0..b33677b3df 100644 --- a/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java +++ b/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java @@ -65,10 +65,12 @@ public class ChannelEventRunnable implements Runnable, EstimatableObjectWrapper /** * Sends the event upstream. */ + @Override public void run() { ctx.sendUpstream(e); } + @Override public Object unwrap() { return e; } diff --git a/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java b/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java index 831a828bce..16b63c8fe2 100644 --- a/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java +++ b/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java @@ -137,15 +137,18 @@ public class ExecutionHandler implements ChannelUpstreamHandler, ChannelDownstre * Shuts down the {@link Executor} which was specified with the constructor * and wait for its termination. */ + @Override public void releaseExternalResources() { ExecutorUtil.terminate(getExecutor()); } + @Override public void handleUpstream( ChannelHandlerContext context, ChannelEvent e) throws Exception { executor.execute(new ChannelEventRunnable(context, e)); } + @Override public void handleDownstream( ChannelHandlerContext ctx, ChannelEvent e) throws Exception { if (e instanceof ChannelStateEvent) { diff --git a/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java b/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java index e985126942..d914bd0e9b 100644 --- a/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java +++ b/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java @@ -518,6 +518,7 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor { super(); } + @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { try { final Thread t = new Thread(r, "Temporary task executor"); @@ -537,6 +538,7 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor { this.task = task; } + @Override public void run() { task.run(); } diff --git a/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java b/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java index 82b294ed14..52306b76bb 100644 --- a/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java +++ b/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java @@ -290,6 +290,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends super(); } + @Override public void execute(Runnable command) { boolean needsExecution; synchronized (tasks) { @@ -302,6 +303,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends } } + @Override public void run() { Thread thread = Thread.currentThread(); for (;;) { diff --git a/src/main/java/org/jboss/netty/handler/logging/LoggingHandler.java b/src/main/java/org/jboss/netty/handler/logging/LoggingHandler.java index d6050d1970..9da46e4595 100644 --- a/src/main/java/org/jboss/netty/handler/logging/LoggingHandler.java +++ b/src/main/java/org/jboss/netty/handler/logging/LoggingHandler.java @@ -225,12 +225,14 @@ public class LoggingHandler implements ChannelUpstreamHandler, ChannelDownstream } } + @Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { log(e); ctx.sendUpstream(e); } + @Override public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { log(e); diff --git a/src/main/java/org/jboss/netty/handler/queue/BufferedWriteHandler.java b/src/main/java/org/jboss/netty/handler/queue/BufferedWriteHandler.java index 105d235e2b..56ee069670 100644 --- a/src/main/java/org/jboss/netty/handler/queue/BufferedWriteHandler.java +++ b/src/main/java/org/jboss/netty/handler/queue/BufferedWriteHandler.java @@ -301,6 +301,7 @@ public class BufferedWriteHandler extends SimpleChannelHandler { ChannelBuffer composite = ChannelBuffers.wrappedBuffer(data); ChannelFuture future = Channels.future(ctx.getChannel()); future.addListener(new ChannelFutureListener() { + @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { diff --git a/src/main/java/org/jboss/netty/handler/ssl/ImmediateExecutor.java b/src/main/java/org/jboss/netty/handler/ssl/ImmediateExecutor.java index 52d83595be..f07a059c6e 100644 --- a/src/main/java/org/jboss/netty/handler/ssl/ImmediateExecutor.java +++ b/src/main/java/org/jboss/netty/handler/ssl/ImmediateExecutor.java @@ -33,6 +33,7 @@ final class ImmediateExecutor implements Executor { */ static final ImmediateExecutor INSTANCE = new ImmediateExecutor(); + @Override public void execute(Runnable command) { command.run(); } diff --git a/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java b/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java index 1bf1dd810d..6192432fda 100644 --- a/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java +++ b/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java @@ -381,6 +381,7 @@ public class SslHandler extends FrameDecoder this.enableRenegotiation = enableRenegotiation; } + @Override public void handleDownstream( final ChannelHandlerContext context, final ChannelEvent evt) throws Exception { if (evt instanceof ChannelStateEvent) { @@ -774,6 +775,7 @@ public class SslHandler extends FrameDecoder future = future(channel); future.addListener(new ChannelFutureListener() { + @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.getCause() instanceof ClosedChannelException) { @@ -978,6 +980,7 @@ public class SslHandler extends FrameDecoder } delegatedTaskExecutor.execute(new Runnable() { + @Override public void run() { synchronized (handshakeLock) { task.run(); @@ -1057,6 +1060,7 @@ public class SslHandler extends FrameDecoder this.e = e; } + @Override public void operationComplete(ChannelFuture closeNotifyFuture) throws Exception { if (!(closeNotifyFuture.getCause() instanceof ClosedChannelException)) { Channels.close(context, e.getFuture()); @@ -1064,18 +1068,22 @@ public class SslHandler extends FrameDecoder } } + @Override public void beforeAdd(ChannelHandlerContext ctx) throws Exception { this.ctx = ctx; } + @Override public void afterAdd(ChannelHandlerContext ctx) throws Exception { // Unused } + @Override public void beforeRemove(ChannelHandlerContext ctx) throws Exception { // Unused } + @Override public void afterRemove(ChannelHandlerContext ctx) throws Exception { // Unused } diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java index 45f9b9f358..d046222984 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java @@ -131,18 +131,22 @@ public class ChunkedFile implements ChunkedInput { return offset; } + @Override public boolean hasNextChunk() throws Exception { return offset < endOffset && file.getChannel().isOpen(); } + @Override public boolean isEndOfInput() throws Exception { return !hasNextChunk(); } + @Override public void close() throws Exception { file.close(); } + @Override public Object nextChunk() throws Exception { long offset = this.offset; if (offset >= endOffset) { diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedNioFile.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedNioFile.java index 969516bcc8..9896aa3cbb 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedNioFile.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedNioFile.java @@ -137,18 +137,22 @@ public class ChunkedNioFile implements ChunkedInput { return offset; } + @Override public boolean hasNextChunk() throws Exception { return offset < endOffset && in.isOpen(); } + @Override public boolean isEndOfInput() throws Exception { return !hasNextChunk(); } + @Override public void close() throws Exception { in.close(); } + @Override public Object nextChunk() throws Exception { long offset = this.offset; if (offset >= endOffset) { diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedNioStream.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedNioStream.java index b30ec47d5d..e302ff4b97 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedNioStream.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedNioStream.java @@ -78,6 +78,7 @@ public class ChunkedNioStream implements ChunkedInput { return offset; } + @Override public boolean hasNextChunk() throws Exception { if (byteBuffer.position() > 0) { // A previous read was not over, so there is a next chunk in the buffer at least @@ -96,14 +97,17 @@ public class ChunkedNioStream implements ChunkedInput { return false; } + @Override public boolean isEndOfInput() throws Exception { return !hasNextChunk(); } + @Override public void close() throws Exception { in.close(); } + @Override public Object nextChunk() throws Exception { if (!hasNextChunk()) { return null; diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java index 6946911c88..4d9c21c13f 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java @@ -74,6 +74,7 @@ public class ChunkedStream implements ChunkedInput { return offset; } + @Override public boolean hasNextChunk() throws Exception { int b = in.read(); if (b < 0) { @@ -84,14 +85,17 @@ public class ChunkedStream implements ChunkedInput { } } + @Override public boolean isEndOfInput() throws Exception { return !hasNextChunk(); } + @Override public void close() throws Exception { in.close(); } + @Override public Object nextChunk() throws Exception { if (!hasNextChunk()) { return null; diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java index 3bcae617d1..26c397d671 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java @@ -108,6 +108,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns } } + @Override public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { if (!(e instanceof MessageEvent)) { @@ -124,6 +125,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns } } + @Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { if (e instanceof ChannelStateEvent) { @@ -228,6 +230,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns } else { writeFuture = future(channel); writeFuture.addListener(new ChannelFutureListener() { + @Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { diff --git a/src/main/java/org/jboss/netty/handler/timeout/DefaultIdleStateEvent.java b/src/main/java/org/jboss/netty/handler/timeout/DefaultIdleStateEvent.java index cff9a9bf16..53426d6dcc 100644 --- a/src/main/java/org/jboss/netty/handler/timeout/DefaultIdleStateEvent.java +++ b/src/main/java/org/jboss/netty/handler/timeout/DefaultIdleStateEvent.java @@ -53,18 +53,22 @@ public class DefaultIdleStateEvent implements IdleStateEvent { this.lastActivityTimeMillis = lastActivityTimeMillis; } + @Override public Channel getChannel() { return channel; } + @Override public ChannelFuture getFuture() { return succeededFuture(getChannel()); } + @Override public IdleState getState() { return state; } + @Override public long getLastActivityTimeMillis() { return lastActivityTimeMillis; } diff --git a/src/main/java/org/jboss/netty/handler/timeout/IdleStateHandler.java b/src/main/java/org/jboss/netty/handler/timeout/IdleStateHandler.java index e2952361fb..e0604fd04b 100644 --- a/src/main/java/org/jboss/netty/handler/timeout/IdleStateHandler.java +++ b/src/main/java/org/jboss/netty/handler/timeout/IdleStateHandler.java @@ -224,10 +224,12 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler * handler. You should not call this method if the {@link Timer} is in use * by other objects. */ + @Override public void releaseExternalResources() { timer.stop(); } + @Override public void beforeAdd(ChannelHandlerContext ctx) throws Exception { if (ctx.getPipeline().isAttached()) { // channelOpen event has been fired already, which means @@ -240,14 +242,17 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler } } + @Override public void afterAdd(ChannelHandlerContext ctx) throws Exception { // NOOP } + @Override public void beforeRemove(ChannelHandlerContext ctx) throws Exception { destroy(); } + @Override public void afterRemove(ChannelHandlerContext ctx) throws Exception { // NOOP } @@ -332,6 +337,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler this.ctx = ctx; } + @Override public void run(Timeout timeout) throws Exception { if (timeout.isCancelled() || !ctx.getChannel().isOpen()) { return; @@ -366,6 +372,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler this.ctx = ctx; } + @Override public void run(Timeout timeout) throws Exception { if (timeout.isCancelled() || !ctx.getChannel().isOpen()) { return; @@ -399,6 +406,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler this.ctx = ctx; } + @Override public void run(Timeout timeout) throws Exception { if (timeout.isCancelled() || !ctx.getChannel().isOpen()) { return; diff --git a/src/main/java/org/jboss/netty/handler/timeout/ReadTimeoutHandler.java b/src/main/java/org/jboss/netty/handler/timeout/ReadTimeoutHandler.java index c06e722aac..2d06a95716 100644 --- a/src/main/java/org/jboss/netty/handler/timeout/ReadTimeoutHandler.java +++ b/src/main/java/org/jboss/netty/handler/timeout/ReadTimeoutHandler.java @@ -134,10 +134,12 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler * handler. You should not call this method if the {@link Timer} is in use * by other objects. */ + @Override public void releaseExternalResources() { timer.stop(); } + @Override public void beforeAdd(ChannelHandlerContext ctx) throws Exception { if (ctx.getPipeline().isAttached()) { // channelOpen event has been fired already, which means @@ -150,14 +152,17 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler } } + @Override public void afterAdd(ChannelHandlerContext ctx) throws Exception { // NOOP } + @Override public void beforeRemove(ChannelHandlerContext ctx) throws Exception { destroy(); } + @Override public void afterRemove(ChannelHandlerContext ctx) throws Exception { // NOOP } @@ -218,6 +223,7 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler this.ctx = ctx; } + @Override public void run(Timeout timeout) throws Exception { if (timeout.isCancelled()) { return; diff --git a/src/main/java/org/jboss/netty/handler/timeout/WriteTimeoutHandler.java b/src/main/java/org/jboss/netty/handler/timeout/WriteTimeoutHandler.java index 931d3e583b..b7eabe2c09 100644 --- a/src/main/java/org/jboss/netty/handler/timeout/WriteTimeoutHandler.java +++ b/src/main/java/org/jboss/netty/handler/timeout/WriteTimeoutHandler.java @@ -131,6 +131,7 @@ public class WriteTimeoutHandler extends SimpleChannelDownstreamHandler * handler. You should not call this method if the {@link Timer} is in use * by other objects. */ + @Override public void releaseExternalResources() { timer.stop(); } @@ -171,6 +172,7 @@ public class WriteTimeoutHandler extends SimpleChannelDownstreamHandler this.future = future; } + @Override public void run(Timeout timeout) throws Exception { if (timeout.isCancelled()) { return; @@ -204,6 +206,7 @@ public class WriteTimeoutHandler extends SimpleChannelDownstreamHandler this.timeout = timeout; } + @Override public void operationComplete(ChannelFuture future) throws Exception { timeout.cancel(); } diff --git a/src/main/java/org/jboss/netty/logging/AbstractInternalLogger.java b/src/main/java/org/jboss/netty/logging/AbstractInternalLogger.java index 4a1c634e4d..02437e1c15 100644 --- a/src/main/java/org/jboss/netty/logging/AbstractInternalLogger.java +++ b/src/main/java/org/jboss/netty/logging/AbstractInternalLogger.java @@ -33,6 +33,7 @@ public abstract class AbstractInternalLogger implements InternalLogger { super(); } + @Override public boolean isEnabled(InternalLogLevel level) { switch (level) { case DEBUG: @@ -48,6 +49,7 @@ public abstract class AbstractInternalLogger implements InternalLogger { } } + @Override public void log(InternalLogLevel level, String msg, Throwable cause) { switch (level) { case DEBUG: @@ -67,6 +69,7 @@ public abstract class AbstractInternalLogger implements InternalLogger { } } + @Override public void log(InternalLogLevel level, String msg) { switch (level) { case DEBUG: diff --git a/src/main/java/org/jboss/netty/logging/CommonsLogger.java b/src/main/java/org/jboss/netty/logging/CommonsLogger.java index dd9733b181..bdeb996fe4 100644 --- a/src/main/java/org/jboss/netty/logging/CommonsLogger.java +++ b/src/main/java/org/jboss/netty/logging/CommonsLogger.java @@ -37,50 +37,62 @@ class CommonsLogger extends AbstractInternalLogger { this.loggerName = loggerName; } + @Override public void debug(String msg) { logger.debug(msg); } + @Override public void debug(String msg, Throwable cause) { logger.debug(msg, cause); } + @Override public void error(String msg) { logger.error(msg); } + @Override public void error(String msg, Throwable cause) { logger.error(msg, cause); } + @Override public void info(String msg) { logger.info(msg); } + @Override public void info(String msg, Throwable cause) { logger.info(msg, cause); } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isErrorEnabled() { return logger.isErrorEnabled(); } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return logger.isWarnEnabled(); } + @Override public void warn(String msg) { logger.warn(msg); } + @Override public void warn(String msg, Throwable cause) { logger.warn(msg, cause); } diff --git a/src/main/java/org/jboss/netty/logging/InternalLoggerFactory.java b/src/main/java/org/jboss/netty/logging/InternalLoggerFactory.java index 4eff53564c..fe33b5f160 100644 --- a/src/main/java/org/jboss/netty/logging/InternalLoggerFactory.java +++ b/src/main/java/org/jboss/netty/logging/InternalLoggerFactory.java @@ -81,66 +81,81 @@ public abstract class InternalLoggerFactory { final InternalLogger logger = getDefaultFactory().newInstance(name); return new InternalLogger() { + @Override public void debug(String msg) { logger.debug(msg); } + @Override public void debug(String msg, Throwable cause) { StackTraceSimplifier.simplify(cause); logger.debug(msg, cause); } + @Override public void error(String msg) { logger.error(msg); } + @Override public void error(String msg, Throwable cause) { StackTraceSimplifier.simplify(cause); logger.error(msg, cause); } + @Override public void info(String msg) { logger.info(msg); } + @Override public void info(String msg, Throwable cause) { StackTraceSimplifier.simplify(cause); logger.info(msg, cause); } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isErrorEnabled() { return logger.isErrorEnabled(); } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return logger.isWarnEnabled(); } + @Override public void warn(String msg) { logger.warn(msg); } + @Override public void warn(String msg, Throwable cause) { StackTraceSimplifier.simplify(cause); logger.warn(msg, cause); } + @Override public boolean isEnabled(InternalLogLevel level) { return logger.isEnabled(level); } + @Override public void log(InternalLogLevel level, String msg) { logger.log(level, msg); } + @Override public void log(InternalLogLevel level, String msg, Throwable cause) { StackTraceSimplifier.simplify(cause); logger.log(level, msg, cause); diff --git a/src/main/java/org/jboss/netty/logging/JBossLogger.java b/src/main/java/org/jboss/netty/logging/JBossLogger.java index 74b712dbb5..940b0c7147 100644 --- a/src/main/java/org/jboss/netty/logging/JBossLogger.java +++ b/src/main/java/org/jboss/netty/logging/JBossLogger.java @@ -35,52 +35,64 @@ class JBossLogger extends AbstractInternalLogger { this.logger = logger; } + @Override public void debug(String msg) { logger.debug(msg); } + @Override public void debug(String msg, Throwable cause) { logger.debug(msg, cause); } + @Override public void error(String msg) { logger.error(msg); } + @Override public void error(String msg, Throwable cause) { logger.error(msg, cause); } + @Override public void info(String msg) { logger.info(msg); } + @Override public void info(String msg, Throwable cause) { logger.info(msg, cause); } + @Override @SuppressWarnings("deprecation") public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isErrorEnabled() { return true; } + @Override @SuppressWarnings("deprecation") public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return true; } + @Override public void warn(String msg) { logger.warn(msg); } + @Override public void warn(String msg, Throwable cause) { logger.warn(msg, cause); } diff --git a/src/main/java/org/jboss/netty/logging/JdkLogger.java b/src/main/java/org/jboss/netty/logging/JdkLogger.java index ff07d1da47..920c468027 100644 --- a/src/main/java/org/jboss/netty/logging/JdkLogger.java +++ b/src/main/java/org/jboss/netty/logging/JdkLogger.java @@ -38,50 +38,62 @@ class JdkLogger extends AbstractInternalLogger { this.loggerName = loggerName; } + @Override public void debug(String msg) { logger.logp(Level.FINE, loggerName, null, msg); } + @Override public void debug(String msg, Throwable cause) { logger.logp(Level.FINE, loggerName, null, msg, cause); } + @Override public void error(String msg) { logger.logp(Level.SEVERE, loggerName, null, msg); } + @Override public void error(String msg, Throwable cause) { logger.logp(Level.SEVERE, loggerName, null, msg, cause); } + @Override public void info(String msg) { logger.logp(Level.INFO, loggerName, null, msg); } + @Override public void info(String msg, Throwable cause) { logger.logp(Level.INFO, loggerName, null, msg, cause); } + @Override public boolean isDebugEnabled() { return logger.isLoggable(Level.FINE); } + @Override public boolean isErrorEnabled() { return logger.isLoggable(Level.SEVERE); } + @Override public boolean isInfoEnabled() { return logger.isLoggable(Level.INFO); } + @Override public boolean isWarnEnabled() { return logger.isLoggable(Level.WARNING); } + @Override public void warn(String msg) { logger.logp(Level.WARNING, loggerName, null, msg); } + @Override public void warn(String msg, Throwable cause) { logger.logp(Level.WARNING, loggerName, null, msg, cause); } diff --git a/src/main/java/org/jboss/netty/logging/Log4JLogger.java b/src/main/java/org/jboss/netty/logging/Log4JLogger.java index 8257ed7ee9..bcd4c246dd 100644 --- a/src/main/java/org/jboss/netty/logging/Log4JLogger.java +++ b/src/main/java/org/jboss/netty/logging/Log4JLogger.java @@ -35,50 +35,62 @@ class Log4JLogger extends AbstractInternalLogger { this.logger = logger; } + @Override public void debug(String msg) { logger.debug(msg); } + @Override public void debug(String msg, Throwable cause) { logger.debug(msg, cause); } + @Override public void error(String msg) { logger.error(msg); } + @Override public void error(String msg, Throwable cause) { logger.error(msg, cause); } + @Override public void info(String msg) { logger.info(msg); } + @Override public void info(String msg, Throwable cause) { logger.info(msg, cause); } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isErrorEnabled() { return true; } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return true; } + @Override public void warn(String msg) { logger.warn(msg); } + @Override public void warn(String msg, Throwable cause) { logger.warn(msg, cause); } diff --git a/src/main/java/org/jboss/netty/logging/OsgiLogger.java b/src/main/java/org/jboss/netty/logging/OsgiLogger.java index 9eaf28b152..21117fd49c 100644 --- a/src/main/java/org/jboss/netty/logging/OsgiLogger.java +++ b/src/main/java/org/jboss/netty/logging/OsgiLogger.java @@ -40,6 +40,7 @@ class OsgiLogger extends AbstractInternalLogger { prefix = "[" + name + "] "; } + @Override public void debug(String msg) { LogService logService = parent.getLogService(); if (logService != null) { @@ -49,6 +50,7 @@ class OsgiLogger extends AbstractInternalLogger { } } + @Override public void debug(String msg, Throwable cause) { LogService logService = parent.getLogService(); if (logService != null) { @@ -58,6 +60,7 @@ class OsgiLogger extends AbstractInternalLogger { } } + @Override public void error(String msg) { LogService logService = parent.getLogService(); if (logService != null) { @@ -67,6 +70,7 @@ class OsgiLogger extends AbstractInternalLogger { } } + @Override public void error(String msg, Throwable cause) { LogService logService = parent.getLogService(); if (logService != null) { @@ -76,6 +80,7 @@ class OsgiLogger extends AbstractInternalLogger { } } + @Override public void info(String msg) { LogService logService = parent.getLogService(); if (logService != null) { @@ -85,6 +90,7 @@ class OsgiLogger extends AbstractInternalLogger { } } + @Override public void info(String msg, Throwable cause) { LogService logService = parent.getLogService(); if (logService != null) { @@ -94,22 +100,27 @@ class OsgiLogger extends AbstractInternalLogger { } } + @Override public boolean isDebugEnabled() { return true; } + @Override public boolean isErrorEnabled() { return true; } + @Override public boolean isInfoEnabled() { return true; } + @Override public boolean isWarnEnabled() { return true; } + @Override public void warn(String msg) { LogService logService = parent.getLogService(); if (logService != null) { @@ -119,6 +130,7 @@ class OsgiLogger extends AbstractInternalLogger { } } + @Override public void warn(String msg, Throwable cause) { LogService logService = parent.getLogService(); if (logService != null) { diff --git a/src/main/java/org/jboss/netty/logging/Slf4JLogger.java b/src/main/java/org/jboss/netty/logging/Slf4JLogger.java index 32d5397cbb..a5e8db0c91 100644 --- a/src/main/java/org/jboss/netty/logging/Slf4JLogger.java +++ b/src/main/java/org/jboss/netty/logging/Slf4JLogger.java @@ -34,50 +34,62 @@ class Slf4JLogger extends AbstractInternalLogger { this.logger = logger; } + @Override public void debug(String msg) { logger.debug(msg); } + @Override public void debug(String msg, Throwable cause) { logger.debug(msg, cause); } + @Override public void error(String msg) { logger.error(msg); } + @Override public void error(String msg, Throwable cause) { logger.error(msg, cause); } + @Override public void info(String msg) { logger.info(msg); } + @Override public void info(String msg, Throwable cause) { logger.info(msg, cause); } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isErrorEnabled() { return logger.isErrorEnabled(); } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return logger.isWarnEnabled(); } + @Override public void warn(String msg) { logger.warn(msg); } + @Override public void warn(String msg, Throwable cause) { logger.warn(msg, cause); } diff --git a/src/main/java/org/jboss/netty/util/DefaultObjectSizeEstimator.java b/src/main/java/org/jboss/netty/util/DefaultObjectSizeEstimator.java index 209e7544c0..7035f73c23 100644 --- a/src/main/java/org/jboss/netty/util/DefaultObjectSizeEstimator.java +++ b/src/main/java/org/jboss/netty/util/DefaultObjectSizeEstimator.java @@ -55,6 +55,7 @@ public class DefaultObjectSizeEstimator implements ObjectSizeEstimator { class2size.put(void.class, 0); } + @Override public int estimateSize(Object o) { if (o == null) { return 8; diff --git a/src/main/java/org/jboss/netty/util/HashedWheelTimer.java b/src/main/java/org/jboss/netty/util/HashedWheelTimer.java index 3926f554b4..58f87b1990 100644 --- a/src/main/java/org/jboss/netty/util/HashedWheelTimer.java +++ b/src/main/java/org/jboss/netty/util/HashedWheelTimer.java @@ -272,6 +272,7 @@ public class HashedWheelTimer implements Timer { } } + @Override public synchronized Set stop() { if (!shutdown.compareAndSet(false, true)) { return Collections.emptySet(); @@ -302,6 +303,7 @@ public class HashedWheelTimer implements Timer { return Collections.unmodifiableSet(unprocessedTimeouts); } + @Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { final long currentTime = System.currentTimeMillis(); @@ -358,6 +360,7 @@ public class HashedWheelTimer implements Timer { super(); } + @Override public void run() { List expiredTimeouts = new ArrayList(); @@ -470,14 +473,17 @@ public class HashedWheelTimer implements Timer { this.remainingRounds = remainingRounds; } + @Override public Timer getTimer() { return HashedWheelTimer.this; } + @Override public TimerTask getTask() { return task; } + @Override public void cancel() { if (isExpired()) { return; @@ -489,10 +495,12 @@ public class HashedWheelTimer implements Timer { wheel[stopIndex].remove(this); } + @Override public boolean isCancelled() { return cancelled; } + @Override public boolean isExpired() { return cancelled || System.currentTimeMillis() > deadline; } diff --git a/src/main/java/org/jboss/netty/util/ThreadNameDeterminer.java b/src/main/java/org/jboss/netty/util/ThreadNameDeterminer.java index 4baa2c118e..5ea27892d8 100644 --- a/src/main/java/org/jboss/netty/util/ThreadNameDeterminer.java +++ b/src/main/java/org/jboss/netty/util/ThreadNameDeterminer.java @@ -29,6 +29,7 @@ public interface ThreadNameDeterminer { * which contains all specified information. */ ThreadNameDeterminer PROPOSED = new ThreadNameDeterminer() { + @Override public String determineThreadName(String current, String service, String category, String parentId, String id, String comment) throws Exception { @@ -68,6 +69,7 @@ public interface ThreadNameDeterminer { * thread name and retains the current one. */ ThreadNameDeterminer CURRENT = new ThreadNameDeterminer() { + @Override public String determineThreadName(String current, String service, String category, String parentId, String id, String comment) throws Exception { return null; diff --git a/src/main/java/org/jboss/netty/util/ThreadRenamingRunnable.java b/src/main/java/org/jboss/netty/util/ThreadRenamingRunnable.java index fc7c40fe07..d2ade4993c 100644 --- a/src/main/java/org/jboss/netty/util/ThreadRenamingRunnable.java +++ b/src/main/java/org/jboss/netty/util/ThreadRenamingRunnable.java @@ -175,6 +175,7 @@ public class ThreadRenamingRunnable implements Runnable { this.comment = comment; } + @Override public void run() { final Thread currentThread = Thread.currentThread(); final String oldThreadName = currentThread.getName(); diff --git a/src/main/java/org/jboss/netty/util/VirtualExecutorService.java b/src/main/java/org/jboss/netty/util/VirtualExecutorService.java index 357c20d8df..7f6f586cdf 100644 --- a/src/main/java/org/jboss/netty/util/VirtualExecutorService.java +++ b/src/main/java/org/jboss/netty/util/VirtualExecutorService.java @@ -103,18 +103,21 @@ public class VirtualExecutorService extends AbstractExecutorService { } } + @Override public boolean isShutdown() { synchronized (startStopLock) { return shutdown; } } + @Override public boolean isTerminated() { synchronized (startStopLock) { return shutdown && activeThreads.isEmpty(); } } + @Override public void shutdown() { synchronized (startStopLock) { if (shutdown) { @@ -124,6 +127,7 @@ public class VirtualExecutorService extends AbstractExecutorService { } } + @Override public List shutdownNow() { synchronized (startStopLock) { if (!isTerminated()) { @@ -137,6 +141,7 @@ public class VirtualExecutorService extends AbstractExecutorService { return Collections.emptyList(); } + @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { synchronized (startStopLock) { @@ -148,6 +153,7 @@ public class VirtualExecutorService extends AbstractExecutorService { } } + @Override public void execute(Runnable command) { if (command == null) { throw new NullPointerException("command"); @@ -172,6 +178,7 @@ public class VirtualExecutorService extends AbstractExecutorService { this.runnable = runnable; } + @Override public void run() { Thread thread = Thread.currentThread(); synchronized (startStopLock) { diff --git a/src/main/java/org/jboss/netty/util/internal/ConcurrentHashMap.java b/src/main/java/org/jboss/netty/util/internal/ConcurrentHashMap.java index db0d7af661..e22e75614d 100644 --- a/src/main/java/org/jboss/netty/util/internal/ConcurrentHashMap.java +++ b/src/main/java/org/jboss/netty/util/internal/ConcurrentHashMap.java @@ -929,6 +929,7 @@ public final class ConcurrentHashMap extends AbstractMap * null if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ + @Override public V putIfAbsent(K key, V value) { if (value == null) { throw new NullPointerException(); @@ -971,6 +972,7 @@ public final class ConcurrentHashMap extends AbstractMap * * @throws NullPointerException if the specified key is null */ + @Override public boolean remove(Object key, Object value) { int hash = hashOf(key); if (value == null) { @@ -984,6 +986,7 @@ public final class ConcurrentHashMap extends AbstractMap * * @throws NullPointerException if any of the arguments are null */ + @Override public boolean replace(K key, V oldValue, V newValue) { if (oldValue == null || newValue == null) { throw new NullPointerException(); @@ -999,6 +1002,7 @@ public final class ConcurrentHashMap extends AbstractMap * null if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ + @Override public V replace(K key, V value) { if (value == null) { throw new NullPointerException(); @@ -1192,10 +1196,12 @@ public final class ConcurrentHashMap extends AbstractMap final class KeyIterator extends HashIterator implements ReusableIterator, Enumeration { + @Override public K next() { return super.nextEntry().key(); } + @Override public K nextElement() { return super.nextEntry().key(); } @@ -1204,10 +1210,12 @@ public final class ConcurrentHashMap extends AbstractMap final class ValueIterator extends HashIterator implements ReusableIterator, Enumeration { + @Override public V next() { return super.nextEntry().value(); } + @Override public V nextElement() { return super.nextEntry().value(); } @@ -1234,14 +1242,17 @@ public final class ConcurrentHashMap extends AbstractMap } + @Override public K getKey() { return key; } + @Override public V getValue() { return value; } + @Override public V setValue(V value) { V oldValue = this.value; this.value = value; @@ -1306,6 +1317,7 @@ public final class ConcurrentHashMap extends AbstractMap final class EntryIterator extends HashIterator implements ReusableIterator> { + @Override public Map.Entry next() { HashEntry e = super.nextEntry(); return new WriteThroughEntry(e.key(), e.value()); diff --git a/src/main/java/org/jboss/netty/util/internal/ConcurrentIdentityHashMap.java b/src/main/java/org/jboss/netty/util/internal/ConcurrentIdentityHashMap.java index a83f938528..d0ab933c50 100644 --- a/src/main/java/org/jboss/netty/util/internal/ConcurrentIdentityHashMap.java +++ b/src/main/java/org/jboss/netty/util/internal/ConcurrentIdentityHashMap.java @@ -929,6 +929,7 @@ public final class ConcurrentIdentityHashMap extends AbstractMap * null if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ + @Override public V putIfAbsent(K key, V value) { if (value == null) { throw new NullPointerException(); @@ -971,6 +972,7 @@ public final class ConcurrentIdentityHashMap extends AbstractMap * * @throws NullPointerException if the specified key is null */ + @Override public boolean remove(Object key, Object value) { int hash = hashOf(key); if (value == null) { @@ -984,6 +986,7 @@ public final class ConcurrentIdentityHashMap extends AbstractMap * * @throws NullPointerException if any of the arguments are null */ + @Override public boolean replace(K key, V oldValue, V newValue) { if (oldValue == null || newValue == null) { throw new NullPointerException(); @@ -999,6 +1002,7 @@ public final class ConcurrentIdentityHashMap extends AbstractMap * null if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ + @Override public V replace(K key, V value) { if (value == null) { throw new NullPointerException(); @@ -1192,10 +1196,12 @@ public final class ConcurrentIdentityHashMap extends AbstractMap final class KeyIterator extends HashIterator implements ReusableIterator, Enumeration { + @Override public K next() { return super.nextEntry().key(); } + @Override public K nextElement() { return super.nextEntry().key(); } @@ -1204,10 +1210,12 @@ public final class ConcurrentIdentityHashMap extends AbstractMap final class ValueIterator extends HashIterator implements ReusableIterator, Enumeration { + @Override public V next() { return super.nextEntry().value(); } + @Override public V nextElement() { return super.nextEntry().value(); } @@ -1236,14 +1244,17 @@ public final class ConcurrentIdentityHashMap extends AbstractMap } + @Override public K getKey() { return key; } + @Override public V getValue() { return value; } + @Override public V setValue(V value) { V oldValue = this.value; this.value = value; @@ -1308,6 +1319,7 @@ public final class ConcurrentIdentityHashMap extends AbstractMap final class EntryIterator extends HashIterator implements ReusableIterator> { + @Override public Map.Entry next() { HashEntry e = super.nextEntry(); return new WriteThroughEntry(e.key(), e.value()); diff --git a/src/main/java/org/jboss/netty/util/internal/ConcurrentIdentityWeakKeyHashMap.java b/src/main/java/org/jboss/netty/util/internal/ConcurrentIdentityWeakKeyHashMap.java index fd9ceb68f3..1c7f546cbb 100644 --- a/src/main/java/org/jboss/netty/util/internal/ConcurrentIdentityWeakKeyHashMap.java +++ b/src/main/java/org/jboss/netty/util/internal/ConcurrentIdentityWeakKeyHashMap.java @@ -992,6 +992,7 @@ public final class ConcurrentIdentityWeakKeyHashMap extends AbstractMapnull if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ + @Override public V putIfAbsent(K key, V value) { if (value == null) { throw new NullPointerException(); @@ -1034,6 +1035,7 @@ public final class ConcurrentIdentityWeakKeyHashMap extends AbstractMap extends AbstractMap extends AbstractMapnull if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ + @Override public V replace(K key, V value) { if (value == null) { throw new NullPointerException(); @@ -1272,10 +1276,12 @@ public final class ConcurrentIdentityWeakKeyHashMap extends AbstractMap, Enumeration { + @Override public K next() { return super.nextEntry().key(); } + @Override public K nextElement() { return super.nextEntry().key(); } @@ -1284,10 +1290,12 @@ public final class ConcurrentIdentityWeakKeyHashMap extends AbstractMap, Enumeration { + @Override public V next() { return super.nextEntry().value(); } + @Override public V nextElement() { return super.nextEntry().value(); } @@ -1314,14 +1322,17 @@ public final class ConcurrentIdentityWeakKeyHashMap extends AbstractMap extends AbstractMap> { + @Override public Map.Entry next() { HashEntry e = super.nextEntry(); return new WriteThroughEntry(e.key(), e.value()); diff --git a/src/main/java/org/jboss/netty/util/internal/ConcurrentWeakKeyHashMap.java b/src/main/java/org/jboss/netty/util/internal/ConcurrentWeakKeyHashMap.java index 010c4fe3cf..018e58b3cf 100644 --- a/src/main/java/org/jboss/netty/util/internal/ConcurrentWeakKeyHashMap.java +++ b/src/main/java/org/jboss/netty/util/internal/ConcurrentWeakKeyHashMap.java @@ -992,6 +992,7 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl * null if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ + @Override public V putIfAbsent(K key, V value) { if (value == null) { throw new NullPointerException(); @@ -1034,6 +1035,7 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl * * @throws NullPointerException if the specified key is null */ + @Override public boolean remove(Object key, Object value) { int hash = hashOf(key); if (value == null) { @@ -1047,6 +1049,7 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl * * @throws NullPointerException if any of the arguments are null */ + @Override public boolean replace(K key, V oldValue, V newValue) { if (oldValue == null || newValue == null) { throw new NullPointerException(); @@ -1062,6 +1065,7 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl * null if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ + @Override public V replace(K key, V value) { if (value == null) { throw new NullPointerException(); @@ -1272,10 +1276,12 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl final class KeyIterator extends HashIterator implements ReusableIterator, Enumeration { + @Override public K next() { return super.nextEntry().key(); } + @Override public K nextElement() { return super.nextEntry().key(); } @@ -1284,10 +1290,12 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl final class ValueIterator extends HashIterator implements ReusableIterator, Enumeration { + @Override public V next() { return super.nextEntry().value(); } + @Override public V nextElement() { return super.nextEntry().value(); } @@ -1314,14 +1322,17 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl } + @Override public K getKey() { return key; } + @Override public V getValue() { return value; } + @Override public V setValue(V value) { V oldValue = this.value; this.value = value; @@ -1386,6 +1397,7 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl final class EntryIterator extends HashIterator implements ReusableIterator> { + @Override public Map.Entry next() { HashEntry e = super.nextEntry(); return new WriteThroughEntry(e.key(), e.value()); diff --git a/src/main/java/org/jboss/netty/util/internal/IoWorkerRunnable.java b/src/main/java/org/jboss/netty/util/internal/IoWorkerRunnable.java index 10c71cb4cf..58821f3adc 100644 --- a/src/main/java/org/jboss/netty/util/internal/IoWorkerRunnable.java +++ b/src/main/java/org/jboss/netty/util/internal/IoWorkerRunnable.java @@ -40,6 +40,7 @@ public class IoWorkerRunnable implements Runnable { this.runnable = runnable; } + @Override public void run() { IN_IO_THREAD.set(Boolean.TRUE); try { diff --git a/src/main/java/org/jboss/netty/util/internal/LinkedTransferQueue.java b/src/main/java/org/jboss/netty/util/internal/LinkedTransferQueue.java index 33d303ba32..463c62529f 100644 --- a/src/main/java/org/jboss/netty/util/internal/LinkedTransferQueue.java +++ b/src/main/java/org/jboss/netty/util/internal/LinkedTransferQueue.java @@ -895,10 +895,12 @@ public class LinkedTransferQueue extends AbstractQueue advance(null); } + @Override public final boolean hasNext() { return nextNode != null; } + @Override public final E next() { Node p = nextNode; if (p == null) { @@ -909,6 +911,7 @@ public class LinkedTransferQueue extends AbstractQueue return e; } + @Override public final void remove() { Node p = lastRet; if (p == null) { @@ -1052,6 +1055,7 @@ public class LinkedTransferQueue extends AbstractQueue * * @throws NullPointerException if the specified element is null */ + @Override public void put(E e) { xfer(e, true, ASYNC, 0); } @@ -1065,6 +1069,7 @@ public class LinkedTransferQueue extends AbstractQueue * {@link BlockingQueue#offer(Object,long,TimeUnit) BlockingQueue.offer}) * @throws NullPointerException if the specified element is null */ + @Override public boolean offer(E e, long timeout, TimeUnit unit) { xfer(e, true, ASYNC, 0); return true; @@ -1078,6 +1083,7 @@ public class LinkedTransferQueue extends AbstractQueue * {@link BlockingQueue#offer(Object) BlockingQueue.offer}) * @throws NullPointerException if the specified element is null */ + @Override public boolean offer(E e) { xfer(e, true, ASYNC, 0); return true; @@ -1154,6 +1160,7 @@ public class LinkedTransferQueue extends AbstractQueue throw new InterruptedException(); } + @Override public E take() throws InterruptedException { E e = xfer(null, false, SYNC, 0); if (e != null) { @@ -1163,6 +1170,7 @@ public class LinkedTransferQueue extends AbstractQueue throw new InterruptedException(); } + @Override public E poll(long timeout, TimeUnit unit) throws InterruptedException { E e = xfer(null, false, TIMED, unit.toNanos(timeout)); if (e != null || !Thread.interrupted()) { @@ -1171,6 +1179,7 @@ public class LinkedTransferQueue extends AbstractQueue throw new InterruptedException(); } + @Override public E poll() { return xfer(null, false, NOW, 0); } @@ -1179,6 +1188,7 @@ public class LinkedTransferQueue extends AbstractQueue * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ + @Override public int drainTo(Collection c) { if (c == null) { throw new NullPointerException(); @@ -1199,6 +1209,7 @@ public class LinkedTransferQueue extends AbstractQueue * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ + @Override public int drainTo(Collection c, int maxElements) { if (c == null) { throw new NullPointerException(); @@ -1233,6 +1244,7 @@ public class LinkedTransferQueue extends AbstractQueue return new Itr(); } + @Override public E peek() { return firstDataItem(); } @@ -1300,6 +1312,7 @@ public class LinkedTransferQueue extends AbstractQueue * @return {@code Integer.MAX_VALUE} (as specified by * {@link BlockingQueue#remainingCapacity()}) */ + @Override public int remainingCapacity() { return Integer.MAX_VALUE; } diff --git a/src/main/java/org/jboss/netty/util/internal/NonReentrantLock.java b/src/main/java/org/jboss/netty/util/internal/NonReentrantLock.java index 164afaad68..b6aeb02625 100644 --- a/src/main/java/org/jboss/netty/util/internal/NonReentrantLock.java +++ b/src/main/java/org/jboss/netty/util/internal/NonReentrantLock.java @@ -32,23 +32,28 @@ public final class NonReentrantLock extends AbstractQueuedSynchronizer private Thread owner; + @Override public void lock() { acquire(1); } + @Override public void lockInterruptibly() throws InterruptedException { acquireInterruptibly(1); } + @Override public boolean tryLock() { return tryAcquire(1); } + @Override public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { return tryAcquireNanos(1, unit.toNanos(time)); } + @Override public void unlock() { release(1); } @@ -57,6 +62,7 @@ public final class NonReentrantLock extends AbstractQueuedSynchronizer return isHeldExclusively(); } + @Override public Condition newCondition() { return new ConditionObject(); } diff --git a/src/main/java/org/jboss/netty/util/internal/UnterminatableExecutor.java b/src/main/java/org/jboss/netty/util/internal/UnterminatableExecutor.java index e66b486060..37dfda8bef 100644 --- a/src/main/java/org/jboss/netty/util/internal/UnterminatableExecutor.java +++ b/src/main/java/org/jboss/netty/util/internal/UnterminatableExecutor.java @@ -35,6 +35,7 @@ public class UnterminatableExecutor implements Executor { this.executor = executor; } + @Override public void execute(Runnable command) { executor.execute(command); } diff --git a/src/test/java/org/jboss/netty/channel/CompleteChannelFutureTest.java b/src/test/java/org/jboss/netty/channel/CompleteChannelFutureTest.java index 24d952cdbc..7ac070df28 100644 --- a/src/test/java/org/jboss/netty/channel/CompleteChannelFutureTest.java +++ b/src/test/java/org/jboss/netty/channel/CompleteChannelFutureTest.java @@ -59,6 +59,7 @@ public class CompleteChannelFutureTest { @Test public void shouldNotRethrowListenerException() { ChannelFutureListener l = new ChannelFutureListener() { + @Override public void operationComplete(ChannelFuture future) throws Exception { throw new ExpectedError(); @@ -97,10 +98,12 @@ public class CompleteChannelFutureTest { super(channel); } + @Override public Throwable getCause() { throw new Error(); } + @Override public boolean isSuccess() { throw new Error(); } diff --git a/src/test/java/org/jboss/netty/handler/ssl/ImmediateExecutorTest.java b/src/test/java/org/jboss/netty/handler/ssl/ImmediateExecutorTest.java index 6f78e9e720..f3ac997901 100644 --- a/src/test/java/org/jboss/netty/handler/ssl/ImmediateExecutorTest.java +++ b/src/test/java/org/jboss/netty/handler/ssl/ImmediateExecutorTest.java @@ -34,6 +34,7 @@ public class ImmediateExecutorTest { ImmediateExecutor e = ImmediateExecutor.INSTANCE; long startTime = System.nanoTime(); e.execute(new Runnable() { + @Override public void run() { long startTime = System.nanoTime(); for (;;) { diff --git a/src/test/java/org/jboss/netty/util/DummyHandler.java b/src/test/java/org/jboss/netty/util/DummyHandler.java index 9881293872..4885f91a57 100644 --- a/src/test/java/org/jboss/netty/util/DummyHandler.java +++ b/src/test/java/org/jboss/netty/util/DummyHandler.java @@ -30,11 +30,13 @@ import org.jboss.netty.channel.ChannelUpstreamHandler; */ public class DummyHandler implements ChannelUpstreamHandler, ChannelDownstreamHandler { + @Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { ctx.sendUpstream(e); } + @Override public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { ctx.sendDownstream(e); diff --git a/src/test/java/org/jboss/netty/util/ThreadRenamingRunnableTest.java b/src/test/java/org/jboss/netty/util/ThreadRenamingRunnableTest.java index 28cba88126..0b5e98339a 100644 --- a/src/test/java/org/jboss/netty/util/ThreadRenamingRunnableTest.java +++ b/src/test/java/org/jboss/netty/util/ThreadRenamingRunnableTest.java @@ -43,6 +43,7 @@ public class ThreadRenamingRunnableTest { Executor e = new ImmediateExecutor(); e.execute(new ThreadRenamingRunnable( new Runnable() { + @Override public void run() { assertEquals(oldThreadName, Thread.currentThread().getName()); } @@ -57,6 +58,7 @@ public class ThreadRenamingRunnableTest { Executor e = new ImmediateExecutor(); e.execute(new ThreadRenamingRunnable( new Runnable() { + @Override public void run() { assertEquals(oldThreadName, Thread.currentThread().getName()); } @@ -71,6 +73,7 @@ public class ThreadRenamingRunnableTest { Executor e = new ImmediateExecutor(); e.execute(new ThreadRenamingRunnable( new Runnable() { + @Override public void run() { assertEquals("a b #c:d (e)", Thread.currentThread().getName()); assertFalse(oldThreadName.equals(Thread.currentThread().getName())); @@ -104,6 +107,7 @@ public class ThreadRenamingRunnableTest { try { e.execute(new ThreadRenamingRunnable( new Runnable() { + @Override public void run() { assertEquals(oldThreadName, Thread.currentThread().getName()); } @@ -120,6 +124,7 @@ public class ThreadRenamingRunnableTest { super(); } + @Override public void execute(Runnable command) { command.run(); }