@Override public int waitFor() throws InterruptedException { // when there's no application controller we don't have to wait to terminate // (as we've already been terminated) if (m_controller != null) { // here we simply try to wait for the application's start future // to complete executing. try { if (m_startListener != null) { m_startListener.get(); } } catch (InterruptedException e) { throw e; } catch (ExecutionException e) { throw new RuntimeException(e.getCause()); } } return 0; }
/** * Submits a {@link Callable} for remote execution by the * {@link Application} and blocks waiting for the result. * * @param callable the {@link Callable} to execute * @param <T> the type of the result */ public <T> T submit(Callable<T> callable) { FutureCompletionListener<T> future = new FutureCompletionListener<T>(); submit(callable, future); try { return future.get(); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException("Failed to execute the Callable: " + callable, e); } }
@Override public void close() { if (m_controller != null) { // now try to stop try { m_destroyListener = new FutureCompletionListener<Void>(); m_controller.destroy(this, m_destroyListener); m_destroyListener.get(); } catch (Exception e) { LOGGER.log(Level.WARNING, "An exception occurred while closing the application", e); } m_controller = null; } // close the scope m_classLoader.getContainerScope().close(); }