Additionally, the "shutDown()" method (that shadows the one in
org.apache.nutch.plugin.Plugin) appears never to be called, even if
System.runFinalizersOnExit(true) (which is deprecated as dangerous) was
previously invoked.
The only way of having my shutdown code executed seems to be to place it in
my plugin's finalize() method, AND ensuring that the finalizers be called on
exit by placing somewhere in the initialization code the (deprecated) call
System.runFinalizersOnExit(true) .
Enzo
----- Original Message -----
From: "Enzo Michelangeli" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, June 05, 2007 10:20 AM
Subject: Loading mechnism of plugin classes and singleton objects
I have a question about the loading mechanism of plugin classes. I'm
working with a custom URLFilter, and I need a singleton object loaded and
initialized by the first instance of the URLFilter, and shared by other
instances (e.g., instantiated by other threads). I was assuming that the
URLFilter class was being loaded only once even when the filter is used by
multiple threads, so I tried to use a static member variable of my
URLFilter class to hold a reference to the object to be shared: but it
appears that the supposed singleton, actually, isn't, because the method
responsible for its instantiation finds the static field initialized to
null. So: are URLFilter classes loaded multiple times by their classloader
in Nutch? The wiki page at
http://wiki.apache.org/nutch/WhichTechnicalConceptsAreBehindTheNutchPluginSystem
seems to suggest otherwise:
Until Nutch runtime, only one instance of such a plugin
class is alive in the Java virtual machine.
(By the way, what does "Until Nutch runtime" mean here? Before Nutch
runtime, no class whatsoever is supposed to be alive in the JVM, is it?)
Enzo