Remove GetAssemblyName and friends from the SE interface. It's now handled

internally
mysql-performance
Melanie 2009-11-26 12:08:20 +00:00
parent cc3617f74f
commit 88842edc95
5 changed files with 91 additions and 134 deletions

View File

@ -184,12 +184,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns></returns> /// <returns></returns>
List<UUID> GetInventoryList(); List<UUID> GetInventoryList();
/// <summary>
/// Get the names of the assemblies associated with scripts in this inventory.
/// </summary>
/// <returns></returns>
string[] GetScriptAssemblies();
/// <summary> /// <summary>
/// Get the xml representing the saved states of scripts in this inventory. /// Get the xml representing the saved states of scripts in this inventory.
/// </summary> /// </summary>

View File

@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
{ {
string ScriptEngineName { get; } string ScriptEngineName { get; }
string GetAssemblyName(UUID itemID);
string GetXMLState(UUID itemID); string GetXMLState(UUID itemID);
bool CanBeDeleted(UUID itemID); bool CanBeDeleted(UUID itemID);

View File

@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes
public string GetStateSnapshot() public string GetStateSnapshot()
{ {
//m_log.Debug(" >>> GetStateSnapshot <<<");
List<string> assemblies = new List<string>();
Dictionary<UUID, string> states = new Dictionary<UUID, string>(); Dictionary<UUID, string> states = new Dictionary<UUID, string>();
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
foreach (string a in part.Inventory.GetScriptAssemblies())
{
if (a != "" && !assemblies.Contains(a))
assemblies.Add(a);
}
foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates()) foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates())
{
states[s.Key] = s.Value; states[s.Key] = s.Value;
}
} }
if (states.Count < 1 || assemblies.Count < 1) if (states.Count < 1)
return ""; return "";
XmlDocument xmldoc = new XmlDocument(); XmlDocument xmldoc = new XmlDocument();
@ -342,94 +331,21 @@ namespace OpenSim.Region.Framework.Scenes
xmldoc.AppendChild(rootElement); xmldoc.AppendChild(rootElement);
XmlElement wrapper = xmldoc.CreateElement("", "Assemblies",
"");
rootElement.AppendChild(wrapper); XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates",
foreach (string assembly in assemblies)
{
string fn = Path.GetFileName(assembly);
if (fn == String.Empty)
continue;
String filedata = String.Empty;
if (File.Exists(assembly+".text"))
{
FileInfo tfi = new FileInfo(assembly+".text");
if (tfi == null)
continue;
Byte[] tdata = new Byte[tfi.Length];
try
{
FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read);
tfs.Read(tdata, 0, tdata.Length);
tfs.Close();
}
catch (Exception e)
{
m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message);
}
filedata = new System.Text.ASCIIEncoding().GetString(tdata);
}
else
{
FileInfo fi = new FileInfo(assembly);
if (fi == null)
continue;
Byte[] data = new Byte[fi.Length];
try
{
FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
fs.Read(data, 0, data.Length);
fs.Close();
}
catch (Exception e)
{
m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message);
}
filedata = System.Convert.ToBase64String(data);
}
XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
assemblyName.Value = fn;
assemblyData.Attributes.Append(assemblyName);
assemblyData.InnerText = filedata;
wrapper.AppendChild(assemblyData);
}
wrapper = xmldoc.CreateElement("", "ScriptStates",
""); "");
rootElement.AppendChild(wrapper); rootElement.AppendChild(wrapper);
foreach (KeyValuePair<UUID, string> state in states) foreach (KeyValuePair<UUID, string> state in states)
{ {
XmlElement stateData = xmldoc.CreateElement("", "State", "");
XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", "");
stateID.Value = state.Key.ToString();
stateData.Attributes.Append(stateID);
XmlDocument sdoc = new XmlDocument(); XmlDocument sdoc = new XmlDocument();
sdoc.LoadXml(state.Value); sdoc.LoadXml(state.Value);
XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); XmlNodeList rootL = sdoc.GetElementsByTagName("State");
XmlNode rootNode = rootL[0]; XmlNode rootNode = rootL[0];
XmlNode newNode = xmldoc.ImportNode(rootNode, true); XmlNode newNode = xmldoc.ImportNode(rootNode, true);
stateData.AppendChild(newNode); wrapper.AppendChild(newNode);
wrapper.AppendChild(stateData);
} }
return xmldoc.InnerXml; return xmldoc.InnerXml;
@ -437,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SetState(string objXMLData, UUID RegionID) public void SetState(string objXMLData, UUID RegionID)
{ {
m_log.Debug("SetState called with " + objXMLData);
if (objXMLData == String.Empty) if (objXMLData == String.Empty)
return; return;

View File

@ -857,36 +857,6 @@ namespace OpenSim.Region.Framework.Scenes
return ret; return ret;
} }
public string[] GetScriptAssemblies()
{
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
List<string> ret = new List<string>();
if (engines == null) // No engine at all
return new string[0];
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == (int)InventoryType.LSL)
{
foreach (IScriptModule e in engines)
{
if (e != null)
{
string n = e.GetAssemblyName(item.ItemID);
if (n != String.Empty)
{
if (!ret.Contains(n))
ret.Add(n);
break;
}
}
}
}
}
return ret.ToArray();
}
public Dictionary<UUID, string> GetScriptStates() public Dictionary<UUID, string> GetScriptStates()
{ {
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();

View File

@ -1245,20 +1245,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
} }
public string GetAssemblyName(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return "";
return instance.GetAssemblyName();
}
public string GetXMLState(UUID itemID) public string GetXMLState(UUID itemID)
{ {
IScriptInstance instance = GetInstance(itemID); IScriptInstance instance = GetInstance(itemID);
if (instance == null) if (instance == null)
return ""; return "";
return instance.GetXMLState(); string xml = instance.GetXMLState();
XmlDocument sdoc = new XmlDocument();
sdoc.LoadXml(xml);
XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
XmlNode rootNode = rootL[0];
// Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">
XmlDocument doc = new XmlDocument();
XmlElement stateData = doc.CreateElement("", "State", "");
XmlAttribute stateID = doc.CreateAttribute("", "UUID", "");
stateID.Value = itemID.ToString();
stateData.Attributes.Append(stateID);
XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
assetID.Value = instance.AssetID.ToString();
stateData.Attributes.Append(assetID);
doc.AppendChild(stateData);
// Add <ScriptState>...</ScriptState>
XmlNode xmlstate = doc.ImportNode(rootNode, true);
stateData.AppendChild(xmlstate);
string assemName = instance.GetAssemblyName();
string fn = Path.GetFileName(assemName);
string assem = String.Empty;
if (File.Exists(assemName + ".text"))
{
FileInfo tfi = new FileInfo(assemName + ".text");
if (tfi != null)
{
Byte[] tdata = new Byte[tfi.Length];
try
{
FileStream tfs = File.Open(assemName + ".text",
FileMode.Open, FileAccess.Read);
tfs.Read(tdata, 0, tdata.Length);
tfs.Close();
assem = new System.Text.ASCIIEncoding().GetString(tdata);
}
catch (Exception e)
{
m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message);
}
}
}
else
{
FileInfo fi = new FileInfo(assemName);
if (fi != null)
{
Byte[] data = new Byte[fi.Length];
try
{
FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read);
fs.Read(data, 0, data.Length);
fs.Close();
assem = System.Convert.ToBase64String(data);
}
catch (Exception e)
{
m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message);
}
}
}
XmlElement assemblyData = doc.CreateElement("", "Assembly", "");
XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", "");
assemblyName.Value = fn;
assemblyData.Attributes.Append(assemblyName);
assemblyData.InnerText = assem;
stateData.AppendChild(assemblyData);
return doc.InnerXml;
} }
public bool CanBeDeleted(UUID itemID) public bool CanBeDeleted(UUID itemID)