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