/** * Starts the service. Will start a socket listener to listen for management operation requests. * * @param context The start context * @throws StartException If any errors occur */ public synchronized void start(StartContext context) throws StartException { System.out.println("Installing 2"); final ExecutorService executorService = executorServiceValue.getValue(); final ThreadFactory threadFactory = threadFactoryValue.getValue(); final NetworkInterfaceBinding interfaceBinding = interfaceBindingValue.getValue(); final Integer port = portValue.getValue(); try { final ProtocolServer.Configuration config = new ProtocolServer.Configuration(); config.setBindAddress(new InetSocketAddress(interfaceBinding.getAddress(), port)); config.setThreadFactory(threadFactory); config.setReadExecutor(executorService); config.setSocketFactory(ServerSocketFactory.getDefault()); config.setBacklog(50); config.setConnectionHandler(this); server = new ProtocolServer(config); server.start(); } catch (Exception e) { throw new StartException("Failed to start server socket", e); } }
/** * Stops the service. Will shutdown the socket listener and will no longer accept requests. * * @param context The stop context */ public synchronized void stop(StopContext context) { if (server != null) { server.stop(); } }