diff options
author | Sean Dague | 2008-09-03 18:04:37 +0000 |
---|---|---|
committer | Sean Dague | 2008-09-03 18:04:37 +0000 |
commit | 12beaccec79319186ae2a7bf3663510584117a63 (patch) | |
tree | 0dadf7a61269ae5215d1c007a2c8b7749e84e434 /OpenSim/Region/Environment/Modules/ContentManagementSystem/ContentManagementModule.cs | |
parent | Update svn properties. (diff) | |
download | opensim-SC-12beaccec79319186ae2a7bf3663510584117a63.zip opensim-SC-12beaccec79319186ae2a7bf3663510584117a63.tar.gz opensim-SC-12beaccec79319186ae2a7bf3663510584117a63.tar.bz2 opensim-SC-12beaccec79319186ae2a7bf3663510584117a63.tar.xz |
Merge branch 'cms' of http://pokgsa.ibm.com/~jbongio/public/opensim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ContentManagementSystem/ContentManagementModule.cs | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/ContentManagementSystem/ContentManagementModule.cs b/OpenSim/Region/Environment/Modules/ContentManagementSystem/ContentManagementModule.cs new file mode 100644 index 0000000..22177ae --- /dev/null +++ b/OpenSim/Region/Environment/Modules/ContentManagementSystem/ContentManagementModule.cs | |||
@@ -0,0 +1,111 @@ | |||
1 | // ContentManagementModule.cs | ||
2 | // User: bongiojp | ||
3 | |||
4 | |||
5 | |||
6 | using System; | ||
7 | using System.Collections.Generic; | ||
8 | using libsecondlife; | ||
9 | using Nini.Config; | ||
10 | using OpenSim; | ||
11 | using OpenSim.Framework; | ||
12 | using OpenSim.Region.Environment.Interfaces; | ||
13 | using OpenSim.Region.Environment.Scenes; | ||
14 | using log4net; | ||
15 | using OpenSim.Region.Physics.Manager; | ||
16 | using Axiom.Math; | ||
17 | using System.Threading; | ||
18 | |||
19 | namespace OpenSim.Region.Environment.Modules.ContentManagement | ||
20 | { | ||
21 | public class ContentManagementModule : IRegionModule | ||
22 | { | ||
23 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
24 | CMController m_control = null; | ||
25 | CMModel m_model = null; | ||
26 | CMView m_view = null; | ||
27 | bool initialised = false; | ||
28 | bool m_posted = false; | ||
29 | bool m_enabled = true; | ||
30 | |||
31 | public void Initialise(Scene scene, IConfigSource source) | ||
32 | { | ||
33 | string databaseDir = "./"; | ||
34 | string database = "FilesyStemDatabase"; | ||
35 | int channel = 345; | ||
36 | try | ||
37 | { | ||
38 | if (!source.Configs["CMS"].GetBoolean("Enabled", false)) | ||
39 | m_enabled = false; | ||
40 | |||
41 | databaseDir = source.Configs["CMS"].GetString("Directory", databaseDir); | ||
42 | database = source.Configs["CMS"].GetString("Database", database); | ||
43 | channel = source.Configs["CMS"].GetInt("Channel", channel); | ||
44 | if (database != "FileSystemDatabase" && database != "GitDatabase") | ||
45 | { | ||
46 | m_log.ErrorFormat("[Content Management]: The Database attribute must be defined as either FileSystemDatabase or GitDatabase"); | ||
47 | m_enabled = false; | ||
48 | } | ||
49 | } | ||
50 | catch (Exception e) | ||
51 | { | ||
52 | m_log.ErrorFormat("[Content Management]: Exception thrown while reading parameters from configuration file. Message: " + e); | ||
53 | m_enabled = false; | ||
54 | } | ||
55 | |||
56 | if (!m_enabled) | ||
57 | { | ||
58 | m_log.Info("[Content Management]: Content Management System is not Enabled."); | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | lock(this) | ||
63 | { | ||
64 | if (!initialised) //only init once | ||
65 | { | ||
66 | m_view = new CMView(); | ||
67 | m_model = new CMModel(); | ||
68 | m_control = new CMController(m_model, m_view, scene, channel); | ||
69 | m_model.Initialise(database); | ||
70 | m_view.Initialise(m_model); | ||
71 | |||
72 | initialised = true; | ||
73 | m_model.InitialiseDatabase(scene, databaseDir); | ||
74 | } | ||
75 | else | ||
76 | { | ||
77 | m_model.InitialiseDatabase(scene, databaseDir); | ||
78 | m_control.RegisterNewRegion(scene); | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | |||
83 | public void PostInitialise() | ||
84 | { | ||
85 | if (! m_enabled) | ||
86 | return; | ||
87 | |||
88 | lock(this) | ||
89 | { | ||
90 | if (!m_posted) //only post once | ||
91 | { | ||
92 | m_model.PostInitialise(); | ||
93 | m_posted = true; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public void Close() | ||
99 | {} | ||
100 | |||
101 | public string Name | ||
102 | { | ||
103 | get { return "ContentManagementModule"; } | ||
104 | } | ||
105 | |||
106 | public bool IsSharedModule | ||
107 | { | ||
108 | get { return true; } | ||
109 | } | ||
110 | } | ||
111 | } | ||