/*\r
- * Copyright 2001-2007 Internet2\r
+ * Copyright 2001-2009 Internet2\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
#include "internal.h"\r
#include "util/NDC.h"\r
+#include "util/PathResolver.h"\r
#include "util/ReloadableXMLFile.h"\r
#include "util/XMLConstants.h"\r
#include "util/XMLHelper.h"\r
\r
#include <xercesc/framework/LocalFileInputSource.hpp>\r
#include <xercesc/framework/Wrapper4InputSource.hpp>\r
-#include <xercesc/framework/URLInputSource.hpp>\r
#include <xercesc/util/XMLUniDefs.hpp>\r
\r
+using namespace xmltooling::logging;\r
using namespace xmltooling;\r
-using namespace log4cpp;\r
+using namespace xercesc;\r
using namespace std;\r
\r
static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i);\r
}\r
\r
if (m_local) {\r
+ XMLToolingConfig::getConfig().getPathResolver()->resolve(m_source, PathResolver::XMLTOOLING_CFG_FILE);\r
+\r
flag=e->getAttributeNS(NULL,reloadChanges);\r
if (!XMLString::equals(flag,xmlconstants::XML_FALSE) && !XMLString::equals(flag,xmlconstants::XML_ZERO)) {\r
#ifdef WIN32\r
if (source && *source) {\r
auto_ptr_char temp2(source);\r
m_backing=temp2.get();\r
+ XMLToolingConfig::getConfig().getPathResolver()->resolve(m_backing, PathResolver::XMLTOOLING_RUN_FILE);\r
log.debug("backup remote resource with (%s)", m_backing.c_str());\r
}\r
source = e->getAttributeNS(NULL,reloadInterval);\r
m_log.debug("loading configuration from external resource...");\r
\r
DOMDocument* doc=NULL;\r
- auto_ptr_XMLCh widenit(backup ? m_backing.c_str() : m_source.c_str());\r
if (m_local || backup) {\r
+ auto_ptr_XMLCh widenit(backup ? m_backing.c_str() : m_source.c_str());\r
LocalFileInputSource src(widenit.get());\r
Wrapper4InputSource dsrc(&src,false);\r
if (m_validate)\r
doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);\r
}\r
else {\r
- URLInputSource src(widenit.get());\r
+ URLInputSource src(m_root);\r
Wrapper4InputSource dsrc(&src,false);\r
if (m_validate)\r
doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc);\r
doc=XMLToolingConfig::getConfig().getParser().parse(dsrc);\r
}\r
\r
- m_log.infoStream() << "loaded XML resource (" << (backup ? m_backing : m_source) << ")" << CategoryStream::ENDLINE;\r
+ m_log.infoStream() << "loaded XML resource (" << (backup ? m_backing : m_source) << ")" << logging::eol;\r
\r
if (!backup && !m_backing.empty()) {\r
m_log.debug("backing up remote resource to (%s)", m_backing.c_str());\r
}\r
catch (XMLException& e) {\r
auto_ptr_char msg(e.getMessage());\r
- m_log.critStream() << "Xerces error while loading resource (" << (backup ? m_backing : m_source) << "): "\r
- << msg.get() << CategoryStream::ENDLINE;\r
+ m_log.errorStream() << "Xerces error while loading resource (" << (backup ? m_backing : m_source) << "): "\r
+ << msg.get() << logging::eol;\r
if (!backup && !m_backing.empty())\r
return load(true);\r
throw XMLParserException(msg.get());\r
}\r
catch (exception& e) {\r
- m_log.critStream() << "error while loading configuration from ("\r
- << (m_source.empty() ? "inline" : (backup ? m_backing : m_source)) << "): " << e.what() << CategoryStream::ENDLINE;\r
+ m_log.errorStream() << "error while loading configuration from ("\r
+ << (m_source.empty() ? "inline" : (backup ? m_backing : m_source)) << "): " << e.what() << logging::eol;\r
if (!backup && !m_backing.empty())\r
return load(true);\r
throw;\r
return this;\r
\r
// Elevate lock and recheck.\r
+ m_log.debug("timestamp of local resource changed, elevating to a write lock");\r
m_lock->unlock();\r
m_lock->wrlock();\r
if (m_filestamp>=stat_buf.st_mtime) {\r
// Somebody else handled it, just downgrade.\r
+ m_log.debug("update of local resource handled by another thread, downgrading lock");\r
m_lock->unlock();\r
m_lock->rdlock();\r
return this;\r
return this;\r
\r
// Elevate lock and recheck.\r
+ m_log.debug("reload interval for remote resource elapsed, elevating to a write lock");\r
m_lock->unlock();\r
m_lock->wrlock();\r
if (now - m_filestamp < m_reloadInterval) {\r
// Somebody else handled it, just downgrade.\r
+ m_log.debug("update of remote resource handled by another thread, downgrading lock");\r
m_lock->unlock();\r
m_lock->rdlock();\r
return this;\r
}\r
\r
// If we made it here, the swap may or may not have worked, but we need to relock.\r
+ m_log.debug("attempt to update resource complete, relocking");\r
m_lock->rdlock();\r
return this;\r
}\r