KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > protocol > tcm > MessageChannel


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.net.protocol.tcm;
5
6 import com.tc.net.MaxConnectionsExceededException;
7 import com.tc.net.TCSocketAddress;
8 import com.tc.net.protocol.NetworkStackID;
9 import com.tc.net.protocol.TCNetworkMessage;
10 import com.tc.util.TCTimeoutException;
11
12 import java.io.IOException JavaDoc;
13 import java.net.UnknownHostException JavaDoc;
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 JavaDoc getAttachment(String JavaDoc 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 JavaDoc key, Object JavaDoc 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 JavaDoc removeAttachment(String JavaDoc 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() throws MaxConnectionsExceededException, TCTimeoutException, UnknownHostException JavaDoc,
63       IOException JavaDoc;
64
65   public void close();
66
67 }
Popular Tags