aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs
diff options
context:
space:
mode:
authorTedd Hansen2008-02-16 07:53:02 +0000
committerTedd Hansen2008-02-16 07:53:02 +0000
commit169032b4a42736b3feef682fcbfd1cc1f8b159ba (patch)
treef452996b38d6c84c9b9c204040dab13cb3c43d77 /OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs
parent* ODE Stability update 4 :D (diff)
downloadopensim-SC_OLD-169032b4a42736b3feef682fcbfd1cc1f8b159ba.zip
opensim-SC_OLD-169032b4a42736b3feef682fcbfd1cc1f8b159ba.tar.gz
opensim-SC_OLD-169032b4a42736b3feef682fcbfd1cc1f8b159ba.tar.bz2
opensim-SC_OLD-169032b4a42736b3feef682fcbfd1cc1f8b159ba.tar.xz
Fixed ScriptEngine config in OpenSim.ini.example that was out of place.
Added some info to failure on GridServices listening port so people can see what actually went wrong. Moved most of the function/event execution module to a baseclass so other execution methods (instead of reflection) can be used with custom script modules run by ScriptEngine.Common. + some accumulated patches
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs107
1 files changed, 107 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs
new file mode 100644
index 0000000..83aa230
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs
@@ -0,0 +1,107 @@
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*/
28using System;
29using System.Collections.Generic;
30using System.Runtime.Remoting.Lifetime;
31using System.Text;
32
33namespace OpenSim.Region.ScriptEngine.Common
34{
35 public abstract class ExecutorBase : MarshalByRefObject
36 {
37 /// <summary>
38 /// Contains the script to execute functions in.
39 /// </summary>
40 protected IScript m_Script;
41 /// <summary>
42 /// If set to False events will not be executed.
43 /// </summary>
44 protected bool m_Running = true;
45
46 /// <summary>
47 /// Create a new instance of ExecutorBase
48 /// </summary>
49 /// <param name="Script"></param>
50 public ExecutorBase(IScript Script)
51 {
52 m_Script = Script;
53 }
54
55 /// <summary>
56 /// Make sure our object does not timeout when in AppDomain. (Called by ILease base class)
57 /// </summary>
58 /// <returns></returns>
59 public override Object InitializeLifetimeService()
60 {
61 //Console.WriteLine("Executor: InitializeLifetimeService()");
62 // return null;
63 ILease lease = (ILease)base.InitializeLifetimeService();
64
65 if (lease.CurrentState == LeaseState.Initial)
66 {
67 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
68 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
69 // lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
70 }
71 return lease;
72 }
73
74 /// <summary>
75 /// Get current AppDomain
76 /// </summary>
77 /// <returns>Current AppDomain</returns>
78 public AppDomain GetAppDomain()
79 {
80 return AppDomain.CurrentDomain;
81 }
82
83 /// <summary>
84 /// Execute a specific function/event in script.
85 /// </summary>
86 /// <param name="FunctionName">Name of function to execute</param>
87 /// <param name="args">Arguments to pass to function</param>
88 public void ExecuteEvent(string FunctionName, object[] args)
89 {
90 if (m_Running == false)
91 {
92 // Script is inactive, do not execute!
93 return;
94 }
95 }
96 protected abstract void DoExecuteEvent(string FunctionName, object[] args);
97
98 /// <summary>
99 /// Stop script from running. Event execution will be ignored.
100 /// </summary>
101 public void StopScript()
102 {
103 m_Running = false;
104 }
105
106 }
107}