1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package goldengate.commandexec.server;
22
23 import goldengate.commandexec.utils.LocalExecDefaultResult;
24 import goldengate.common.logging.GgSlf4JLoggerFactory;
25
26 import java.net.InetAddress;
27 import java.net.InetSocketAddress;
28 import java.util.concurrent.ExecutorService;
29 import java.util.concurrent.Executors;
30
31 import org.jboss.netty.bootstrap.ServerBootstrap;
32 import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
33 import org.jboss.netty.logging.InternalLoggerFactory;
34
35
36
37
38
39
40 public class LocalExecServer {
41
42 static ExecutorService threadPool;
43 static ExecutorService threadPool2;
44
45
46
47
48
49
50
51
52
53
54 public static void main(String[] args) throws Exception {
55 InternalLoggerFactory.setDefaultFactory(new GgSlf4JLoggerFactory(null));
56 int port = 9999;
57 InetAddress addr;
58 long delay = LocalExecDefaultResult.MAXWAITPROCESS;
59 if (args.length >=2) {
60 addr = InetAddress.getByName(args[0]);
61 port = Integer.parseInt(args[1]);
62 if (args.length > 2) {
63 delay = Long.parseLong(args[2]);
64 }
65 } else {
66 byte []loop = {127,0,0,1};
67 addr = InetAddress.getByAddress(loop);
68 }
69 threadPool = Executors.newCachedThreadPool();
70 threadPool2 = Executors.newCachedThreadPool();
71
72 ServerBootstrap bootstrap = new ServerBootstrap(
73 new NioServerSocketChannelFactory(threadPool, threadPool2));
74
75
76 bootstrap.setPipelineFactory(new LocalExecServerPipelineFactory(delay));
77
78
79 bootstrap.bind(new InetSocketAddress(addr, port));
80 }
81 }