Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TransportLayer |
|
| 1.0;1 |
1 | /* | |
2 | * Created on 15-Apr-2004 | |
3 | */ | |
4 | package ca.uhn.hl7v2.protocol; | |
5 | ||
6 | import java.util.Map; | |
7 | ||
8 | /** | |
9 | * Encapsulates the transport layer of a connection to another | |
10 | * HL7 server. This is the layer responsible for sending and receiving | |
11 | * message strings. The underlying protocol used is implementation | |
12 | * dependent, that is there may be transport layers that are implemented | |
13 | * over email, or JMS, or HTTP. | |
14 | * | |
15 | * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a> | |
16 | * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:38 $ by $Author: jamesagnew $ | |
17 | */ | |
18 | public interface TransportLayer { | |
19 | ||
20 | /** | |
21 | * Sends a message to a remote HL7 service. | |
22 | * | |
23 | * @param theMessage the message to send | |
24 | * @throws TransportException | |
25 | */ | |
26 | public void send(Transportable theMessage) throws TransportException; | |
27 | ||
28 | /** | |
29 | * Gets the next message from the remote system. This call blocks until | |
30 | * the next message is available. | |
31 | * | |
32 | * @return the next available message | |
33 | * @throws TransportException | |
34 | */ | |
35 | public Transportable receive() throws TransportException; | |
36 | ||
37 | /** | |
38 | * @return metadata to be added to the metadata of all incoming messages. | |
39 | * This provides a way of associating connection information with | |
40 | * incoming messages (eg the IP address of the remote server). | |
41 | */ | |
42 | public Map<String, Object> getCommonMetadata(); | |
43 | ||
44 | /** | |
45 | * Initializes a connection to the remote server. This can be called after | |
46 | * an exception is encountered, to refresh a dead connection. | |
47 | * @throws TransportException | |
48 | */ | |
49 | public void connect() throws TransportException; | |
50 | ||
51 | /** | |
52 | * @return true if connect() has completed successfully. Note that true | |
53 | * may be returned even if a connection is dead (ie the implementation need | |
54 | * not test a connection during this call) but should return false if connect() | |
55 | * has not been called, or if connect() has been called and is pending. | |
56 | */ | |
57 | public boolean isConnected(); | |
58 | ||
59 | /** | |
60 | * Drops any existing connection to the remote server. | |
61 | * @throws TransportException | |
62 | */ | |
63 | public void disconnect() throws TransportException; | |
64 | ||
65 | } |