From b17a7656152a9982d69f94d2e87ea6b5cf4b2680 Mon Sep 17 00:00:00 2001 From: Michael Nitschinger Date: Mon, 9 Dec 2013 08:15:31 +0100 Subject: [PATCH] codec-memcache: prefix abstract classes with Abstract. --- ...java => AbstractMemcacheObjectAggregator.java} | 9 +++++---- ...er.java => AbstractMemcacheObjectDecoder.java} | 2 +- ...er.java => AbstractMemcacheObjectEncoder.java} | 4 ++-- .../handler/codec/memcache/MemcacheContent.java | 8 ++++---- ...er.java => AbstractBinaryMemcacheDecoder.java} | 15 ++++++++------- ...er.java => AbstractBinaryMemcacheEncoder.java} | 7 ++++--- ...a => AbstractBinaryMemcacheMessageHeader.java} | 2 +- .../binary/BinaryMemcacheClientCodec.java | 2 +- .../binary/BinaryMemcacheObjectAggregator.java | 6 +++--- .../binary/BinaryMemcacheRequestDecoder.java | 2 +- .../binary/BinaryMemcacheRequestEncoder.java | 2 +- .../binary/BinaryMemcacheResponseDecoder.java | 2 +- .../binary/BinaryMemcacheResponseEncoder.java | 2 +- .../binary/BinaryMemcacheServerCodec.java | 2 +- .../DefaultBinaryMemcacheRequestHeader.java | 2 +- .../DefaultBinaryMemcacheResponseHeader.java | 2 +- .../binary/BinaryMemcacheDecoderTest.java | 2 +- .../binary/BinaryMemcacheEncoderTest.java | 2 +- 18 files changed, 38 insertions(+), 35 deletions(-) rename codec-memcache/src/main/java/io/netty/handler/codec/memcache/{MemcacheObjectAggregator.java => AbstractMemcacheObjectAggregator.java} (92%) rename codec-memcache/src/main/java/io/netty/handler/codec/memcache/{MemcacheObjectDecoder.java => AbstractMemcacheObjectDecoder.java} (91%) rename codec-memcache/src/main/java/io/netty/handler/codec/memcache/{MemcacheObjectEncoder.java => AbstractMemcacheObjectEncoder.java} (94%) rename codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/{BinaryMemcacheDecoder.java => AbstractBinaryMemcacheDecoder.java} (92%) rename codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/{BinaryMemcacheEncoder.java => AbstractBinaryMemcacheEncoder.java} (90%) rename codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/{DefaultBinaryMemcacheMessageHeader.java => AbstractBinaryMemcacheMessageHeader.java} (96%) diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheObjectAggregator.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/AbstractMemcacheObjectAggregator.java similarity index 92% rename from codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheObjectAggregator.java rename to codec-memcache/src/main/java/io/netty/handler/codec/memcache/AbstractMemcacheObjectAggregator.java index 430156b28c..15e5042cc7 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheObjectAggregator.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/AbstractMemcacheObjectAggregator.java @@ -27,7 +27,7 @@ import io.netty.handler.codec.memcache.binary.BinaryMemcacheResponseEncoder; * and its following {@link MemcacheContent}s into a single {@link MemcacheMessage} with * no following {@link MemcacheContent}s. It is useful when you don't want to take * care of memcache messages where the content comes along in chunks. Insert this - * handler after a MemcacheObjectDecoder in the {@link ChannelPipeline}. + * handler after a AbstractMemcacheObjectDecoder in the {@link ChannelPipeline}. *

* For example, here for the binary protocol: *

