aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ScriptEngine/Engines
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs171
-rw-r--r--OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine_ScriptLoadUnload.cs68
2 files changed, 215 insertions, 24 deletions
diff --git a/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs b/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs
index 3f24763..0f9b964 100644
--- a/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs
+++ b/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs
@@ -28,47 +28,170 @@ using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using System.Text; 30using System.Text;
31using System.Text.RegularExpressions;
31using log4net; 32using log4net;
32using Nini.Config; 33using Nini.Config;
34using OpenMetaverse;
33using OpenSim.ApplicationPlugins.ScriptEngine; 35using OpenSim.ApplicationPlugins.ScriptEngine;
34using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
36using ComponentProviders = OpenSim.ApplicationPlugins.ScriptEngine.ComponentRegistry; 38using OpenSim.ScriptEngine.Components.DotNetEngine.Events;
39using OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler;
40using OpenSim.ScriptEngine.Shared;
41using ComponentProviders = OpenSim.ApplicationPlugins.ScriptEngine;
37 42
38namespace OpenSim.ScriptEngine.Engines.DotNetEngine 43namespace OpenSim.ScriptEngine.Engines.DotNetEngine
39{ 44{
40 // This is a sample engine 45 // This is a sample engine
41 public class DotNetEngine : RegionScriptEngineBase 46 public partial class DotNetEngine : IScriptEngine
42 { 47 {
43 48
44 49 //private string[] _ComponentNames = new string[] {
45 // This will be the makeup of this script engine 50 // "Commands_LSL",
46 public string[] ComponentNames = new string[] { 51 // "Commands_OSSL",
47 "Commands_LSL", 52 // "Compiler_CS",
48 "Commands_OSSL", 53 // "Compiler_JS",
49 "Compiler_CS", 54 // "Compiler_LSL",
50 "Compiler_JS", 55 // "Compiler_VB",
51 "Compiler_LSL", 56 // "LSLEventProvider",
52 "Compiler_VB", 57 // "Scheduler"
53 "LSLEventProvider", 58 // };
54 "Scheduler" 59 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 }; 60
56 61 public string Name { get { return "SECS.DotNetEngine"; } }
57 public override string Name 62 //public bool IsSharedModule { get { return true; } }
63 internal RegionInfoStructure RegionInfo;
64
65 private string[] commandNames = new string[]
66 {
67 "Commands_LSL"
68 };
69
70 private string[] compilerNames = new string[]
71 {
72 "Compiler_CS",
73 "Compiler_JS",
74 "Compiler_LSL",
75 "Compiler_YP",
76 "Compiler_VB"
77 };
78 private string[] schedulerNames = new string[]
79 {
80 "Scheduler"
81 };
82
83 //internal IScriptLoader m_ScriptLoader;
84 internal LSLEventProvider m_LSLEventProvider;
85 //internal IScriptExecutor m_Executor;
86 //internal Dictionary<string, IScriptCompiler> Compilers = new Dictionary<string, IScriptCompiler>();
87 internal Dictionary<string, IScriptScheduler> Schedulers = new Dictionary<string, IScriptScheduler>();
88 public static Dictionary<string, IScriptCompiler> Compilers = new Dictionary<string, IScriptCompiler>();
89// private static bool haveInitialized = false;
90
91 public DotNetEngine()
58 { 92 {
59 get { return "DotNetEngine"; } 93 RegionInfo = new RegionInfoStructure();
94 RegionInfo.Compilers = Compilers;
95 RegionInfo.Schedulers = Schedulers;
96 RegionInfo.Executors = new Dictionary<string, IScriptExecutor>();
97 RegionInfo.CommandProviders = new Dictionary<string, IScriptCommandProvider>();
98 RegionInfo.EventProviders = new Dictionary<string, IScriptEventProvider>();
99 RegionInfo.Logger = LogManager.GetLogger("SECS.DotNetEngine.RegionInfo");
60 } 100 }
61 101
62 public override void Initialize() 102 public void Initialise(Scene scene, IConfigSource source)
63 { 103 {
64 // We need to initialize the components we will be using. Our baseclass already has builtin functions for this. 104 RegionInfo.Scene = scene;
65 m_log.Info("[" + Name + "]: Initializing SECs (Script Engine Components)"); 105 RegionInfo.ConfigSource = source;
66 InitializeComponents(ComponentNames); 106
107 m_log.DebugFormat("[{0}] Initializing components", Name);
108 InitializeComponents();
67 } 109 }
68 110
69 public override void PreClose() 111 public void PostInitialise() { }
112
113 /// <summary>
114 /// Called on region close
115 /// </summary>
116 public void Close()
70 { 117 {
71 // Before 118 ComponentClose();
72 } 119 }
120 #region Initialize the Script Engine Components we need
121 public void InitializeComponents()
122 {
123 string cname = "";
124 m_log.DebugFormat("[{0}] Component initialization", Name);
125 // Initialize an instance of all module we want
126 try
127 {
128 cname = "ScriptManager";
129 m_log.DebugFormat("[{0}] Executor: {1}", Name, cname);
130 RegionInfo.Executors.Add(cname,
131 ScriptEnginePlugin.GetComponentInstance(RegionInfo, cname) as IScriptExecutor);
132
133 cname = "ScriptLoader";
134 m_log.DebugFormat("[{0}] ScriptLoader: {1}", Name, cname);
135 RegionInfo.ScriptLoader =
136 ScriptEnginePlugin.GetComponentInstance(RegionInfo, cname) as IScriptExecutor as ScriptLoader;
137
138 // CommandProviders
139 foreach (string cn in commandNames)
140 {
141 cname = cn;
142 m_log.DebugFormat("[{0}] CommandProvider: {1}", Name, cname);
143 RegionInfo.CommandProviders.Add(cname,
144 ScriptEnginePlugin.GetComponentInstance(RegionInfo, cname) as
145 IScriptCommandProvider);
146 }
147
148 // Compilers
149 foreach (string cn in compilerNames)
150 {
151 cname = cn;
152 m_log.DebugFormat("[{0}] Compiler: {1}", Name, cname);
153 RegionInfo.Compilers.Add(cname,
154 ScriptEnginePlugin.GetComponentInstance(RegionInfo, cname) as
155 IScriptCompiler);
156 }
157
158 // Schedulers
159 foreach (string cn in schedulerNames)
160 {
161 cname = cn;
162 m_log.DebugFormat("[{0}] Scheduler: {1}", Name, cname);
163 RegionInfo.Schedulers.Add(cname,
164 ScriptEnginePlugin.GetComponentInstance(RegionInfo, cname) as
165 IScriptScheduler);
166 }
167
168 // Event provider
169 cname = "LSLEventProvider";
170 m_log.DebugFormat("[{0}] EventProvider: {1}", Name, cname);
171 IScriptEventProvider sep = ScriptEnginePlugin.GetComponentInstance(RegionInfo, cname) as IScriptEventProvider;
172 RegionInfo.EventProviders.Add(cname, sep);
173 m_LSLEventProvider = sep as LSLEventProvider;
174
175 // Hook up events
176 m_LSLEventProvider.RezScript += Events_RezScript;
177 m_LSLEventProvider.RemoveScript += Events_RemoveScript;
178 }
179 catch (Exception e)
180 {
181 m_log.ErrorFormat("[{0}] Exception while loading \"{1}\": {2}", Name, cname, e.ToString());
182 }
183 }
184
185 private void ComponentClose()
186 {
187 // Close schedulers
188 foreach (IScriptScheduler scheduler in RegionInfo.Schedulers.Values)
189 {
190 scheduler.Close();
191 }
192 }
193
194 #endregion
195
73 } 196 }
74} 197}
diff --git a/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine_ScriptLoadUnload.cs b/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine_ScriptLoadUnload.cs
new file mode 100644
index 0000000..bf429f6
--- /dev/null
+++ b/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine_ScriptLoadUnload.cs
@@ -0,0 +1,68 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenMetaverse;
5using OpenSim.ScriptEngine.Components.DotNetEngine.Events;
6using OpenSim.ScriptEngine.Shared;
7
8namespace OpenSim.ScriptEngine.Engines.DotNetEngine
9{
10 public partial class DotNetEngine
11 {
12
13 //internal Dictionary<int, IScriptScheduler> ScriptMapping = new Dictionary<int, IScriptScheduler>();
14
15
16 //
17 // HANDLE EVENTS FROM SCRIPTS
18 // We will handle script add, change and remove events outside of command pipeline
19 //
20 #region Script Add/Change/Remove
21 void Events_RezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
22 {
23 // ###
24 // # New script created
25 // ###
26 m_log.DebugFormat(
27 "[{0}] NEW SCRIPT: localID: {1}, itemID: {2}, startParam: {3}, postOnRez: {4}, engine: {5}",
28 Name, localID, itemID, startParam, postOnRez, engine);
29
30 // Make a script object
31 ScriptStructure scriptObject = new ScriptStructure();
32 scriptObject.RegionInfo = RegionInfo;
33 scriptObject.LocalID = localID;
34 scriptObject.ItemID = itemID;
35 scriptObject.Source = script;
36
37 //
38 // Get MetaData from script header
39 //
40 ScriptMetaData scriptMetaData = ScriptMetaData.Extract(ref script);
41 scriptObject.ScriptMetaData = scriptMetaData;
42 foreach (string key in scriptObject.ScriptMetaData.Keys)
43 {
44 m_log.DebugFormat("[{0}] Script metadata: Key: \"{1}\", Value: \"{2}\".", Name, key, scriptObject.ScriptMetaData[key]);
45 }
46
47 //
48 // Load this assembly
49 //
50 // TODO: Use Executor to send a command instead?
51 m_log.DebugFormat("[{0}] Adding script to scheduler", Name);
52 RegionInfo.FindScheduler(scriptObject.ScriptMetaData).AddScript(scriptObject);
53 // Add to our internal mapping
54 //ScriptMapping.Add(itemID, Schedulers[scheduler]);
55 }
56
57 private void Events_RemoveScript(uint localID, UUID itemID)
58 {
59 // Tell all schedulers to remove this item
60 foreach (IScriptScheduler scheduler in RegionInfo.Schedulers.Values)
61 {
62 scheduler.Removecript(localID, itemID);
63 }
64 }
65 #endregion
66
67 }
68}