Re: Pluggable Modules

From: Bent C Dalager (bcd_at_pvv.ntnu.no)
Date: 10/05/03


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


Relevant Pages

  • Re: modular application
    ... > I just have a config file to load the modules... ... If your application allows for extensibility via remotely loaded plugins, ... There are some articles e.g., on MSDN that touch this topic briefly, e.g., ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Having Module::Pluggable find plugins at runtime
    ... # stateDir => the path plugins can store state data to ... # Want to load all the .pm files in pluginDir now ... it to be specified in a config file. ...
    (perl.beginners)
  • Re: AICU320.ADD failed to load
    ... adapter to the hard drive and edit the config file. ... I achieved this by creating boot floppies which included the same driver. ... How do I persuade it to load from the hard drive? ...
    (comp.periphs.scsi)
  • Re: kinit ignores kdc in config file on Mac 10.5
    ... As to why it would try to contact a host matching the name of the realm, ... Our basic library code shouldn't do that, but Apple ships a couple of KDC-locating plugins in /System/Library/ KerberosPlugins/KerberosFrameworkPlugins which I haven't looked at. ... Our library code does allow plugins to override the config file; perhaps one of them is doing so. ...
    (comp.protocols.kerberos)
  • Re: Cross domain performance
    ... I will assume there is no solution and I have to load the plugins in the ... main appdomain in order to perform at a respectable level. ... Calling in to these interfaces is what is slowing me down. ...
    (microsoft.public.dotnet.framework.performance)

Loading