Repository: mina Updated Branches: refs/heads/2.0 fed4aed8e -> 894c28cfc
Added some missing Javadoc Project: http://git-wip-us.apache.org/repos/asf/mina/repo Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/894c28cf Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/894c28cf Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/894c28cf Branch: refs/heads/2.0 Commit: 894c28cfc5671aceab00b1de837e1f4dd5334bb2 Parents: fed4aed Author: Emmanuel Lécharny <elecha...@symas.com> Authored: Wed Nov 30 14:48:33 2016 +0100 Committer: Emmanuel Lécharny <elecha...@symas.com> Committed: Wed Nov 30 14:48:33 2016 +0100 ---------------------------------------------------------------------- .../mina/core/buffer/AbstractIoBuffer.java | 49 +- .../mina/core/buffer/BufferDataException.java | 18 + .../mina/core/buffer/CachedBufferAllocator.java | 18 +- .../org/apache/mina/core/buffer/IoBuffer.java | 21 +- .../mina/core/buffer/IoBufferHexDumper.java | 2 +- .../mina/core/buffer/IoBufferWrapper.java | 520 +++++++++++++++++++ .../core/session/ExpiringSessionRecycler.java | 21 +- .../mina/core/session/IoSessionRecycler.java | 4 +- 8 files changed, 605 insertions(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina/blob/894c28cf/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java b/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java index 2d19ce9..db434cf 100644 --- a/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java +++ b/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java @@ -522,6 +522,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public IoBuffer putUnsigned(byte value) { autoExpand(1); buf().put((byte) (value & 0xff)); @@ -531,6 +532,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public IoBuffer putUnsigned(int index, byte value) { autoExpand(index, 1); buf().put(index, (byte) (value & 0xff)); @@ -540,6 +542,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public IoBuffer putUnsigned(short value) { autoExpand(1); buf().put((byte) (value & 0x00ff)); @@ -549,6 +552,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public IoBuffer putUnsigned(int index, short value) { autoExpand(index, 1); buf().put(index, (byte) (value & 0x00ff)); @@ -558,6 +562,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public IoBuffer putUnsigned(int value) { autoExpand(1); buf().put((byte) (value & 0x000000ff)); @@ -567,6 +572,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public IoBuffer putUnsigned(int index, int value) { autoExpand(index, 1); buf().put(index, (byte) (value & 0x000000ff)); @@ -576,6 +582,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public IoBuffer putUnsigned(long value) { autoExpand(1); buf().put((byte) (value & 0x00000000000000ffL)); @@ -585,6 +592,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public IoBuffer putUnsigned(int index, long value) { autoExpand(index, 1); buf().put(index, (byte) (value & 0x00000000000000ffL)); @@ -828,7 +836,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { @Override public final IoBuffer putUnsignedInt(byte value) { autoExpand(4); - buf().putInt((value & 0x00ff)); + buf().putInt(value & 0x00ff); return this; } @@ -838,7 +846,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { @Override public final IoBuffer putUnsignedInt(int index, byte value) { autoExpand(index, 4); - buf().putInt(index, (value & 0x00ff)); + buf().putInt(index, value & 0x00ff); return this; } @@ -848,7 +856,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { @Override public final IoBuffer putUnsignedInt(short value) { autoExpand(4); - buf().putInt((value & 0x0000ffff)); + buf().putInt(value & 0x0000ffff); return this; } @@ -858,7 +866,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { @Override public final IoBuffer putUnsignedInt(int index, short value) { autoExpand(index, 4); - buf().putInt(index, (value & 0x0000ffff)); + buf().putInt(index, value & 0x0000ffff); return this; } @@ -1289,6 +1297,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public int compareTo(IoBuffer that) { int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { @@ -1438,9 +1447,6 @@ public abstract class AbstractIoBuffer extends IoBuffer { return b3 << 16 | b2 << 8 | b1; } - /** - * {@inheritDoc} - */ private int getMediumInt(byte b1, byte b2, byte b3) { int ret = b1 << 16 & 0xff0000 | b2 << 8 & 0xff00 | b3 & 0xff; // Check to see if the medium int is negative (high bit in b1 set) @@ -2168,10 +2174,8 @@ public abstract class AbstractIoBuffer extends IoBuffer { int oldLimit = limit(); limit(position() + length); - ObjectInputStream in = null; - try { - in = new ObjectInputStream(asInputStream()) { + try (ObjectInputStream in = new ObjectInputStream(asInputStream()) { @Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { int type = read(); @@ -2205,19 +2209,11 @@ public abstract class AbstractIoBuffer extends IoBuffer { return clazz; } } - }; + }) { return in.readObject(); } catch (IOException e) { throw new BufferDataException(e); } finally { - try { - if (in != null) { - in.close(); - } - } catch (IOException ioe) { - // Nothing to do - } - limit(oldLimit); } } @@ -2229,10 +2225,8 @@ public abstract class AbstractIoBuffer extends IoBuffer { public IoBuffer putObject(Object o) { int oldPos = position(); skip(4); // Make a room for the length field. - ObjectOutputStream out = null; - try { - out = new ObjectOutputStream(asOutputStream()) { + try (ObjectOutputStream out = new ObjectOutputStream(asOutputStream()) { @Override protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException { Class<?> clazz = desc.forClass(); @@ -2246,19 +2240,11 @@ public abstract class AbstractIoBuffer extends IoBuffer { writeUTF(desc.getName()); } } - }; + }) { out.writeObject(o); out.flush(); } catch (IOException e) { throw new BufferDataException(e); - } finally { - try { - if (out != null) { - out.close(); - } - } catch (IOException ioe) { - // Nothing to do - } } // Fill the length field @@ -2496,6 +2482,7 @@ public abstract class AbstractIoBuffer extends IoBuffer { /** * {@inheritDoc} */ + @Override public <E extends Enum<E>> E getEnumInt(int index, Class<E> enumClass) { return toEnum(enumClass, getInt(index)); } http://git-wip-us.apache.org/repos/asf/mina/blob/894c28cf/mina-core/src/main/java/org/apache/mina/core/buffer/BufferDataException.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/buffer/BufferDataException.java b/mina-core/src/main/java/org/apache/mina/core/buffer/BufferDataException.java index 93f9c62..07ea614 100644 --- a/mina-core/src/main/java/org/apache/mina/core/buffer/BufferDataException.java +++ b/mina-core/src/main/java/org/apache/mina/core/buffer/BufferDataException.java @@ -29,18 +29,36 @@ package org.apache.mina.core.buffer; public class BufferDataException extends RuntimeException { private static final long serialVersionUID = -4138189188602563502L; + /** + * Create a new BufferDataException instance + */ public BufferDataException() { super(); } + /** + * Create a new BufferDataException instance + * + * @param message The exception message + */ public BufferDataException(String message) { super(message); } + /** + * Create a new BufferDataException instance + * + * @param message The exception message + * @param cause The original cause + */ public BufferDataException(String message, Throwable cause) { super(message, cause); } + /** + * Create a new BufferDataException instance + * @param cause The original cause + */ public BufferDataException(Throwable cause) { super(cause); } http://git-wip-us.apache.org/repos/asf/mina/blob/894c28cf/mina-core/src/main/java/org/apache/mina/core/buffer/CachedBufferAllocator.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/buffer/CachedBufferAllocator.java b/mina-core/src/main/java/org/apache/mina/core/buffer/CachedBufferAllocator.java index 30b47aa..991a872 100644 --- a/mina-core/src/main/java/org/apache/mina/core/buffer/CachedBufferAllocator.java +++ b/mina-core/src/main/java/org/apache/mina/core/buffer/CachedBufferAllocator.java @@ -133,7 +133,7 @@ public class CachedBufferAllocator implements IoBufferAllocator { } Map<Integer, Queue<CachedBuffer>> newPoolMap() { - Map<Integer, Queue<CachedBuffer>> poolMap = new HashMap<Integer, Queue<CachedBuffer>>(); + Map<Integer, Queue<CachedBuffer>> poolMap = new HashMap<>(); for (int i = 0; i < 31; i++) { poolMap.put(1 << i, new ConcurrentLinkedQueue<CachedBuffer>()); @@ -145,6 +145,10 @@ public class CachedBufferAllocator implements IoBufferAllocator { return poolMap; } + /** + * {@inheritDoc} + */ + @Override public IoBuffer allocate(int requestedCapacity, boolean direct) { int actualCapacity = IoBuffer.normalizeCapacity(requestedCapacity); IoBuffer buf; @@ -184,14 +188,26 @@ public class CachedBufferAllocator implements IoBufferAllocator { return buf; } + /** + * {@inheritDoc} + */ + @Override public ByteBuffer allocateNioBuffer(int capacity, boolean direct) { return allocate(capacity, direct).buf(); } + /** + * {@inheritDoc} + */ + @Override public IoBuffer wrap(ByteBuffer nioBuffer) { return new CachedBuffer(nioBuffer); } + /** + * {@inheritDoc} + */ + @Override public void dispose() { // Do nothing } http://git-wip-us.apache.org/repos/asf/mina/blob/894c28cf/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java b/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java index 7372ab7..819f7fd 100644 --- a/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java +++ b/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java @@ -153,6 +153,14 @@ public abstract class IoBuffer implements Comparable<IoBuffer> { private static boolean useDirectBuffer = false; /** + * Creates a new instance. This is an empty constructor. It's protected, + * to forbid its usage by the users. + */ + protected IoBuffer() { + // Do nothing + } + + /** * @return the allocator used by existing and new buffers */ public static IoBufferAllocator getAllocator() { @@ -284,14 +292,6 @@ public abstract class IoBuffer implements Comparable<IoBuffer> { } /** - * Creates a new instance. This is an empty constructor. It's protected, - * to forbid its usage by the users. - */ - protected IoBuffer() { - // Do nothing - } - - /** * Declares this buffer and all its derived buffers are not used anymore so * that it can be reused by some {@link IoBufferAllocator} implementations. * It is not mandatory to call this method, but you might want to invoke @@ -1326,9 +1326,6 @@ public abstract class IoBuffer implements Comparable<IoBuffer> { * * @param index the position in the buffer to write the value * @param value the int to write - * - * @param index The position where to put the unsigned short - * @param value The unsigned short to put in the IoBuffer * @return the modified IoBuffer */ public abstract IoBuffer putUnsignedShort(int index, int value); @@ -1372,7 +1369,6 @@ public abstract class IoBuffer implements Comparable<IoBuffer> { * @param index The position where to put the int * @param value The int to put in the IoBuffer * @return the modified IoBuffer - * @return the modified IoBuffer */ public abstract IoBuffer putInt(int index, int value); @@ -1412,7 +1408,6 @@ public abstract class IoBuffer implements Comparable<IoBuffer> { * @param index The position where to put the long * @param value The long to put in the IoBuffer * @return the modified IoBuffer - * @return the modified IoBuffer */ public abstract IoBuffer putLong(int index, long value); http://git-wip-us.apache.org/repos/asf/mina/blob/894c28cf/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferHexDumper.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferHexDumper.java b/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferHexDumper.java index 720ef3b..0a9e41f 100644 --- a/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferHexDumper.java +++ b/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferHexDumper.java @@ -60,7 +60,7 @@ class IoBufferHexDumper { * * @param in the buffer to dump * @param lengthLimit the limit at which hex dumping will stop - * @return a hex formatted string representation of the <i>in</i> {@link Iobuffer}. + * @return a hex formatted string representation of the <i>in</i> {@link IoBuffer}. */ public static String getHexdump(IoBuffer in, int lengthLimit) { if (lengthLimit == 0) { http://git-wip-us.apache.org/repos/asf/mina/blob/894c28cf/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferWrapper.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferWrapper.java b/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferWrapper.java index 78ddaf9..600db21 100644 --- a/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferWrapper.java +++ b/mina-core/src/main/java/org/apache/mina/core/buffer/IoBufferWrapper.java @@ -70,530 +70,819 @@ public class IoBufferWrapper extends IoBuffer { return buf; } + /** + * {@inheritDoc} + */ @Override public boolean isDirect() { return buf.isDirect(); } + /** + * {@inheritDoc} + */ @Override public ByteBuffer buf() { return buf.buf(); } + /** + * {@inheritDoc} + */ @Override public int capacity() { return buf.capacity(); } + /** + * {@inheritDoc} + */ @Override public int position() { return buf.position(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer position(int newPosition) { buf.position(newPosition); return this; } + /** + * {@inheritDoc} + */ @Override public int limit() { return buf.limit(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer limit(int newLimit) { buf.limit(newLimit); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer mark() { buf.mark(); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer reset() { buf.reset(); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer clear() { buf.clear(); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer sweep() { buf.sweep(); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer sweep(byte value) { buf.sweep(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer flip() { buf.flip(); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer rewind() { buf.rewind(); return this; } + /** + * {@inheritDoc} + */ @Override public int remaining() { return buf.remaining(); } + /** + * {@inheritDoc} + */ @Override public boolean hasRemaining() { return buf.hasRemaining(); } + /** + * {@inheritDoc} + */ @Override public byte get() { return buf.get(); } + /** + * {@inheritDoc} + */ @Override public short getUnsigned() { return buf.getUnsigned(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer put(byte b) { buf.put(b); return this; } + /** + * {@inheritDoc} + */ @Override public byte get(int index) { return buf.get(index); } + /** + * {@inheritDoc} + */ @Override public short getUnsigned(int index) { return buf.getUnsigned(index); } + /** + * {@inheritDoc} + */ @Override public IoBuffer put(int index, byte b) { buf.put(index, b); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer get(byte[] dst, int offset, int length) { buf.get(dst, offset, length); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer getSlice(int index, int length) { return buf.getSlice(index, length); } + /** + * {@inheritDoc} + */ @Override public IoBuffer getSlice(int length) { return buf.getSlice(length); } + /** + * {@inheritDoc} + */ @Override public IoBuffer get(byte[] dst) { buf.get(dst); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer put(IoBuffer src) { buf.put(src); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer put(ByteBuffer src) { buf.put(src); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer put(byte[] src, int offset, int length) { buf.put(src, offset, length); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer put(byte[] src) { buf.put(src); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer compact() { buf.compact(); return this; } + /** + * {@inheritDoc} + */ @Override public String toString() { return buf.toString(); } + /** + * {@inheritDoc} + */ @Override public int hashCode() { return buf.hashCode(); } + /** + * {@inheritDoc} + */ @Override public boolean equals(Object ob) { return buf.equals(ob); } + /** + * {@inheritDoc} + */ + @Override public int compareTo(IoBuffer that) { return buf.compareTo(that); } + /** + * {@inheritDoc} + */ @Override public ByteOrder order() { return buf.order(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer order(ByteOrder bo) { buf.order(bo); return this; } + /** + * {@inheritDoc} + */ @Override public char getChar() { return buf.getChar(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putChar(char value) { buf.putChar(value); return this; } + /** + * {@inheritDoc} + */ @Override public char getChar(int index) { return buf.getChar(index); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putChar(int index, char value) { buf.putChar(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public CharBuffer asCharBuffer() { return buf.asCharBuffer(); } + /** + * {@inheritDoc} + */ @Override public short getShort() { return buf.getShort(); } + /** + * {@inheritDoc} + */ @Override public int getUnsignedShort() { return buf.getUnsignedShort(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putShort(short value) { buf.putShort(value); return this; } + /** + * {@inheritDoc} + */ @Override public short getShort(int index) { return buf.getShort(index); } + /** + * {@inheritDoc} + */ @Override public int getUnsignedShort(int index) { return buf.getUnsignedShort(index); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putShort(int index, short value) { buf.putShort(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public ShortBuffer asShortBuffer() { return buf.asShortBuffer(); } + /** + * {@inheritDoc} + */ @Override public int getInt() { return buf.getInt(); } + /** + * {@inheritDoc} + */ @Override public long getUnsignedInt() { return buf.getUnsignedInt(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putInt(int value) { buf.putInt(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedInt(byte value) { buf.putUnsignedInt(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedInt(int index, byte value) { buf.putUnsignedInt(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedInt(short value) { buf.putUnsignedInt(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedInt(int index, short value) { buf.putUnsignedInt(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedInt(int value) { buf.putUnsignedInt(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedInt(int index, int value) { buf.putUnsignedInt(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedInt(long value) { buf.putUnsignedInt(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedInt(int index, long value) { buf.putUnsignedInt(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedShort(byte value) { buf.putUnsignedShort(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedShort(int index, byte value) { buf.putUnsignedShort(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedShort(short value) { buf.putUnsignedShort(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedShort(int index, short value) { buf.putUnsignedShort(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedShort(int value) { buf.putUnsignedShort(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedShort(int index, int value) { buf.putUnsignedShort(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedShort(long value) { buf.putUnsignedShort(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsignedShort(int index, long value) { buf.putUnsignedShort(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public int getInt(int index) { return buf.getInt(index); } + /** + * {@inheritDoc} + */ @Override public long getUnsignedInt(int index) { return buf.getUnsignedInt(index); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putInt(int index, int value) { buf.putInt(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IntBuffer asIntBuffer() { return buf.asIntBuffer(); } + /** + * {@inheritDoc} + */ @Override public long getLong() { return buf.getLong(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putLong(long value) { buf.putLong(value); return this; } + /** + * {@inheritDoc} + */ @Override public long getLong(int index) { return buf.getLong(index); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putLong(int index, long value) { buf.putLong(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public LongBuffer asLongBuffer() { return buf.asLongBuffer(); } + /** + * {@inheritDoc} + */ @Override public float getFloat() { return buf.getFloat(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putFloat(float value) { buf.putFloat(value); return this; } + /** + * {@inheritDoc} + */ @Override public float getFloat(int index) { return buf.getFloat(index); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putFloat(int index, float value) { buf.putFloat(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public FloatBuffer asFloatBuffer() { return buf.asFloatBuffer(); } + /** + * {@inheritDoc} + */ @Override public double getDouble() { return buf.getDouble(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putDouble(double value) { buf.putDouble(value); return this; } + /** + * {@inheritDoc} + */ @Override public double getDouble(int index) { return buf.getDouble(index); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putDouble(int index, double value) { buf.putDouble(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public DoubleBuffer asDoubleBuffer() { return buf.asDoubleBuffer(); } + /** + * {@inheritDoc} + */ @Override public String getHexDump() { return buf.getHexDump(); } + /** + * {@inheritDoc} + */ @Override public String getString(int fieldSize, CharsetDecoder decoder) throws CharacterCodingException { return buf.getString(fieldSize, decoder); } + /** + * {@inheritDoc} + */ @Override public String getString(CharsetDecoder decoder) throws CharacterCodingException { return buf.getString(decoder); } + /** + * {@inheritDoc} + */ @Override public String getPrefixedString(CharsetDecoder decoder) throws CharacterCodingException { return buf.getPrefixedString(decoder); } + /** + * {@inheritDoc} + */ @Override public String getPrefixedString(int prefixLength, CharsetDecoder decoder) throws CharacterCodingException { return buf.getPrefixedString(prefixLength, decoder); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putString(CharSequence in, int fieldSize, CharsetEncoder encoder) throws CharacterCodingException { buf.putString(in, fieldSize, encoder); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putString(CharSequence in, CharsetEncoder encoder) throws CharacterCodingException { buf.putString(in, encoder); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putPrefixedString(CharSequence in, CharsetEncoder encoder) throws CharacterCodingException { buf.putPrefixedString(in, encoder); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putPrefixedString(CharSequence in, int prefixLength, CharsetEncoder encoder) throws CharacterCodingException { @@ -601,6 +890,9 @@ public class IoBufferWrapper extends IoBuffer { return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putPrefixedString(CharSequence in, int prefixLength, int padding, CharsetEncoder encoder) throws CharacterCodingException { @@ -608,6 +900,9 @@ public class IoBufferWrapper extends IoBuffer { return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putPrefixedString(CharSequence in, int prefixLength, int padding, byte padValue, CharsetEncoder encoder) throws CharacterCodingException { @@ -615,263 +910,410 @@ public class IoBufferWrapper extends IoBuffer { return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer skip(int size) { buf.skip(size); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer fill(byte value, int size) { buf.fill(value, size); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer fillAndReset(byte value, int size) { buf.fillAndReset(value, size); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer fill(int size) { buf.fill(size); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer fillAndReset(int size) { buf.fillAndReset(size); return this; } + /** + * {@inheritDoc} + */ @Override public boolean isAutoExpand() { return buf.isAutoExpand(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer setAutoExpand(boolean autoExpand) { buf.setAutoExpand(autoExpand); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer expand(int pos, int expectedRemaining) { buf.expand(pos, expectedRemaining); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer expand(int expectedRemaining) { buf.expand(expectedRemaining); return this; } + /** + * {@inheritDoc} + */ @Override public Object getObject() throws ClassNotFoundException { return buf.getObject(); } + /** + * {@inheritDoc} + */ @Override public Object getObject(ClassLoader classLoader) throws ClassNotFoundException { return buf.getObject(classLoader); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putObject(Object o) { buf.putObject(o); return this; } + /** + * {@inheritDoc} + */ @Override public InputStream asInputStream() { return buf.asInputStream(); } + /** + * {@inheritDoc} + */ @Override public OutputStream asOutputStream() { return buf.asOutputStream(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer duplicate() { return buf.duplicate(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer slice() { return buf.slice(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer asReadOnlyBuffer() { return buf.asReadOnlyBuffer(); } + /** + * {@inheritDoc} + */ @Override public byte[] array() { return buf.array(); } + /** + * {@inheritDoc} + */ @Override public int arrayOffset() { return buf.arrayOffset(); } + /** + * {@inheritDoc} + */ @Override public int minimumCapacity() { return buf.minimumCapacity(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer minimumCapacity(int minimumCapacity) { buf.minimumCapacity(minimumCapacity); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer capacity(int newCapacity) { buf.capacity(newCapacity); return this; } + /** + * {@inheritDoc} + */ @Override public boolean isReadOnly() { return buf.isReadOnly(); } + /** + * {@inheritDoc} + */ @Override public int markValue() { return buf.markValue(); } + /** + * {@inheritDoc} + */ @Override public boolean hasArray() { return buf.hasArray(); } + /** + * {@inheritDoc} + */ @Override public void free() { buf.free(); } + /** + * {@inheritDoc} + */ @Override public boolean isDerived() { return buf.isDerived(); } + /** + * {@inheritDoc} + */ @Override public boolean isAutoShrink() { return buf.isAutoShrink(); } + /** + * {@inheritDoc} + */ @Override public IoBuffer setAutoShrink(boolean autoShrink) { buf.setAutoShrink(autoShrink); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer shrink() { buf.shrink(); return this; } + /** + * {@inheritDoc} + */ @Override public int getMediumInt() { return buf.getMediumInt(); } + /** + * {@inheritDoc} + */ @Override public int getUnsignedMediumInt() { return buf.getUnsignedMediumInt(); } + /** + * {@inheritDoc} + */ @Override public int getMediumInt(int index) { return buf.getMediumInt(index); } + /** + * {@inheritDoc} + */ @Override public int getUnsignedMediumInt(int index) { return buf.getUnsignedMediumInt(index); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putMediumInt(int value) { buf.putMediumInt(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putMediumInt(int index, int value) { buf.putMediumInt(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public String getHexDump(int lengthLimit) { return buf.getHexDump(lengthLimit); } + /** + * {@inheritDoc} + */ @Override public boolean prefixedDataAvailable(int prefixLength) { return buf.prefixedDataAvailable(prefixLength); } + /** + * {@inheritDoc} + */ @Override public boolean prefixedDataAvailable(int prefixLength, int maxDataLength) { return buf.prefixedDataAvailable(prefixLength, maxDataLength); } + /** + * {@inheritDoc} + */ @Override public int indexOf(byte b) { return buf.indexOf(b); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> E getEnum(Class<E> enumClass) { return buf.getEnum(enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> E getEnum(int index, Class<E> enumClass) { return buf.getEnum(index, enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> E getEnumShort(Class<E> enumClass) { return buf.getEnumShort(enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> E getEnumShort(int index, Class<E> enumClass) { return buf.getEnumShort(index, enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> E getEnumInt(Class<E> enumClass) { return buf.getEnumInt(enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> E getEnumInt(int index, Class<E> enumClass) { return buf.getEnumInt(index, enumClass); } + /** + * {@inheritDoc} + */ @Override public IoBuffer putEnum(Enum<?> e) { buf.putEnum(e); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putEnum(int index, Enum<?> e) { buf.putEnum(index, e); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putEnumShort(Enum<?> e) { buf.putEnumShort(e); @@ -884,112 +1326,172 @@ public class IoBufferWrapper extends IoBuffer { return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putEnumInt(Enum<?> e) { buf.putEnumInt(e); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putEnumInt(int index, Enum<?> e) { buf.putEnumInt(index, e); return this; } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> EnumSet<E> getEnumSet(Class<E> enumClass) { return buf.getEnumSet(enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> EnumSet<E> getEnumSet(int index, Class<E> enumClass) { return buf.getEnumSet(index, enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> EnumSet<E> getEnumSetShort(Class<E> enumClass) { return buf.getEnumSetShort(enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> EnumSet<E> getEnumSetShort(int index, Class<E> enumClass) { return buf.getEnumSetShort(index, enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> EnumSet<E> getEnumSetInt(Class<E> enumClass) { return buf.getEnumSetInt(enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> EnumSet<E> getEnumSetInt(int index, Class<E> enumClass) { return buf.getEnumSetInt(index, enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> EnumSet<E> getEnumSetLong(Class<E> enumClass) { return buf.getEnumSetLong(enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> EnumSet<E> getEnumSetLong(int index, Class<E> enumClass) { return buf.getEnumSetLong(index, enumClass); } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> IoBuffer putEnumSet(Set<E> set) { buf.putEnumSet(set); return this; } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> IoBuffer putEnumSet(int index, Set<E> set) { buf.putEnumSet(index, set); return this; } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> IoBuffer putEnumSetShort(Set<E> set) { buf.putEnumSetShort(set); return this; } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> IoBuffer putEnumSetShort(int index, Set<E> set) { buf.putEnumSetShort(index, set); return this; } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> IoBuffer putEnumSetInt(Set<E> set) { buf.putEnumSetInt(set); return this; } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> IoBuffer putEnumSetInt(int index, Set<E> set) { buf.putEnumSetInt(index, set); return this; } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> IoBuffer putEnumSetLong(Set<E> set) { buf.putEnumSetLong(set); return this; } + /** + * {@inheritDoc} + */ @Override public <E extends Enum<E>> IoBuffer putEnumSetLong(int index, Set<E> set) { buf.putEnumSetLong(index, set); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsigned(byte value) { buf.putUnsigned(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsigned(int index, byte value) { buf.putUnsigned(index, value); @@ -997,35 +1499,53 @@ public class IoBufferWrapper extends IoBuffer { } @Override + /** + * {@inheritDoc} + */ public IoBuffer putUnsigned(short value) { buf.putUnsigned(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsigned(int index, short value) { buf.putUnsigned(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsigned(int value) { buf.putUnsigned(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsigned(int index, int value) { buf.putUnsigned(index, value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsigned(long value) { buf.putUnsigned(value); return this; } + /** + * {@inheritDoc} + */ @Override public IoBuffer putUnsigned(int index, long value) { buf.putUnsigned(index, value); http://git-wip-us.apache.org/repos/asf/mina/blob/894c28cf/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java b/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java index f38f499..430d3c3 100644 --- a/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java +++ b/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java @@ -34,18 +34,33 @@ public class ExpiringSessionRecycler implements IoSessionRecycler { /** A map used to store the session */ private ExpiringMap<SocketAddress, IoSession> sessionMap; + /** A map used to keep a track of the expiration */ private ExpiringMap<SocketAddress, IoSession>.Expirer mapExpirer; + /** + * Create a new ExpiringSessionRecycler instance + */ public ExpiringSessionRecycler() { this(ExpiringMap.DEFAULT_TIME_TO_LIVE); } + /** + * Create a new ExpiringSessionRecycler instance + * + * @param timeToLive The delay after which the session is going to be recycled + */ public ExpiringSessionRecycler(int timeToLive) { this(timeToLive, ExpiringMap.DEFAULT_EXPIRATION_INTERVAL); } + /** + * Create a new ExpiringSessionRecycler instance + * + * @param timeToLive The delay after which the session is going to be recycled + * @param expirationInterval + */ public ExpiringSessionRecycler(int timeToLive, int expirationInterval) { - sessionMap = new ExpiringMap<SocketAddress, IoSession>(timeToLive, expirationInterval); + sessionMap = new ExpiringMap<>(timeToLive, expirationInterval); mapExpirer = sessionMap.getExpirer(); sessionMap.addExpirationListener(new DefaultExpirationListener()); } @@ -53,6 +68,7 @@ public class ExpiringSessionRecycler implements IoSessionRecycler { /** * {@inheritDoc} */ + @Override public void put(IoSession session) { mapExpirer.startExpiringIfNotStarted(); @@ -66,6 +82,7 @@ public class ExpiringSessionRecycler implements IoSessionRecycler { /** * {@inheritDoc} */ + @Override public IoSession recycle(SocketAddress remoteAddress) { return sessionMap.get(remoteAddress); } @@ -73,6 +90,7 @@ public class ExpiringSessionRecycler implements IoSessionRecycler { /** * {@inheritDoc} */ + @Override public void remove(IoSession session) { sessionMap.remove(session.getRemoteAddress()); } @@ -98,6 +116,7 @@ public class ExpiringSessionRecycler implements IoSessionRecycler { } private class DefaultExpirationListener implements ExpirationListener<IoSession> { + @Override public void expired(IoSession expiredSession) { expiredSession.closeNow(); } http://git-wip-us.apache.org/repos/asf/mina/blob/894c28cf/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java b/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java index 55d7dcd..f7c3b21 100644 --- a/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java +++ b/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java @@ -28,7 +28,6 @@ import org.apache.mina.core.service.IoService; * {@link IoSessionRecycler} to an {@link IoService}. * * @author <a href="http://mina.apache.org">Apache MINA Project</a> - * TODO More documentation */ public interface IoSessionRecycler { /** @@ -40,6 +39,7 @@ public interface IoSessionRecycler { /** * {@inheritDoc} */ + @Override public void put(IoSession session) { // Do nothing } @@ -47,6 +47,7 @@ public interface IoSessionRecycler { /** * {@inheritDoc} */ + @Override public IoSession recycle(SocketAddress remoteAddress) { return null; } @@ -54,6 +55,7 @@ public interface IoSessionRecycler { /** * {@inheritDoc} */ + @Override public void remove(IoSession session) { // Do nothing }