#include <XML_Loader.h>
Inheritance diagram for TAO_Notify::XML_Loader:


Public Member Functions | |
| XML_Loader () | |
| The constructor. | |
| virtual | ~XML_Loader () |
| bool | open (const ACE_CString &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) throw (ACEXML_SAXException) |
| virtual void | endElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *name ACEXML_ENV_ARG_DECL_NOT_USED) throw (ACEXML_SAXException) |
Private Types | |
| typedef ACE_Unbounded_Stack< Topology_Object * > | TopoStack |
Private Attributes | |
| ACE_CString | 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_ |
Definition at line 37 of file XML_Loader.h.
|
|
Definition at line 76 of file XML_Loader.h. |
|
|
The constructor.
Definition at line 52 of file XML_Loader.cpp.
|
|
|
Definition at line 58 of file XML_Loader.cpp.
00059 {
00060 }
|
|
||||||||||||||||
|
Definition at line 214 of file XML_Loader.cpp. References ACE_ASSERT, ACE_DEBUG, ACE_TEXT, DEBUG_LEVEL, and LM_INFO.
00218 {
00219 ACE_UNUSED_ARG (name);
00220 if (this->live_)
00221 {
00222 ACE_ASSERT (object_stack_.size () > 0);
00223 if (DEBUG_LEVEL > 5) ACE_DEBUG ((LM_INFO,
00224 ACE_TEXT("(%P|%t) XML_Loader: End Element %s\n"),
00225 name
00226 ));
00227 Topology_Object* cur;
00228 object_stack_.pop (cur);
00229 }
00230 }
|
|
|
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 127 of file XML_Loader.cpp. References ACE_ASSERT, ACE_DEBUG, ACE_ERROR, ACE_TEXT, ACE_THROW, file_name_, live_, LM_DEBUG, LM_ERROR, object_stack_, ACE_Unbounded_Stack< T >::pop(), ACE_Unbounded_Stack< T >::push(), and ACE_Unbounded_Stack< T >::size().
00128 {
00129 ACE_ASSERT (root != 0);
00130 this->live_ = true;
00131
00132 ACEXML_FileCharStream* fstm = new ACEXML_FileCharStream;
00133 // xml input source will take ownership
00134
00135 if (fstm->open (this->file_name_.c_str ()) == 0)
00136 {
00137 // InputSource takes ownership
00138 ACEXML_InputSource input (fstm);
00139
00140 ACEXML_Parser parser;
00141 parser.setContentHandler (this);
00142 parser.setDTDHandler (this);
00143 parser.setErrorHandler (this);
00144 parser.setEntityResolver (this);
00145
00146 ACEXML_TRY_NEW_ENV
00147 {
00148 object_stack_.push (root);
00149 parser.parse (&input ACEXML_ENV_ARG_PARAMETER);
00150 ACEXML_TRY_CHECK;
00151 ACE_ASSERT (object_stack_.size () == 1);
00152 Topology_Object* cur;
00153 object_stack_.pop (cur);
00154 }
00155 ACEXML_CATCH (ACEXML_Exception, ex)
00156 {
00157 // The only way to find out what it is, it to let it print itself, so...
00158 ACE_ERROR ((LM_ERROR, "Unable to load \"%s\".\n", this->file_name_.c_str ()));
00159 ex.print ();
00160 ACE_THROW(CORBA::INTERNAL());
00161 }
00162 ACEXML_ENDTRY;
00163 }
00164 else
00165 {
00166 ACE_DEBUG((LM_DEBUG, ACE_TEXT("Unable to open the XML input file: %s.\n"), file_name_.c_str()));
00167 ACE_THROW(CORBA::INTERNAL());
00168 }
00169 }
|
|
|
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. References ACE_OS::access(), ACE_DEBUG, ACE_ERROR, ACE_TEXT, file_name_, live_, LM_DEBUG, and LM_ERROR. Referenced by TAO_Notify::XML_Topology_Factory::create_loader().
00064 {
00065 bool result = false;
00066
00067 // if *.xml exists, use it
00068 // if it does not exist then
00069 // use the previous one was renamed to *.000
00070 // If neither *.xml nor *.000 exist then something
00071 // "impossible" happened (or its a new system with no saved state).
00072
00073 this->file_name_ = base_name;
00074 this->file_name_ += ".xml";
00075
00076 // 4 is "read permission"
00077 result = (0 == ACE_OS::access (this->file_name_.c_str (), 4));
00078 if (result)
00079 {
00080 this->live_ = false;
00081 ACEXML_FileCharStream* fstm = new ACEXML_FileCharStream;
00082 // xml input source will take ownership
00083
00084 if (fstm->open (this->file_name_.c_str ()) == 0)
00085 {
00086 // InputSource takes ownership
00087 ACEXML_InputSource input (fstm);
00088
00089 ACEXML_Parser parser;
00090 parser.setContentHandler (this);
00091 parser.setDTDHandler (this);
00092 parser.setErrorHandler (this);
00093 parser.setEntityResolver (this);
00094
00095 ACEXML_TRY_NEW_ENV
00096 {
00097 parser.parse (&input ACEXML_ENV_ARG_PARAMETER);
00098 ACEXML_TRY_CHECK;
00099 }
00100 ACEXML_CATCH (ACEXML_Exception, ex)
00101 {
00102 // The only way to find out what it is, it to let it print itself, so...
00103 ACE_ERROR ((LM_ERROR, "Unable to load \"%s\".\n Will try backup file.\n", this->file_name_.c_str ()));
00104 ex.print ();
00105 result = false;
00106 }
00107 ACEXML_ENDTRY;
00108 }
00109 else
00110 {
00111 ACE_DEBUG((LM_DEBUG, ACE_TEXT("Unable to open the XML input file: %s.\n Will try backup file.\n"), file_name_.c_str()));
00112 result = false;
00113 }
00114 }
00115
00116 if (! result)
00117 {
00118 this->file_name_ = base_name;
00119 this->file_name_ += ".000";
00120 result = (0 == ACE_OS::access (this->file_name_.c_str (), 4));
00121 }
00122 return result;
00123 }
|
|
||||||||||||||||||||
|
|
|
|
The name of the file from which data is read.
Definition at line 72 of file XML_Loader.h. |
|
|
A stream representing our current output.
Definition at line 74 of file XML_Loader.h. |
|
|
Definition at line 79 of file XML_Loader.h. |
|
|
Definition at line 77 of file XML_Loader.h. Referenced by load(). |
1.3.6