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.io;
05:
06: import java.io.IOException;
07: import java.nio.channels.FileChannel;
08: import java.nio.channels.FileLock;
09: import java.nio.channels.OverlappingFileLockException;
10:
11: public class TCFileChannelImpl implements TCFileChannel {
12:
13: private final FileChannel channel;
14:
15: public TCFileChannelImpl(FileChannel channel) {
16: this .channel = channel;
17: }
18:
19: public TCFileLock lock() throws IOException,
20: OverlappingFileLockException {
21: return new TCFileLockImpl(channel.lock());
22: }
23:
24: public void close() throws IOException {
25: channel.close();
26: }
27:
28: public TCFileLock tryLock() throws IOException,
29: OverlappingFileLockException {
30: FileLock lock = channel.tryLock();
31: if (lock != null) {
32: return new TCFileLockImpl(lock);
33: }
34: return null;
35: }
36:
37: }
|