Hi all,

some thoughts about the plugin package:

Currently the method Extension.getExtensionInstance returns a new
instance of an extension each time it is called. If an extension is a
singleton, each extension has to implement the singleton pattern.

My suggestion:
Add an instance cache to the Extension class. If an extension is marked
as a singleton, getExtensionInstance would always return the same instance.
Whether an extension is a singleton or not is determined by the
plugin.xml, for example:
<implementation id="org.apache.nutch.protocol.httpclient.Http"
                      class="org.apache.nutch.protocol.httpclient.Http"
                      singleton="true"
                      protocolName="https"/>
To be compatible with the current implementation, the singleton
attribute would not be required and the default value is false.

Main advantages I see:
- singleton code in extensions would disappear, the code is getting more
readable and smaller
-- static variable access would disappear (think of concurrency and
classloader issues)
- Instance control is handed over to the plugin "container"
- it's possible to have two instances of a singleton for testing purposes


What do you think?
 Thomas


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Nutch-developers mailing list
Nutch-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nutch-developers

Reply via email to