Load Notification Service Topology from an XML file. More...
#include <XML_Loader.h>
Public Member Functions | |
XML_Loader () | |
The constructor. | |
virtual | ~XML_Loader () |
bool | open (const ACE_TString &file_name) |
virtual void | load (Topology_Object *root) |
Begin the restore process. | |
virtual void | startElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName, ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL) |
virtual void | endElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *name ACEXML_ENV_ARG_DECL_NOT_USED) |
Private Types | |
typedef ACE_Unbounded_Stack < Topology_Object * > | TopoStack |
Private Attributes | |
ACE_TString | file_name_ |
The name of the file from which data is read. | |
FILE * | input_ |
A stream representing our current output. | |
TopoStack | object_stack_ |
bool | live_ |
if false, then we're just checking syntax of topology file. |
Load Notification Service Topology from an XML file.
Definition at line 37 of file XML_Loader.h.
typedef ACE_Unbounded_Stack<Topology_Object*> TAO_Notify::XML_Loader::TopoStack [private] |
Definition at line 73 of file XML_Loader.h.
TAO_Notify::XML_Loader::XML_Loader | ( | ) |
TAO_Notify::XML_Loader::~XML_Loader | ( | ) | [virtual] |
Definition at line 58 of file XML_Loader.cpp.
{ }
virtual void TAO_Notify::XML_Loader::endElement | ( | const ACEXML_Char * | , | |
const ACEXML_Char * | , | |||
const ACEXML_Char *name | ACEXML_ENV_ARG_DECL_NOT_USED | |||
) | [virtual] |
void TAO_Notify::XML_Loader::load | ( | Topology_Object * | root | ) | [virtual] |
Begin the restore process.
Call this function to start the reload of data from a persistent store. When the Topology_Loader detects a child object, it should call the load_child method of the object passed in, then do the same loading process on the returned object.
Implements TAO_Notify::Topology_Loader.
Definition at line 126 of file XML_Loader.cpp.
{ ACE_ASSERT (root != 0); this->live_ = true; auto_ptr<ACEXML_FileCharStream> fstm (new ACEXML_FileCharStream); // xml input source will take ownership if (fstm->open (this->file_name_.c_str ()) == 0) { // InputSource takes ownership ACEXML_InputSource input (fstm.get ()); (void) fstm.release (); ACEXML_Parser parser; parser.setContentHandler (this); parser.setDTDHandler (this); parser.setErrorHandler (this); parser.setEntityResolver (this); try { object_stack_.push (root); parser.parse (&input ACEXML_ENV_ARG_PARAMETER); ACEXML_TRY_CHECK; ACE_ASSERT (object_stack_.size () == 1); Topology_Object* cur; object_stack_.pop (cur); } catch (const ACEXML_Exception& ex) { // The only way to find out what it is, it to let it print itself, so... ACE_ERROR ((LM_ERROR, "Unable to load \"%s\".\n", this->file_name_.c_str ())); ex.print (); throw CORBA::INTERNAL(); } } else { ACE_DEBUG((LM_DEBUG, ACE_TEXT("Unable to open the XML input file: %s.\n"), file_name_.c_str())); throw CORBA::INTERNAL(); } }
bool TAO_Notify::XML_Loader::open | ( | const ACE_TString & | file_name | ) |
Open a file and perform preliminary validation to determine whether the file is complete and valid.
Definition at line 63 of file XML_Loader.cpp.
{ bool result = false; // if *.xml exists, use it // if it does not exist then // use the previous one was renamed to *.000 // If neither *.xml nor *.000 exist then something // "impossible" happened (or its a new system with no saved state). this->file_name_ = base_name; this->file_name_ += ACE_TEXT(".xml"); // 4 is "read permission" result = (0 == ACE_OS::access (this->file_name_.c_str (), 4)); if (result) { this->live_ = false; auto_ptr<ACEXML_FileCharStream> fstm (new ACEXML_FileCharStream); // xml input source will take ownership if (fstm->open (this->file_name_.c_str ()) == 0) { // InputSource takes ownership ACEXML_InputSource input (fstm.get ()); (void) fstm.release (); ACEXML_Parser parser; parser.setContentHandler (this); parser.setDTDHandler (this); parser.setErrorHandler (this); parser.setEntityResolver (this); try { parser.parse (&input); } catch (const ACEXML_Exception& ex) { // The only way to find out what it is, it to let it print itself, so... ACE_ERROR ((LM_ERROR, "Unable to load \"%s\".\n Will try backup file.\n", this->file_name_.c_str ())); ex.print (); result = false; } } else { ACE_DEBUG((LM_DEBUG, ACE_TEXT("Unable to open the XML input file: %s.\n Will try backup file.\n"), file_name_.c_str())); result = false; } } if (! result) { this->file_name_ = base_name; this->file_name_ += ACE_TEXT(".000"); result = (0 == ACE_OS::access (this->file_name_.c_str (), 4)); } return result; }
virtual void TAO_Notify::XML_Loader::startElement | ( | const ACEXML_Char * | namespaceURI, | |
const ACEXML_Char * | localName, | |||
const ACEXML_Char * | qName, | |||
ACEXML_Attributes *atts | ACEXML_ENV_ARG_DECL | |||
) | [virtual] |
The name of the file from which data is read.
Definition at line 69 of file XML_Loader.h.
FILE* TAO_Notify::XML_Loader::input_ [private] |
A stream representing our current output.
Definition at line 71 of file XML_Loader.h.
bool TAO_Notify::XML_Loader::live_ [private] |
if false, then we're just checking syntax of topology file.
Definition at line 76 of file XML_Loader.h.
Definition at line 74 of file XML_Loader.h.