public abstract class AbstractMemcacheObjectAggregator<H extends MemcacheMessage> extends MessageAggregator<MemcacheObject,H,MemcacheContent,FullMemcacheMessage>
ChannelHandler that aggregates an MemcacheMessage
and its following MemcacheContents into a single MemcacheMessage with
no following MemcacheContents. 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 AbstractMemcacheObjectDecoder in the ChannelPipeline.
For example, here for the binary protocol:
ChannelPipelinep = ...; ... p.addLast("decoder", newBinaryMemcacheRequestDecoder()); p.addLast("aggregator", newBinaryMemcacheObjectAggregator(1048576) ); ... p.addLast("encoder", newBinaryMemcacheResponseEncoder()); p.addLast("handler", new YourMemcacheRequestHandler());
ChannelHandler.Sharable, ChannelHandler.Skip| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMemcacheObjectAggregator(int maxContentLength) |
| Modifier and Type | Method and Description |
|---|---|
protected long |
contentLength(H start)
Retrieves the length of the whole content from the specified start message.
|
protected boolean |
hasContentLength(H start)
Returns
true if and only if the specified start message already contains the information about the
length of the whole content. |
protected boolean |
isAggregated(MemcacheObject msg)
Returns
true if and only if the specified message is already aggregated. |
protected boolean |
isContentMessage(MemcacheObject msg)
Returns
true if and only if the specified message is a content message. |
protected boolean |
isLastContentMessage(MemcacheContent msg)
Returns
true if and only if the specified message is the last content message. |
protected Object |
newContinueResponse(H start)
Returns the 'continue response' for the specified start message if necessary.
|
acceptInboundMessage, aggregate, beginAggregation, channelInactive, ctx, decode, finishAggregation, handleOversizedMessage, handlerAdded, handlerRemoved, isHandlingOversizedMessage, isStartMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponentschannelReadbind, channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, isSharable, read, userEventTriggered, writeprotected AbstractMemcacheObjectAggregator(int maxContentLength)
protected boolean isContentMessage(MemcacheObject msg) throws Exception
MessageAggregatortrue if and only if the specified message is a content message. Typically, this method is
implemented as a single return statement with instanceof:
return msg instanceof MyContentMessage;
isContentMessage in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>Exceptionprotected boolean isLastContentMessage(MemcacheContent msg) throws Exception
MessageAggregatortrue if and only if the specified message is the last content message. Typically, this method is
implemented as a single return statement with instanceof:
return msg instanceof MyLastContentMessage;or with
instanceof and boolean field check:
return msg instanceof MyContentMessage && msg.isLastFragment();
isLastContentMessage in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>Exceptionprotected boolean isAggregated(MemcacheObject msg) throws Exception
MessageAggregatortrue if and only if the specified message is already aggregated. If this method returns
true, this handler will simply forward the message to the next handler as-is.isAggregated in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>Exceptionprotected boolean hasContentLength(H start) throws Exception
MessageAggregatortrue if and only if the specified start message already contains the information about the
length of the whole content.hasContentLength in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>Exceptionprotected long contentLength(H start) throws Exception
MessageAggregatorMessageAggregator.hasContentLength(Object) returned true.contentLength in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>Exceptionprotected Object newContinueResponse(H start) throws Exception
MessageAggregatornewContinueResponse in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>null if there's no message to sendExceptionCopyright © 2008–2015 The Netty Project. All rights reserved.