本文整理了Java中org.openide.filesystems.FileLock.releaseLock()
方法的一些代码示例,展示了FileLock.releaseLock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileLock.releaseLock()
方法的具体详情如下:
包路径:org.openide.filesystems.FileLock
类名称:FileLock
方法名:releaseLock
[英]Release this lock. In typical usage this method will be called in a finally
clause.
[中]松开这把锁。在典型用法中,此方法将在finally
子句中调用。
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/** overriden */
public void close() throws IOException {
flock.releaseLock();
super.close();
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
private void releaseLockForDelegates() {
Iterator it = map.values().iterator();
while (it.hasNext()) {
FileLock l = (FileLock) it.next();
l.releaseLock();
}
map.clear();
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/** Releases lock for old file object and
* takes new one from newFo
*/
public void changeLocks(FileObject old, FileObject n)
throws IOException {
FileLock l = map.remove(old);
if (l != null) {
l.releaseLock();
}
addLock(n);
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
@Override
public void close() throws IOException {
try {
super.flush();
lock.releaseLock();
super.close();
} catch(IOException iex) {
if (lock.isValid()) {
lock.releaseLock();
}
throw iex;
}
}
};
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/** Finalize this object. Calls {@link #releaseLock} to release the lock if the program
* for some reason failed to.
*/
@Override
public void finalize() {
if(isValid()) {
releaseLock();
boolean assertOn = false;
assert assertOn = true;
if (assertOn) {
StreamPool.LOG.log(Level.SEVERE,
"Not released lock for file: " + toString() + " (trapped in finalizer)", lockedBy); // NOI18N
}
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/**
* Test if file is locked
* @return true if file is locked
* @since 7.3
*/
public boolean isLocked() {
FileLock fLock = null;
try {
fLock = lock();
} catch (FileAlreadyLockedException fax) {
return true;
} catch (IOException ex) {
return false;
} finally {
if (fLock != null) {
fLock.releaseLock();
}
}
return fLock == null;
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
public void releaseLock() {
if (this.isValid()) {
super.releaseLock();
unlock(this);
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/** Delete this file. If the file is a folder and it is not empty then
* all of its contents are also recursively deleted. FileObject is locked
* before delete and finally is this lock released.
*
* @exception IOException if the file could not be deleted or
* FileAlreadyLockedException if the file is already locked {@link #lock}
* @since 1.15
*/
public final void delete() throws IOException {
FileLock lock = lock();
try {
delete(lock);
} finally {
lock.releaseLock();
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
public void releaseLock() {
if (this.isValid()) {
super.releaseLock();
releaseLockForDelegates();
if (getCurrentMfLock() == this) {
// clears the reference to this lock from the file object
MultiFileObject.this.lock = null;
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/** Deletes a file object that will mask the given file.
* @param fs filesystem to work on
* @param res resource name of the file
* @exception IOException if it fails
*/
void unmaskFile(FileSystem fs, String res) throws IOException {
FileObject fo = findResourceOn(fs, res + MASK);
if (fo != null) {
FileLock lock = fo.lock();
try {
fo.delete(lock);
} finally {
lock.releaseLock();
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/** Moves file to the selected folder.
* This implementation uses a copy-and-delete mechanism, and automatically uses the necessary lock.
* @param source source file object
* @param destFolder destination folder
* @param newName file name (without extension) of destination file
* @return new file object
* @exception IOException if either the {@link #copyFile copy} or {@link FileObject#delete delete} failed
*/
public static FileObject moveFile(FileObject source, FileObject destFolder, String newName)
throws IOException {
FileLock lock = null;
try {
lock = source.lock();
return source.move(lock, destFolder, newName, source.getExt());
} finally {
if (lock != null) {
lock.releaseLock();
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
lock.releaseLock();
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
} catch(IOException iex) {
if (lock.isValid()) {
lock.releaseLock();
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
lock.releaseLock();
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
final public void delete(FileLock lock) throws IOException {
if (isFolder()) {
FileObject[] fos = this.getChildren();
for (int i = 0; i < fos.length; i++) {
FileObject fo = fos[i];
FileLock foLock = fo.lock();
try {
fo.delete(foLock);
} catch (IOException iex) {
String message = NbBundle.getMessage(AbstractFolder.class, "EXC_CannotDelete",
// XXX use FileUtil.getFileDisplayName instead?
getPath(), fo.getFileSystem().getDisplayName()
);
ExternalUtil.annotate(iex, message); //NOI18N
throw iex;
} finally {
foLock.releaseLock();
}
}
}
handleDelete(lock);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf
public @Override void close() throws IOException {
try {
this.delegate.close();
} finally {
this.lock.releaseLock();
synchronized (SourceFileObject.this) {
text = null;
}
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
private void releaseLockForDelegates() {
Iterator it = map.values().iterator();
while (it.hasNext()) {
FileLock l = (FileLock)it.next ();
l.releaseLock ();
}
map.clear ();
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base
public @Override void close() throws IOException {
try {
this.delegate.close();
} finally {
this.lock.releaseLock();
resetCaches();
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** Finalize this object. Calls {@link #releaseLock} to release the lock if the program
* for some reason failed to.
*/
public void finalize () {
assert (isValid ()) : assertMessageForInvalidLocks();
releaseLock ();
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders
public FileObject rename (String name) throws IOException {
boolean locked = isLocked ();
FileLock lock = takeLock();
try {
getFile().rename(lock, name, getFile().getExt());
} finally {
if (!locked)
lock.releaseLock();
}
return getFile ();
}
内容来源于网络,如有侵权,请联系作者删除!