[Opensim-dev] Module/Plugin Loading

Stefan Andersson stefan at tribalmedia.se
Tue Jun 24 09:20:15 UTC 2008


Looks promising, yes. I especially like the idea of wrapping mono addins with our own interface.
 
We at Tribal have some software where we hard-load all plugins, circumventing all that general addins functionality.
 
I would suggest the PluginLoader change name to PluginCollection, though?
Best regards,Stefan AnderssonTribal Media AB Join the 3d web revolution : http://tribalnet.se/ 



> From: sempuki1 at gmail.com> To: opensim-dev at lists.berlios.de> Date: Tue, 24 Jun 2008 17:53:41 +0900> Subject: [Opensim-dev] Module/Plugin Loading> > I've started looking at module/plugin loading in OpenSim. Some have> commented that the current situation where things are loaded and> initialized ad hoc should be replaced by a greater use of Mono.Addins.> > In my survey of the code I've identified a lot of copy-paste code, which> minimally I can remove by consolidating that code into a common class or> method. However I'd like to try and do a little better, and provide a> framework for all the ad hoc loading.> > I've identified the following Interfaces which appear to be loaded> dynamically somewhere:> > > ILogData> IUserData> IAssetProvider> IInventoryData> IApplicationPlugin> IRegionModule> IRegionDataStore> IGridPlugin> IGridData> IGenericConfig> IDataNode> IDataSnapshotProvider> IClientNetworkServer> IPhysicsPlugin> IMeshingPlugin> ITerrainEffect> ITerrainLoader> ITarget> > Does that look like a comprehensive list?> Whats the difference between a Plugin and a Module?> > I suggest wrapping Mono.Addins into a simple common loader class as> follows:> > Extend IPlugin to the following:> > public class PluginInitData {}> > public interface IPlugin : IDispose> {> string Version { get; }> string Name { get; }> void Initialise (PluginInitData);> }> > and create:> > PluginLoader : IDispose> {> List<IPlugin> plugins = new List<IPlugin>();> > PluginLoader (string dir)> { > AddPluginDir (dir);> }> > void AddPluginDir (string dir)> {> AddinManager.Initialize (dir);> }> > void Load (string extpoint, PluginInitData data)> {> LoadUninitialized (extpoint);> Initialize (data);> }> > void LoadUninitialized <T> (string extpoint) where T : IPlugin> {> AddinManager.Registry.Update (null);> ExtensionNodeList ns = AddinManager.GetExtensionNodes(extpoint);> foreach (TypeExtensionNode n in ns)> {> log.Info("[PLUGINS]: Loading plugin " + n.Path);> plugins.Add ((T) n.CreateInstance());> }> }> > void Initialize (PluginInitData data)> {> foreach (IPlugin p in plugins)> p.Initialize (data);> }> > void Dispose ()> {> foreach (IPlugin p in plugins)> p.Dispose ();> }> }> > Which would be used in the following way:> > 1. Plugins would be created this way> > class MyPluginInitData : PluginInitData> {> int foo;> string bar;> };> > class MyPlugin : IPlugin> {> Initialize (PluginInitData data)> {> MyPluginInitData d = data as MyPluginInitData;> //...> }> //...> }> > 2. And would be loaded this way:> > PluginLoader loader = new PluginLoader ("my/plugin/dir");> MyPluginInitData data = new MyPluginInitData (42, "huzzah");> > loader.load ("/OpenSim/MyPlugins", data);> > Whozit w = new Whozit();> w.lart (loader.plugins); // does stuff with plugins> > What do you think?> > > _______________________________________________> Opensim-dev mailing list> Opensim-dev at lists.berlios.de> https://lists.berlios.de/mailman/listinfo/opensim-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-dev/attachments/20080624/b499a490/attachment-0001.html>


More information about the Opensim-dev mailing list