Example #1
0
        /// <summary>
        /// Based on <typeparam name="T" />, returns the appropriate
        /// PluginInitialiserBase instance in <paramref name="init" /> and
        /// extension point path in <paramref name="path" />.
        /// </summary>
        /// <param name="connect">
        /// The DB connection string used when creating a new
        /// PluginInitialiserBase, returned in <paramref name="init" />.
        /// </param>
        /// <param name="init">
        /// A reference to a PluginInitialiserBase object in which the proper
        /// initialiser will be returned.
        /// </param>
        /// <param name="path">
        /// A string in which the proper extension point path will be returned.
        /// </param>
        /// <typeparam name="T">
        /// The type of data plugin requested.
        /// </typeparam>
        /// <exception cref="NotImplementedException">
        /// Thrown if <typeparamref name="T" /> is not one of the expected data
        /// interfaces.
        /// </exception>
        private static void PluginLoaderParamFactory <T>(string connect, out PluginInitialiserBase init, out string path) where T : IPlugin
        {
            Type type = typeof(T);

            if (type == typeof(IInventoryDataPlugin))
            {
                init = new InventoryDataInitialiser(connect);
                path = "/OpenSim/InventoryData";
            }
            else if (type == typeof(IUserDataPlugin))
            {
                init = new UserDataInitialiser(connect);
                path = "/OpenSim/UserData";
            }
            else if (type == typeof(IGridDataPlugin))
            {
                init = new GridDataInitialiser(connect);
                path = "/OpenSim/GridData";
            }
            else if (type == typeof(ILogDataPlugin))
            {
                init = new LogDataInitialiser(connect);
                path = "/OpenSim/LogData";
            }
            else if (type == typeof(IAssetDataPlugin))
            {
                init = new AssetDataInitialiser(connect);
                path = "/OpenSim/AssetData";
            }
            else
            {
                // We don't support this data plugin.
                throw new NotImplementedException(String.Format("The type '{0}' is not a valid data plugin.", type));
            }
        }
Example #2
0
        // This method loads the identified asset server, passing an approrpiately
        // initialized Initialise wrapper. There should to be exactly one match,
        // if not, then the first match is used.
        private IAssetServer loadAssetServer(string id, PluginInitialiserBase pi)
        {
            if (id != null && id != String.Empty)
            {
                m_log.DebugFormat("[OpenSim Base]: Attempting to load asset server id={0}", id);

                try
                {
                    PluginLoader<IAssetServer> loader = new PluginLoader<IAssetServer>(pi);
                    loader.AddFilter(PLUGIN_ASSET_SERVER_CLIENT, new PluginProviderFilter(id));
                    loader.Load(PLUGIN_ASSET_SERVER_CLIENT);

                    if (loader.Plugins.Count > 0)
                    {
                        m_log.DebugFormat("[OpenSim Base]: Asset server {0} loaded", id);
                        return (IAssetServer) loader.Plugins[0];
                    }
                }

                catch (Exception e)
                {
                    m_log.DebugFormat("[OpenSim]: Asset server {0} not loaded ({1})", id, e.Message);
                }
            }

            return null;
        }