aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/ModuleLoader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/ModuleLoader.cs')
-rw-r--r--OpenSim/Region/Environment/ModuleLoader.cs320
1 files changed, 160 insertions, 160 deletions
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
index ea416cb..5e27f50 100644
--- a/OpenSim/Region/Environment/ModuleLoader.cs
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -1,160 +1,160 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Reflection; 3using System.Reflection;
4using System.Text; 4using System.Text;
5using OpenSim.Framework.Console; 5using OpenSim.Framework.Console;
6using OpenSim.Region.Environment.Scenes; 6using OpenSim.Region.Environment.Scenes;
7using OpenSim.Region.Environment.Interfaces; 7using OpenSim.Region.Environment.Interfaces;
8using OpenSim.Region.Environment.Modules; 8using OpenSim.Region.Environment.Modules;
9 9
10namespace OpenSim.Region.Environment 10namespace OpenSim.Region.Environment
11{ 11{
12 public class ModuleLoader 12 public class ModuleLoader
13 { 13 {
14 14
15 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); 15 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
16 16
17 public List<IRegionModule> LoadedModules = new List<IRegionModule>(); 17 public List<IRegionModule> LoadedModules = new List<IRegionModule>();
18 public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); 18 public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>();
19 19
20 public ModuleLoader() 20 public ModuleLoader()
21 { 21 {
22 22
23 } 23 }
24 24
25 /// <summary> 25 /// <summary>
26 /// Should have a module factory? 26 /// Should have a module factory?
27 /// </summary> 27 /// </summary>
28 /// <param name="scene"></param> 28 /// <param name="scene"></param>
29 public void CreateDefaultModules(Scene scene, string exceptModules) 29 public void CreateDefaultModules(Scene scene, string exceptModules)
30 { 30 {
31 IRegionModule module = new XferModule(); 31 IRegionModule module = new XferModule();
32 InitialiseModule(module, scene); 32 InitialiseModule(module, scene);
33 33
34 module = new ChatModule(); 34 module = new ChatModule();
35 InitialiseModule(module, scene); 35 InitialiseModule(module, scene);
36 36
37 module = new AvatarProfilesModule(); 37 module = new AvatarProfilesModule();
38 InitialiseModule(module, scene); 38 InitialiseModule(module, scene);
39 39
40 this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); 40 this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene);
41 41
42 string lslPath = System.IO.Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); 42 string lslPath = System.IO.Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
43 this.LoadRegionModule(lslPath, "LSLScriptingModule", scene); 43 this.LoadRegionModule(lslPath, "LSLScriptingModule", scene);
44 44
45 } 45 }
46 46
47 47
48 public void LoadDefaultSharedModules(string exceptModules) 48 public void LoadDefaultSharedModules(string exceptModules)
49 { 49 {
50 DynamicTextureModule dynamicModule = new DynamicTextureModule(); 50 DynamicTextureModule dynamicModule = new DynamicTextureModule();
51 this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); 51 this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule);
52 } 52 }
53 53
54 public void InitialiseSharedModules(Scene scene) 54 public void InitialiseSharedModules(Scene scene)
55 { 55 {
56 foreach (IRegionModule module in this.LoadedSharedModules.Values) 56 foreach (IRegionModule module in this.LoadedSharedModules.Values)
57 { 57 {
58 module.Initialise(scene); 58 module.Initialise(scene);
59 scene.AddModule(module.GetName(), module); //should be doing this? 59 scene.AddModule(module.GetName(), module); //should be doing this?
60 } 60 }
61 } 61 }
62 62
63 private void InitialiseModule(IRegionModule module, Scene scene) 63 private void InitialiseModule(IRegionModule module, Scene scene)
64 { 64 {
65 module.Initialise(scene); 65 module.Initialise(scene);
66 scene.AddModule(module.GetName(), module); 66 scene.AddModule(module.GetName(), module);
67 LoadedModules.Add(module); 67 LoadedModules.Add(module);
68 } 68 }
69 69
70 /// <summary> 70 /// <summary>
71 /// Loads/initialises a Module instance that can be used by mutliple Regions 71 /// Loads/initialises a Module instance that can be used by mutliple Regions
72 /// </summary> 72 /// </summary>
73 /// <param name="dllName"></param> 73 /// <param name="dllName"></param>
74 /// <param name="moduleName"></param> 74 /// <param name="moduleName"></param>
75 /// <param name="scene"></param> 75 /// <param name="scene"></param>
76 public void LoadSharedModule(string dllName, string moduleName) 76 public void LoadSharedModule(string dllName, string moduleName)
77 { 77 {
78 IRegionModule module = this.LoadModule(dllName, moduleName); 78 IRegionModule module = this.LoadModule(dllName, moduleName);
79 if (module != null) 79 if (module != null)
80 { 80 {
81 this.LoadedSharedModules.Add(module.GetName(), module); 81 this.LoadedSharedModules.Add(module.GetName(), module);
82 } 82 }
83 } 83 }
84 84
85 public void LoadRegionModule(string dllName, string moduleName, Scene scene) 85 public void LoadRegionModule(string dllName, string moduleName, Scene scene)
86 { 86 {
87 IRegionModule module = this.LoadModule(dllName, moduleName); 87 IRegionModule module = this.LoadModule(dllName, moduleName);
88 if (module != null) 88 if (module != null)
89 { 89 {
90 this.InitialiseModule(module, scene); 90 this.InitialiseModule(module, scene);
91 } 91 }
92 } 92 }
93 93
94 /// <summary> 94 /// <summary>
95 /// Loads a external Module (if not already loaded) and creates a new instance of it. 95 /// Loads a external Module (if not already loaded) and creates a new instance of it.
96 /// </summary> 96 /// </summary>
97 /// <param name="dllName"></param> 97 /// <param name="dllName"></param>
98 /// <param name="moduleName"></param> 98 /// <param name="moduleName"></param>
99 /// <param name="scene"></param> 99 /// <param name="scene"></param>
100 public IRegionModule LoadModule(string dllName, string moduleName) 100 public IRegionModule LoadModule(string dllName, string moduleName)
101 { 101 {
102 Assembly pluginAssembly = null; 102 Assembly pluginAssembly = null;
103 if (LoadedAssemblys.ContainsKey(dllName)) 103 if (LoadedAssemblys.ContainsKey(dllName))
104 { 104 {
105 pluginAssembly = LoadedAssemblys[dllName]; 105 pluginAssembly = LoadedAssemblys[dllName];
106 } 106 }
107 else 107 else
108 { 108 {
109 pluginAssembly = Assembly.LoadFrom(dllName); 109 pluginAssembly = Assembly.LoadFrom(dllName);
110 this.LoadedAssemblys.Add(dllName, pluginAssembly); 110 this.LoadedAssemblys.Add(dllName, pluginAssembly);
111 } 111 }
112 112
113 IRegionModule module = null; 113 IRegionModule module = null;
114 foreach (Type pluginType in pluginAssembly.GetTypes()) 114 foreach (Type pluginType in pluginAssembly.GetTypes())
115 { 115 {
116 if (pluginType.IsPublic) 116 if (pluginType.IsPublic)
117 { 117 {
118 if (!pluginType.IsAbstract) 118 if (!pluginType.IsAbstract)
119 { 119 {
120 Type typeInterface = pluginType.GetInterface("IRegionModule", true); 120 Type typeInterface = pluginType.GetInterface("IRegionModule", true);
121 121
122 if (typeInterface != null) 122 if (typeInterface != null)
123 { 123 {
124 module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 124 module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
125 break; 125 break;
126 } 126 }
127 typeInterface = null; 127 typeInterface = null;
128 } 128 }
129 } 129 }
130 } 130 }
131 pluginAssembly = null; 131 pluginAssembly = null;
132 132
133 if ((module != null ) || (module.GetName() == moduleName)) 133 if ((module != null ) || (module.GetName() == moduleName))
134 { 134 {
135 return module; 135 return module;
136 } 136 }
137 137
138 return null; 138 return null;
139 139
140 } 140 }
141 141
142 public void PostInitialise() 142 public void PostInitialise()
143 { 143 {
144 foreach (IRegionModule module in this.LoadedSharedModules.Values) 144 foreach (IRegionModule module in this.LoadedSharedModules.Values)
145 { 145 {
146 module.PostInitialise(); 146 module.PostInitialise();
147 } 147 }
148 148
149 foreach (IRegionModule module in this.LoadedModules) 149 foreach (IRegionModule module in this.LoadedModules)
150 { 150 {
151 module.PostInitialise(); 151 module.PostInitialise();
152 } 152 }
153 } 153 }
154 154
155 public void ClearCache() 155 public void ClearCache()
156 { 156 {
157 this.LoadedAssemblys.Clear(); 157 this.LoadedAssemblys.Clear();
158 } 158 }
159 } 159 }
160} 160}