Package ca.uhn.hl7v2.app.AcceptorThread

Examples of ca.uhn.hl7v2.app.AcceptorThread.AcceptedSocket


      setServiceExitedWithException(acceptor.getServiceExitedWithException());
    }
   
    try {
      // Wait some period of time for connections
      AcceptedSocket newSocket = queue.poll(AcceptorThread.TIMEOUT, TimeUnit.MILLISECONDS);
      if (newSocket != null) {
        log.info("Accepted connection from {} on port {}", newSocket.socket.getInetAddress().getHostAddress(), port);
        Connection c = new Connection(parser, llp, newSocket.socket,
            getExecutorService());
        newConnection(c);
View Full Code Here


  private Connection acceptConnection(AcceptedSocket newSocket)
      throws LLPException, IOException {
    Connection conn = null;
    if (newSocket != null) {
      String address = newSocket.socket.getInetAddress().getHostAddress();
      AcceptedSocket otherSocket = waitingForSecondSocket.remove(address);
      if (otherSocket != null && otherSocket.origin != newSocket.origin) {
        log.debug("Socket {} completes a two-port connection",
            newSocket.socket);
        Socket in = getInboundSocket(newSocket, otherSocket);
        Socket out = getOutboundSocket(newSocket, otherSocket);
View Full Code Here

      setServiceExitedWithException(acceptor.getServiceExitedWithException());
    }
   
    try {
      // Wait some period of time for connections
      AcceptedSocket newSocket = queue.poll(AcceptorThread.TIMEOUT, TimeUnit.MILLISECONDS);
      if (newSocket != null) {
        log.info("Accepted connection from {} on port {}", newSocket.socket.getInetAddress().getHostAddress(), port);
        Connection c = new Connection(getParser(), getLlp(), newSocket.socket,
            getExecutorService());
        newConnection(c);
View Full Code Here

      setServiceExitedWithException(acceptor.getServiceExitedWithException());
    }
   
    try {
      // Wait some period of time for connections
      AcceptedSocket newSocket = queue.poll(AcceptorThread.TIMEOUT, TimeUnit.MILLISECONDS);
      if (newSocket != null) {
        log.info("Accepted connection from {} on port {}", newSocket.socket.getInetAddress().getHostAddress(), port);
        ActiveConnection c = new ActiveConnection(getParser(), getLlp(), newSocket.socket,
            getExecutorService());
        newConnection(c);
View Full Code Here

  private ActiveConnection acceptConnection(AcceptedSocket newSocket)
      throws LLPException, IOException {
    ActiveConnection conn = null;
    if (newSocket != null) {
      String address = newSocket.socket.getInetAddress().getHostAddress();
      AcceptedSocket otherSocket = waitingForSecondSocket.remove(address);
      if (otherSocket != null && otherSocket.origin != newSocket.origin) {
        log.debug("Socket {} completes a two-port connection",
            newSocket.socket);
        Socket in = getInboundSocket(newSocket, otherSocket);
        Socket out = getOutboundSocket(newSocket, otherSocket);
View Full Code Here

    public void start() {
        /*
        * The server may have any number of "application" objects registered to handle messages. We
        * are going to create an application to listen to ADT^A01 messages.
        */
        Application handler = new SampleApp();
        server.registerApplication("*", "*", handler);

        /*
        * Another option would be to specify a single application to handle all messages, like
        * this:
 
View Full Code Here

    @Override
    protected void startEndpoint(HL7Endpoint endpoint) throws AxisFault {
        LowerLayerProtocol llp = LowerLayerProtocol.makeLLP();
        PipeParser parser = new PipeParser();
        SimpleServer server = new SimpleServer(endpoint.getPort(), llp, parser);
        Application callback = new HL7MessageProcessor(endpoint);
        server.registerApplication("*", "*", callback);
        server.start();
        serverTable.put(endpoint, server);

        log.info("Started HL7 endpoint on port: " + endpoint.getPort());
View Full Code Here

    public void send(String host, int port) throws HL7Exception {
        System.out.println("[ Executing HL7Sender : HOST:" + host + "  ;port :" + port + " ]");
        // The connection hub connects to listening servers
        ConnectionHub connectionHub = ConnectionHub.getInstance();
        // A connection object represents a socket attached to an HL7 server
        Connection connection = connectionHub
                .attach(host, port, new PipeParser(), MinLowerLayerProtocol.class);

        // The initiator is used to transmit unsolicited messages
        Initiator initiator = connection.getInitiator();
        HL7Message sampleMessage = new HL7Message();

        //send
        Message response = null;
        try {
View Full Code Here

        Map<String,String> params = getURLParameters(targetEPR);

        try {
            Message message = parser.parse(xmlFormat);
            ConnectionHub connectionHub = ConnectionHub.getInstance();
            Connection connection = getConnection(targetEPR, connectionHub);
            Initiator initiator = connection.getInitiator();
            String timeout = params.get(HL7Constants.TIMEOUT_PARAM);
            if (timeout != null) {
                initiator.setTimeoutMillis(Integer.parseInt(timeout));
            } else {
                initiator.setTimeoutMillis(HL7Constants.DEFAULT_TIMEOUT);
View Full Code Here

public class HL7Sender {

    public void send(String host, int port) throws HL7Exception {
        System.out.println("[ Executing HL7Sender : HOST:" + host + "  ;port :" + port + " ]");
        // The connection hub connects to listening servers
        ConnectionHub connectionHub = ConnectionHub.getInstance();
        // A connection object represents a socket attached to an HL7 server
        Connection connection = connectionHub
                .attach(host, port, new PipeParser(), MinLowerLayerProtocol.class);

        // The initiator is used to transmit unsolicited messages
        Initiator initiator = connection.getInitiator();
        HL7Message sampleMessage = new HL7Message();

        //send
        Message response = null;
        try {
            response = initiator.sendAndReceive(sampleMessage.getHL7Message());
            PipeParser parser = new PipeParser();
            String responseString = parser.encode(response);
            System.out.println("Received response:\n" + responseString);
        } catch (LLPException e) {
            System.out.println("Error : " + e);
        } catch (IOException e) {
            System.out.println("Error : " + e);
        }

        // Close the connection and server
        connectionHub.discard(connection);
    }
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.app.AcceptorThread.AcceptedSocket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.