Javadocs cleanup / added

This commit is contained in:
Norman Maurer 2013-03-10 21:07:19 +01:00
parent 0504a442ae
commit 0a1bc86569
8 changed files with 52 additions and 0 deletions

View File

@ -1123,6 +1123,10 @@ public abstract class AbstractByteBuf implements ByteBuf {
}
}
/**
* Should be called by every method that tries to access the buffers content to check
* if the buffer was released before.
*/
protected final void ensureAccessible() {
if (refCnt() == 0) {
throw new IllegalBufferAccessException();

View File

@ -19,6 +19,9 @@ import io.netty.util.internal.PlatformDependent;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
/**
* Abstract base class for classes wants to implement {@link ReferenceCounted}.
*/
public abstract class AbstractReferenceCounted implements ReferenceCounted {
private static final AtomicIntegerFieldUpdater<AbstractReferenceCounted> refCntUpdater =
@ -131,5 +134,8 @@ public abstract class AbstractReferenceCounted implements ReferenceCounted {
}
}
/**
* Called once {@link #refCnt()} is equals 0.
*/
protected abstract void deallocate();
}

View File

@ -139,5 +139,8 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf {
}
}
/**
* Called once {@link #refCnt()} is equals 0.
*/
protected abstract void deallocate();
}

View File

@ -94,18 +94,32 @@ public final class Unpooled {
*/
public static final ByteBuf EMPTY_BUFFER = ALLOC.buffer(0, 0);
/**
* Creates a new {@link MessageBuf} with reasonably small initial capacity, which
* expands its capacity boundlessly on demand.
*/
public static <T> MessageBuf<T> messageBuffer() {
return new DefaultMessageBuf<T>();
}
/**
* Creates a new {@link MessageBuf} with the specified {@code initialCapacity}.
*/
public static <T> MessageBuf<T> messageBuffer(int initialCapacity) {
return new DefaultMessageBuf<T>(initialCapacity);
}
/**
* Creates a new {@link MessageBuf} with the specified {@code initialCapacity} and
* {@code maxCapacity}.
*/
public static <T> MessageBuf<T> messageBuffer(int initialCapacity, int maxCapacity) {
return new DefaultMessageBuf<T>(initialCapacity, maxCapacity);
}
/**
* Creates a new {@link MessageBuf} which wraps the given {@code queue}.
*/
public static <T> MessageBuf<T> wrappedBuffer(Queue<T> queue) {
if (queue instanceof MessageBuf) {
return (MessageBuf<T>) queue;

View File

@ -22,9 +22,18 @@ import io.netty.util.internal.PlatformDependent;
*/
public final class UnpooledByteBufAllocator extends AbstractByteBufAllocator {
/**
* Default instance
*/
public static final UnpooledByteBufAllocator DEFAULT =
new UnpooledByteBufAllocator(PlatformDependent.directBufferPreferred());
/**
* Create a new instance
*
* @param preferDirect {@code true} if {@link #buffer(int)} should try to allocate a direct buffer rather than
* a heap buffer
*/
public UnpooledByteBufAllocator(boolean preferDirect) {
super(preferDirect);
}

View File

@ -16,6 +16,9 @@
package io.netty.channel;
/**
* Skelton implementation of a {@link ChannelHandler}.
*/
public abstract class ChannelHandlerAdapter implements ChannelHandler {
// Not using volatile because it's used only for a sanity check.

View File

@ -23,6 +23,9 @@ import io.netty.util.Signal;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
/**
* Utility methods for use within your {@link ChannelHandler} implementation.
*/
public final class ChannelHandlerUtil {
public static final Signal ABORT = new Signal(ChannelHandlerUtil.class.getName() + ".ABORT");

View File

@ -17,6 +17,10 @@ package io.netty.channel;
import java.net.SocketAddress;
/**
* Skelton implementation of a {@link ChannelOperationHandler}. This implementation just forwards each method call via
* the {@link ChannelHandlerContext}.
*/
public abstract class ChannelOperationHandlerAdapter extends ChannelHandlerAdapter implements ChannelOperationHandler {
/**
@ -79,6 +83,12 @@ public abstract class ChannelOperationHandlerAdapter extends ChannelHandlerAdapt
ctx.deregister(promise);
}
/**
* Calls {@link ChannelHandlerContext#read()} to forward
* to the next {@link ChannelOperationHandler} in the {@link ChannelPipeline}.
*
* Sub-classes may override this method to change behavior.
*/
@Override
public void read(ChannelHandlerContext ctx) {
ctx.read();