コード例 #1
0
        /// <summary>
        /// Initializes the asset cache. This supports legacy configuration values
        /// to ensure consistent operation, but values outside of that namespace
        /// are handled by the more generic resolution mechanism provided by
        /// the ResolveAssetServer virtual method. If extended resolution fails,
        /// then the normal default action is taken.
        /// Creation of the AssetCache is handled by ResolveAssetCache. This
        /// function accepts a reference to the instantiated AssetServer and
        /// returns an IAssetCache implementation, if possible. This is a virtual
        /// method.
        /// </summary>
        protected virtual void InitializeAssetCache()
        {
            IAssetServer assetServer = null;
            string       mode        = m_configSettings.AssetStorage;

            if (String.IsNullOrEmpty(mode))
            {
                throw new Exception("No asset server specified");
            }

            AssetClientPluginInitializer linit = new AssetClientPluginInitializer(m_configSettings);

            //todo: hack to handle transition from whip
            if (mode.ToUpper() == "WHIP")
            {
                mode = mode.ToUpper();
            }

            assetServer = loadAssetServer(mode, linit);

            if (assetServer == null)
            {
                throw new Exception(String.Format("Asset server {0} could not be loaded", mode));
            }

            // Initialize the asset cache, passing a reference to the selected
            // asset server interface.
            m_assetCache = ResolveAssetCache(assetServer);

            assetServer.Start();
        }
コード例 #2
0
ファイル: OpenSimBase.cs プロジェクト: boodie/Opensim2
        /// <summary>
        ///     Initialises the asset cache. This supports legacy configuration values
        ///     to ensure consistent operation, but values outside of that namespace
        ///     are handled by the more generic resolution mechanism provided by 
        ///     the ResolveAssetServer virtual method. If extended resolution fails, 
        ///     then the normal default action is taken.
        ///     Creation of the AssetCache is handled by ResolveAssetCache. This
        ///     function accepts a reference to the instantiated AssetServer and
        ///     returns an IAssetCache implementation, if possible. This is a virtual
        ///     method.
        /// </summary>
        protected virtual void InitialiseAssetCache()
        {
            LegacyAssetClientPluginInitialiser linit = null;
            CryptoAssetClientPluginInitialiser cinit = null;
            AssetClientPluginInitialiser init = null;

            IAssetServer assetServer = null;
            string mode = m_configSettings.AssetStorage;

            if (mode == null | mode == String.Empty)
            {
                mode = "default";
            }

            // If "default" is specified, then the value is adjusted
            // according to whether or not the server is running in
            // standalone mode.
            if (mode.ToLower() == "default")
            {
                if (m_configSettings.Standalone == false)
                {
                    mode = "grid";
                }
                else
                {
                    mode = "local";
                }
            }

            switch (mode.ToLower())
            {
                // If grid is specified then the grid server is chose regardless 
                // of whether the server is standalone.
                case "grid":
                    linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
                    assetServer = loadAssetServer("Grid", linit);
                    break;

                // If cryptogrid is specified then the cryptogrid server is chose regardless 
                // of whether the server is standalone.
                case "cryptogrid":
                    cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,                                                   Environment.CurrentDirectory, true);
                    assetServer = loadAssetServer("Crypto", cinit);
                    break;

                // If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless 
                // of whether the server is standalone.
                case "cryptogrid_eou":
                    cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,                                                   Environment.CurrentDirectory, false);
                    assetServer = loadAssetServer("Crypto", cinit);
                    break;

                // If file is specified then the file server is chose regardless 
                // of whether the server is standalone.
                case "file":
                    linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
                    assetServer = loadAssetServer("File", linit);
                    break;

                // If local is specified then we're going to use the local SQL server
                // implementation. We drop through, because that will be the fallback
                // for the following default clause too.
                case "local":
                    break;

                // If the asset_database value is none of the previously mentioned strings, then we
                // try to load a turnkey plugin that matches this value. If not we drop through to 
                // a local default.
                default:
                    try
                    {
                        init = new AssetClientPluginInitialiser(m_configSettings);
                        assetServer = loadAssetServer(m_configSettings.AssetStorage, init);
                        break;
                    }
                    catch
                    {
                    }

                    m_log.Info("[OpenSim Base]: Default assetserver will be used");                
                    break;
            }

            // Open the local SQL-based database asset server
            if (assetServer == null)
            {
                init = new AssetClientPluginInitialiser(m_configSettings);
                SQLAssetServer sqlAssetServer = (SQLAssetServer) loadAssetServer("SQL", init);
                sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile);
                assetServer = sqlAssetServer;
            }

            // Initialize the asset cache, passing a reference to the selected
            // asset server interface.
            m_assetCache = ResolveAssetCache(assetServer);
            
            assetServer.Start();
        }