/** * The dispose operation is called at the end of a components lifecycle. Instances of this class * use this method to release and destroy any resources that they own. * * <p>This implementation shuts down the LinearProcessors managed by this JamesSpoolManager * * @throws Exception if an error is encountered during shutdown */ public void dispose() { getLogger().info("JamesSpoolManager dispose..."); active = false; // shutdown the threads for (Iterator it = spoolThreads.iterator(); it.hasNext(); ) { ((Thread) it.next()).interrupt(); // interrupt any waiting accept() calls. } long stop = System.currentTimeMillis() + 60000; // give the spooler threads one minute to terminate gracefully while (numActive != 0 && stop > System.currentTimeMillis()) { try { Thread.sleep(1000); } catch (Exception ignored) { } } getLogger().info("JamesSpoolManager thread shutdown completed."); Iterator it = processors.keySet().iterator(); while (it.hasNext()) { String processorName = (String) it.next(); if (getLogger().isDebugEnabled()) { getLogger().debug("Processor " + processorName); } LinearProcessor processor = (LinearProcessor) processors.get(processorName); processor.dispose(); processors.remove(processor); } }