01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.net.protocol.tcm;
05:
06: import com.tc.net.MaxConnectionsExceededException;
07: import com.tc.net.TCSocketAddress;
08: import com.tc.net.protocol.NetworkStackID;
09: import com.tc.net.protocol.TCNetworkMessage;
10: import com.tc.util.TCTimeoutException;
11:
12: import java.io.IOException;
13: import java.net.UnknownHostException;
14:
15: /**
16: * Outward facing message channel interface. This is the interface that most high level application code wants to deal
17: * with, as opposed to the MessageChannelInternal interface which has some extra noise
18: *
19: * @author teck
20: */
21: public interface MessageChannel {
22:
23: public TCSocketAddress getLocalAddress();
24:
25: public TCSocketAddress getRemoteAddress();
26:
27: public void addListener(ChannelEventListener listener);
28:
29: public ChannelID getChannelID();
30:
31: public boolean isOpen();
32:
33: public boolean isClosed();
34:
35: public TCMessage createMessage(TCMessageType type);
36:
37: public Object getAttachment(String key);
38:
39: /**
40: * Attach anonymous data to this channel with the given key
41: *
42: * @param key the key for the attachment
43: * @param value the data to attach
44: * @param replace true if we should not check if a mapping already exists, else false
45: */
46: public void addAttachment(String key, Object value, boolean replace);
47:
48: /**
49: * Remove anonymous data from this channel
50: *
51: * @return the attachement object removed (if any)
52: */
53: public Object removeAttachment(String key);
54:
55: // ////////////////////////////////
56: // Methods duplicated from NetworkLayer
57: // ////////////////////////////////
58: public boolean isConnected();
59:
60: public void send(TCNetworkMessage message);
61:
62: public NetworkStackID open()
63: throws MaxConnectionsExceededException, TCTimeoutException,
64: UnknownHostException, IOException;
65:
66: public void close();
67:
68: }
|