aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs248
1 files changed, 124 insertions, 124 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
index 3500545..83bd0ab 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
@@ -1,124 +1,124 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Text; 32using System.Text;
33using System.Reflection; 33using System.Reflection;
34 34
35namespace OpenSim.Region.Environment.Scenes.Scripting 35namespace OpenSim.Region.Environment.Scenes.Scripting
36{ 36{
37 public class ScriptEngineLoader 37 public class ScriptEngineLoader
38 { 38 {
39 private OpenSim.Framework.Console.LogBase m_log; 39 private OpenSim.Framework.Console.LogBase m_log;
40 public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger) 40 public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger)
41 { 41 {
42 m_log = logger; 42 m_log = logger;
43 } 43 }
44 44
45 public ScriptEngineInterface LoadScriptEngine(string EngineName) 45 public ScriptEngineInterface LoadScriptEngine(string EngineName)
46 { 46 {
47 ScriptEngineInterface ret = null; 47 ScriptEngineInterface ret = null;
48 try 48 try
49 { 49 {
50 ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), 50 ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"),
51 "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); 51 "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine");
52 } 52 }
53 catch (Exception e) 53 catch (Exception e)
54 { 54 {
55 m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString()); 55 m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString());
56 } 56 }
57 return ret; 57 return ret;
58 } 58 }
59 59
60 /// <summary> 60 /// <summary>
61 /// Does actual loading and initialization of script Assembly 61 /// Does actual loading and initialization of script Assembly
62 /// </summary> 62 /// </summary>
63 /// <param name="FreeAppDomain">AppDomain to load script into</param> 63 /// <param name="FreeAppDomain">AppDomain to load script into</param>
64 /// <param name="FileName">FileName of script assembly (.dll)</param> 64 /// <param name="FileName">FileName of script assembly (.dll)</param>
65 /// <returns></returns> 65 /// <returns></returns>
66 private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) 66 private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace)
67 { 67 {
68 //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); 68 //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName);
69 // Load .Net Assembly (.dll) 69 // Load .Net Assembly (.dll)
70 // Initialize and return it 70 // Initialize and return it
71 71
72 // TODO: Add error handling 72 // TODO: Add error handling
73 73
74 Assembly a; 74 Assembly a;
75 //try 75 //try
76 //{ 76 //{
77 77
78 78
79 // Load to default appdomain (temporary) 79 // Load to default appdomain (temporary)
80 a = Assembly.LoadFrom(FileName); 80 a = Assembly.LoadFrom(FileName);
81 // Load to specified appdomain 81 // Load to specified appdomain
82 // TODO: Insert security 82 // TODO: Insert security
83 //a = FreeAppDomain.Load(FileName); 83 //a = FreeAppDomain.Load(FileName);
84 //} 84 //}
85 //catch (Exception e) 85 //catch (Exception e)
86 //{ 86 //{
87 // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString()); 87 // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString());
88 //} 88 //}
89 89
90 90
91 //Console.WriteLine("Loading: " + FileName); 91 //Console.WriteLine("Loading: " + FileName);
92 //foreach (Type _t in a.GetTypes()) 92 //foreach (Type _t in a.GetTypes())
93 //{ 93 //{
94 // Console.WriteLine("Type: " + _t.ToString()); 94 // Console.WriteLine("Type: " + _t.ToString());
95 //} 95 //}
96 96
97 Type t; 97 Type t;
98 //try 98 //try
99 //{ 99 //{
100 t = a.GetType(NameSpace, true); 100 t = a.GetType(NameSpace, true);
101 //} 101 //}
102 //catch (Exception e) 102 //catch (Exception e)
103 //{ 103 //{
104 // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); 104 // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString());
105 //} 105 //}
106 106
107 ScriptEngineInterface ret; 107 ScriptEngineInterface ret;
108 //try 108 //try
109 //{ 109 //{
110 ret = (ScriptEngineInterface)Activator.CreateInstance(t); 110 ret = (ScriptEngineInterface)Activator.CreateInstance(t);
111 //} 111 //}
112 //catch (Exception e) 112 //catch (Exception e)
113 //{ 113 //{
114 // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); 114 // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString());
115 //} 115 //}
116 116
117 return ret; 117 return ret;
118 118
119 119
120 } 120 }
121 121
122 122
123 } 123 }
124} 124}