aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2009-10-27 21:17:08 +0000
committerMelanie2009-10-27 21:17:08 +0000
commit704bc08e5c3cdab8c0551ea803a77800cad0294f (patch)
tree2abf21a52de0f838fef95dee74989547516fc8f7 /OpenSim
parentMerge branch 'master' into vehicles (diff)
parentRemove the SECS loader (diff)
downloadopensim-SC-704bc08e5c3cdab8c0551ea803a77800cad0294f.zip
opensim-SC-704bc08e5c3cdab8c0551ea803a77800cad0294f.tar.gz
opensim-SC-704bc08e5c3cdab8c0551ea803a77800cad0294f.tar.bz2
opensim-SC-704bc08e5c3cdab8c0551ea803a77800cad0294f.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/ScriptEngine/ComponentFactory.cs145
-rw-r--r--OpenSim/ApplicationPlugins/ScriptEngine/Properties/AssemblyInfo.cs62
-rw-r--r--OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs119
-rw-r--r--OpenSim/ApplicationPlugins/ScriptEngine/Resources/ScriptEnginePlugin.addin.xml11
-rw-r--r--OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs106
5 files changed, 0 insertions, 443 deletions
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/ComponentFactory.cs b/OpenSim/ApplicationPlugins/ScriptEngine/ComponentFactory.cs
deleted file mode 100644
index c85634b..0000000
--- a/OpenSim/ApplicationPlugins/ScriptEngine/ComponentFactory.cs
+++ /dev/null
@@ -1,145 +0,0 @@
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 OpenSimulator 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.IO;
30using System.Reflection;
31using log4net;
32using OpenSim.ScriptEngine.Shared;
33
34namespace OpenSim.ApplicationPlugins.ScriptEngine
35{
36 public static class ComponentFactory
37 {
38 // Component providers are registered here wit a name (string)
39 // When a script engine is created the components are instanciated
40 public static Dictionary<string, Type> providers = new Dictionary<string, Type>();
41 public static Dictionary<string, Type> scriptEngines = new Dictionary<string, Type>();
42
43 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 private readonly static string nameIScriptEngineComponent = typeof(IScriptEngineComponent).Name; // keep interface name in managed code
45 private readonly static string nameIScriptEngine = typeof(IScriptEngine).Name; // keep interface name in managed code
46
47 public static string Name
48 {
49 get { return "SECS.ComponentFactory"; }
50 }
51
52 /// <summary>
53 /// Load components from directory
54 /// </summary>
55 /// <param name="directory"></param>
56 internal static void Load(string directory, string filter)
57 {
58 // We may want to change how this functions as currently it required unique class names for each component
59
60 foreach (string file in Directory.GetFiles(directory, filter))
61 {
62 //m_log.DebugFormat("[ScriptEngine]: Loading: [{0}].", file);
63 Assembly componentAssembly = null;
64 try
65 {
66 componentAssembly = Assembly.LoadFrom(file);
67 }
68 catch
69 {
70 m_log.ErrorFormat("[{0}] Error loading: \"{1}\".", Name, file);
71 }
72
73 if (componentAssembly != null)
74 {
75 try
76 {
77 // Go through all types in the assembly
78 foreach (Type componentType in componentAssembly.GetTypes())
79 {
80 if (componentType.IsPublic
81 && !componentType.IsAbstract)
82 {
83 //if (componentType.IsSubclassOf(typeof(ComponentBase)))
84 if (componentType.GetInterface(nameIScriptEngineComponent) != null)
85 {
86 // We have found an type which is derived from ProdiverBase, add it to provider list
87 m_log.InfoFormat("[{0}] Adding component: {1}", Name, componentType.Name);
88 lock (providers)
89 {
90 providers.Add(componentType.Name, componentType);
91 }
92 }
93 //if (componentType.IsSubclassOf(typeof(ScriptEngineBase)))
94 if (componentType.GetInterface(nameIScriptEngine) != null)
95 {
96 // We have found an type which is derived from RegionScriptEngineBase, add it to engine list
97 m_log.InfoFormat("[{0}] Adding script engine: {1}", Name, componentType.Name);
98 lock (scriptEngines)
99 {
100 scriptEngines.Add(componentType.Name, componentType);
101 }
102 }
103 }
104 }
105 }
106 catch
107 (ReflectionTypeLoadException re)
108 {
109 m_log.ErrorFormat("[{0}] Could not load component \"{1}\": {2}", Name, componentAssembly.FullName, re.ToString());
110 int c = 0;
111 foreach (Exception e in re.LoaderExceptions)
112 {
113 c++;
114 m_log.ErrorFormat("[{0}] LoaderException {1}: {2}", Name, c, e.ToString());
115 }
116 }
117 } //if
118 } //foreach
119 }
120
121 public static IScriptEngineComponent GetComponentInstance(string name, params Object[] args)
122 {
123 lock (providers)
124 {
125 if (!providers.ContainsKey(name))
126 throw new Exception("ScriptEngine requested component named \"" + name +
127 "\" that does not exist.");
128 return Activator.CreateInstance(providers[name], args) as IScriptEngineComponent;
129 }
130 }
131
132 private readonly static string nameIScriptEngineRegionComponent = typeof(IScriptEngineRegionComponent).Name; // keep interface name in managed code
133 public static IScriptEngineComponent GetComponentInstance(RegionInfoStructure info, string name, params Object[] args)
134 {
135 IScriptEngineComponent c = GetComponentInstance(name, args);
136
137 // If module is IScriptEngineRegionComponent then it will have one instance per region and we will initialize it
138 if (c.GetType().GetInterface(nameIScriptEngineRegionComponent) != null)
139 ((IScriptEngineRegionComponent)c).Initialize(info);
140
141 return c;
142 }
143
144 }
145}
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Properties/AssemblyInfo.cs b/OpenSim/ApplicationPlugins/ScriptEngine/Properties/AssemblyInfo.cs
deleted file mode 100644
index 890774d..0000000
--- a/OpenSim/ApplicationPlugins/ScriptEngine/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,62 +0,0 @@
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 OpenSimulator 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
28using System.Reflection;
29using System.Runtime.InteropServices;
30
31// General Information about an assembly is controlled through the following
32// set of attributes. Change these attribute values to modify the information
33// associated with an assembly.
34[assembly: AssemblyTitle("OpenSim.ApplicationPlugins.ScriptEngine")]
35[assembly: AssemblyDescription("")]
36[assembly: AssemblyConfiguration("")]
37[assembly: AssemblyCompany("http://opensimulator.org")]
38[assembly: AssemblyProduct("OpenSim.ApplicationPlugins.ScriptEngine")]
39[assembly: AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
40[assembly: AssemblyTrademark("")]
41[assembly: AssemblyCulture("")]
42
43// Setting ComVisible to false makes the types in this assembly not visible
44// to COM components. If you need to access a type in this assembly from
45// COM, set the ComVisible attribute to true on that type.
46[assembly: ComVisible(false)]
47
48// The following GUID is for the ID of the typelib if this project is exposed to COM
49[assembly: Guid("a234c402-3014-45de-9f6b-c024d9f71983")]
50
51// Version information for an assembly consists of the following four values:
52//
53// Major Version
54// Minor Version
55// Build Number
56// Revision
57//
58// You can specify all the values or you can default the Build and Revision Numbers
59// by using the '*' as shown below:
60// [assembly: AssemblyVersion("0.6.5.*")]
61[assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs b/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
deleted file mode 100644
index 41a5278..0000000
--- a/OpenSim/ApplicationPlugins/ScriptEngine/RegionEngineLoader.cs
+++ /dev/null
@@ -1,119 +0,0 @@
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 OpenSimulator 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.Reflection;
29using log4net;
30using Nini.Config;
31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.ScriptEngine.Shared;
34
35namespace OpenSim.ApplicationPlugins.ScriptEngine
36{
37 public class RegionEngineLoader : IRegionModule
38 {
39 // This is a region module.
40 // This means: Every time a new region is created, a new instance of this module is also created.
41 // This module is responsible for starting the script engine for this region.
42 public string Name { get { return "SECS.DotNetEngine.Scheduler.RegionLoader"; } }
43 public bool IsSharedModule { get { return true; } }
44
45 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private string tempScriptEngineName = "DotNetEngine";
47 public IScriptEngine scriptEngine;
48 public IConfigSource ConfigSource;
49 public IConfig ScriptConfigSource;
50 public void Initialise(Scene scene, IConfigSource source)
51 {
52 // New region is being created
53 // Create a new script engine
54 // Make sure we have config
55 try
56 {
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 catch (NullReferenceException)
70 {
71 }
72 }
73
74 public void PostInitialise()
75 {
76 if (scriptEngine != null)
77 scriptEngine.PostInitialise();
78 }
79
80 public void Close()
81 {
82 try
83 {
84 if (scriptEngine != null)
85 scriptEngine.Close();
86 }
87 catch (Exception ex)
88 {
89 m_log.ErrorFormat("[{0}] Unable to close engine \"{1}\": {2}", Name, tempScriptEngineName, ex.ToString());
90 }
91 }
92
93 private void LoadEngine()
94 {
95 m_log.DebugFormat("[{0}] Loading region script engine engine \"{1}\".", Name, tempScriptEngineName);
96 try
97 {
98 lock (ComponentFactory.scriptEngines)
99 {
100 if (!ComponentFactory.scriptEngines.ContainsKey(tempScriptEngineName))
101 {
102 m_log.ErrorFormat("[{0}] Unable to load region script engine: Script engine \"{1}\" does not exist.", Name, tempScriptEngineName);
103 }
104 else
105 {
106 scriptEngine =
107 Activator.CreateInstance(ComponentFactory.scriptEngines[tempScriptEngineName]) as
108 IScriptEngine;
109 }
110 }
111 }
112 catch (Exception ex)
113 {
114 m_log.ErrorFormat("[{0}] Internal error loading region script engine \"{1}\": {2}", Name, tempScriptEngineName, ex.ToString());
115 }
116 }
117
118 }
119}
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Resources/ScriptEnginePlugin.addin.xml b/OpenSim/ApplicationPlugins/ScriptEngine/Resources/ScriptEnginePlugin.addin.xml
deleted file mode 100644
index f067bf4..0000000
--- a/OpenSim/ApplicationPlugins/ScriptEngine/Resources/ScriptEnginePlugin.addin.xml
+++ /dev/null
@@ -1,11 +0,0 @@
1<Addin id="OpenSim.ApplicationPlugins.ScriptEngine" version="0.1">
2 <Runtime>
3 <Import assembly="OpenSim.ApplicationPlugins.ScriptEngine.dll" />
4 </Runtime>
5 <Dependencies>
6 <Addin id="OpenSim" version="0.5" />
7 </Dependencies>
8 <Extension path = "/OpenSim/Startup">
9 <Plugin id="ScriptEnginePlugin" type="OpenSim.ApplicationPlugins.ScriptEngine.ScriptEnginePlugin" />
10 </Extension>
11</Addin>
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs b/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs
deleted file mode 100644
index cd34f70..0000000
--- a/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs
+++ /dev/null
@@ -1,106 +0,0 @@
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 OpenSimulator 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.Reflection;
28using log4net;
29
30namespace OpenSim.ApplicationPlugins.ScriptEngine
31{
32 /// <summary>
33 /// Loads all Script Engine Components
34 /// </summary>
35 public class ScriptEnginePlugin : IApplicationPlugin
36 {
37 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38 internal OpenSimBase m_OpenSim;
39
40
41
42 public ScriptEnginePlugin()
43 {
44 // Application startup
45#if DEBUG
46 m_log.InfoFormat("[{0}] ##################################", Name);
47 m_log.InfoFormat("[{0}] # Script Engine Component System #", Name);
48 m_log.InfoFormat("[{0}] ##################################", Name);
49#else
50 m_log.InfoFormat("[{0}] Script Engine Component System", Name);
51#endif
52
53 // Load all modules from current directory
54 // We only want files named OpenSim.ScriptEngine.*.dll
55 ComponentFactory.Load(".", "OpenSim.ScriptEngine.*.dll");
56 }
57
58 public void Initialise(OpenSimBase openSim)
59 {
60
61 // Our objective: Load component .dll's
62 m_OpenSim = openSim;
63 //m_OpenSim.Shutdown();
64 }
65
66 public void PostInitialise()
67 {
68 }
69
70
71 #region IApplicationPlugin stuff
72 /// <summary>
73 /// Returns the plugin version
74 /// </summary>
75 /// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
76 public string Version
77 {
78 get { return "1.0.0.0"; }
79 }
80
81 /// <summary>
82 /// Returns the plugin name
83 /// </summary>
84 /// <returns>Plugin name, eg MySQL User Provider</returns>
85 public string Name
86 {
87 get { return "SECS"; }
88 }
89
90 /// <summary>
91 /// Default-initialises the plugin
92 /// </summary>
93 public void Initialise() { }
94
95 ///<summary>
96 ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
97 ///</summary>
98 ///<filterpriority>2</filterpriority>
99 public void Dispose()
100 {
101 //throw new NotImplementedException();
102 }
103 #endregion
104
105 }
106}