KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > DSOClientMessageChannelImpl


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

5 package com.tc.object;
6
7 import com.tc.async.api.Sink;
8 import com.tc.net.MaxConnectionsExceededException;
9 import com.tc.net.protocol.tcm.ChannelEventListener;
10 import com.tc.net.protocol.tcm.ChannelIDProvider;
11 import com.tc.net.protocol.tcm.ClientMessageChannel;
12 import com.tc.net.protocol.tcm.TCMessageType;
13 import com.tc.object.msg.AcknowledgeTransactionMessage;
14 import com.tc.object.msg.AcknowledgeTransactionMessageFactory;
15 import com.tc.object.msg.ClientHandshakeMessage;
16 import com.tc.object.msg.ClientHandshakeMessageFactory;
17 import com.tc.object.msg.CommitTransactionMessage;
18 import com.tc.object.msg.CommitTransactionMessageFactory;
19 import com.tc.object.msg.JMXMessage;
20 import com.tc.object.msg.LockRequestMessage;
21 import com.tc.object.msg.LockRequestMessageFactory;
22 import com.tc.object.msg.ObjectIDBatchRequestMessage;
23 import com.tc.object.msg.ObjectIDBatchRequestMessageFactory;
24 import com.tc.object.msg.RequestManagedObjectMessage;
25 import com.tc.object.msg.RequestManagedObjectMessageFactory;
26 import com.tc.object.msg.RequestRootMessage;
27 import com.tc.object.msg.RequestRootMessageFactory;
28 import com.tc.object.net.DSOClientMessageChannel;
29 import com.tc.util.TCTimeoutException;
30
31 import java.io.IOException JavaDoc;
32 import java.net.UnknownHostException JavaDoc;
33
34 public class DSOClientMessageChannelImpl implements DSOClientMessageChannel, LockRequestMessageFactory,
35     RequestRootMessageFactory, RequestManagedObjectMessageFactory, ClientHandshakeMessageFactory,
36     ObjectIDBatchRequestMessageFactory, CommitTransactionMessageFactory, AcknowledgeTransactionMessageFactory {
37
38   private final ClientMessageChannel channel;
39
40   public DSOClientMessageChannelImpl(ClientMessageChannel theChannel) {
41     this.channel = theChannel;
42   }
43
44   public void addClassMapping(TCMessageType messageType, Class JavaDoc messageClass) {
45     this.channel.addClassMapping(messageType, messageClass);
46   }
47
48   public ChannelIDProvider getChannelIDProvider() {
49     return channel.getChannelIDProvider();
50   }
51
52   public void addListener(ChannelEventListener listener) {
53     channel.addListener(listener);
54   }
55
56   public void routeMessageType(TCMessageType messageType, Sink destSink, Sink hydrateSink) {
57     channel.routeMessageType(messageType, destSink, hydrateSink);
58   }
59
60   public ClientMessageChannel channel() {
61     return channel;
62   }
63
64   public void open() throws TCTimeoutException, UnknownHostException JavaDoc, IOException JavaDoc, MaxConnectionsExceededException {
65     channel.open();
66   }
67
68   public void close() {
69     channel.close();
70   }
71
72   public LockRequestMessage newLockRequestMessage() {
73     return (LockRequestMessage) channel.createMessage(TCMessageType.LOCK_REQUEST_MESSAGE);
74   }
75
76   public LockRequestMessageFactory getLockRequestMessageFactory() {
77     return this;
78   }
79
80   public RequestRootMessage newRequestRootMessage() {
81     return (RequestRootMessage) channel.createMessage(TCMessageType.REQUEST_ROOT_MESSAGE);
82   }
83
84   public RequestRootMessageFactory getRequestRootMessageFactory() {
85     return this;
86   }
87
88   public RequestManagedObjectMessage newRequestManagedObjectMessage() {
89     return (RequestManagedObjectMessage) channel.createMessage(TCMessageType.REQUEST_MANAGED_OBJECT_MESSAGE);
90   }
91
92   public RequestManagedObjectMessageFactory getRequestManagedObjectMessageFactory() {
93     return this;
94   }
95
96   public AcknowledgeTransactionMessageFactory getAcknowledgeTransactionMessageFactory() {
97     return this;
98   }
99
100   public AcknowledgeTransactionMessage newAcknowledgeTransactionMessage() {
101     return (AcknowledgeTransactionMessage) channel.createMessage(TCMessageType.ACKNOWLEDGE_TRANSACTION_MESSAGE);
102   }
103
104   public ClientHandshakeMessage newClientHandshakeMessage() {
105     return (ClientHandshakeMessage) channel.createMessage(TCMessageType.CLIENT_HANDSHAKE_MESSAGE);
106   }
107
108   public ClientHandshakeMessageFactory getClientHandshakeMessageFactory() {
109     return this;
110   }
111
112   public ObjectIDBatchRequestMessage newObjectIDBatchRequestMessage() {
113     return (ObjectIDBatchRequestMessage) channel.createMessage(TCMessageType.OBJECT_ID_BATCH_REQUEST_MESSAGE);
114   }
115
116   public JMXMessage getJMXMessage() {
117     return (JMXMessage) channel.createMessage(TCMessageType.JMX_MESSAGE);
118   }
119
120   public ObjectIDBatchRequestMessageFactory getObjectIDBatchRequestMessageFactory() {
121     return this;
122   }
123
124   public CommitTransactionMessage newCommitTransactionMessage() {
125     return (CommitTransactionMessage) channel.createMessage(TCMessageType.COMMIT_TRANSACTION_MESSAGE);
126   }
127
128   public CommitTransactionMessageFactory getCommitTransactionMessageFactory() {
129     return this;
130   }
131
132   public boolean isConnected() {
133     return channel.isConnected();
134   }
135
136 }
Popular Tags