@Override public void restart() { DynamicTasks.queue("stop (if running)", new Runnable() { public void run() { boolean previouslyRunning = isRunning(); try { getEntity().setAttribute(Attributes.SERVICE_STATE, Lifecycle.STOPPING); stop(); } catch (Exception e) { if (previouslyRunning) { log.debug(getEntity() + " restart: stop failed, when was previously running", e); } else { log.debug(getEntity() + " restart: stop failed (but was not previously running, so not a surprise)", e); } } }}); if (doFullStartOnRestart()) { DynamicTasks.waitForLast(); getEntity().setAttribute(Attributes.SERVICE_STATE, Lifecycle.STARTING); start(); } else { DynamicTasks.queue("launch", new Runnable() { public void run() { getEntity().setAttribute(Attributes.SERVICE_STATE, Lifecycle.STARTING); launch(); }}); DynamicTasks.queue("post-launch", new Runnable() { public void run() { postLaunch(); }}); } }