1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.channel;
17
18 import org.jboss.netty.buffer.ChannelBufferFactory;
19 import org.jboss.netty.buffer.HeapChannelBufferFactory;
20 import org.jboss.netty.channel.socket.ServerSocketChannelConfig;
21
22 import java.util.Map;
23 import java.util.Map.Entry;
24
25
26
27
28 public class DefaultServerChannelConfig implements ChannelConfig {
29
30 private volatile ChannelPipelineFactory pipelineFactory;
31 private volatile ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance();
32
33 public void setOptions(Map<String, Object> options) {
34 for (Entry<String, Object> e: options.entrySet()) {
35 setOption(e.getKey(), e.getValue());
36 }
37 }
38
39
40
41
42
43 public boolean setOption(String key, Object value) {
44 if (key == null) {
45 throw new NullPointerException("key");
46 }
47 if ("pipelineFactory".equals(key)) {
48 setPipelineFactory((ChannelPipelineFactory) value);
49 } else if ("bufferFactory".equals(key)) {
50 setBufferFactory((ChannelBufferFactory) value);
51 } else {
52 return false;
53 }
54 return true;
55 }
56
57 public ChannelPipelineFactory getPipelineFactory() {
58 return pipelineFactory;
59 }
60
61 public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
62 if (pipelineFactory == null) {
63 throw new NullPointerException("pipelineFactory");
64 }
65 this.pipelineFactory = pipelineFactory;
66 }
67
68 public ChannelBufferFactory getBufferFactory() {
69 return bufferFactory;
70 }
71
72 public void setBufferFactory(ChannelBufferFactory bufferFactory) {
73 if (bufferFactory == null) {
74 throw new NullPointerException("bufferFactory");
75 }
76
77 this.bufferFactory = bufferFactory;
78 }
79
80 public int getConnectTimeoutMillis() {
81 return 0;
82 }
83
84 public void setConnectTimeoutMillis(int connectTimeoutMillis) {
85
86 }
87 }