Plugins

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(New page: ==Overview== OpenSim uses several mechanisms to enable dynamic configuration of functionality. This page describes these mechanisms. ==Dynamic Plugins with Mono.Addins== Some types of p...)
 
m (Robot: Replacing 'OpenSim' to 'OpenSimulator', which is the precise name)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Overview==
 
==Overview==
  
OpenSim uses several mechanisms to enable dynamic configuration of functionality. This page describes these mechanisms.
+
OpenSimulator uses several mechanisms to enable dynamic configuration of functionality. This page describes these mechanisms.
  
==Dynamic Plugins with Mono.Addins==
+
== Dynamic Plugins with Mono.Addins ==
  
 
Some types of plugins are discovered at runtime using '''Extension Points''', and loaded using '''Mono.Addins'''. This mechanism is described in detail [[How to create a dynamic plugin|here]] and [[Dynamic Plugin Quickstart|here]].
 
Some types of plugins are discovered at runtime using '''Extension Points''', and loaded using '''Mono.Addins'''. This mechanism is described in detail [[How to create a dynamic plugin|here]] and [[Dynamic Plugin Quickstart|here]].
Line 12: Line 12:
 
This mechanism is currently used in the following cases:
 
This mechanism is currently used in the following cases:
  
'''/OpenSim/Startup''' - application plugins (IApplicationPlugin). Loaded by OpenSimBase when OpenSim starts. The plugins are loaded using PluginLoader.
+
'''/OpenSim/Startup''' - application plugins (IApplicationPlugin). Loaded by OpenSimBase when OpenSimulator starts. The plugins are loaded using PluginLoader.
  
 
'''/OpenSim/RegionModules''' - region modules. Loaded by RegionModulesControllerPlugin, which is itself an application plugin. The plugins are loaded by calling AddinManager directly (not through PluginLoader).
 
'''/OpenSim/RegionModules''' - region modules. Loaded by RegionModulesControllerPlugin, which is itself an application plugin. The plugins are loaded by calling AddinManager directly (not through PluginLoader).
Line 18: Line 18:
 
'''/OpenSim/WindModule''' - wind models. Loaded by WindModule, which is itself a region module. The plugins are loaded by calling AddinManager directly.
 
'''/OpenSim/WindModule''' - wind models. Loaded by WindModule, which is itself a region module. The plugins are loaded by calling AddinManager directly.
  
==Specifying Plugin Implementation in the Configuration==
+
 
 +
==== Unused Extension Points ====
 +
 
 +
There are some extension points defined that are never actually loaded. For example, OpenSim.data.MySQL.addin.xml defines plugins that '''provide''' implementations for extension points such as "/OpenSim/GridData" and "/OpenSim/AssetData". However, no-one actually loads these extension points (as far as I can see). Instead, these plugins are loaded using the config-files technique described below.
 +
 
 +
These points have been removed in OpenSimulator code after 0.7.1.1.
 +
 
 +
== Specifying Plugin Implementation in the Configuration ==
  
 
For most plugins, the class that should be used to implement the plugin's interface is specified explicitly in one of the .INI files. The application then simply loads the assembly (DLL); finds the specified class; and instantiates it.
 
For most plugins, the class that should be used to implement the plugin's interface is specified explicitly in one of the .INI files. The application then simply loads the assembly (DLL); finds the specified class; and instantiates it.
Line 33: Line 40:
  
  
Let's take the example of the data-access plugin further. Most classes that need to access the database have a Data interface defined. For example, PresenseService defines IPresenceData. This interface has implementations for all of the databases OpenSim supports. When the service starts, it loads the database assembly that was specified in the configuration, and then finds in that assembly the class that implements the desired interface (IPresenceData). The code looks something like this (although this is simplified):
+
Let's take the example of the data-access plugin further. Most classes that need to access the database have a Data interface defined. For example, PresenseService defines IPresenceData. This interface has implementations for all of the databases OpenSimulator supports. When the service starts, it loads the database assembly that was specified in the configuration, and then finds in that assembly the class that implements the desired interface (IPresenceData). The code looks something like this (although this is simplified):
  
 
  IConfig dbConfig = config.Configs["DatabaseService"];
 
  IConfig dbConfig = config.Configs["DatabaseService"];
