diff options
author | Tedd Hansen | 2008-09-21 00:03:13 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-09-21 00:03:13 +0000 |
commit | 752d3f3879f13dc77f35b5e8ada2cdf5ba625ee4 (patch) | |
tree | 3aa418cb4f46747c6d789fa6c97a3f7997eabe0a /OpenSim/ApplicationPlugins/ScriptEngine | |
parent | And re-reverse the names from last commit (diff) | |
download | opensim-SC_OLD-752d3f3879f13dc77f35b5e8ada2cdf5ba625ee4.zip opensim-SC_OLD-752d3f3879f13dc77f35b5e8ada2cdf5ba625ee4.tar.gz opensim-SC_OLD-752d3f3879f13dc77f35b5e8ada2cdf5ba625ee4.tar.bz2 opensim-SC_OLD-752d3f3879f13dc77f35b5e8ada2cdf5ba625ee4.tar.xz |
EXPERIMENTAL: Early commit of new Script Engine Component System
Diffstat (limited to '')
12 files changed, 771 insertions, 0 deletions
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/ComponentLoader.cs b/OpenSim/ApplicationPlugins/ScriptEngine/ComponentLoader.cs new file mode 100644 index 0000000..ab39568 --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/ComponentLoader.cs | |||
@@ -0,0 +1,95 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using OpenSim.ApplicationPlugins.ScriptEngine.Components; | ||
34 | |||
35 | namespace OpenSim.ApplicationPlugins.ScriptEngine | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Used to load ScriptEngine component .dll's | ||
39 | /// </summary> | ||
40 | internal class ComponentLoader | ||
41 | { | ||
42 | internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | private ScriptEnginePlugin scriptEnginePlugin; | ||
44 | public ComponentLoader(ScriptEnginePlugin sep) | ||
45 | { | ||
46 | scriptEnginePlugin = sep; | ||
47 | } | ||
48 | |||
49 | /// <summary> | ||
50 | /// Load components from directory | ||
51 | /// </summary> | ||
52 | /// <param name="directory"></param> | ||
53 | public void Load(string directory) | ||
54 | { | ||
55 | // We may want to change how this functions as currently it required unique class names for each component | ||
56 | |||
57 | foreach (string file in Directory.GetFiles(directory, "*.dll")) | ||
58 | { | ||
59 | //m_log.DebugFormat("[ScriptEngine]: Loading: [{0}].", file); | ||
60 | Assembly componentAssembly = Assembly.LoadFrom(file); | ||
61 | if (componentAssembly != null) | ||
62 | { | ||
63 | try | ||
64 | { | ||
65 | // Go through all types in the assembly | ||
66 | foreach (Type componentType in componentAssembly.GetTypes()) | ||
67 | { | ||
68 | if (componentType.IsPublic | ||
69 | && !componentType.IsAbstract) | ||
70 | { | ||
71 | if (componentType.IsSubclassOf(typeof (ComponentBase))) | ||
72 | { | ||
73 | // We have found an type which is derived from ProdiverBase, add it to provider list | ||
74 | m_log.InfoFormat("[ScriptEngine]: Adding component: {0}", componentType.Name); | ||
75 | ComponentRegistry.providers.Add(componentType.Name, componentType); | ||
76 | } | ||
77 | if (componentType.IsSubclassOf(typeof(RegionScriptEngineBase))) | ||
78 | { | ||
79 | // We have found an type which is derived from RegionScriptEngineBase, add it to engine list | ||
80 | m_log.InfoFormat("[ScriptEngine]: Adding script engine: {0}", componentType.Name); | ||
81 | ComponentRegistry.scriptEngines.Add(componentType.Name, componentType); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | catch | ||
87 | (ReflectionTypeLoadException) | ||
88 | { | ||
89 | m_log.InfoFormat("[ScriptEngine]: Could not load types for [{0}].", componentAssembly.FullName); | ||
90 | } | ||
91 | } //if | ||
92 | } //foreach | ||
93 | } | ||
94 | } | ||
95 | } \ No newline at end of file | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/ComponentRegistry.cs b/OpenSim/ApplicationPlugins/ScriptEngine/ComponentRegistry.cs new file mode 100644 index 0000000..dcb435d --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/ComponentRegistry.cs | |||
@@ -0,0 +1,68 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using OpenSim.ApplicationPlugins.ScriptEngine; | ||
31 | using OpenSim.ApplicationPlugins.ScriptEngine.Components; | ||
32 | |||
33 | namespace OpenSim.ApplicationPlugins.ScriptEngine | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Component providers | ||
37 | /// This is where any component (any part) of the Script Engine Component System (SECS) registers. | ||
38 | /// Nothing is instanciated at this point. The modules just need to register here to be available for any script engine. | ||
39 | /// </summary> | ||
40 | public static class ComponentRegistry | ||
41 | { | ||
42 | // Component providers are registered here wit a name (string) | ||
43 | // When a script engine is created the components are instanciated | ||
44 | public static Dictionary<string, Type> providers = new Dictionary<string, Type>(); | ||
45 | public static Dictionary<string, Type> scriptEngines = new Dictionary<string, Type>(); | ||
46 | |||
47 | ///// <summary> | ||
48 | ///// Returns a list of ProviderBase objects which has been instanciated by their name | ||
49 | ///// </summary> | ||
50 | ///// <param name="Providers">List of Script Engine Components</param> | ||
51 | ///// <returns></returns> | ||
52 | //public static List<ComponentBase> GetComponents(string[] Providers) | ||
53 | //{ | ||
54 | // List<ComponentBase> pbl = new List<ComponentBase>(); | ||
55 | // if (Providers != null) | ||
56 | // { | ||
57 | // foreach (string p in Providers) | ||
58 | // { | ||
59 | // if (providers.ContainsKey(p)) | ||
60 | // pbl.Add(Activator.CreateInstance(providers[p]) as ComponentBase); | ||
61 | // } | ||
62 | // } | ||
63 | |||
64 | // return pbl; | ||
65 | //} | ||
66 | |||
67 | } | ||
68 | } \ No newline at end of file | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Components/CommandBase.cs b/OpenSim/ApplicationPlugins/ScriptEngine/Components/CommandBase.cs new file mode 100644 index 0000000..01a052f --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/Components/CommandBase.cs | |||
@@ -0,0 +1,45 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | |||
31 | namespace OpenSim.ApplicationPlugins.ScriptEngine.Components | ||
32 | { | ||
33 | public abstract class CommandBase: ComponentBase | ||
34 | { | ||
35 | //public override iProviderBase CreateInstance() | ||
36 | //{ | ||
37 | // throw new NotImplementedException(); | ||
38 | //} | ||
39 | |||
40 | //public override void Start() | ||
41 | //{ | ||
42 | // throw new NotImplementedException(); | ||
43 | //} | ||
44 | } | ||
45 | } \ No newline at end of file | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Components/CompilerBase.cs b/OpenSim/ApplicationPlugins/ScriptEngine/Components/CompilerBase.cs new file mode 100644 index 0000000..69b54a5 --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/Components/CompilerBase.cs | |||
@@ -0,0 +1,45 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | |||
31 | namespace OpenSim.ApplicationPlugins.ScriptEngine.Components | ||
32 | { | ||
33 | public abstract class CompilerBase: ComponentBase | ||
34 | { | ||
35 | //public override iProviderBase CreateInstance() | ||
36 | //{ | ||
37 | // throw new NotImplementedException(); | ||
38 | //} | ||
39 | |||
40 | //public override void Start() | ||
41 | //{ | ||
42 | // throw new NotImplementedException(); | ||
43 | //} | ||
44 | } | ||
45 | } \ No newline at end of file | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Components/ComponentBase.cs b/OpenSim/ApplicationPlugins/ScriptEngine/Components/ComponentBase.cs new file mode 100644 index 0000000..8879e53 --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/Components/ComponentBase.cs | |||
@@ -0,0 +1,53 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | |||
31 | namespace OpenSim.ApplicationPlugins.ScriptEngine.Components | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Generic baseclass for component providers | ||
35 | /// </summary> | ||
36 | public abstract class ComponentBase //: iProviderBase | ||
37 | { | ||
38 | //public abstract iProviderBase CreateInstance(); | ||
39 | public abstract void Start(); | ||
40 | public abstract void Close(); | ||
41 | public RegionScriptEngineBase scriptEngine; | ||
42 | public void Initialize(RegionScriptEngineBase ScriptEngine) | ||
43 | { | ||
44 | scriptEngine = ScriptEngine; | ||
45 | } | ||
46 | |||
47 | static ComponentBase() | ||
48 | { | ||
49 | // We got loaded -- should we register now? | ||
50 | //OpenSim.ApplicationPlugins.ScriptEngine.ComponentProviders.providers.Add(GetType()); | ||
51 | } | ||
52 | } | ||
53 | } \ No newline at end of file | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Components/EventBase.cs b/OpenSim/ApplicationPlugins/ScriptEngine/Components/EventBase.cs new file mode 100644 index 0000000..d9c29a9 --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/Components/EventBase.cs | |||
@@ -0,0 +1,45 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | |||
31 | namespace OpenSim.ApplicationPlugins.ScriptEngine.Components | ||
32 | { | ||
33 | public abstract class EventBase : ComponentBase | ||
34 | { | ||
35 | //public override iProviderBase CreateInstance() | ||
36 | //{ | ||
37 | // throw new NotImplementedException(); | ||
38 | //} | ||
39 | |||
40 | //public override void Start() | ||
41 | //{ | ||
42 | // throw new NotImplementedException(); | ||
43 | //} | ||
44 | } | ||
45 | } \ No newline at end of file | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Components/SchedulerBase.cs b/OpenSim/ApplicationPlugins/ScriptEngine/Components/SchedulerBase.cs new file mode 100644 index 0000000..7c19beb --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/Components/SchedulerBase.cs | |||
@@ -0,0 +1,45 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | |||
31 | namespace OpenSim.ApplicationPlugins.ScriptEngine.Components | ||
32 | { | ||
33 | public abstract class SchedulerBase: ComponentBase | ||
34 | { | ||
35 | //public override iProviderBase CreateInstance() | ||
36 | //{ | ||
37 | // throw new NotImplementedException(); | ||
38 | //} | ||
39 | |||
40 | //public override void Start() | ||
41 | //{ | ||
42 | // throw new NotImplementedException(); | ||
43 | //} | ||
44 | } | ||
45 | } \ No newline at end of file | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Properties/AssemblyInfo.cs b/OpenSim/ApplicationPlugins/ScriptEngine/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..166a6d7 --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,36 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.ApplicationPlugins.ScriptEngine")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("Microsoft")] | ||
12 | [assembly: AssemblyProduct("OpenSim.ApplicationPlugins.ScriptEngine")] | ||
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2008")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("a234c402-3014-45de-9f6b-c024d9f71983")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Build and Revision Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | // [assembly: AssemblyVersion("1.0.*")] | ||
35 | [assembly: AssemblyVersion("1.0.0.0")] | ||
36 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEngineBase.cs b/OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEngineBase.cs new file mode 100644 index 0000000..c0a37a0 --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEngineBase.cs | |||
@@ -0,0 +1,166 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using System.Text; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.ApplicationPlugins.ScriptEngine.Components; | ||
34 | using OpenSim.Region.Environment.Scenes; | ||
35 | |||
36 | namespace OpenSim.ApplicationPlugins.ScriptEngine | ||
37 | { | ||
38 | public abstract class RegionScriptEngineBase | ||
39 | { | ||
40 | |||
41 | /// <summary> | ||
42 | /// Called on region initialize | ||
43 | /// </summary> | ||
44 | public abstract void Initialize(); | ||
45 | public abstract string Name { get; } | ||
46 | /// <summary> | ||
47 | /// Called before components receive Close() | ||
48 | /// </summary> | ||
49 | public abstract void PreClose(); | ||
50 | // Hold list of all the different components we have working for us | ||
51 | public List<ComponentBase> Components = new List<ComponentBase>(); | ||
52 | |||
53 | public Scene m_Scene; | ||
54 | public IConfigSource m_ConfigSource; | ||
55 | public readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
56 | |||
57 | public void Initialize(Scene scene, IConfigSource source) | ||
58 | { | ||
59 | // Region started | ||
60 | m_Scene = scene; | ||
61 | m_ConfigSource = source; | ||
62 | Initialize(); | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Creates instances of script engine components inside "components" List | ||
67 | /// </summary> | ||
68 | /// <param name="ComponentList">Array of comonent names to initialize</param> | ||
69 | public void InitializeComponents(string[] ComponentList) | ||
70 | { | ||
71 | // Take list of providers to initialize and make instances of them | ||
72 | foreach (string c in ComponentList) | ||
73 | { | ||
74 | m_log.Info("[" + Name + "]: Loading: " + c); | ||
75 | try | ||
76 | { | ||
77 | if (ComponentRegistry.providers.ContainsKey(c)) | ||
78 | Components.Add(Activator.CreateInstance(ComponentRegistry.providers[c]) as ComponentBase); | ||
79 | else | ||
80 | m_log.Error("[" + Name + "]: Component \"" + c + "\" not found, can not load"); | ||
81 | } catch (Exception ex) | ||
82 | { | ||
83 | m_log.Error("[" + Name + "]: Exception loading \"" + c + "\": " + ex.ToString()); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | |||
88 | // Run Initialize on all our providers, hand over a reference of ourself. | ||
89 | foreach (ComponentBase p in Components) | ||
90 | { | ||
91 | try | ||
92 | { | ||
93 | p.Initialize(this); | ||
94 | } | ||
95 | catch (Exception ex) | ||
96 | { | ||
97 | m_log.Error("[" + Name + "]: Error initializing \"" + p.GetType().FullName + "\": " + ex.ToString()); | ||
98 | Components.Remove(p); | ||
99 | } | ||
100 | } | ||
101 | // All modules has been initialized, call Start() on them. | ||
102 | foreach (ComponentBase p in Components) | ||
103 | { | ||
104 | try | ||
105 | { | ||
106 | p.Start(); | ||
107 | } | ||
108 | catch (Exception ex) | ||
109 | { | ||
110 | m_log.Error("[" + Name + "]: Error starting \"" + p.GetType().FullName + "\": " + ex.ToString()); | ||
111 | Components.Remove(p); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | } | ||
116 | |||
117 | #region Functions to return lists based on type | ||
118 | // Predicate for searching List for a certain type | ||
119 | private static bool FindType<T>(ComponentBase pb) | ||
120 | { | ||
121 | if (pb.GetType() is T) | ||
122 | return true; | ||
123 | return false; | ||
124 | } | ||
125 | public List<ComponentBase> GetCommandComponentList() | ||
126 | { | ||
127 | return Components.FindAll(FindType<CommandBase>); | ||
128 | } | ||
129 | public List<ComponentBase> GetCompilerComponentList() | ||
130 | { | ||
131 | return Components.FindAll(FindType<CompilerBase>); | ||
132 | } | ||
133 | public List<ComponentBase> GetEventComponentList() | ||
134 | { | ||
135 | return Components.FindAll(FindType<EventBase>); | ||
136 | } | ||
137 | public List<ComponentBase> GetScheduleComponentList() | ||
138 | { | ||
139 | return Components.FindAll(FindType<SchedulerBase>); | ||
140 | } | ||
141 | |||
142 | #endregion | ||
143 | |||
144 | public void Close() | ||
145 | { | ||
146 | // We need to shut down | ||
147 | |||
148 | // First call abstracted PreClose() | ||
149 | PreClose(); | ||
150 | |||
151 | // Then Call Close() on all components | ||
152 | foreach (ComponentBase p in Components) | ||
153 | { | ||
154 | try | ||
155 | { | ||
156 | p.Close(); | ||
157 | } | ||
158 | catch (Exception ex) | ||
159 | { | ||
160 | // TODO: Print error to console | ||
161 | } | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | |||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEnginePlugin.cs b/OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEnginePlugin.cs new file mode 100644 index 0000000..a0622ea --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/RegionScriptEnginePlugin.cs | |||
@@ -0,0 +1,72 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Region.Environment.Interfaces; | ||
32 | using OpenSim.Region.Environment.Scenes; | ||
33 | |||
34 | namespace OpenSim.ApplicationPlugins.ScriptEngine | ||
35 | { | ||
36 | public class RegionScriptEnginePlugin : IRegionModule | ||
37 | { | ||
38 | // This is a region module. | ||
39 | // 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. | ||
41 | |||
42 | private string tempScriptEngineName = "DotNetEngine"; | ||
43 | public RegionScriptEngineBase scriptEngine; | ||
44 | public void Initialise(Scene scene, IConfigSource source) | ||
45 | { | ||
46 | // New region is being created | ||
47 | // Create a new script engine | ||
48 | scriptEngine = Activator.CreateInstance(ComponentRegistry.scriptEngines[tempScriptEngineName]) as RegionScriptEngineBase; | ||
49 | scriptEngine.Initialize(scene, source); | ||
50 | } | ||
51 | |||
52 | public void PostInitialise() | ||
53 | { | ||
54 | // Nothing | ||
55 | } | ||
56 | |||
57 | public void Close() | ||
58 | { | ||
59 | scriptEngine.Close(); | ||
60 | } | ||
61 | |||
62 | public string Name | ||
63 | { | ||
64 | get { return "ScriptEngine Region Loader"; } | ||
65 | } | ||
66 | |||
67 | public bool IsSharedModule | ||
68 | { | ||
69 | get { return true; } | ||
70 | } | ||
71 | } | ||
72 | } | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/Resources/ScriptEngine.addin.xml b/OpenSim/ApplicationPlugins/ScriptEngine/Resources/ScriptEngine.addin.xml new file mode 100644 index 0000000..38f6eb0 --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/Resources/ScriptEngine.addin.xml | |||
@@ -0,0 +1,12 @@ | |||
1 | <Addin id="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 | <Addin id="RegionProxy" version="0.1" /> | ||
8 | </Dependencies> | ||
9 | <Extension path="/OpenSim/Startup"> | ||
10 | <Plugin id="ScriptEngine" type="OpenSim.ApplicationPlugins.ScriptEngine.ScriptEnginePlugin" /> | ||
11 | </Extension> | ||
12 | </Addin> | ||
diff --git a/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs b/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs new file mode 100644 index 0000000..cd584d5 --- /dev/null +++ b/OpenSim/ApplicationPlugins/ScriptEngine/ScriptEnginePlugin.cs | |||
@@ -0,0 +1,89 @@ | |||
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using System.Text; | ||
31 | using log4net; | ||
32 | |||
33 | namespace OpenSim.ApplicationPlugins.ScriptEngine | ||
34 | { | ||
35 | public class ScriptEnginePlugin : IApplicationPlugin | ||
36 | { | ||
37 | internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
38 | internal OpenSimBase m_OpenSim; | ||
39 | private ComponentLoader pluginLoader; | ||
40 | |||
41 | public void Initialise(OpenSimBase openSim) | ||
42 | { | ||
43 | // Our objective: Load component .dll's | ||
44 | m_OpenSim = openSim; | ||
45 | pluginLoader = new ComponentLoader(this); | ||
46 | |||
47 | m_log.Info("[" + Name + "]: Script Engine Component System"); | ||
48 | m_log.Info("[" + Name + "]: Loading Script Engine Components"); | ||
49 | pluginLoader.Load("ScriptEngines"); | ||
50 | |||
51 | } | ||
52 | #region IApplicationPlugin stuff | ||
53 | /// <summary> | ||
54 | /// Returns the plugin version | ||
55 | /// </summary> | ||
56 | /// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns> | ||
57 | public string Version | ||
58 | { | ||
59 | get { return "1.0.0.0"; } | ||
60 | } | ||
61 | |||
62 | /// <summary> | ||
63 | /// Returns the plugin name | ||
64 | /// </summary> | ||
65 | /// <returns>Plugin name, eg MySQL User Provider</returns> | ||
66 | public string Name | ||
67 | { | ||
68 | get { return "ScriptEngine"; } | ||
69 | } | ||
70 | |||
71 | /// <summary> | ||
72 | /// Default-initialises the plugin | ||
73 | /// </summary> | ||
74 | public void Initialise() | ||
75 | { | ||
76 | //throw new NotImplementedException(); | ||
77 | } | ||
78 | |||
79 | ///<summary> | ||
80 | ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. | ||
81 | ///</summary> | ||
82 | ///<filterpriority>2</filterpriority> | ||
83 | public void Dispose() | ||
84 | { | ||
85 | //throw new NotImplementedException(); | ||
86 | } | ||
87 | #endregion | ||
88 | } | ||
89 | } | ||