* Rex merge, region/environment
parent
dd96983915
commit
bd57a81e76
File diff suppressed because it is too large
Load Diff
|
@ -1,28 +1,56 @@
|
||||||
using System;
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
namespace OpenSim.Region.Environment
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
{
|
*
|
||||||
/// <summary>
|
* Redistribution and use in source and binary forms, with or without
|
||||||
/// Bit Vector for Which Modules to send an instant message to from the Scene or an Associated Module
|
* modification, are permitted provided that the following conditions are met:
|
||||||
/// </summary>
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// This prevents the Modules from sending Instant messages to other modules through the scene
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
// and then receiving the same messages
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
// This is mostly here because on LLSL and the SecondLife Client, IMs,Groups and friends are linked
|
* * Neither the name of the OpenSim Project nor the
|
||||||
// inseparably
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
[Flags]
|
*
|
||||||
public enum InstantMessageReceiver : uint
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
{
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
/// <summary>None of them.. here for posterity and amusement</summary>
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
None = 0,
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/// <summary>The IM Module</summary>
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
IMModule = 0x00000001,
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
/// <summary>The Friends Module</summary>
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
FriendsModule = 0x00000002,
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/// <summary>The Groups Module</summary>
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
GroupsModule = 0x00000004
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
}
|
*/
|
||||||
}
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Environment
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Bit Vector for Which Modules to send an instant message to from the Scene or an Associated Module
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
// This prevents the Modules from sending Instant messages to other modules through the scene
|
||||||
|
// and then receiving the same messages
|
||||||
|
|
||||||
|
// This is mostly here because on LLSL and the SecondLife Client, IMs,Groups and friends are linked
|
||||||
|
// inseparably
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum InstantMessageReceiver : uint
|
||||||
|
{
|
||||||
|
/// <summary>None of them.. here for posterity and amusement</summary>
|
||||||
|
None = 0,
|
||||||
|
/// <summary>The IM Module</summary>
|
||||||
|
IMModule = 0x00000001,
|
||||||
|
/// <summary>The Friends Module</summary>
|
||||||
|
FriendsModule = 0x00000002,
|
||||||
|
/// <summary>The Groups Module</summary>
|
||||||
|
GroupsModule = 0x00000004
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,297 +1,316 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Region.Environment.Interfaces;
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
using OpenSim.Region.Environment.Modules;
|
using OpenSim.Region.Environment.Modules;
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment
|
namespace OpenSim.Region.Environment
|
||||||
{
|
{
|
||||||
public class ModuleLoader
|
public class ModuleLoader
|
||||||
{
|
{
|
||||||
public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private readonly List<IRegionModule> m_loadedModules = new List<IRegionModule>();
|
public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
|
||||||
private Dictionary<string, IRegionModule> m_loadedSharedModules = new Dictionary<string, IRegionModule>();
|
|
||||||
private readonly LogBase m_log;
|
private readonly List<IRegionModule> m_loadedModules = new List<IRegionModule>();
|
||||||
private readonly IConfigSource m_config;
|
private readonly Dictionary<string, IRegionModule> m_loadedSharedModules = new Dictionary<string, IRegionModule>();
|
||||||
|
private readonly IConfigSource m_config;
|
||||||
public ModuleLoader(LogBase log, IConfigSource config)
|
|
||||||
{
|
public ModuleLoader(IConfigSource config)
|
||||||
m_log = log;
|
{
|
||||||
m_config = config;
|
m_config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRegionModule[] GetLoadedSharedModules
|
public IRegionModule[] GetLoadedSharedModules
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
IRegionModule[] regionModules = new IRegionModule[m_loadedSharedModules.Count];
|
IRegionModule[] regionModules = new IRegionModule[m_loadedSharedModules.Count];
|
||||||
m_loadedSharedModules.Values.CopyTo(regionModules, 0);
|
m_loadedSharedModules.Values.CopyTo(regionModules, 0);
|
||||||
return regionModules;
|
return regionModules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PickupModules(Scene scene, string moduleDir)
|
public void PickupModules(Scene scene, string moduleDir)
|
||||||
{
|
{
|
||||||
DirectoryInfo dir = new DirectoryInfo(moduleDir);
|
DirectoryInfo dir = new DirectoryInfo(moduleDir);
|
||||||
|
|
||||||
foreach (FileInfo fileInfo in dir.GetFiles("*.dll"))
|
foreach (FileInfo fileInfo in dir.GetFiles("*.dll"))
|
||||||
{
|
{
|
||||||
LoadRegionModules(fileInfo.FullName, scene);
|
LoadRegionModules(fileInfo.FullName, scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadDefaultSharedModules()
|
public void LoadDefaultSharedModules()
|
||||||
{
|
{
|
||||||
DynamicTextureModule dynamicModule = new DynamicTextureModule();
|
DynamicTextureModule dynamicModule = new DynamicTextureModule();
|
||||||
if (m_loadedSharedModules.ContainsKey(dynamicModule.Name))
|
if (m_loadedSharedModules.ContainsKey(dynamicModule.Name))
|
||||||
{
|
{
|
||||||
m_log.Error("MODULES", "Module name \"{0}\" already exists in module list. Module type {1} not added!", dynamicModule.Name, "DynamicTextureModule");
|
m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", dynamicModule.Name, "DynamicTextureModule");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_loadedSharedModules.Add(dynamicModule.Name, dynamicModule);
|
m_loadedSharedModules.Add(dynamicModule.Name, dynamicModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatModule chat = new ChatModule();
|
ChatModule chat = new ChatModule();
|
||||||
if (m_loadedSharedModules.ContainsKey(chat.Name))
|
if (m_loadedSharedModules.ContainsKey(chat.Name))
|
||||||
{
|
{
|
||||||
m_log.Error("MODULES", "Module name \"{0}\" already exists in module list. Module type {1} not added!", chat.Name, "ChatModule");
|
m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", chat.Name, "ChatModule");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_loadedSharedModules.Add(chat.Name, chat);
|
m_loadedSharedModules.Add(chat.Name, chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstantMessageModule imMod = new InstantMessageModule();
|
InstantMessageModule imMod = new InstantMessageModule();
|
||||||
if (m_loadedSharedModules.ContainsKey(imMod.Name))
|
if (m_loadedSharedModules.ContainsKey(imMod.Name))
|
||||||
{
|
{
|
||||||
m_log.Error("MODULES", "Module name \"{0}\" already exists in module list. Module type {1} not added!", imMod.Name, "InstantMessageModule");
|
m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", imMod.Name, "InstantMessageModule");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_loadedSharedModules.Add(imMod.Name, imMod);
|
m_loadedSharedModules.Add(imMod.Name, imMod);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadImageURLModule loadMod = new LoadImageURLModule();
|
LoadImageURLModule loadMod = new LoadImageURLModule();
|
||||||
if (m_loadedSharedModules.ContainsKey(loadMod.Name))
|
if (m_loadedSharedModules.ContainsKey(loadMod.Name))
|
||||||
{
|
{
|
||||||
m_log.Error("MODULES", "Module name \"{0}\" already exists in module list. Module type {1} not added!", loadMod.Name, "LoadImageURLModule");
|
m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", loadMod.Name, "LoadImageURLModule");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_loadedSharedModules.Add(loadMod.Name, loadMod);
|
m_loadedSharedModules.Add(loadMod.Name, loadMod);
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarFactoryModule avatarFactory = new AvatarFactoryModule();
|
AvatarFactoryModule avatarFactory = new AvatarFactoryModule();
|
||||||
if (m_loadedSharedModules.ContainsKey(avatarFactory.Name))
|
if (m_loadedSharedModules.ContainsKey(avatarFactory.Name))
|
||||||
{
|
{
|
||||||
m_log.Error("MODULES", "Module name \"{0}\" already exists in module list. Module type {1} not added!", avatarFactory.Name, "AvarFactoryModule");
|
m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", avatarFactory.Name, "AvarFactoryModule");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_loadedSharedModules.Add(avatarFactory.Name, avatarFactory);
|
m_loadedSharedModules.Add(avatarFactory.Name, avatarFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLRPCModule xmlRpcMod = new XMLRPCModule();
|
XMLRPCModule xmlRpcMod = new XMLRPCModule();
|
||||||
if (m_loadedSharedModules.ContainsKey(xmlRpcMod.Name))
|
if (m_loadedSharedModules.ContainsKey(xmlRpcMod.Name))
|
||||||
{
|
{
|
||||||
m_log.Error("MODULES", "Module name \"{0}\" already exists in module list. Module type {1} not added!", xmlRpcMod.Name, "XMLRPCModule");
|
m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", xmlRpcMod.Name, "XMLRPCModule");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_loadedSharedModules.Add(xmlRpcMod.Name, xmlRpcMod);
|
m_loadedSharedModules.Add(xmlRpcMod.Name, xmlRpcMod);
|
||||||
}
|
}
|
||||||
//TextureDownloadModule textureModule = new TextureDownloadModule();
|
//TextureDownloadModule textureModule = new TextureDownloadModule();
|
||||||
//LoadedSharedModules.Add(textureModule.Name, textureModule);
|
|
||||||
}
|
//LoadedSharedModules.Add(textureModule.Name, textureModule);
|
||||||
|
|
||||||
public void InitialiseSharedModules(Scene scene)
|
AgentAssetTransactionModule transactionsModule = new AgentAssetTransactionModule();
|
||||||
{
|
if (m_loadedSharedModules.ContainsKey(transactionsModule.Name))
|
||||||
foreach (IRegionModule module in m_loadedSharedModules.Values)
|
{
|
||||||
{
|
m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", xmlRpcMod.Name, "XMLRPCModule");
|
||||||
module.Initialise(scene, m_config);
|
}
|
||||||
scene.AddModule(module.Name, module); //should be doing this?
|
else
|
||||||
}
|
{
|
||||||
}
|
m_loadedSharedModules.Add(transactionsModule.Name, transactionsModule);
|
||||||
|
}
|
||||||
public void InitializeModule(IRegionModule module, Scene scene)
|
|
||||||
{
|
}
|
||||||
module.Initialise(scene, m_config);
|
|
||||||
scene.AddModule(module.Name, module);
|
public void InitialiseSharedModules(Scene scene)
|
||||||
m_loadedModules.Add(module);
|
{
|
||||||
}
|
foreach (IRegionModule module in m_loadedSharedModules.Values)
|
||||||
|
{
|
||||||
/// <summary>
|
module.Initialise(scene, m_config);
|
||||||
/// Loads/initialises a Module instance that can be used by multiple Regions
|
scene.AddModule(module.Name, module); //should be doing this?
|
||||||
/// </summary>
|
}
|
||||||
/// <param name="dllName"></param>
|
}
|
||||||
/// <param name="moduleName"></param>
|
|
||||||
public void LoadSharedModule(string dllName, string moduleName)
|
public void InitializeModule(IRegionModule module, Scene scene)
|
||||||
{
|
{
|
||||||
IRegionModule module = LoadModule(dllName, moduleName);
|
module.Initialise(scene, m_config);
|
||||||
|
scene.AddModule(module.Name, module);
|
||||||
if (module != null)
|
m_loadedModules.Add(module);
|
||||||
LoadSharedModule(module);
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// Loads/initialises a Module instance that can be used by multiple Regions
|
||||||
/// Loads/initialises a Module instance that can be used by multiple Regions
|
/// </summary>
|
||||||
/// </summary>
|
/// <param name="dllName"></param>
|
||||||
/// <param name="module"></param>
|
/// <param name="moduleName"></param>
|
||||||
public void LoadSharedModule(IRegionModule module)
|
public void LoadSharedModule(string dllName, string moduleName)
|
||||||
{
|
{
|
||||||
if (!m_loadedSharedModules.ContainsKey(module.Name))
|
IRegionModule module = LoadModule(dllName, moduleName);
|
||||||
{
|
|
||||||
m_loadedSharedModules.Add(module.Name, module);
|
if (module != null)
|
||||||
}
|
LoadSharedModule(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadRegionModules(string dllName, Scene scene)
|
/// <summary>
|
||||||
{
|
/// Loads/initialises a Module instance that can be used by multiple Regions
|
||||||
IRegionModule[] modules = LoadModules(dllName);
|
/// </summary>
|
||||||
|
/// <param name="module"></param>
|
||||||
if (modules.Length > 0)
|
public void LoadSharedModule(IRegionModule module)
|
||||||
{
|
{
|
||||||
m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName);
|
if (!m_loadedSharedModules.ContainsKey(module.Name))
|
||||||
foreach (IRegionModule module in modules)
|
{
|
||||||
{
|
m_loadedSharedModules.Add(module.Name, module);
|
||||||
if (!module.IsSharedModule)
|
}
|
||||||
{
|
}
|
||||||
m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name);
|
|
||||||
InitializeModule(module, scene);
|
public void LoadRegionModules(string dllName, Scene scene)
|
||||||
}
|
{
|
||||||
else
|
IRegionModule[] modules = LoadModules(dllName);
|
||||||
{
|
|
||||||
m_log.Verbose("MODULES", " [{0}]: Loading Shared Module.", module.Name);
|
if (modules.Length > 0)
|
||||||
LoadSharedModule(module);
|
{
|
||||||
}
|
m_log.InfoFormat("[MODULES]: Found Module Library [{0}]", dllName);
|
||||||
}
|
foreach (IRegionModule module in modules)
|
||||||
}
|
{
|
||||||
}
|
if (!module.IsSharedModule)
|
||||||
|
{
|
||||||
public void LoadRegionModule(string dllName, string moduleName, Scene scene)
|
m_log.InfoFormat("[MODULES]: [{0}]: Initializing.", module.Name);
|
||||||
{
|
InitializeModule(module, scene);
|
||||||
IRegionModule module = LoadModule(dllName, moduleName);
|
}
|
||||||
if (module != null)
|
else
|
||||||
{
|
{
|
||||||
InitializeModule(module, scene);
|
m_log.InfoFormat("[MODULES]: [{0}]: Loading Shared Module.", module.Name);
|
||||||
}
|
LoadSharedModule(module);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
}
|
||||||
/// Loads a external Module (if not already loaded) and creates a new instance of it.
|
}
|
||||||
/// </summary>
|
|
||||||
/// <param name="dllName"></param>
|
public void LoadRegionModule(string dllName, string moduleName, Scene scene)
|
||||||
/// <param name="moduleName"></param>
|
{
|
||||||
public IRegionModule LoadModule(string dllName, string moduleName)
|
IRegionModule module = LoadModule(dllName, moduleName);
|
||||||
{
|
if (module != null)
|
||||||
IRegionModule[] modules = LoadModules(dllName);
|
{
|
||||||
|
InitializeModule(module, scene);
|
||||||
foreach (IRegionModule module in modules)
|
}
|
||||||
{
|
}
|
||||||
if ((module != null) && (module.Name == moduleName))
|
|
||||||
{
|
/// <summary>
|
||||||
return module;
|
/// Loads a external Module (if not already loaded) and creates a new instance of it.
|
||||||
}
|
/// </summary>
|
||||||
}
|
/// <param name="dllName"></param>
|
||||||
|
/// <param name="moduleName"></param>
|
||||||
return null;
|
public IRegionModule LoadModule(string dllName, string moduleName)
|
||||||
}
|
{
|
||||||
|
IRegionModule[] modules = LoadModules(dllName);
|
||||||
public IRegionModule[] LoadModules(string dllName)
|
|
||||||
{
|
foreach (IRegionModule module in modules)
|
||||||
List<IRegionModule> modules = new List<IRegionModule>();
|
{
|
||||||
|
if ((module != null) && (module.Name == moduleName))
|
||||||
Assembly pluginAssembly;
|
{
|
||||||
if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly))
|
return module;
|
||||||
{
|
}
|
||||||
try
|
}
|
||||||
{
|
|
||||||
pluginAssembly = Assembly.LoadFrom(dllName);
|
return null;
|
||||||
LoadedAssemblys.Add(dllName, pluginAssembly);
|
}
|
||||||
}
|
|
||||||
catch (BadImageFormatException)
|
public IRegionModule[] LoadModules(string dllName)
|
||||||
{
|
{
|
||||||
//m_log.Verbose("MODULES", "The file [{0}] is not a module assembly.", e.FileName);
|
List<IRegionModule> modules = new List<IRegionModule>();
|
||||||
}
|
|
||||||
}
|
Assembly pluginAssembly;
|
||||||
|
if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly))
|
||||||
if (pluginAssembly != null)
|
{
|
||||||
{
|
try
|
||||||
try
|
{
|
||||||
{
|
pluginAssembly = Assembly.LoadFrom(dllName);
|
||||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
LoadedAssemblys.Add(dllName, pluginAssembly);
|
||||||
{
|
}
|
||||||
if (pluginType.IsPublic)
|
catch (BadImageFormatException)
|
||||||
{
|
{
|
||||||
if (!pluginType.IsAbstract)
|
//m_log.InfoFormat("[MODULES]: The file [{0}] is not a module assembly.", e.FileName);
|
||||||
{
|
}
|
||||||
if (pluginType.GetInterface("IRegionModule") != null)
|
}
|
||||||
{
|
|
||||||
modules.Add((IRegionModule)Activator.CreateInstance(pluginType));
|
if (pluginAssembly != null)
|
||||||
}
|
{
|
||||||
}
|
try
|
||||||
}
|
{
|
||||||
}
|
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||||
}
|
{
|
||||||
catch (ReflectionTypeLoadException)
|
if (pluginType.IsPublic)
|
||||||
{
|
{
|
||||||
m_log.Verbose("MODULES", "Could not load types for [{0}].", pluginAssembly.FullName);
|
if (!pluginType.IsAbstract)
|
||||||
}
|
{
|
||||||
}
|
if (pluginType.GetInterface("IRegionModule") != null)
|
||||||
|
{
|
||||||
return modules.ToArray();
|
modules.Add((IRegionModule)Activator.CreateInstance(pluginType));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void PostInitialise()
|
}
|
||||||
{
|
}
|
||||||
foreach (IRegionModule module in m_loadedSharedModules.Values)
|
}
|
||||||
{
|
catch (ReflectionTypeLoadException)
|
||||||
module.PostInitialise();
|
{
|
||||||
}
|
m_log.InfoFormat("[MODULES]: Could not load types for [{0}].", pluginAssembly.FullName);
|
||||||
|
}
|
||||||
foreach (IRegionModule module in m_loadedModules)
|
}
|
||||||
{
|
|
||||||
module.PostInitialise();
|
return modules.ToArray();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void PostInitialise()
|
||||||
public void ClearCache()
|
{
|
||||||
{
|
foreach (IRegionModule module in m_loadedSharedModules.Values)
|
||||||
LoadedAssemblys.Clear();
|
{
|
||||||
}
|
module.PostInitialise();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
foreach (IRegionModule module in m_loadedModules)
|
||||||
|
{
|
||||||
|
module.PostInitialise();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearCache()
|
||||||
|
{
|
||||||
|
LoadedAssemblys.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnloadModule(IRegionModule rm)
|
||||||
|
{
|
||||||
|
rm.Close();
|
||||||
|
|
||||||
|
m_loadedModules.Remove(rm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,77 +1,79 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Region.Environment.Interfaces;
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment
|
namespace OpenSim.Region.Environment
|
||||||
{
|
{
|
||||||
public class StorageManager
|
public class StorageManager
|
||||||
{
|
{
|
||||||
private IRegionDataStore m_dataStore;
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
public IRegionDataStore DataStore
|
private IRegionDataStore m_dataStore;
|
||||||
{
|
|
||||||
get { return m_dataStore; }
|
public IRegionDataStore DataStore
|
||||||
}
|
{
|
||||||
|
get { return m_dataStore; }
|
||||||
public StorageManager(IRegionDataStore storage)
|
}
|
||||||
{
|
|
||||||
m_dataStore = storage;
|
public StorageManager(IRegionDataStore storage)
|
||||||
}
|
{
|
||||||
|
m_dataStore = storage;
|
||||||
public StorageManager(string dllName, string connectionstring)
|
}
|
||||||
{
|
|
||||||
MainLog.Instance.Verbose("DATASTORE", "Attempting to load " + dllName);
|
public StorageManager(string dllName, string connectionstring, bool persistPrimInventories)
|
||||||
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
|
{
|
||||||
|
m_log.Info("[DATASTORE]: Attempting to load " + dllName);
|
||||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
|
||||||
{
|
|
||||||
if (pluginType.IsPublic)
|
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||||
{
|
{
|
||||||
Type typeInterface = pluginType.GetInterface("IRegionDataStore", true);
|
if (pluginType.IsPublic)
|
||||||
|
{
|
||||||
if (typeInterface != null)
|
Type typeInterface = pluginType.GetInterface("IRegionDataStore", true);
|
||||||
{
|
|
||||||
IRegionDataStore plug =
|
if (typeInterface != null)
|
||||||
(IRegionDataStore) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
{
|
||||||
plug.Initialise(connectionstring, false);
|
IRegionDataStore plug =
|
||||||
|
(IRegionDataStore) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||||
m_dataStore = plug;
|
plug.Initialise(connectionstring, persistPrimInventories);
|
||||||
|
|
||||||
MainLog.Instance.Verbose("DATASTORE", "Added IRegionDataStore Interface");
|
m_dataStore = plug;
|
||||||
}
|
|
||||||
}
|
m_log.Info("[DATASTORE]: Added IRegionDataStore Interface");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//TODO: Add checking and warning to make sure it initialised.
|
}
|
||||||
}
|
|
||||||
}
|
//TODO: Add checking and warning to make sure it initialised.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue