diff options
author | Melanie Thielker | 2009-05-19 00:36:06 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-05-19 00:36:06 +0000 |
commit | 744100821d3af92f812b9f9e5545563f0130c65f (patch) | |
tree | cfa286ca2524f560e16b006fe291e7285ad08e88 /OpenSim/SimulatorServices/RegionAssetService.cs | |
parent | Remove the old asset cache and local services and the configurations for them (diff) | |
download | opensim-SC_OLD-744100821d3af92f812b9f9e5545563f0130c65f.zip opensim-SC_OLD-744100821d3af92f812b9f9e5545563f0130c65f.tar.gz opensim-SC_OLD-744100821d3af92f812b9f9e5545563f0130c65f.tar.bz2 opensim-SC_OLD-744100821d3af92f812b9f9e5545563f0130c65f.tar.xz |
Refactor RegionAssetService to load the service connector rather than
duplicating it's functionality
Diffstat (limited to 'OpenSim/SimulatorServices/RegionAssetService.cs')
-rw-r--r-- | OpenSim/SimulatorServices/RegionAssetService.cs | 74 |
1 files changed, 26 insertions, 48 deletions
diff --git a/OpenSim/SimulatorServices/RegionAssetService.cs b/OpenSim/SimulatorServices/RegionAssetService.cs index 3a7ccc8..06f42d3 100644 --- a/OpenSim/SimulatorServices/RegionAssetService.cs +++ b/OpenSim/SimulatorServices/RegionAssetService.cs | |||
@@ -25,51 +25,40 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
28 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | ||
29 | using log4net; | 31 | using log4net; |
30 | using Nini.Config; | 32 | using Nini.Config; |
31 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Servers.HttpServer; | 34 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
34 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Server.Handlers.Asset; | 37 | using OpenSim.Server.Base; |
38 | using OpenSim.Server.Handlers.Base; | ||
36 | 39 | ||
37 | namespace OpenSim.Region.SimulatorServices | 40 | namespace OpenSim.Region.SimulatorServices |
38 | { | 41 | { |
39 | public class RegionAssetService : IRegionModule | 42 | public class RegionAssetService : ISharedRegionModule |
40 | { | 43 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | private static bool initialized = false; | ||
43 | private static bool enabled = false; | 45 | private static bool enabled = false; |
44 | 46 | ||
45 | private bool m_gridMode = false; | 47 | private IConfigSource m_Config; |
46 | Scene m_scene; | 48 | bool m_Registered = false; |
47 | 49 | ||
48 | #region IRegionModule interface | 50 | #region IRegionModule interface |
49 | 51 | ||
50 | public void Initialise(Scene scene, IConfigSource config) | 52 | public void Initialise(IConfigSource config) |
51 | { | 53 | { |
52 | if (!initialized) | 54 | // This module is only on for standalones in hypergrid mode |
53 | { | 55 | enabled = ((!config.Configs["Startup"].GetBoolean("gridmode", true)) && |
54 | initialized = true; | 56 | config.Configs["Startup"].GetBoolean("hypergrid", true)) || |
55 | m_scene = scene; | 57 | ((config.Configs["MXP"] != null) && config.Configs["MXP"].GetBoolean("Enabled", true)); |
56 | |||
57 | // This module is only on for standalones in hypergrid mode | ||
58 | enabled = ((!config.Configs["Startup"].GetBoolean("gridmode", true)) && | ||
59 | config.Configs["Startup"].GetBoolean("hypergrid", true)) || | ||
60 | ((config.Configs["MXP"] != null) && config.Configs["MXP"].GetBoolean("Enabled", true)); | ||
61 | m_gridMode = config.Configs["Startup"].GetBoolean("gridmode", true); | ||
62 | } | ||
63 | } | 58 | } |
64 | 59 | ||
65 | public void PostInitialise() | 60 | public void PostInitialise() |
66 | { | 61 | { |
67 | if (enabled) | ||
68 | { | ||
69 | m_log.Info("[RegionAssetService]: Starting..."); | ||
70 | |||
71 | new AssetService(m_scene,m_gridMode); | ||
72 | } | ||
73 | } | 62 | } |
74 | 63 | ||
75 | public void Close() | 64 | public void Close() |
@@ -81,43 +70,32 @@ namespace OpenSim.Region.SimulatorServices | |||
81 | get { return "RegionAssetService"; } | 70 | get { return "RegionAssetService"; } |
82 | } | 71 | } |
83 | 72 | ||
84 | public bool IsSharedModule | 73 | public void AddRegion(Scene scene) |
85 | { | 74 | { |
86 | get { return true; } | 75 | if (!enabled) |
87 | } | 76 | return; |
88 | 77 | ||
89 | #endregion | 78 | if (!m_Registered) |
79 | { | ||
80 | m_Registered = true; | ||
90 | 81 | ||
91 | } | 82 | m_log.Info("[RegionAssetService]: Starting..."); |
92 | 83 | ||
93 | public class AssetService | 84 | Object[] args = new Object[] { m_Config, scene.CommsManager.HttpServer }; |
94 | { | ||
95 | private bool m_doLookup = false; | ||
96 | private bool m_gridMode = false; | ||
97 | 85 | ||
98 | public bool DoLookup | 86 | ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); |
99 | { | 87 | } |
100 | get { return m_doLookup; } | ||
101 | set { m_doLookup = value; } | ||
102 | } | 88 | } |
103 | // private static readonly ILog m_log | ||
104 | // = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
105 | 89 | ||
106 | public AssetService(Scene m_scene, bool gridMode) | 90 | public void RemoveRegion(Scene scene) |
107 | { | 91 | { |
108 | m_gridMode = gridMode; | ||
109 | AddHttpHandlers(m_scene); | ||
110 | } | 92 | } |
111 | 93 | ||
112 | protected void AddHttpHandlers(Scene m_scene) | 94 | public void RegionLoaded(Scene scene) |
113 | { | 95 | { |
114 | IHttpServer httpServer = m_scene.CommsManager.HttpServer; | 96 | } |
115 | |||
116 | httpServer.AddStreamHandler(new AssetServerGetHandler(m_scene.AssetService)); | ||
117 | httpServer.AddStreamHandler(new AssetServerPostHandler(m_scene.AssetService)); | ||
118 | httpServer.AddStreamHandler(new AssetServerDeleteHandler(m_scene.AssetService)); | ||
119 | 97 | ||
98 | #endregion | ||
120 | 99 | ||
121 | } | ||
122 | } | 100 | } |
123 | } | 101 | } |