Advertisement
Favorlock

Untitled

Jul 12th, 2016
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. public class AtomixServer {
  2.     private AtomixServerConfig config;
  3.  
  4.     private void init() throws Exception {
  5.         this.config = JsonConfig.load(new File("./config.json"), AtomixServerConfig.class);
  6.  
  7.         Serializer serializer = new Serializer();
  8.         serializer.registerClassLoader(DistributedGroupFactory.class.getName(), getClass().getClassLoader());
  9.         Address address = new Address(this.config.address.host, this.config.address.port);
  10.         ResourceServer server = ResourceServer.builder(address).withSerializer(serializer).withTransport(new NettyTransport()).build();
  11.         server.bootstrap(address).join();
  12.  
  13.         synchronized (AtomixServer.class) {
  14.             while (server.isRunning()) {
  15.                 getClass().wait();
  16.             }
  17.         }
  18.     }
  19.  
  20.     public static void main(String ... args) {
  21.         try {
  22.             new AtomixServer().init();
  23.         } catch (Exception e) {
  24.             System.exit(0);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement