@@ -0,0 +1,3162 @@
+package com.orbekk.same;%0A%0Aimport org.eclipse.jetty.server.Server;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.googlecode.jsonrpc4j.JsonRpcServer;%0Aimport com.orbekk.paxos.PaxosService;%0Aimport com.orbekk.paxos.PaxosServiceImpl;%0A%0Apublic class SameController implements UrlReceiver %7B%0A    private Logger logger = LoggerFactory.getLogger(getClass());%0A    private Server server;%0A    private MasterServiceImpl master;%0A    private ClientServiceImpl client;%0A    private PaxosServiceImpl paxos;%0A    %0A    /**%0A     * Timeout for remote operations in milliseconds.%0A     */%0A    private static final int timeout = 2000;%0A    %0A    public static SameController create(int port) %7B%0A        ConnectionManagerImpl connections = new ConnectionManagerImpl(%0A                timeout, timeout);%0A        State state = new State(%22Default%22);%0A        Broadcaster broadcaster = BroadcasterImpl.getDefaultBroadcastRunner();%0A        %0A        MasterServiceImpl master = new MasterServiceImpl(state, connections,%0A                broadcaster);%0A        JsonRpcServer jsonMaster = new JsonRpcServer(master, MasterService.class);%0A        ClientServiceImpl client = new ClientServiceImpl(state, connections);%0A        JsonRpcServer jsonClient = new JsonRpcServer(client, ClientService.class);%0A        PaxosServiceImpl paxos = new PaxosServiceImpl(%22%22);%0A        JsonRpcServer jsonPaxos = new JsonRpcServer(paxos, PaxosService.class);%0A        %0A        Server server = new Server(port);%0A        SameController controller = new SameController(server, master, client,%0A                paxos);%0A        RpcHandler rpcHandler = new RpcHandler(controller);%0A        %0A        rpcHandler.addRpcServer(%22/MasterService.json%22, jsonMaster);%0A        rpcHandler.addRpcServer(%22/ClientService.json%22, jsonClient);%0A        rpcHandler.addRpcServer(%22/PaxosService.json%22, jsonPaxos);%0A        %0A        server.setHandler(rpcHandler);%0A        return controller;%0A    %7D%0A    %0A    public SameController(%0A            Server server,%0A            MasterServiceImpl master,%0A            ClientServiceImpl client,%0A            PaxosServiceImpl paxos) %7B%0A        this.server = server;%0A        this.master = master;%0A        this.paxos = paxos;%0A    %7D%0A%0A    public void start() throws Exception %7B%0A        server.start();%0A        master.start();%0A    %7D%0A    %0A    public void stop() %7B%0A        try %7B%0A            server.stop();%0A        %7D catch (Exception e) %7B%0A            logger.error(%22Failed to stop webserver%22, e);%0A            master.interrupt();%0A        %7D%0A    %7D%0A    %0A    public void join() %7B%0A        try %7B%0A            server.join();%0A            master.join();%0A        %7D catch (InterruptedException e) %7B%0A            master.interrupt();%0A            try %7B%0A                server.stop();%0A            %7D catch (Exception e1) %7B%0A                logger.error(%22Failed to stop server%22, e);%0A            %7D%0A        %7D%0A    %7D%0A    %0A    public void joinNetwork(String url) %7B%0A        client.joinNetwork(url + %22MasterService.json%22);%0A    %7D%0A    %0A    @Override%0A    public void setUrl(String url) %7B%0A        if (master != null) %7B%0A            master.setUrl(url);%0A        %7D%0A        if (client != null) %7B%0A            client.setUrl(url);%0A        %7D%0A    %7D%0A    %0A%7D%0A

Add SameController.