summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-07-15 15:31:18 +0000
committerrandomdan <randomdan@localhost>2011-07-15 15:31:18 +0000
commit76761670bacd5c28e22a911f0b0a0939c6b6195f (patch)
tree66a14bfad90cb05c6095a8ce0b4c2492c5355a86
parentAll new dynamic transformations and processing and tidyup and stuff (diff)
downloadproject2-76761670bacd5c28e22a911f0b0a0939c6b6195f.tar.bz2
project2-76761670bacd5c28e22a911f0b0a0939c6b6195f.tar.xz
project2-76761670bacd5c28e22a911f0b0a0939c6b6195f.zip
Make *Host parse their XML document on first run of components, fixes sendmailTask not doing so by centralising it in a sensible place
-rw-r--r--project2/cgi/cgiStagePresent.cpp2
-rw-r--r--project2/cgi/cgiStageRequest.cpp1
-rw-r--r--project2/checkHost.cpp1
-rw-r--r--project2/console/consoleAppEngine.cpp1
-rw-r--r--project2/taskHost.cpp1
-rw-r--r--project2/viewHost.cpp1
-rw-r--r--project2/xmlScriptParser.cpp13
-rw-r--r--project2/xmlScriptParser.h3
8 files changed, 14 insertions, 9 deletions
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index aaa1092..6091ed8 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -10,7 +10,6 @@ CgiApplicationEngine::PresentStage::PresentStage(const CgiEnvironment * e, const
CheckHost(e->presentRoot, id),
ViewHost(e->presentRoot, id)
{
- parseDocument();
}
CgiApplicationEngine::PresentStage::PresentStage(const CgiEnvironment * e, const std::string & group, const std::string & id) :
@@ -19,7 +18,6 @@ CgiApplicationEngine::PresentStage::PresentStage(const CgiEnvironment * e, const
CheckHost(group, id),
ViewHost(group, id)
{
- parseDocument();
}
CgiApplicationEngine::NextStage
diff --git a/project2/cgi/cgiStageRequest.cpp b/project2/cgi/cgiStageRequest.cpp
index 94f3b49..ee72b81 100644
--- a/project2/cgi/cgiStageRequest.cpp
+++ b/project2/cgi/cgiStageRequest.cpp
@@ -14,7 +14,6 @@ CgiApplicationEngine::RequestStage::RequestStage(const CgiEnvironment * e, const
present = requestRoot->get_attribute_value("present");
rollbackBeforeHandle = requestRoot->get_attribute_value("rollbackBeforeHandle") == "true";
localErrorHandling = requestRoot->get_attribute_value("errorHandling") == "local";
- parseDocument();
}
CgiApplicationEngine::NextStage
diff --git a/project2/checkHost.cpp b/project2/checkHost.cpp
index 05e7d58..cda07fc 100644
--- a/project2/checkHost.cpp
+++ b/project2/checkHost.cpp
@@ -21,6 +21,7 @@ CheckHost::~CheckHost()
void
CheckHost::runChecks() const
{
+ parseDocument();
BOOST_FOREACH(const ParamCheckers::value_type & pc, parameterChecks) {
if (!pc->performCheck()) {
ApplicationEngine::getCurrent()->logMessage(false, pc->group(), pc->message());
diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp
index 8e95b16..dab1c46 100644
--- a/project2/console/consoleAppEngine.cpp
+++ b/project2/console/consoleAppEngine.cpp
@@ -65,7 +65,6 @@ ConsoleApplicationEngine::ConsoleApplicationEngine(const ConsoleEnvironment * en
xmlpp::Element * requestRoot = get_document()->get_root_node();
rollbackBeforeHandle = requestRoot->get_attribute_value("rollbackBeforeHandle") == "true";
localErrorHandling = requestRoot->get_attribute_value("errorHandling") == "local";
- parseDocument();
}
ConsoleApplicationEngine::~ConsoleApplicationEngine()
diff --git a/project2/taskHost.cpp b/project2/taskHost.cpp
index 2955dc0..20595f9 100644
--- a/project2/taskHost.cpp
+++ b/project2/taskHost.cpp
@@ -24,6 +24,7 @@ TaskHost::~TaskHost()
void
TaskHost::executeTasks() const
{
+ parseDocument();
try {
run(normTasks);
commitAll();
diff --git a/project2/viewHost.cpp b/project2/viewHost.cpp
index 1fa8d9b..6bdbe34 100644
--- a/project2/viewHost.cpp
+++ b/project2/viewHost.cpp
@@ -28,6 +28,7 @@ ViewHost::~ViewHost()
void
ViewHost::executeViews(const DefaultPresenterProvider & dpp) const
{
+ parseDocument();
if (pmp.presenters.empty()) {
pmp.presenters.insert(dpp(get_document()->get_root_node()));
}
diff --git a/project2/xmlScriptParser.cpp b/project2/xmlScriptParser.cpp
index fad9542..6d30d67 100644
--- a/project2/xmlScriptParser.cpp
+++ b/project2/xmlScriptParser.cpp
@@ -4,14 +4,16 @@
XmlScriptParser::XmlScriptParser(const std::string & group, const std::string & name, bool ii) :
IsInclusion(ii),
- loader(true)
+ loader(true),
+ documentParsed(false)
{
loadDocument(group + "/" + name + ".xml");
}
XmlScriptParser::XmlScriptParser(const std::string & file, bool ii) :
IsInclusion(ii),
- loader(true)
+ loader(true),
+ documentParsed(false)
{
loadDocument(file);
}
@@ -42,8 +44,11 @@ XmlScriptParser::loadDocument(const std::string & file)
}
void
-XmlScriptParser::parseDocument()
+XmlScriptParser::parseDocument() const
{
- loader.collectAll(this, get_document()->get_root_node(), true, ErrorOnUnsupported);
+ if (!documentParsed) {
+ loader.collectAll(this, get_document()->get_root_node(), true, ErrorOnUnsupported);
+ documentParsed = true;
+ }
}
diff --git a/project2/xmlScriptParser.h b/project2/xmlScriptParser.h
index 7b7f644..72d6938 100644
--- a/project2/xmlScriptParser.h
+++ b/project2/xmlScriptParser.h
@@ -19,11 +19,12 @@ class XmlScriptParser : public xmlpp::DomParser, virtual public CommonObjects, v
XmlScriptParser(const std::string & group, const std::string & name, bool isInclusion);
XmlScriptParser(const std::string & file, bool isInclusion);
- void parseDocument();
const bool IsInclusion;
protected:
LoaderBase loader;
+ mutable bool documentParsed;
+ void parseDocument() const;
private:
void loadDocument(const std::string & file);