I don't know if there is general interest in a plugin architecture. In search of one, I found the platonos pluginengine project:
http://platonos.sourceforge.net/quickstart/
which uses a simple plugin.xml configuration file, which defines extension points for or dependencies on other plugins. Plugins can either be deployed in a jar or as a file system directory hierarchy.
I have tried to integrate platonos into the Spring RC. I have an initial version which is partly tested (immediately after coding it, I had to leave
it to do some other work).
The idea behind it is: if an extension point has a name which is equal to a bean name in the application context and no class is specified, then a new extension is constructed during the extension loading process and
provided to the extended plugin.
I think I cannot express it very well, so, here is an example:
plugin.xml contains
Extension point "dataSource" is a bean which is configured in the main application's spring context.Code:<plugin start="true"> <uid>my.data.plugin</uid> <name>My Data Plugin</name> <lifecycleclass>xyz.plugin.data.DbMaintenance</lifecycleclass> <extensionpoints> <extensionpoint name="dataSource" /> </extensionpoints> </plugin>
The plugin java code which uses the bean called dataSource looks like this:
Additionally, I have introduced a default spring configuration file 'plugin-context.xml' which can be used to configure beans whichCode:public class DbMaintenance extends SpringPlugin { private DriverManagerDataSource ds; public DbMaintenance() { super(); } protected void onInitialize() { // do something useful } protected void onStart() { log.info("Starting"); ds = (DriverManagerDataSource) getBean("dataSource"); log.info("data source driver: " + ds.getDriverClassName()); // ... } protected void stop() { log.info("Stopping"); // clean up by de-referencing the extensions ds = null; } }
are not injected from the application context, but defined in the plugin itself.
Using this method, a bean 'hibernateDao' defined in plugin-context.xml can be retrieved with
I found this a convenient way to avoid app context creation code.Code:HibernateDao dao = (HibernateDao) getBean("hibernateDao");
If there is interest in this code, I could test it and submit a patch for platonos and for spring rich client.
Kambiz


Reply With Quote