1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.example.telnet;
17
18 import static org.jboss.netty.channel.Channels.*;
19
20 import org.jboss.netty.channel.ChannelPipeline;
21 import org.jboss.netty.channel.ChannelPipelineFactory;
22 import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
23 import org.jboss.netty.handler.codec.frame.Delimiters;
24 import org.jboss.netty.handler.codec.string.StringDecoder;
25 import org.jboss.netty.handler.codec.string.StringEncoder;
26
27
28
29
30 public class TelnetServerPipelineFactory implements
31 ChannelPipelineFactory {
32
33 public ChannelPipeline getPipeline() throws Exception {
34
35 ChannelPipeline pipeline = pipeline();
36
37
38 pipeline.addLast("framer", new DelimiterBasedFrameDecoder(
39 8192, Delimiters.lineDelimiter()));
40 pipeline.addLast("decoder", new StringDecoder());
41 pipeline.addLast("encoder", new StringEncoder());
42
43
44 pipeline.addLast("handler", new TelnetServerHandler());
45
46 return pipeline;
47 }
48 }