// The DelimiterBasedFrameDecoder is not sharable
// so we need to wrap it's configuration in a ChannelHandlerProviderFactory
// so that a new one is created for each new pipeline created
// The ChannelPipelineFactoryImpl is a stickler for types, so all primitive supporting
// types are assumed to be primitive
ChannelHandlerProvider frameDecoder = ChannelHandlerProviderFactory.getInstance(
"frameDecoder",
//DelimiterBasedFrameDecoder.class,
InstrumentedDelimiterBasedFrameDecoder.class,
Integer.MAX_VALUE,
true,
true,
new ChannelBuffer[]{ChannelBuffers.wrappedBuffer("|".getBytes())}
);
// The String decoder is sharable so we wrap it in a simple SharedChannelHandlerProvider
ChannelHandlerProvider stringDecoder = ChannelHandlerProviderFactory.getInstance("stringDecoder", new StringDecoder());
// Lastly, we need a "business" handler. It is sharable so we wrap it in a simple SharedChannelHandlerProvider
ChannelHandlerProvider stringReporter = ChannelHandlerProviderFactory.getInstance("stringReporter", new StringReporter());
// We want to send some numbers back to the caller, so we need an ObjectEncoder
// We're going to use a simple groovy client to submit strings, so it needs to be a CompatibleObjectEncoder
// which is not sharable so we need to wrap it's configuration in a ChannelHandlerProviderFactory
ChannelHandlerProvider objectEncoder = ChannelHandlerProviderFactory.getInstance(
"objectEncoder",
CompatibleObjectEncoder.class);
ChannelHandlerProvider stringEncoder = ChannelHandlerProviderFactory.getInstance(
"stringEncoder",
StringEncoder.class);
// Create a map for the channel options