private void work() throws IOException { try { // always delete file after invoking handler this.requestHandler.handleRequest(); } finally { try { this.file.delete(); } catch (SecurityException e) { ControllableProcess.getOrCreateLogWriter().warning("Unable to delete " + this.file, e); } } }
public void stop() { try { this.statusRequestFileWatchdog.stop(); } catch (InterruptedException e) { getOrCreateLogWriter().warning("Interrupted while stopping status handler for controllable process.", e); } finally { try { this.stopRequestFileWatchdog.stop(); } catch (InterruptedException e) { getOrCreateLogWriter().warning("Interrupted while stopping stop handler for controllable process.", e); } this.launcher.close(); } }
statusFileWatchdog.stop(); } catch (InterruptedException e) { ControllableProcess.getOrCreateLogWriter().info("Interrupted while stopping status file watchdog.", e); } catch (RuntimeException e) { ControllableProcess.getOrCreateLogWriter().info("Unexpected failure while stopping status file watchdog.", e);
@Override public void run() { try { // always set this.alive before stopping while (isAlive()) { try { // handle handle exceptions Thread.sleep(SLEEP_MILLIS); if (this.file.exists()) { try { // always check stopAfterRequest after main work work(); } finally { if (this.stopAfterRequest) { stopMe(); } } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); // allow to loop around and check isAlive() } catch (IOException e) { ControllableProcess.getOrCreateLogWriter().error("Unable to control process with " + this.file + ". Please add tools.jar from JDK to classpath for improved process control."); // allow to loop around and check isAlive() } } } finally { synchronized (this) { this.alive = false; } } }