aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTedd Hansen2007-08-13 19:39:51 +0000
committerTedd Hansen2007-08-13 19:39:51 +0000
commit876f71cf931b887a3132ce719a4cc539b77cbca9 (patch)
treea1b31e54c85218deedcc257ad693e0ff64d56f81
parentSetting culture for startup thread to invariant. Config now read correctly on... (diff)
downloadopensim-SC_OLD-876f71cf931b887a3132ce719a4cc539b77cbca9.zip
opensim-SC_OLD-876f71cf931b887a3132ce719a4cc539b77cbca9.tar.gz
opensim-SC_OLD-876f71cf931b887a3132ce719a4cc539b77cbca9.tar.bz2
opensim-SC_OLD-876f71cf931b887a3132ce719a4cc539b77cbca9.tar.xz
(DotNet) ScriptEngine is now loaded and added to Scene during startup.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs9
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs9
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs (renamed from OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngineInterface.cs)4
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs100
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs2
6 files changed, 123 insertions, 3 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index ca95a8d..4dd5fe1 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -154,14 +154,21 @@ namespace OpenSim
154 configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); 154 configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
155 } 155 }
156 156
157 // Load all script engines found
158 OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader();
159
157 for (int i = 0; i < configFiles.Length; i++) 160 for (int i = 0; i < configFiles.Length; i++)
158 { 161 {
159 //Console.WriteLine("Loading region config file"); 162 //Console.WriteLine("Loading region config file");
160 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]); 163 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]);
161 164
165
162 UDPServer udpServer; 166 UDPServer udpServer;
163 Scene scene = SetupScene(regionInfo, out udpServer); 167 Scene scene = SetupScene(regionInfo, out udpServer);
164 168
169
170 scene.AddScriptEngine(ScriptEngineLoader.LoadScriptEngine("DotNetEngine"));
171
165 m_localScenes.Add(scene); 172 m_localScenes.Add(scene);
166 173
167 m_udpServers.Add(udpServer); 174 m_udpServers.Add(udpServer);
@@ -174,6 +181,8 @@ namespace OpenSim
174 this.m_udpServers[i].ServerListener(); 181 this.m_udpServers[i].ServerListener();
175 } 182 }
176 183
184
185
177 186
178 } 187 }
179 188
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index d47450a..faf6f66 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -139,5 +139,7 @@ namespace OpenSim.Region.ClientStack
139 } 139 }
140 140
141 protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager); 141 protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager);
142
143
142 } 144 }
143} 145}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 42d8c27..08722a0 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1012,5 +1012,14 @@ namespace OpenSim.Region.Environment.Scenes
1012 return result; 1012 return result;
1013 } 1013 }
1014 #endregion 1014 #endregion
1015
1016 #region Script Engine
1017 private List<OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface> ScriptEngines = new List<OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface>();
1018 public void AddScriptEngine(OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine)
1019 {
1020 ScriptEngines.Add(ScriptEngine);
1021 ScriptEngine.InitializeEngine(this);
1022 }
1023 #endregion
1015 } 1024 }
1016} 1025}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
index bc735c9..3c3b5a7 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngineInterface.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
@@ -30,9 +30,9 @@ using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32//TODO: WHERE TO PLACE THIS? 32//TODO: WHERE TO PLACE THIS?
33namespace OpenSim.Region.ScriptEngine.DotNetEngine 33namespace OpenSim.Region.Environment.Scenes.Scripting
34{ 34{
35 interface ScriptEngineInterface 35 public interface ScriptEngineInterface
36 { 36 {
37 void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld); 37 void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld);
38 void Shutdown(); 38 void Shutdown();
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
new file mode 100644
index 0000000..2f0551c
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
@@ -0,0 +1,100 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28/* Original code: Tedd Hansen */
29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.Reflection;
33
34namespace OpenSim.Region.Environment.Scenes.Scripting
35{
36 public class ScriptEngineLoader
37 {
38 public ScriptEngineLoader()
39 {
40 }
41
42 public ScriptEngineInterface LoadScriptEngine(string EngineName)
43 {
44 return LoadAndInitAssembly(@"ScriptEngines\OpenSim.Region.ScriptEngine." + EngineName + ".dll",
45 "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine");
46 }
47
48 /// <summary>
49 /// Does actual loading and initialization of script Assembly
50 /// </summary>
51 /// <param name="FreeAppDomain">AppDomain to load script into</param>
52 /// <param name="FileName">FileName of script assembly (.dll)</param>
53 /// <returns></returns>
54 private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace)
55 {
56 //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName);
57 // Load .Net Assembly (.dll)
58 // Initialize and return it
59
60 // TODO: Add error handling
61
62 Assembly a;
63 //try
64 //{
65
66
67 // Load to default appdomain (temporary)
68 a = Assembly.LoadFrom(FileName);
69 // Load to specified appdomain
70 // TODO: Insert security
71 //a = FreeAppDomain.Load(FileName);
72 //}
73 //catch (Exception e)
74 //{
75 //}
76
77
78 //Console.WriteLine("Loading: " + FileName);
79 //foreach (Type _t in a.GetTypes())
80 //{
81 // Console.WriteLine("Type: " + _t.ToString());
82 //}
83
84 Type t;
85 //try
86 //{
87 t = a.GetType(NameSpace, true);
88 //}
89 //catch (Exception e)
90 //{
91 //}
92
93 return (ScriptEngineInterface)Activator.CreateInstance(t);
94
95
96 }
97
98
99 }
100}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
index a1e2e1d..8f90483 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
@@ -32,7 +32,7 @@ using System.Text;
32 32
33namespace OpenSim.Region.ScriptEngine.DotNetEngine 33namespace OpenSim.Region.ScriptEngine.DotNetEngine
34{ 34{
35 public class ScriptEngine : ScriptEngineInterface 35 public class ScriptEngine : OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface
36 { 36 {
37 // 37 //
38 // This is the root object for ScriptEngine 38 // This is the root object for ScriptEngine