/** * The boolean configuration flags determine when new connections are made. For example if this * transport is being used for query/response, you might set connectOnSend to true and * the others to false, so that each query/response is done over a fresh connection. If * you are using a transport just to read data from a URL, you might set connectOnReceive to * true and the others to false. * * @param theURL the URL at which messages are to be read and written * @param connectOnSend makes a new connection before each send * @param connectOnReceive makes a new connection before each receive * @param connectOnConnect makes a new connection when connect() is called */ public URLTransport(URL theURL, boolean connectOnSend, boolean connectOnReceive, boolean connectOnConnect) { myURL = theURL; getCommonMetadata().put(URL_KEY, theURL); myConnectOnSend = connectOnSend; myConnectOnReceive = connectOnReceive; myConnectOnConnect = connectOnConnect; }
/** * Calls openConnection() on the underlying URL and configures the connection, * if this transport is configured to connect when connect() is called (see * constructor params). * * @see ca.uhn.hl7v2.protocol.AbstractTransport#doConnect() */ public void doConnect() throws TransportException { if (myConnectOnConnect) { makeConnection(); } }
private void makeConnection() throws TransportException { try { myConnection = myURL.openConnection(); myConnection.setDoOutput(true); myConnection.setDoInput(true); myConnection.setRequestProperty("Content-Type", getContentType()); myConnection.connect(); } catch (IOException e) { throw new TransportException(e); } log.debug("Made connection to {}", myURL.toExternalForm()); }
private void makeConnection() throws TransportException { try { myConnection = myURL.openConnection(); myConnection.setDoOutput(true); myConnection.setDoInput(true); myConnection.setRequestProperty("Content-Type", getContentType()); myConnection.connect(); } catch (IOException e) { throw new TransportException(e); } log.debug("Made connection to {}", myURL.toExternalForm()); }
/** * Calls openConnection() on the underlying URL and configures the connection, * if this transport is configured to connect when connect() is called (see * constructor params). * * @see ca.uhn.hl7v2.protocol.AbstractTransport#doConnect() */ public void doConnect() throws TransportException { if (myConnectOnConnect) { makeConnection(); } }
/** * The boolean configuration flags determine when new connections are made. For example if this * transport is being used for query/response, you might set connectOnSend to true and * the others to false, so that each query/response is done over a fresh connection. If * you are using a transport just to read data from a URL, you might set connectOnReceive to * true and the others to false. * * @param theURL the URL at which messages are to be read and written * @param connectOnSend makes a new connection before each send * @param connectOnReceive makes a new connection before each receive * @param connectOnConnect makes a new connection when connect() is called */ public URLTransport(URL theURL, boolean connectOnSend, boolean connectOnReceive, boolean connectOnConnect) { myURL = theURL; getCommonMetadata().put(URL_KEY, theURL); myConnectOnSend = connectOnSend; myConnectOnReceive = connectOnReceive; myConnectOnConnect = connectOnConnect; }
/** * Writes the given message to the URL. * * @param theMessage the message to send * @see ca.uhn.hl7v2.protocol.AbstractTransport#doSend(ca.uhn.hl7v2.protocol.Transportable) */ public void doSend(Transportable theMessage) throws TransportException { if (myConnectOnSend) { makeConnection(); } try { Writer out = new OutputStreamWriter(new BufferedOutputStream(myConnection.getOutputStream())); out.write(theMessage.getMessage()); out.flush(); } catch (IOException e) { throw new TransportException(e); } }
/** * Writes the given message to the URL. * * @param theMessage the message to send * @see ca.uhn.hl7v2.protocol.AbstractTransport#doSend(ca.uhn.hl7v2.protocol.Transportable) */ public void doSend(Transportable theMessage) throws TransportException { if (myConnectOnSend) { makeConnection(); } try { Writer out = new OutputStreamWriter(new BufferedOutputStream(myConnection.getOutputStream())); out.write(theMessage.getMessage()); out.flush(); } catch (IOException e) { throw new TransportException(e); } }