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.memorydatastore.client;
05:
06: import com.tc.exception.TCRuntimeException;
07: import com.tc.memorydatastore.message.MemoryDataStoreResponseMessage;
08: import com.tc.net.protocol.tcm.TCMessage;
09: import com.tc.net.protocol.tcm.TCMessageSink;
10: import com.tc.net.protocol.tcm.UnknownNameException;
11: import com.tc.net.protocol.tcm.UnsupportedMessageTypeException;
12: import com.tc.object.lockmanager.api.ThreadID;
13:
14: import java.io.IOException;
15:
16: public class MemoryDataStoreResponseSink implements TCMessageSink {
17: private final MemoryDataStoreClient client;
18:
19: public MemoryDataStoreResponseSink(MemoryDataStoreClient client) {
20: super ();
21: this .client = client;
22: }
23:
24: public void putMessage(TCMessage message)
25: throws UnsupportedMessageTypeException {
26: try {
27: message.hydrate();
28: } catch (UnknownNameException e) {
29: throw new TCRuntimeException(e);
30: } catch (IOException e) {
31: throw new TCRuntimeException(e);
32: }
33:
34: MemoryDataStoreResponseMessage responseMessage = (MemoryDataStoreResponseMessage) message;
35:
36: if (responseMessage.isGetResponse()) {
37: ThreadID threadID = responseMessage.getThreadID();
38: client.notifyResponse(threadID, responseMessage);
39: }
40: }
41:
42: }
|