private void initializeInstanceFile() throws IOException { if (instanceFile != null || readOnly) return; this.instanceFile = File.createTempFile(".tmp", ".instance", managerRoot); //$NON-NLS-1$//$NON-NLS-2$ this.instanceFile.deleteOnExit(); instanceLocker = LocationHelper.createLocker(instanceFile, lockMode, false); instanceLocker.lock(); }
private void initializeInstanceFile() throws IOException { if (instanceFile != null || readOnly) return; this.instanceFile = File.createTempFile(".tmp", ".instance", managerRoot); //$NON-NLS-1$//$NON-NLS-2$ this.instanceFile.deleteOnExit(); instanceLocker = LocationHelper.createLocker(instanceFile, lockMode, false); instanceLocker.lock(); }
private void initializeInstanceFile() throws IOException { if (instanceFile != null || readOnly) return; this.instanceFile = File.createTempFile(".tmp", ".instance", managerRoot); //$NON-NLS-1$//$NON-NLS-2$ this.instanceFile.deleteOnExit(); instanceLocker = LocationHelper.createLocker(instanceFile, lockMode, false); instanceLocker.lock(); }
private void initializeInstanceFile() throws IOException { if (instanceFile != null || readOnly) return; this.instanceFile = File.createTempFile(".tmp", ".instance", managerRoot); //$NON-NLS-1$//$NON-NLS-2$ this.instanceFile.deleteOnExit(); instanceLocker = LocationHelper.createLocker(instanceFile, lockMode, false); instanceLocker.lock(); }
private void initializeInstanceFile() throws IOException { if (instanceFile != null || readOnly) return; this.instanceFile = File.createTempFile(".tmp", ".instance", managerRoot); //$NON-NLS-1$//$NON-NLS-2$ this.instanceFile.deleteOnExit(); instanceLocker = LocationHelper.createLocker(instanceFile, lockMode, false); instanceLocker.lock(); }
private void initializeInstanceFile() throws IOException { if (instanceFile != null || readOnly) return; this.instanceFile = File.createTempFile(".tmp", ".instance", managerRoot); //$NON-NLS-1$//$NON-NLS-2$ this.instanceFile.deleteOnExit(); instanceLocker = LocationHelper.createLocker(instanceFile, lockMode, false); instanceLocker.lock(); }
private boolean lock(boolean wait) throws IOException { if (readOnly) return false; if (locker == null) { locker = LocationHelper.createLocker(lockFile, lockMode, false); if (locker == null) throw new IOException(Msg.fileManager_cannotLock); } boolean locked = locker.lock(); if (locked || !wait) return locked; //Someone else must have the directory locked, but they should release it quickly long start = System.currentTimeMillis(); while (true) { try { Thread.sleep(200); // 5x per second } catch (InterruptedException e) {/*ignore*/ } locked = locker.lock(); if (locked) return true; // never wait longer than 5 seconds long time = System.currentTimeMillis() - start; if (time > MAX_LOCK_WAIT) return false; } }
private boolean lock(boolean wait) throws IOException { if (readOnly) return false; if (locker == null) { locker = LocationHelper.createLocker(lockFile, lockMode, false); if (locker == null) throw new IOException(Msg.fileManager_cannotLock); } boolean locked = locker.lock(); if (locked || !wait) return locked; //Someone else must have the directory locked, but they should release it quickly long start = System.currentTimeMillis(); while (true) { try { Thread.sleep(200); // 5x per second } catch (InterruptedException e) {/*ignore*/ } locked = locker.lock(); if (locked) return true; // never wait longer than 5 seconds long time = System.currentTimeMillis() - start; if (time > MAX_LOCK_WAIT) return false; } }
private boolean lock(boolean wait) throws IOException { if (readOnly) return false; if (locker == null) { locker = LocationHelper.createLocker(lockFile, lockMode, false); if (locker == null) throw new IOException(Msg.fileManager_cannotLock); } boolean locked = locker.lock(); if (locked || !wait) return locked; //Someone else must have the directory locked, but they should release it quickly long start = System.currentTimeMillis(); while (true) { try { Thread.sleep(200); // 5x per second } catch (InterruptedException e) {/*ignore*/ } locked = locker.lock(); if (locked) return true; // never wait longer than 5 seconds long time = System.currentTimeMillis() - start; if (time > MAX_LOCK_WAIT) return false; } }
private boolean lock(boolean wait) throws IOException { if (readOnly) return false; if (locker == null) { locker = LocationHelper.createLocker(lockFile, lockMode, false); if (locker == null) throw new IOException(Msg.fileManager_cannotLock); } boolean locked = locker.lock(); if (locked || !wait) return locked; //Someone else must have the directory locked, but they should release it quickly long start = System.currentTimeMillis(); while (true) { try { Thread.sleep(200); // 5x per second } catch (InterruptedException e) {/*ignore*/ } locked = locker.lock(); if (locked) return true; // never wait longer than 5 seconds long time = System.currentTimeMillis() - start; if (time > MAX_LOCK_WAIT) return false; } }
private boolean lock(boolean wait) throws IOException { if (readOnly) return false; if (locker == null) { locker = LocationHelper.createLocker(lockFile, lockMode, false); if (locker == null) throw new IOException(Msg.fileManager_cannotLock); } boolean locked = locker.lock(); if (locked || !wait) return locked; //Someone else must have the directory locked, but they should release it quickly long start = System.currentTimeMillis(); while (true) { try { Thread.sleep(200); // 5x per second } catch (InterruptedException e) {/*ignore*/ } locked = locker.lock(); if (locked) return true; // never wait longer than 5 seconds long time = System.currentTimeMillis() - start; if (time > MAX_LOCK_WAIT) return false; } }
private boolean lock(boolean wait) throws IOException { if (readOnly) return false; if (locker == null) { locker = LocationHelper.createLocker(lockFile, lockMode, false); if (locker == null) throw new IOException(Msg.fileManager_cannotLock); } boolean locked = locker.lock(); if (locked || !wait) return locked; //Someone else must have the directory locked, but they should release it quickly long start = System.currentTimeMillis(); while (true) { try { Thread.sleep(200); // 5x per second } catch (InterruptedException e) {/*ignore*/ } locked = locker.lock(); if (locked) return true; // never wait longer than 5 seconds long time = System.currentTimeMillis() - start; if (time > MAX_LOCK_WAIT) return false; } }
private boolean lock(File lock, URL locationValue) throws IOException { if (isReadOnly) throw new IOException(NLS.bind(Msg.location_folderReadOnly, lock)); if (lock == null) { if (locationValue != null && !"file".equalsIgnoreCase(locationValue.getProtocol())) //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.location_notFileProtocol, locationValue)); throw new IllegalStateException(Msg.location_noLockFile); // this is really unexpected } if (isLocked()) return false; File parentFile = new File(lock.getParent()); if (!parentFile.isDirectory()) { parentFile.mkdirs(); if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); } setLocker(lock); if (locker == null) return true; boolean locked = false; try { locked = locker.lock(); return locked; } finally { if (!locked) locker = null; } }
private boolean lock(File lock, URL locationValue) throws IOException { if (isReadOnly) throw new IOException(NLS.bind(Msg.location_folderReadOnly, lock)); if (lock == null) { if (locationValue != null && !"file".equalsIgnoreCase(locationValue.getProtocol())) //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.location_notFileProtocol, locationValue)); throw new IllegalStateException(Msg.location_noLockFile); // this is really unexpected } if (isLocked()) return false; File parentFile = new File(lock.getParent()); if (!parentFile.isDirectory()) { parentFile.mkdirs(); if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); } setLocker(lock); if (locker == null) return true; boolean locked = false; try { locked = locker.lock(); return locked; } finally { if (!locked) locker = null; } }
private boolean lock(File lock, URL locationValue) throws IOException { if (isReadOnly) throw new IOException(NLS.bind(Msg.location_folderReadOnly, lock)); if (lock == null) { if (locationValue != null && !"file".equalsIgnoreCase(locationValue.getProtocol())) //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.location_notFileProtocol, locationValue)); throw new IllegalStateException(Msg.location_noLockFile); // this is really unexpected } if (isLocked()) return false; File parentFile = new File(lock.getParent()); if (!parentFile.isDirectory()) { parentFile.mkdirs(); if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); } setLocker(lock); if (locker == null) return true; boolean locked = false; try { locked = locker.lock(); return locked; } finally { if (!locked) locker = null; } }
private boolean lock(File lock, URL locationValue) throws IOException { if (isReadOnly) throw new IOException(NLS.bind(Msg.location_folderReadOnly, lock)); if (lock == null) { if (locationValue != null && !"file".equalsIgnoreCase(locationValue.getProtocol())) //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.location_notFileProtocol, locationValue)); throw new IllegalStateException(Msg.location_noLockFile); // this is really unexpected } if (isLocked()) return false; File parentFile = new File(lock.getParent()); if (!parentFile.isDirectory()) { parentFile.mkdirs(); if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); } setLocker(lock); if (locker == null) return true; boolean locked = false; try { locked = locker.lock(); return locked; } finally { if (!locked) locker = null; } }
private boolean lock(File lock, URL locationValue) throws IOException { if (isReadOnly) throw new IOException(NLS.bind(Msg.location_folderReadOnly, lock)); if (lock == null) { if (locationValue != null && !"file".equalsIgnoreCase(locationValue.getProtocol())) //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.location_notFileProtocol, locationValue)); throw new IllegalStateException(Msg.location_noLockFile); // this is really unexpected } if (isLocked()) return false; File parentFile = new File(lock.getParent()); if (!parentFile.isDirectory()) { parentFile.mkdirs(); if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); } setLocker(lock); if (locker == null) return true; boolean locked = false; try { locked = locker.lock(); return locked; } finally { if (!locked) locker = null; } }
private boolean lock(File lock, URL locationValue) throws IOException { if (isReadOnly) throw new IOException(NLS.bind(Msg.location_folderReadOnly, lock)); if (lock == null) { if (locationValue != null && !"file".equalsIgnoreCase(locationValue.getProtocol())) //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.location_notFileProtocol, locationValue)); throw new IllegalStateException(Msg.location_noLockFile); // this is really unexpected } if (isLocked()) return false; File parentFile = new File(lock.getParent()); if (!parentFile.isDirectory()) { parentFile.mkdirs(); if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); } setLocker(lock); if (locker == null) return true; boolean locked = false; try { locked = locker.lock(); return locked; } finally { if (!locked) locker = null; } }
if (files[i].endsWith(".instance") && (instanceFile == null || !files[i].equalsIgnoreCase(instanceFile.getName()))) { //$NON-NLS-1$ Locker tmpLocker = LocationHelper.createLocker(new File(managerRoot, files[i]), lockMode, false); if (tmpLocker.lock()) {
if (files[i].endsWith(".instance") && (instanceFile == null || !files[i].equalsIgnoreCase(instanceFile.getName()))) { //$NON-NLS-1$ Locker tmpLocker = LocationHelper.createLocker(new File(managerRoot, files[i]), lockMode, false); if (tmpLocker.lock()) {