/** * Starts the application. */ public void start() { if (m_controller == null) { m_startListener = null; } else { m_startListener = new FutureCompletionListener<Void>(); m_controller.start(this, m_startListener); } }
/** * 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(); }