String host = InetAddress.getLocalHost().getHostAddress();
int port = PortUtil.findFreePort(host);
String locatorURI = "socket://" + host + ":" + port;
locator = new InvokerLocator(locatorURI);
Connector connector = new Connector(locator);
connector.create();
connector.setLeasePeriod(1000);
connector.addConnectionListener(new TestListener());
TestHandler handler = new TestHandler();
connector.addInvocationHandler("test", handler);
connector.start();