public abstract class MessageToMessageEncoder<I> extends ChannelOutboundHandlerAdapter
ChannelOutboundHandlerAdapter which encodes from one message to an other message
For example here is an implementation which decodes an Integer to an String.
public class IntegerToStringEncoder extends
MessageToMessageEncoder<Integer> {
@Override
public void encode(ChannelHandlerContext ctx, Integer message, List<Object> out)
throws Exception {
out.add(message.toString());
}
}
Be aware that you need to call ReferenceCounted.retain() on messages that are just passed through if they
are of type ReferenceCounted. This is needed as the MessageToMessageEncoder will call
ReferenceCounted.release() on encoded messages.ChannelHandler.Sharable| Modifier | Constructor and Description |
|---|---|
protected |
MessageToMessageEncoder()
Create a new instance which will try to detect the types to match out of the type parameter of the class.
|
protected |
MessageToMessageEncoder(Class<? extends I> outboundMessageType)
Create a new instance
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptOutboundMessage( |