Author: j16sdiz
Date: 2008-12-27 05:28:03 +0000 (Sat, 27 Dec 2008)
New Revision: 24795
Modified:
trunk/plugins/XMLSpider/XMLSpider.java
Log:
custom exit hook
Modified: trunk/plugins/XMLSpider/XMLSpider.java
===================================================================
--- trunk/plugins/XMLSpider/XMLSpider.java 2008-12-26 10:07:22 UTC (rev
24794)
+++ trunk/plugins/XMLSpider/XMLSpider.java 2008-12-27 05:28:03 UTC (rev
24795)
@@ -503,7 +503,10 @@
}
public void terminate(){
+ Logger.normal(this, "XMLSpider terminating");
+
synchronized (this) {
+ Runtime.getRuntime().removeShutdownHook(exitHook);
stopped = true;
for (Map.Entry<Page, ClientGetter> me :
runningFetch.entrySet()) {
@@ -521,12 +524,25 @@
synchronized (this) {
termCache.clear();
}
+
+ Logger.normal(this, "XMLSpider terminated");
}
+ public class ExitHook implements Runnable {
+ public void run() {
+ Logger.normal(this, "XMLSpider exit hook called");
+ terminate();
+ }
+ }
+
+ private Thread exitHook = new Thread(new ExitHook());
+
public synchronized void runPlugin(PluginRespirator pr) {
this.core = pr.getNode().clientCore;
this.pr = pr;
pageMaker = pr.getPageMaker();
+
+ Runtime.getRuntime().addShutdownHook(exitHook);
/* Initialize Fetch Context */
this.ctx = pr.getHLSimpleClient().getFetchContext();
@@ -803,7 +819,7 @@
cfg.activationDepth(3);
cfg.updateDepth(3);
- // cfg.automaticShutDown(false);
+ cfg.automaticShutDown(false);
cfg.queries().evaluationMode(QueryEvaluationMode.LAZY);
cfg.diagnostic().addListener(new DiagnosticToConsole());
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs