private void stopController(Object object) { terminateRunningController(); if (!(object instanceof Runnable)) { stopAgentContextAware(object); } }
private void startController(final Object object) { terminateRunningController(); initAgentContextAware(object); // In case of a Runnable, we start a separate thread that executes this task... if (object instanceof Runnable) { ScheduledExecutorService executorService = getHandler(ScheduledExecutorService.class); if (executorService == null || executorService.isShutdown()) { return; } m_future = executorService.submit(new Runnable() { private static final String NAME = "ACE Agent Controller"; @Override public void run() { // Annotate the name of the thread for debugging purposes... Thread.currentThread().setName(NAME); startAgentContextAware(object); ((Runnable) object).run(); stopAgentContextAware(object); } }); } else { // Expect the controller to handle its own execution... startAgentContextAware(object); } }