Re: Pluggable Modules
From: Bent C Dalager (bcd_at_pvv.ntnu.no)
Date: 10/05/03
- Next message: Sandy Dunlop: "Re: Problem with Apache AXIS WSDL2Java"
- Previous message: Paul Lutus: "Re: Difficulties using TableSorter class from Sun's tutorial."
- Next in thread: Lee Fesperman: "Re: Pluggable Modules"
- Maybe reply: Lee Fesperman: "Re: Pluggable Modules"
- Maybe reply: Roedy Green: "Re: Pluggable Modules"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 4 Oct 2003 22:50:23 +0000 (UTC)
In article <ErGfb.6812$QH3.4853@newsfep4-winn.server.ntli.net>,
VisionSet <spam@ntlworld.com> wrote:
>
>"Bent C Dalager" <bcd@pvv.ntnu.no> wrote in message
>news:blnbnb$epm$1@tyfon.itea.ntnu.no...
>> In article <uiGfb.6806$QH3.2724@newsfep4-winn.server.ntli.net>,
>> VisionSet <spam@ntlworld.com> wrote:
>> >
>> >I'm not sure what you're getting at, what's wrong with:
>> >put them on the classpath
>> >Class.forName("myPackage.myClass");
>>
>> You'll typically have a number of these classes. You write one
>> Class.forName() call for each?
>>
>
>Like I said I'm not up on plugins
>so, what usualy happens? user specifies plugin ?
>directory search of available classes under com.me.plugins.* ?
>properties file with plugins specified ?
>loop through them with class.forName()
>or load on demand from these details stored in collection ?
It all really depends on how close you want the user to be to the
configuration. If he is meant to edit it at all, it could just be an
obscure file somewhere he has to load into a text editor to edit
manually, or your app could provide him with a way to edit it in a
user friendly manner. Or the modules might automatically install
themselves and update the config file.
There isn't really a decent way of searching for classes from within
Java, though, so I believe the common solution is to have a list of
classes to load in a config file.
I'd imagine something like this (exception handling omitted):
String[] classesToLoad = myConfig.getPluginModuleClassNames();
for (int i = 0; i < classesToLoad.length; ++i)
{
Module m = (Module) Class.forName(classesToLoad[i]).newInstance();
m.startModule();
}
where myConfig.getPluginModuleClassNames() loads a list of class names
from the config file, and "Module" is the interface that all my
plugins must implement.
Cheers
Bent D
-- Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd powered by emacs
- Next message: Sandy Dunlop: "Re: Problem with Apache AXIS WSDL2Java"
- Previous message: Paul Lutus: "Re: Difficulties using TableSorter class from Sun's tutorial."
- Next in thread: Lee Fesperman: "Re: Pluggable Modules"
- Maybe reply: Lee Fesperman: "Re: Pluggable Modules"
- Maybe reply: Roedy Green: "Re: Pluggable Modules"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|