Line 39: Line 46:
 
  IPresenceData m_Database = LoadPlugin<IPresenceData>(dllName);
 
  IPresenceData m_Database = LoadPlugin<IPresenceData>(dllName);
  
==Connectors==
+
== Connectors ==
  
 
Robust finds and loads its [[Connectors]] by having them specified explicitly in Robust.ini (in the "ServiceConnectors" entry). Since the plugins are specified explicitly, this works by loading the DLL's manually. However, it's somewhat similar to the Mono.Addins technique in that Robust loads '''all''' the connectors specified; not just one. Perhaps it can be refactored someday to truly use Mono.Addins.
 
Robust finds and loads its [[Connectors]] by having them specified explicitly in Robust.ini (in the "ServiceConnectors" entry). Since the plugins are specified explicitly, this works by loading the DLL's manually. However, it's somewhat similar to the Mono.Addins technique in that Robust loads '''all''' the connectors specified; not just one. Perhaps it can be refactored someday to truly use Mono.Addins.
  
 
The connectors are loaded by calling ServerUtils.LoadPlugin<IServiceConnector>().
 
The connectors are loaded by calling ServerUtils.LoadPlugin<IServiceConnector>().

Latest revision as of 22:54, 3 March 2012

Contents

[edit] Overview

OpenSimulator uses several mechanisms to enable dynamic configuration of functionality. This page describes these mechanisms.

[edit] Dynamic Plugins with Mono.Addins

Some types of plugins are discovered at runtime using Extension Points, and loaded using Mono.Addins. This mechanism is described in detail here and here.

These types of plugins are used when it's desirable to load all the plugins of a particular type.


This mechanism is currently used in the following cases:

/OpenSim/Startup - application plugins (IApplicationPlugin). Loaded by OpenSimBase when OpenSimulator starts. The plugins are loaded using PluginLoader.

/OpenSim/RegionModules - region modules. Loaded by RegionModulesControllerPlugin, which is itself an application plugin. The plugins are loaded by calling AddinManager directly (not through PluginLoader).

/OpenSim/WindModule - wind models. Loaded by WindModule, which is itself a region module. The plugins are loaded by calling AddinManager directly.


[edit] Unused Extension Points

There are some extension points defined that are never actually loaded. For example, OpenSim.data.MySQL.addin.xml defines plugins that provide implementations for extension points such as "/OpenSim/GridData" and "/OpenSim/AssetData". However, no-one actually loads these extension points (as far as I can see). Instead, these plugins are loaded using the config-files technique described below.

These points have been removed in OpenSimulator code after 0.7.1.1.

[edit] Specifying Plugin Implementation in the Configuration

For most plugins, the class that should be used to implement the plugin's interface is specified explicitly in one of the .INI files. The application then simply loads the assembly (DLL); finds the specified class; and instantiates it.

These types of plugins are used when it only makes sense to load a single implementation of the plugin; not all the available implementations. For example, only one database access module can be used. Therefore, the .INI files contain directives such as these:

[DatabaseService]
   StorageProvider = "OpenSim.Data.MySQL.dll"

Sometimes the definition also specifies which class to use. For example:

[InventoryService]
   LocalServiceModule = "OpenSim.Services.InventoryService.dll:XInventoryService"


Let's take the example of the data-access plugin further. Most classes that need to access the database have a Data interface defined. For example, PresenseService defines IPresenceData. This interface has implementations for all of the databases OpenSimulator supports. When the service starts, it loads the database assembly that was specified in the configuration, and then finds in that assembly the class that implements the desired interface (IPresenceData). The code looks something like this (although this is simplified):

IConfig dbConfig = config.Configs["DatabaseService"];
string dllName = dbConfig.GetString("StorageProvider");
IPresenceData m_Database = LoadPlugin<IPresenceData>(dllName);

[edit] Connectors

Robust finds and loads its Connectors by having them specified explicitly in Robust.ini (in the "ServiceConnectors" entry). Since the plugins are specified explicitly, this works by loading the DLL's manually. However, it's somewhat similar to the Mono.Addins technique in that Robust loads all the connectors specified; not just one. Perhaps it can be refactored someday to truly use Mono.Addins.

The connectors are loaded by calling ServerUtils.LoadPlugin<IServiceConnector>().

Personal tools
General
About This Wiki