001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tc.object;
006:
007: import com.tc.async.api.Sink;
008: import com.tc.net.MaxConnectionsExceededException;
009: import com.tc.net.protocol.tcm.ChannelEventListener;
010: import com.tc.net.protocol.tcm.ChannelIDProvider;
011: import com.tc.net.protocol.tcm.ClientMessageChannel;
012: import com.tc.net.protocol.tcm.TCMessageType;
013: import com.tc.object.msg.AcknowledgeTransactionMessage;
014: import com.tc.object.msg.AcknowledgeTransactionMessageFactory;
015: import com.tc.object.msg.ClientHandshakeMessage;
016: import com.tc.object.msg.ClientHandshakeMessageFactory;
017: import com.tc.object.msg.CommitTransactionMessage;
018: import com.tc.object.msg.CommitTransactionMessageFactory;
019: import com.tc.object.msg.CompletedTransactionLowWaterMarkMessage;
020: import com.tc.object.msg.CompletedTransactionLowWaterMarkMessageFactory;
021: import com.tc.object.msg.JMXMessage;
022: import com.tc.object.msg.LockRequestMessage;
023: import com.tc.object.msg.LockRequestMessageFactory;
024: import com.tc.object.msg.ObjectIDBatchRequestMessage;
025: import com.tc.object.msg.ObjectIDBatchRequestMessageFactory;
026: import com.tc.object.msg.RequestManagedObjectMessage;
027: import com.tc.object.msg.RequestManagedObjectMessageFactory;
028: import com.tc.object.msg.RequestRootMessage;
029: import com.tc.object.msg.RequestRootMessageFactory;
030: import com.tc.object.net.DSOClientMessageChannel;
031: import com.tc.util.TCTimeoutException;
032:
033: import java.io.IOException;
034: import java.net.UnknownHostException;
035:
036: public class DSOClientMessageChannelImpl implements
037: DSOClientMessageChannel, LockRequestMessageFactory,
038: RequestRootMessageFactory, RequestManagedObjectMessageFactory,
039: ClientHandshakeMessageFactory,
040: ObjectIDBatchRequestMessageFactory,
041: CommitTransactionMessageFactory,
042: AcknowledgeTransactionMessageFactory,
043: CompletedTransactionLowWaterMarkMessageFactory {
044:
045: private final ClientMessageChannel channel;
046:
047: public DSOClientMessageChannelImpl(ClientMessageChannel theChannel) {
048: this .channel = theChannel;
049: }
050:
051: public void addClassMapping(TCMessageType messageType,
052: Class messageClass) {
053: this .channel.addClassMapping(messageType, messageClass);
054: }
055:
056: public ChannelIDProvider getChannelIDProvider() {
057: return channel.getChannelIDProvider();
058: }
059:
060: public void addListener(ChannelEventListener listener) {
061: channel.addListener(listener);
062: }
063:
064: public void routeMessageType(TCMessageType messageType,
065: Sink destSink, Sink hydrateSink) {
066: channel.routeMessageType(messageType, destSink, hydrateSink);
067: }
068:
069: public ClientMessageChannel channel() {
070: return channel;
071: }
072:
073: public void open() throws TCTimeoutException, UnknownHostException,
074: IOException, MaxConnectionsExceededException {
075: channel.open();
076: }
077:
078: public void close() {
079: channel.close();
080: }
081:
082: public LockRequestMessage newLockRequestMessage() {
083: return (LockRequestMessage) channel
084: .createMessage(TCMessageType.LOCK_REQUEST_MESSAGE);
085: }
086:
087: public LockRequestMessageFactory getLockRequestMessageFactory() {
088: return this ;
089: }
090:
091: public RequestRootMessage newRequestRootMessage() {
092: return (RequestRootMessage) channel
093: .createMessage(TCMessageType.REQUEST_ROOT_MESSAGE);
094: }
095:
096: public RequestRootMessageFactory getRequestRootMessageFactory() {
097: return this ;
098: }
099:
100: public RequestManagedObjectMessage newRequestManagedObjectMessage() {
101: return (RequestManagedObjectMessage) channel
102: .createMessage(TCMessageType.REQUEST_MANAGED_OBJECT_MESSAGE);
103: }
104:
105: public RequestManagedObjectMessageFactory getRequestManagedObjectMessageFactory() {
106: return this ;
107: }
108:
109: public AcknowledgeTransactionMessageFactory getAcknowledgeTransactionMessageFactory() {
110: return this ;
111: }
112:
113: public AcknowledgeTransactionMessage newAcknowledgeTransactionMessage() {
114: return (AcknowledgeTransactionMessage) channel
115: .createMessage(TCMessageType.ACKNOWLEDGE_TRANSACTION_MESSAGE);
116: }
117:
118: public ClientHandshakeMessage newClientHandshakeMessage() {
119: ClientHandshakeMessage rv = (ClientHandshakeMessage) channel
120: .createMessage(TCMessageType.CLIENT_HANDSHAKE_MESSAGE);
121: return rv;
122: }
123:
124: public ClientHandshakeMessageFactory getClientHandshakeMessageFactory() {
125: return this ;
126: }
127:
128: public ObjectIDBatchRequestMessage newObjectIDBatchRequestMessage() {
129: return (ObjectIDBatchRequestMessage) channel
130: .createMessage(TCMessageType.OBJECT_ID_BATCH_REQUEST_MESSAGE);
131: }
132:
133: public JMXMessage getJMXMessage() {
134: return (JMXMessage) channel
135: .createMessage(TCMessageType.JMX_MESSAGE);
136: }
137:
138: public CompletedTransactionLowWaterMarkMessage newCompletedTransactionLowWaterMarkMessage() {
139: return (CompletedTransactionLowWaterMarkMessage) channel
140: .createMessage(TCMessageType.COMPLETED_TRANSACTION_LOWWATERMARK_MESSAGE);
141: }
142:
143: public ObjectIDBatchRequestMessageFactory getObjectIDBatchRequestMessageFactory() {
144: return this ;
145: }
146:
147: public CommitTransactionMessage newCommitTransactionMessage() {
148: return (CommitTransactionMessage) channel
149: .createMessage(TCMessageType.COMMIT_TRANSACTION_MESSAGE);
150: }
151:
152: public CommitTransactionMessageFactory getCommitTransactionMessageFactory() {
153: return this ;
154: }
155:
156: public boolean isConnected() {
157: return channel.isConnected();
158: }
159:
160: public CompletedTransactionLowWaterMarkMessageFactory getCompletedTransactionLowWaterMarkMessageFactory() {
161: return this;
162: }
163:
164: }
|