[Opensim-dev] Converting the GridServer to PluginLoader
Ryan McDougall
sempuki1 at gmail.com
Fri Jul 18 02:54:44 UTC 2008
On Thu, 2008-07-17 at 19:19 -0400, Sean Dague wrote:
> On Thu, Jul 17, 2008 at 06:13:25PM +0900, Ryan McDougall wrote:
> > So after I converted the obvious code that was currently using
> > Mono.Addins, I began to look around for other cases for dynamic loading,
> > to see how I adapt it.
> >
> > First is to move IGridData and ILogData to PluginLoader, which is
> > accomplished in the patch attached to the following bug.
> >
> > Due to some problems with HEAD at the time of testing, I am not
> > confident that this should be applied right away. I think that it works
> > fine, but until I can verify that on a known-to-work HEAD, it should be
> > held off.
> >
> > However, that shouldn't stop review of the work. I await your comments.
> >
> > http://opensimulator.org/mantis/view.php?id=1763
>
> I've read through the patch, and it looks pretty reasonable to me (other
> than the typos in the log messages Chris caught).
>
> -Sean
One comment I forgot to make on the bug tracker that affects the public
interface and thus requires public comments:
Currently the GridServer_Config.xml has a database_provider field, which
is the file name of the DLL that the user wishes to use for their
database.
For example:
<Root>
<Config ... database_provider="OpenSim.Data.MySQL.dll" ... />
</Root>
One of the key features of Mono.Addins (and any other sane plugin loader
IMO) is that it abstracts away a dependence on system file names in
favor of an abstract "extension point" for the sink, which looks a
little bit like a path (ex: "/OpenSim/GridData"), and an abstract "addin
id" for the source, which is the fully qualified .NET namespace if you
leave it as default (ex: "OpenSim.Data.MySQL.MySQLGridData").
This allows you to decouple provider and consumer, and is a cleaner
architecture.
Currently OpenSim takes all the classes in a certain namespace and rolls
them into one assembly (ex: OpenSim.Data.MySQL.* ->
OpenSim.Data.MySQL.dll), which acts as a provider for all database
related functionality.
When Mono.Addins starts up, it builds a registry of addins by reading
all assemblies (ex: OpenSim.Data.MySQL.dll,
OpenSim.Data.MSSQL.dll, ...), and extracting the meta-information about
which assemblies provide for which extension points (ex: both MySQL.dll
and MSSQL.dll provide for "/OpenSim/GridData").
In order to select only one (ex: of MySQL or MSSQL), I have to read the
configuration file, and filter the addins based on the content of
"database_provider".
My patch adds a bit of a hack that transforms that DLL file name back
into the fully qualified namespace by striping the "dll", copying the
the nearest namespace member (ex: "MySQL") and appending the class we
are looking for, in order to map the "database_provider" into a "addin
id == fully qualified name".
This is a fragile hack because it relies on a close mapping from file
names to .NET names, and if that ever changes this all breaks.
I am currently investigating a more robust method of mapping/filtering,
but it should be decided whether the current hack is acceptable for the
time being.
In the future I expect that database_provider will have to be changed
from a file name to an abstract name such as simply "MySQL" or "MSSQL",
and that would affect existing installations.
Cheers,
More information about the Opensim-dev
mailing list