<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Looks promising, yes. I especially like the idea of wrapping mono addins with our own interface.<BR>
 <BR>
We at Tribal have some software where we hard-load all plugins, circumventing all that general addins functionality.<BR>
 <BR>
I would suggest the PluginLoader change name to PluginCollection, though?<BR>
<BR>Best regards,<BR>Stefan Andersson<BR>Tribal Media AB<BR> <BR>Join the 3d web revolution : <A href="http://tribalnet.se/" target=_blank>http://tribalnet.se/</A><BR> <BR><BR><BR><BR>

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