/** * Prepare server by initializing the server socket * * @see ca.uhn.hl7v2.app.HL7Service#afterStartup() */ @Override protected void afterStartup() { try { super.afterStartup(); log.info("Starting SimpleServer running on port {}", port); SocketFactory ss = this.hapiContext.getSocketFactory(); acceptor = new AcceptorThread(port, tls, getExecutorService(), queue, ss); acceptor.start(); } catch (Exception e) { log.error("Failed starting SimpleServer on port", port); throw new RuntimeException(e); } }
/** * Polls for accepted sockets */ protected void handle() { if (inboundAcceptor.getServiceExitedWithException() != null) { setServiceExitedWithException(inboundAcceptor.getServiceExitedWithException()); } if (outboundAcceptor.getServiceExitedWithException() != null) { setServiceExitedWithException(outboundAcceptor.getServiceExitedWithException()); } try { ActiveConnection conn = acceptConnection(queue.poll(2, TimeUnit.SECONDS)); if (conn != null) { log.info("Accepted connection from " + conn.getRemoteAddress().getHostAddress()); newConnection(conn); } } catch (Exception e) { log.error("Error while accepting connections: ", e); } }
protected AcceptorThread createAcceptThread(int port) throws SocketException, IOException { SocketFactory ss = this.hapiContext.getSocketFactory(); return new AcceptorThread(port, tls, getExecutorService(), queue, ss); }
/** * Launches two threads that concurrently listen on the inboundPort and * outboundPort. * * @see ca.uhn.hl7v2.app.HL7Service#afterStartup() */ @Override protected void afterStartup() { try { super.afterStartup(); inboundAcceptor = createAcceptThread(inboundPort); outboundAcceptor = createAcceptThread(outboundPort); inboundAcceptor.start(); outboundAcceptor.start(); log.info("TwoPortService running on ports {} and {}", inboundPort, outboundPort); } catch (IOException e) { log.error("Could not run TwoPortService on ports {} and {}", inboundPort, outboundPort); throw new RuntimeException(e); } }
/** * Prepare server by initializing the server socket * * @see ca.uhn.hl7v2.app.HL7Service#afterStartup() */ @Override protected void afterStartup() { try { super.afterStartup(); log.info("Starting SimpleServer running on port {}", port); SocketFactory ss = this.hapiContext.getSocketFactory(); acceptor = new AcceptorThread(port, tls, getExecutorService(), queue, ss); acceptor.start(); } catch (Exception e) { log.error("Failed starting SimpleServer on port", port); throw new RuntimeException(e); } }
/** * Polls for accepted sockets */ protected void handle() { if (inboundAcceptor.getServiceExitedWithException() != null) { setServiceExitedWithException(inboundAcceptor.getServiceExitedWithException()); } if (outboundAcceptor.getServiceExitedWithException() != null) { setServiceExitedWithException(outboundAcceptor.getServiceExitedWithException()); } try { ActiveConnection conn = acceptConnection(queue.poll(2, TimeUnit.SECONDS)); if (conn != null) { log.info("Accepted connection from " + conn.getRemoteAddress().getHostAddress()); newConnection(conn); } } catch (Exception e) { log.error("Error while accepting connections: ", e); } }
protected AcceptorThread createAcceptThread(int port) throws SocketException, IOException { SocketFactory ss = this.hapiContext.getSocketFactory(); return new AcceptorThread(port, tls, getExecutorService(), queue, ss); }
/** * Launches two threads that concurrently listen on the inboundPort and * outboundPort. * * @see ca.uhn.hl7v2.app.HL7Service#afterStartup() */ @Override protected void afterStartup() { try { super.afterStartup(); inboundAcceptor = createAcceptThread(inboundPort); outboundAcceptor = createAcceptThread(outboundPort); inboundAcceptor.start(); outboundAcceptor.start(); log.info("TwoPortService running on ports {} and {}", inboundPort, outboundPort); } catch (IOException e) { log.error("Could not run TwoPortService on ports {} and {}", inboundPort, outboundPort); throw new RuntimeException(e); } }
/** * Loop that waits for a connection and starts a ConnectionManager when it * gets one. */ @Override protected void handle() { if (acceptor.getServiceExitedWithException() != null) { setServiceExitedWithException(acceptor.getServiceExitedWithException()); } try { // Wait some period of time for connections AcceptedSocket newSocket = queue.poll(500, TimeUnit.MILLISECONDS); if (newSocket != null) { log.info("Accepted connection from {}:{} on local port {}", new Object[] { newSocket.socket.getInetAddress().getHostAddress(), newSocket.socket.getPort(), port }); ActiveConnection c = new ActiveConnection(getParser(), getLlp(), newSocket.socket, getExecutorService()); newConnection(c); } } catch (InterruptedException ie) { // just timed out } catch (Exception e) { log.error("Error while accepting connections: ", e); } }
/** * Close down socket */ @Override protected void afterTermination() { super.afterTermination(); acceptor.stop(); }
/** * Loop that waits for a connection and starts a ConnectionManager when it * gets one. */ @Override protected void handle() { if (acceptor.getServiceExitedWithException() != null) { setServiceExitedWithException(acceptor.getServiceExitedWithException()); } try { // Wait some period of time for connections AcceptedSocket newSocket = queue.poll(500, TimeUnit.MILLISECONDS); if (newSocket != null) { log.info("Accepted connection from {}:{} on local port {}", new Object[] { newSocket.socket.getInetAddress().getHostAddress(), newSocket.socket.getPort(), port }); ActiveConnection c = new ActiveConnection(getParser(), getLlp(), newSocket.socket, getExecutorService()); newConnection(c); } } catch (InterruptedException ie) { // just timed out } catch (Exception e) { log.error("Error while accepting connections: ", e); } }
/** * Close down socket */ @Override protected void afterTermination() { super.afterTermination(); acceptor.stop(); }