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
31
32
33
34
35
36 public class TelnetServerPipelineFactory implements
37 ChannelPipelineFactory {
38
39 public ChannelPipeline getPipeline() throws Exception {
40
41 ChannelPipeline pipeline = pipeline();
42
43
44 pipeline.addLast("framer", new DelimiterBasedFrameDecoder(
45 8192, Delimiters.lineDelimiter()));
46 pipeline.addLast("decoder", new StringDecoder());
47 pipeline.addLast("encoder", new StringEncoder());
48
49
50 pipeline.addLast("handler", new TelnetServerHandler());
51
52 return pipeline;
53 }
54 }