1
0

RestRegionPlugin.cs 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 OpenSimulator 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.Xml.Serialization;
  29. namespace OpenSim.ApplicationPlugins.Rest.Regions
  30. {
  31. public partial class RestRegionPlugin : RestPlugin
  32. {
  33. private static XmlSerializerNamespaces _xmlNs;
  34. static RestRegionPlugin()
  35. {
  36. _xmlNs = new XmlSerializerNamespaces();
  37. _xmlNs.Add(String.Empty, String.Empty);
  38. }
  39. #region overriding properties
  40. public override string Name
  41. {
  42. get { return "REGION"; }
  43. }
  44. public override string ConfigName
  45. {
  46. get { return "RestRegionPlugin"; }
  47. }
  48. #endregion overriding properties
  49. #region overriding methods
  50. /// <summary>
  51. /// This method is called by OpenSimMain immediately after loading the
  52. /// plugin and after basic server setup, but before running any server commands.
  53. /// </summary>
  54. /// <remarks>
  55. /// Note that entries MUST be added to the active configuration files before
  56. /// the plugin can be enabled.
  57. /// </remarks>
  58. public override void Initialise(OpenSimBase openSim)
  59. {
  60. try
  61. {
  62. base.Initialise(openSim);
  63. if (!IsEnabled)
  64. {
  65. //m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
  66. return;
  67. }
  68. m_log.InfoFormat("{0} REST region plugin enabled", MsgID);
  69. // add REST method handlers
  70. AddRestStreamHandler("GET", "/regions/", GetHandler);
  71. AddRestStreamHandler("POST", "/regions/", PostHandler);
  72. AddRestStreamHandler("GET", "/regioninfo/", GetRegionInfoHandler);
  73. }
  74. catch (Exception e)
  75. {
  76. m_log.WarnFormat("{0} Initialization failed: {1}", MsgID, e.Message);
  77. m_log.DebugFormat("{0} Initialization failed: {1}", MsgID, e.ToString());
  78. }
  79. }
  80. public override void Close()
  81. {
  82. }
  83. #endregion overriding methods
  84. }
  85. }