@SuppressWarnings("deprecation") @PreDestroy private void cleanUp() throws Exception { // TODO Maybe Spring is better at handling these? log.info("\nClean up " + this.getClass().getSimpleName() + " (4) : "); // Shutdown the proxy if needed if (proxy != null) { proxy.shutdown(); } log.info("1 "); // Kill the message pump from within messageQueue.clear(); putMessage(TournamentEvent.QUIT); messageFeeder.join(); log.info("2 "); // Kill the state machine from within eventQueue.clear(); putEvent(TournamentEvent.QUIT); stateRunner.join(); log.info("3 "); for (Thread t : Thread.getAllStackTraces().keySet()) { if (t.getName().contains("Timer-") || t.getName().contains("ActiveMQ")) { synchronized (t) { t.stop(); } } } log.info("4\n"); }
// Attempt to log into a game. private void gameLogin() { log.info("Ping sim server"); if (null == proxy) { // no proxy yet for this game proxy = new LocalVisualizerProxy(); proxy.init(this); } proxy.sendMessage(new VisualizerStatusRequest()); }
// shut down the proxy at end-of-game, wait a few seconds, go again. private void recycle() { // no longer initialized initialized = false; // shutdown proxy and force re-creation if (proxy != null) { log.info("shut down proxy"); proxy.shutdown(); } proxy = null; // force recreation of the connection connectionFactory.destroy(); // wait for sim process to quit try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } }