Locator_XMLHandler.cpp

Go to the documentation of this file.
00001 // Locator_XMLHandler.cpp,v 1.4 2006/01/04 16:10:11 giovannd Exp
00002 
00003 #include "Locator_XMLHandler.h"
00004 #include "ace/OS_NS_strings.h"
00005 
00006 ACE_RCSID (ImplRepo_Service,Locator_XMLHandler,"Locator_XMLHandler.cpp,v 1.4 2006/01/04 16:10:11 giovannd Exp")
00007 
00008 const char* Locator_XMLHandler::ROOT_TAG = "ImplementationRepository";
00009 const char* Locator_XMLHandler::SERVER_INFO_TAG = "Servers";
00010 const char* Locator_XMLHandler::ACTIVATOR_INFO_TAG = "Activators";
00011 const char* Locator_XMLHandler::ENVIRONMENT_TAG = "EnvironmentVariables";
00012 
00013 Locator_XMLHandler::Locator_XMLHandler (Callback& cb)
00014 : callback_ (cb)
00015 {
00016 }
00017 
00018 void
00019 Locator_XMLHandler::startElement (const ACEXML_Char*,
00020                                   const ACEXML_Char*,
00021                                   const ACEXML_Char* qName,
00022                                   ACEXML_Attributes* attrs ACEXML_ENV_ARG_DECL_NOT_USED)
00023   ACE_THROW_SPEC ((ACEXML_SAXException))
00024 {
00025   ACE_ASSERT (qName != 0);
00026   if (ACE_OS::strcasecmp (qName, SERVER_INFO_TAG) == 0)
00027     {
00028       // We'll use this as a key to determine if we've got a valid record
00029       this->server_name_ = "";
00030       this->env_vars_.clear();
00031 
00032       if (attrs != 0 && attrs->getLength () == 8)
00033         {
00034           this->server_name_ = attrs->getValue ((size_t)0);
00035           this->activator_name_ = attrs->getValue ((size_t)1);
00036           this->command_line_ = attrs->getValue ((size_t)2);
00037           this->working_dir_ = attrs->getValue ((size_t)3);
00038           this->activation_ = attrs->getValue ((size_t)4);
00039           this->env_vars_.clear ();
00040           int limit = ACE_OS::atoi (attrs->getValue ((size_t)5));
00041           this->start_limit_ = limit;
00042           this->partial_ior_ = attrs->getValue ((size_t)6);
00043           this->server_object_ior_ = attrs->getValue ((size_t)7);
00044         }
00045     }
00046   else if (ACE_OS::strcasecmp (qName, ACTIVATOR_INFO_TAG) == 0)
00047   {
00048     if (attrs != 0 && attrs->getLength () == 3)
00049       {
00050         ACE_CString aname = attrs->getValue ((size_t)0);
00051         ACE_CString token_str = attrs->getValue ((size_t)1);
00052         long token = ACE_OS::atoi (token_str.c_str ());
00053         ACE_CString ior = attrs->getValue ((size_t)2);
00054         this->callback_.next_activator (aname, token, ior);
00055       }
00056   }
00057   else if (ACE_OS::strcasecmp (qName, ENVIRONMENT_TAG) == 0)
00058     {
00059       if (attrs != 0 && attrs->getLength () == 2)
00060         {
00061           EnvVar ev;
00062           ev.name = attrs->getValue ((size_t)0);
00063           ev.value = attrs->getValue ((size_t)1);
00064           this->env_vars_.push_back (ev);
00065         }
00066     }
00067 }
00068 
00069 void
00070 Locator_XMLHandler::endElement (const ACEXML_Char*,
00071                                 const ACEXML_Char*,
00072                                 const ACEXML_Char* qName ACEXML_ENV_ARG_DECL_NOT_USED)
00073   ACE_THROW_SPEC ((ACEXML_SAXException))
00074 {
00075   ACE_ASSERT(qName != 0);
00076   if (ACE_OS::strcasecmp (qName, SERVER_INFO_TAG) == 0
00077     && this->server_name_.length () > 0)
00078   {
00079     this->callback_.next_server (this->server_name_,
00080       this->activator_name_, this->command_line_,
00081       this->env_vars_, this->working_dir_, this->activation_,
00082       this->start_limit_, this->partial_ior_, this->server_object_ior_);
00083   }
00084   // activator info is handled in the startElement
00085 }
00086 
00087 bool
00088 Locator_XMLHandler::EnvVar::operator== (const EnvVar& rhs) const
00089 {
00090   return name == rhs.name && value == rhs.value;
00091 }
00092 bool
00093 Locator_XMLHandler::EnvVar::operator!= (const EnvVar& rhs) const
00094 {
00095   return ! (rhs == *this);
00096 }
00097 

Generated on Thu Nov 9 13:36:20 2006 for TAO_Implementation_Repository by doxygen 1.3.6