blob: 2f956fe5290dcbed3a8160477189bf0fa6a33d64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package com.orbekk.rpc;
import com.googlecode.jsonrpc4j.JsonRpcServer;
import com.orbekk.same.SameState;
import com.orbekk.same.SameService;
import com.orbekk.same.SameServiceImpl;
import org.eclipse.jetty.server.Server;
public class App {
public static void main(String[] args) {
if (args.length < 2) {
System.err.println("Arguments: port networkName");
System.exit(1);
}
int port = Integer.parseInt(args[0]);
String networkName = args[1];
SameState sameState = new SameState(networkName);
sameState.start();
SameServiceImpl service = new SameServiceImpl(sameState);
JsonRpcServer jsonServer = new JsonRpcServer(service,
SameService.class);
Server server = new Server(port);
RpcHandler rpcHandler = new RpcHandler(jsonServer, service);
server.setHandler(rpcHandler);
try {
server.start();
} catch (Exception e) {
System.out.println("Could not start jetty server.");
e.printStackTrace();
}
try {
server.join();
} catch (InterruptedException e) {
System.out.println("Interrupt");
}
}
}
|