You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2007/06/17 18:50:45 UTC
svn commit: r548065 - in
/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket:
protocol/http/WebApplication.java util/file/FileCleaner.java
util/thread/Task.java util/watch/ModificationWatcher.java
Author: jdonnerstag
Date: Sun Jun 17 09:50:44 2007
New Revision: 548065
URL: http://svn.apache.org/viewvc?view=rev&rev=548065
Log:
wicket-641: wicket thread handling is not fully servlet container aware
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/file/FileCleaner.java
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Task.java
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java?view=diff&rev=548065&r1=548064&r2=548065
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java Sun Jun 17 09:50:44 2007
@@ -45,6 +45,7 @@
import org.apache.wicket.request.target.coding.SharedResourceRequestTargetUrlCodingStrategy;
import org.apache.wicket.session.ISessionStore;
import org.apache.wicket.util.collections.MostRecentlyUsedMap;
+import org.apache.wicket.util.file.FileCleaner;
import org.apache.wicket.util.file.IResourceFinder;
import org.apache.wicket.util.file.WebApplicationPath;
import org.apache.wicket.util.lang.PackageName;
@@ -494,6 +495,7 @@
super.internalDestroy();
bufferedResponses.clear();
getSessionStore().destroy();
+ FileCleaner.destroy();
}
/**
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/file/FileCleaner.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/file/FileCleaner.java?view=diff&rev=548065&r1=548064&r2=548065
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/file/FileCleaner.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/file/FileCleaner.java Sun Jun 17 09:50:44 2007
@@ -25,9 +25,9 @@
/**
* Keeps track of files awaiting deletion, and deletes them when an associated marker
* object is reclaimed by the garbage collector.
+ *
* @author Noel Bergman
* @author Martin Cooper
- * @version $Id$
*/
public class FileCleaner
{
@@ -82,6 +82,19 @@
reaper.start();
}
+ /**
+ * Stop the daemon thread
+ */
+ public static void destroy()
+ {
+ if (reaper != null)
+ {
+ reaper.interrupt();
+
+ // TODO Do we need to manually remove the temp files now?
+ }
+ }
+
/**
* Track the specified file, using the provided marker, deleting the file when the
* marker instance is garbage collected.
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Task.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Task.java?view=diff&rev=548065&r1=548064&r2=548065
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Task.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Task.java Sun Jun 17 09:50:44 2007
@@ -57,9 +57,12 @@
/** The time that the task should start. */
private Time startTime = Time.now();
- /** When set the taks will stop as soon as possible. */
+ /** When set the task will stop as soon as possible. */
private boolean stop;
+ /** Each task has an associated Thread */
+ private Thread thread;
+
/**
* Constructor.
*
@@ -129,9 +132,9 @@
};
// Start the thread
- final Thread thread = new Thread(runnable, name + " Task");
- thread.setDaemon(isDaemon);
- thread.start();
+ this.thread = new Thread(runnable, name + " Task");
+ this.thread.setDaemon(isDaemon);
+ this.thread.start();
// We're started all right!
isStarted = true;
@@ -224,5 +227,17 @@
public void stop()
{
stop = true;
+ }
+
+ /**
+ * Will stop the task as soon as it does have that opportunity
+ */
+ public void interrupt()
+ {
+ stop();
+ if (this.thread != null)
+ {
+ thread.interrupt();
+ }
}
}
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java?view=diff&rev=548065&r1=548064&r2=548065
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java Sun Jun 17 09:50:44 2007
@@ -56,7 +56,7 @@
// The set of listeners to call when the modifiable changes
final ChangeListenerSet listeners = new ChangeListenerSet();
-
+
// The modifiable thing
IModifiable modifiable;
}
@@ -87,7 +87,8 @@
* The modifiable thing to monitor
* @param listener
* The listener to call if the modifiable is modified
- * @return <tt>true</tt> if the set did not already contain the specified element.
+ * @return <tt>true</tt> if the set did not already contain the specified
+ * element.
*/
public final boolean add(final IModifiable modifiable, final IChangeListener listener)
{
@@ -114,7 +115,7 @@
// The IModifiable is not returning a valid lastModifiedTime
log.info("Cannot track modifications to resource " + modifiable);
}
-
+
return true;
}
else
@@ -133,13 +134,13 @@
public IModifiable remove(final IModifiable modifiable)
{
final Entry entry = (Entry)modifiableToEntry.remove(modifiable);
- if(entry != null)
+ if (entry != null)
{
return entry.modifiable;
}
return null;
}
-
+
/**
* Start watching at a given polling rate
*
@@ -183,16 +184,17 @@
}
/**
- * stops the modification watcher from watching.
+ * stops the modification watcher from watching.
*/
public void destroy()
{
- if(task != null)
+ if (task != null)
{
- task.stop();
+// task.stop();
+ task.interrupt();
}
}
-
+
/**
* @return Gets all IModifiable entries currently maintained
*/