From: <mr...@us...> - 2004-05-12 21:41:18
|
Update of /cvsroot/struts/struts-flow/src/java/flow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20780/src/java/flow Modified Files: ContinuationsManager.java ContinuationsManagerImpl.java Log Message: Added clean shutdown procedures and expiration thread Index: ContinuationsManager.java =================================================================== RCS file: /cvsroot/struts/struts-flow/src/java/flow/ContinuationsManager.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ContinuationsManager.java 12 May 2004 00:03:45 -0000 1.1.1.1 --- ContinuationsManager.java 12 May 2004 21:41:07 -0000 1.2 *************** *** 114,116 **** --- 114,118 ---- */ public void displayAllContinuations(); + + public void destroy(); } Index: ContinuationsManagerImpl.java =================================================================== RCS file: /cvsroot/struts/struts-flow/src/java/flow/ContinuationsManagerImpl.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ContinuationsManagerImpl.java 12 May 2004 00:03:45 -0000 1.1.1.1 --- ContinuationsManagerImpl.java 12 May 2004 21:41:07 -0000 1.2 *************** *** 98,101 **** --- 98,103 ---- */ protected SortedSet expirations = Collections.synchronizedSortedSet(new TreeSet()); + + private Thread expireThread; private Logger logger = new Logger(); *************** *** 113,116 **** --- 115,141 ---- random.setSeed(System.currentTimeMillis()); bytes = new byte[CONTINUATION_ID_LENGTH]; + expireThread = new Thread( + new Runnable() { + public void run() { + boolean shouldKeepRunning = true; + while (shouldKeepRunning) { + try { + Thread.sleep(1000); + } + catch (InterruptedException ex) { + getLogger().debug("Continuation expiration thread interrupted"); + shouldKeepRunning = false; + } + if (shouldKeepRunning) { + expireContinuations(); + } + } + } + }); + + getLogger().debug("Starting continuation expiration thread"); + expireThread.setName("Flow continuations expiration thread"); + expireThread.setPriority(Thread.MIN_PRIORITY); + expireThread.start(); } *************** *** 310,313 **** --- 335,349 ---- } } + + public void destroy() { + expirations.clear(); + for (Iterator i = forrest.iterator(); i.hasNext(); ) { + removeContinuation((WebContinuation)i.next()); + } + + if (expireThread != null && expireThread.isAlive()) { + expireThread.interrupt(); + } + } /** |