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.util.io;
05:
06: import java.io.IOException;
07: import java.nio.channels.Channel;
08: import java.nio.channels.ClosedChannelException;
09:
10: public class MockChannel implements Channel {
11:
12: private boolean isOpen = true;
13:
14: public final synchronized boolean isOpen() {
15: return isOpen;
16: }
17:
18: public final synchronized void close() {
19: isOpen = false;
20: }
21:
22: protected final synchronized void checkOpen() throws IOException {
23: if (!isOpen()) {
24: throw new ClosedChannelException();
25: }
26: }
27: }
|