KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > io > TCFileChannelImpl


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