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.memorydatastore.client;5 6 import com.tc.exception.TCRuntimeException;7 import com.tc.memorydatastore.message.MemoryDataStoreResponseMessage;8 import com.tc.net.protocol.tcm.TCMessage;9 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) throws UnsupportedMessageTypeException {25 try {26 message.hydrate();27 } catch (UnknownNameException e) {28 throw new TCRuntimeException(e);29 } catch (IOException e) {30 throw new TCRuntimeException(e);31 }32 33 MemoryDataStoreResponseMessage responseMessage = (MemoryDataStoreResponseMessage) message;34 35 if (responseMessage.isGetResponse()) {36 ThreadID threadID = responseMessage.getThreadID();37 client.notifyResponse(threadID, responseMessage);38 }39 }40 41 }42