* refactor: break some of xml2 serialization out of sog

0.6.5-rc1
Justin Clarke Casey 2009-05-14 16:33:04 +00:00
parent c82a916886
commit d10b5e29bc
9 changed files with 36 additions and 23 deletions

View File

@ -362,10 +362,12 @@ namespace OpenSim.Framework.Communications.Clients
return true;
}
public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, bool allowScriptCrossing)
public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing)
{
ulong regionHandle = GetRegionHandle(region.RegionHandle);
string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/";
string uri
= "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort
+ "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/";
//m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri);
WebRequest ObjectCreateRequest = WebRequest.Create(uri);
@ -374,7 +376,7 @@ namespace OpenSim.Framework.Communications.Clients
ObjectCreateRequest.Timeout = 10000;
OSDMap args = new OSDMap(2);
args["sog"] = OSD.FromString(sog.ToXmlString2());
args["sog"] = OSD.FromString(sogXml2);
args["extra"] = OSD.FromString(sog.ExtraToXmlString());
if (allowScriptCrossing)
{

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Xml;
using OpenMetaverse;
namespace OpenSim.Framework
@ -33,7 +34,7 @@ namespace OpenSim.Framework
{
UUID UUID { get; }
ISceneObject CloneForNewScene();
string ToXmlString2();
void ToXml2(XmlTextWriter writer);
string ExtraToXmlString();
void ExtraFromXmlString(string xmlstr);
string GetStateSnapshot();

View File

@ -44,6 +44,7 @@ using OpenSim.Framework.Communications.Osp;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
using OpenSim.Tests.Common.Setup;
@ -108,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = new AssetBase();
asset1.FullID = asset1Id;
asset1.Data = Encoding.ASCII.GetBytes(object1.ToXmlString2());
asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1));
cm.AssetCache.AddAsset(asset1);
// Create item

View File

@ -276,7 +276,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
if (regInfo != null)
{
return m_regionClient.DoCreateObjectCall(regInfo, sog, m_aScene.m_allowScriptCrossings);
return m_regionClient.DoCreateObjectCall(
regInfo, sog, SceneObjectSerializer.ToXml2Format(sog), m_aScene.m_allowScriptCrossings);
}
//else
// m_log.Warn("[REST COMMS]: Region not found " + regionHandle);

View File

@ -39,6 +39,7 @@ using OpenSim.Framework.Serialization;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.World.Terrain;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Setup;
@ -242,7 +243,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
part1Name,
Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
part1.UUID);
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, object1.ToXmlString2());
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
tar.Close();

View File

@ -31,6 +31,7 @@ using System.IO.Compression;
using System.Text;
using System.Xml;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
namespace OpenSim.Region.CoreModules.World.Serialiser
{
@ -86,7 +87,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
{
if (ent is SceneObjectGroup)
{
EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2());
EntityXml.Add(SceneObjectSerializer.ToXml2Format((SceneObjectGroup)ent));
}
}
EntityXml.Sort();

View File

@ -583,19 +583,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
public string ToXmlString2()
{
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(sw))
{
ToXml2(writer);
}
return sw.ToString();
}
}
public void ToXml2(XmlTextWriter writer)
{
//m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name);

View File

@ -101,7 +101,7 @@ namespace OpenSim.Region.Framework.Scenes
public static string SaveGroupToXml2(SceneObjectGroup grp)
{
return grp.ToXmlString2();
return SceneObjectSerializer.ToXml2Format(grp);
}
public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes
continue;
}
stream.WriteLine(g.ToXmlString2());
stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
primCount++;
}
}

View File

@ -31,6 +31,7 @@ using System.Reflection;
using System.Xml;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.Scenes.Serialization
@ -247,5 +248,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
//m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
}
/// <summary>
/// Serialize a scene object to the 'xml2' format.
/// </summary>
/// <param name="sceneObject"></param>
/// <returns></returns>
public static string ToXml2Format(ISceneObject sceneObject)
{
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(sw))
{
sceneObject.ToXml2(writer);
}
return sw.ToString();
}
}
}
}