Integration with platonos plugin engine
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
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>
Extension point "dataSource" is a bean which is configured in the main application's spring context.
The plugin java code which uses the bean called dataSource looks like this:
Code:
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;
}
}
Additionally, I have introduced a default spring configuration file 'plugin-context.xml' which can be used to configure beans which
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
Code:
HibernateDao dao = (HibernateDao) getBean("hibernateDao");
I found this a convenient way to avoid app context creation code.
If there is interest in this code, I could test it and submit a patch for platonos and for spring rich client.
Kambiz