aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs (renamed from OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEnginePlugin.cs)72
1 files changed, 47 insertions, 25 deletions
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEnginePlugin.cs b/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
index e6def85..115d237 100644
--- a/OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEnginePlugin.cs
+++ b/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
@@ -26,45 +26,51 @@
26 */ 26 */
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection;
29using System.Text; 30using System.Text;
31using log4net;
30using Nini.Config; 32using Nini.Config;
31using OpenSim.Region.Environment.Interfaces; 33using OpenSim.Region.Environment.Interfaces;
32using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using OpenSim.ScriptEngine.Shared;
33 36
34namespace OpenSim.ApplicationPlugins.ScriptEngine 37namespace OpenSim.ApplicationPlugins.ScriptEngine
35{ 38{
36 public class RegionScriptEnginePlugin : IRegionModule 39 public class RegionEngineLoader : IRegionModule
37 { 40 {
38 // This is a region module. 41 // This is a region module.
39 // This means: Every time a new region is created, a new instance of this module is also created. 42 // This means: Every time a new region is created, a new instance of this module is also created.
40 // This module is responsible for starting the script engine for this region. 43 // This module is responsible for starting the script engine for this region.
44 public string Name { get { return "SECS.DotNetEngine.Scheduler.RegionLoader"; } }
45 public bool IsSharedModule { get { return true; } }
41 46
47 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 private string tempScriptEngineName = "DotNetEngine"; 48 private string tempScriptEngineName = "DotNetEngine";
43 public RegionScriptEngineBase scriptEngine; 49 public IScriptEngine scriptEngine;
50 public IConfigSource ConfigSource;
51 public IConfig ScriptConfigSource;
44 public void Initialise(Scene scene, IConfigSource source) 52 public void Initialise(Scene scene, IConfigSource source)
45 { 53 {
46 return;
47 // New region is being created 54 // New region is being created
48 // Create a new script engine 55 // Create a new script engine
49// try 56 // Make sure we have config
50// { 57 if (ConfigSource.Configs["SECS"] == null)
51// lock (ComponentRegistry.scriptEngines) 58 ConfigSource.AddConfig("SECS");
52// { 59 ScriptConfigSource = ConfigSource.Configs["SECS"];
53// scriptEngine = 60
54// Activator.CreateInstance(ComponentRegistry.scriptEngines[tempScriptEngineName]) as 61 // Is SECS enabled?
55// RegionScriptEngineBase; 62 if (ScriptConfigSource.GetBoolean("Enabled", false))
56// } 63 {
57// scriptEngine.Initialize(scene, source); 64 LoadEngine();
58// } 65 if (scriptEngine != null)
59// catch (Exception ex) 66 scriptEngine.Initialise(scene, source);
60// { 67 }
61// scriptEngine.m_log.Error("[ScriptEngine]: Unable to load engine \"" + tempScriptEngineName + "\": " + ex.ToString());
62// }
63 } 68 }
64 69
65 public void PostInitialise() 70 public void PostInitialise()
66 { 71 {
67 // Nothing 72 if (scriptEngine != null)
73 scriptEngine.PostInitialise();
68 } 74 }
69 75
70 public void Close() 76 public void Close()
@@ -76,18 +82,34 @@ namespace OpenSim.ApplicationPlugins.ScriptEngine
76 } 82 }
77 catch (Exception ex) 83 catch (Exception ex)
78 { 84 {
79 scriptEngine.m_log.Error("[ScriptEngine]: Unable to close engine \"" + tempScriptEngineName + "\": " + ex.ToString()); 85 m_log.ErrorFormat("[{0}] Unable to close engine \"{1}\": {2}", Name, tempScriptEngineName, ex.ToString());
80 } 86 }
81 } 87 }
82 88
83 public string Name 89 private void LoadEngine()
84 { 90 {
85 get { return "ScriptEngine Region Loader"; } 91 m_log.DebugFormat("[{0}] Loading region script engine engine \"{1}\".", Name, tempScriptEngineName);
92 try
93 {
94 lock (ScriptEnginePlugin.scriptEngines)
95 {
96 if (!ScriptEnginePlugin.scriptEngines.ContainsKey(tempScriptEngineName))
97 {
98 m_log.ErrorFormat("[{0}] Unable to load region script engine: Script engine \"{1}\" does not exist.", Name, tempScriptEngineName);
99 }
100 else
101 {
102 scriptEngine =
103 Activator.CreateInstance(ScriptEnginePlugin.scriptEngines[tempScriptEngineName]) as
104 IScriptEngine;
105 }
106 }
107 }
108 catch (Exception ex)
109 {
110 m_log.ErrorFormat("[{0}] Internal error loading region script engine \"{1}\": {2}", Name, tempScriptEngineName, ex.ToString());
111 }
86 } 112 }
87 113
88 public bool IsSharedModule
89 {
90 get { return true; }
91 }
92 } 114 }
93} 115}