@@ -35,13 +35,14 @@ import io.netty.handler.codec.memcache.binary.BinaryMemcacheResponseEncoder; * {@link ChannelPipeline} p = ...; * ... * p.addLast("decoder", new {@link BinaryMemcacheRequestDecoder}()); - * p.addLast("aggregator", new {@link MemcacheObjectAggregator}(1048576)); + * p.addLast("aggregator", new {@link io.netty.handler.codec.memcache.binary.BinaryMemcacheObjectAggregator}(1048576) + * ); * ... * p.addLast("encoder", new {@link BinaryMemcacheResponseEncoder}()); * p.addLast("handler", new YourMemcacheRequestHandler()); * */ -public abstract class MemcacheObjectAggregator extends MessageToMessageDecoder { +public abstract class AbstractMemcacheObjectAggregator extends MessageToMessageDecoder { /** * Contains the current message that gets aggregated. @@ -59,7 +60,7 @@ public abstract class MemcacheObjectAggregator extends MessageToMessageDecoder *

Note that this class is designed to be extended, especially because both the binary and ascii protocol * require different treatment of their messages. Since the content chunk writing is the same for both, the encoder * abstracts this right away.

*/ -public abstract class MemcacheObjectEncoder extends MessageToMessageEncoder { +public abstract class AbstractMemcacheObjectEncoder extends MessageToMessageEncoder { private boolean expectingMoreContent; diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheContent.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheContent.java index 799eb77b09..1734d97cfb 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheContent.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/MemcacheContent.java @@ -21,10 +21,10 @@ import io.netty.channel.ChannelPipeline; /** * An Memcache content chunk. *

- * A MemcacheObjectDecoder generates {@link MemcacheContent} after - * {@link MemcacheMessage} when the content is large. If you prefer not to - * receive {@link MemcacheContent} in your handler, place a aggregator - * after MemcacheObjectDecoder in the {@link ChannelPipeline}. + * A implementation of a {@link AbstractMemcacheObjectDecoder} generates {@link MemcacheContent} after + * {@link MemcacheMessage} when the content is large. If you prefer not to receive {@link MemcacheContent} + * in your handler, place a aggregator after an implementation of the {@link AbstractMemcacheObjectDecoder} + * in the {@link ChannelPipeline}. */ public interface MemcacheContent extends MemcacheObject, ByteBufHolder { diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoder.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java similarity index 92% rename from codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoder.java rename to codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java index f9b798fb17..7feb2ac42b 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoder.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java @@ -17,11 +17,11 @@ package io.netty.handler.codec.memcache.binary; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.memcache.AbstractMemcacheObjectDecoder; import io.netty.handler.codec.memcache.DefaultLastMemcacheContent; import io.netty.handler.codec.memcache.DefaultMemcacheContent; import io.netty.handler.codec.memcache.LastMemcacheContent; import io.netty.handler.codec.memcache.MemcacheContent; -import io.netty.handler.codec.memcache.MemcacheObjectDecoder; import io.netty.util.CharsetUtil; import java.util.List; @@ -33,8 +33,9 @@ import static io.netty.buffer.ByteBufUtil.*; *

* The difference in the protocols (header) is implemented by the subclasses. */ -public abstract class BinaryMemcacheDecoder, H extends BinaryMemcacheMessageHeader> - extends MemcacheObjectDecoder { +public abstract class AbstractBinaryMemcacheDecoder + , H extends BinaryMemcacheMessageHeader> + extends AbstractMemcacheObjectDecoder { public static final int DEFAULT_MAX_CHUNK_SIZE = 8192; @@ -48,18 +49,18 @@ public abstract class BinaryMemcacheDecoder, private State state = State.READ_HEADER; /** - * Create a new {@link BinaryMemcacheDecoder} with default settings. + * Create a new {@link AbstractBinaryMemcacheDecoder} with default settings. */ - protected BinaryMemcacheDecoder() { + protected AbstractBinaryMemcacheDecoder() { this(DEFAULT_MAX_CHUNK_SIZE); } /** - * Create a new {@link BinaryMemcacheDecoder} with custom settings. + * Create a new {@link AbstractBinaryMemcacheDecoder} with custom settings. * * @param chunkSize the maximum chunk size of the payload. */ - protected BinaryMemcacheDecoder(int chunkSize) { + protected AbstractBinaryMemcacheDecoder(int chunkSize) { if (chunkSize < 0) { throw new IllegalArgumentException("chunkSize must be a positive integer: " + chunkSize); } diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoder.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheEncoder.java similarity index 90% rename from codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoder.java rename to codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheEncoder.java index a9dcffb68f..cc7dfe5411 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoder.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheEncoder.java @@ -18,14 +18,15 @@ package io.netty.handler.codec.memcache.binary; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; -import io.netty.handler.codec.memcache.MemcacheObjectEncoder; +import io.netty.handler.codec.memcache.AbstractMemcacheObjectEncoder; import io.netty.util.CharsetUtil; /** * A {@link MessageToByteEncoder} that encodes binary memache messages into bytes. */ -public abstract class BinaryMemcacheEncoder, H extends BinaryMemcacheMessageHeader> - extends MemcacheObjectEncoder { +public abstract class AbstractBinaryMemcacheEncoder + , H extends BinaryMemcacheMessageHeader> + extends AbstractMemcacheObjectEncoder { /** * Every binary memcache message has at least a 24 bytes header. diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheMessageHeader.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheMessageHeader.java similarity index 96% rename from codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheMessageHeader.java rename to codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheMessageHeader.java index 226b19e8d6..215a989a10 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheMessageHeader.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheMessageHeader.java @@ -18,7 +18,7 @@ package io.netty.handler.codec.memcache.binary; /** * The default implementation of a {@link BinaryMemcacheMessageHeader}. */ -public abstract class DefaultBinaryMemcacheMessageHeader implements BinaryMemcacheMessageHeader { +public abstract class AbstractBinaryMemcacheMessageHeader implements BinaryMemcacheMessageHeader { private byte magic; private byte opcode; diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java index 5afc506ce6..8f972aa830 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java @@ -45,7 +45,7 @@ public final class BinaryMemcacheClientCodec * Create a new {@link BinaryMemcacheClientCodec} with the default settings applied. */ public BinaryMemcacheClientCodec() { - this(BinaryMemcacheDecoder.DEFAULT_MAX_CHUNK_SIZE); + this(AbstractBinaryMemcacheDecoder.DEFAULT_MAX_CHUNK_SIZE); } /** diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheObjectAggregator.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheObjectAggregator.java index 577d3f6d65..10a42593ab 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheObjectAggregator.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheObjectAggregator.java @@ -20,20 +20,20 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.DecoderResult; import io.netty.handler.codec.TooLongFrameException; +import io.netty.handler.codec.memcache.AbstractMemcacheObjectAggregator; import io.netty.handler.codec.memcache.FullMemcacheMessage; import io.netty.handler.codec.memcache.LastMemcacheContent; import io.netty.handler.codec.memcache.MemcacheContent; import io.netty.handler.codec.memcache.MemcacheMessage; import io.netty.handler.codec.memcache.MemcacheObject; -import io.netty.handler.codec.memcache.MemcacheObjectAggregator; import io.netty.util.ReferenceCountUtil; import java.util.List; /** - * A {@link MemcacheObjectAggregator} for the binary protocol. + * A memcache object aggregator for the binary protocol. */ -public class BinaryMemcacheObjectAggregator extends MemcacheObjectAggregator { +public class BinaryMemcacheObjectAggregator extends AbstractMemcacheObjectAggregator { private boolean tooLongFrameFound; diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequestDecoder.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequestDecoder.java index 2dc74a79c1..06dd938c9b 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequestDecoder.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequestDecoder.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; * The decoder part which takes care of decoding the request-specific headers. */ public class BinaryMemcacheRequestDecoder - extends BinaryMemcacheDecoder { + extends AbstractBinaryMemcacheDecoder { public BinaryMemcacheRequestDecoder() { this(DEFAULT_MAX_CHUNK_SIZE); diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequestEncoder.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequestEncoder.java index 355a1518a4..de16f1012e 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequestEncoder.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheRequestEncoder.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; * The encoder part which takes care of encoding the request headers. */ public class BinaryMemcacheRequestEncoder - extends BinaryMemcacheEncoder { + extends AbstractBinaryMemcacheEncoder { @Override protected void encodeHeader(ByteBuf buf, BinaryMemcacheRequestHeader header) { diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseDecoder.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseDecoder.java index 605872b170..220412d4da 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseDecoder.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseDecoder.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; * The decoder which takes care of decoding the response headers. */ public class BinaryMemcacheResponseDecoder - extends BinaryMemcacheDecoder { + extends AbstractBinaryMemcacheDecoder { public BinaryMemcacheResponseDecoder() { this(DEFAULT_MAX_CHUNK_SIZE); diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseEncoder.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseEncoder.java index 2ddc345eca..9f92182a4e 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseEncoder.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseEncoder.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; * The encoder which takes care of encoding the response headers. */ public class BinaryMemcacheResponseEncoder - extends BinaryMemcacheEncoder { + extends AbstractBinaryMemcacheEncoder { @Override protected void encodeHeader(ByteBuf buf, BinaryMemcacheResponseHeader header) { diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheServerCodec.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheServerCodec.java index 0dfb0aef3a..cb1a05f3dc 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheServerCodec.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheServerCodec.java @@ -28,7 +28,7 @@ public class BinaryMemcacheServerCodec extends CombinedChannelDuplexHandler { public BinaryMemcacheServerCodec() { - this(BinaryMemcacheDecoder.DEFAULT_MAX_CHUNK_SIZE); + this(AbstractBinaryMemcacheDecoder.DEFAULT_MAX_CHUNK_SIZE); } public BinaryMemcacheServerCodec(int decodeChunkSize) { diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheRequestHeader.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheRequestHeader.java index 1216a0f523..484c0270c0 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheRequestHeader.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheRequestHeader.java @@ -18,7 +18,7 @@ package io.netty.handler.codec.memcache.binary; /** * The default implementation of a {@link BinaryMemcacheRequestHeader}. */ -public class DefaultBinaryMemcacheRequestHeader extends DefaultBinaryMemcacheMessageHeader +public class DefaultBinaryMemcacheRequestHeader extends AbstractBinaryMemcacheMessageHeader implements BinaryMemcacheRequestHeader { /** diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheResponseHeader.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheResponseHeader.java index 7fc94c88f3..71f39b75f7 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheResponseHeader.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/DefaultBinaryMemcacheResponseHeader.java @@ -18,7 +18,7 @@ package io.netty.handler.codec.memcache.binary; /** * The default implementation of a {@link BinaryMemcacheResponseHeader}. */ -public class DefaultBinaryMemcacheResponseHeader extends DefaultBinaryMemcacheMessageHeader +public class DefaultBinaryMemcacheResponseHeader extends AbstractBinaryMemcacheMessageHeader implements BinaryMemcacheResponseHeader { /** diff --git a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java index ce009d6ed6..26b9800489 100644 --- a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java +++ b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java @@ -32,7 +32,7 @@ import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.nullValue; /** - * Verifies the correct functionality of the {@link BinaryMemcacheDecoder}. + * Verifies the correct functionality of the {@link AbstractBinaryMemcacheDecoder}. *

* While technically there are both a {@link BinaryMemcacheRequestDecoder} and a {@link BinaryMemcacheResponseDecoder} * they implement the same basics and just differ in the type of headers returned. diff --git a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoderTest.java b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoderTest.java index d922e3cfcd..bfcc8b4f3f 100644 --- a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoderTest.java +++ b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoderTest.java @@ -31,7 +31,7 @@ import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.*; /** - * Verifies the correct functionality of the {@link BinaryMemcacheEncoder}. + * Verifies the correct functionality of the {@link AbstractBinaryMemcacheEncoder}. */ public class BinaryMemcacheEncoderTest {