aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
diff options
context:
space:
mode:
authorTedd Hansen2008-11-08 17:35:48 +0000
committerTedd Hansen2008-11-08 17:35:48 +0000
commit9511a8c76370f21e839114007dcd2b25c69b009a (patch)
treeb63323dfd96ecd1cc3cd560939bd66bb43ec9c1c /OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
parent* Added IClientIM to IClientCore interfaces (diff)
downloadopensim-SC-9511a8c76370f21e839114007dcd2b25c69b009a.zip
opensim-SC-9511a8c76370f21e839114007dcd2b25c69b009a.tar.gz
opensim-SC-9511a8c76370f21e839114007dcd2b25c69b009a.tar.bz2
opensim-SC-9511a8c76370f21e839114007dcd2b25c69b009a.tar.xz
Work in progress on SECS stuff. Have been holding it off until after 0.6 release. Still messy as hell and doesn't really work yet. Will undergo dramatic changes. AND MOST IMPORTANTLY: Will be conformed to work in coop with todays DNE and XEngine, hopefully one day providing a common interface for all components.
Diffstat (limited to 'OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs')
-rw-r--r--OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs115
1 files changed, 115 insertions, 0 deletions
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs b/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
new file mode 100644
index 0000000..115d237
--- /dev/null
+++ b/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
@@ -0,0 +1,115 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Text;
31using log4net;
32using Nini.Config;
33using OpenSim.Region.Environment.Interfaces;
34using OpenSim.Region.Environment.Scenes;
35using OpenSim.ScriptEngine.Shared;
36
37namespace OpenSim.ApplicationPlugins.ScriptEngine
38{
39 public class RegionEngineLoader : IRegionModule
40 {
41 // This is a region module.
42 // This means: Every time a new region is created, a new instance of this module is also created.
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; } }
46
47 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private string tempScriptEngineName = "DotNetEngine";
49 public IScriptEngine scriptEngine;
50 public IConfigSource ConfigSource;
51 public IConfig ScriptConfigSource;
52 public void Initialise(Scene scene, IConfigSource source)
53 {
54 // New region is being created
55 // Create a new script engine
56 // Make sure we have config
57 if (ConfigSource.Configs["SECS"] == null)
58 ConfigSource.AddConfig("SECS");
59 ScriptConfigSource = ConfigSource.Configs["SECS"];
60
61 // Is SECS enabled?
62 if (ScriptConfigSource.GetBoolean("Enabled", false))
63 {
64 LoadEngine();
65 if (scriptEngine != null)
66 scriptEngine.Initialise(scene, source);
67 }
68 }
69
70 public void PostInitialise()
71 {
72 if (scriptEngine != null)
73 scriptEngine.PostInitialise();
74 }
75
76 public void Close()
77 {
78 try
79 {
80 if (scriptEngine != null)
81 scriptEngine.Close();
82 }
83 catch (Exception ex)
84 {
85 m_log.ErrorFormat("[{0}] Unable to close engine \"{1}\": {2}", Name, tempScriptEngineName, ex.ToString());
86 }
87 }
88
89 private void LoadEngine()
90 {
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 }
112 }
113
114 }
115}