00001
00002
00003 #include "Locator_XMLHandler.h"
00004 #include "ace/OS_NS_strings.h"
00005
00006 ACE_RCSID (ImplRepo_Service,Locator_XMLHandler,"$Id: Locator_XMLHandler.cpp 78900 2007-07-15 13:05:48Z sowayaa $")
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)
00023 {
00024 ACE_ASSERT (qName != 0);
00025 if (ACE_OS::strcasecmp (qName, SERVER_INFO_TAG) == 0)
00026 {
00027
00028 this->server_name_ = "";
00029 this->env_vars_.clear();
00030
00031 if (attrs != 0 && attrs->getLength () == 8)
00032 {
00033 this->server_name_ = attrs->getValue ((size_t)0);
00034 this->activator_name_ = attrs->getValue ((size_t)1);
00035 this->command_line_ = attrs->getValue ((size_t)2);
00036 this->working_dir_ = attrs->getValue ((size_t)3);
00037 this->activation_ = attrs->getValue ((size_t)4);
00038 this->env_vars_.clear ();
00039 int limit = ACE_OS::atoi (attrs->getValue ((size_t)5));
00040 this->start_limit_ = limit;
00041 this->partial_ior_ = attrs->getValue ((size_t)6);
00042 this->server_object_ior_ = attrs->getValue ((size_t)7);
00043 }
00044 }
00045 else if (ACE_OS::strcasecmp (qName, ACTIVATOR_INFO_TAG) == 0)
00046 {
00047 if (attrs != 0 && attrs->getLength () == 3)
00048 {
00049 ACE_CString aname = attrs->getValue ((size_t)0);
00050 ACE_CString token_str = attrs->getValue ((size_t)1);
00051 long token = ACE_OS::atoi (token_str.c_str ());
00052 ACE_CString ior = attrs->getValue ((size_t)2);
00053 this->callback_.next_activator (aname, token, ior);
00054 }
00055 }
00056 else if (ACE_OS::strcasecmp (qName, ENVIRONMENT_TAG) == 0)
00057 {
00058 if (attrs != 0 && attrs->getLength () == 2)
00059 {
00060 EnvVar ev;
00061 ev.name = attrs->getValue ((size_t)0);
00062 ev.value = attrs->getValue ((size_t)1);
00063 this->env_vars_.push_back (ev);
00064 }
00065 }
00066 }
00067
00068 void
00069 Locator_XMLHandler::endElement (const ACEXML_Char*,
00070 const ACEXML_Char*,
00071 const ACEXML_Char* qName)
00072 {
00073 ACE_ASSERT(qName != 0);
00074 if (ACE_OS::strcasecmp (qName, SERVER_INFO_TAG) == 0
00075 && this->server_name_.length () > 0)
00076 {
00077 this->callback_.next_server (this->server_name_,
00078 this->activator_name_, this->command_line_,
00079 this->env_vars_, this->working_dir_, this->activation_,
00080 this->start_limit_, this->partial_ior_, this->server_object_ior_);
00081 }
00082
00083 }
00084
00085 bool
00086 Locator_XMLHandler::EnvVar::operator== (const EnvVar& rhs) const
00087 {
00088 return name == rhs.name && value == rhs.value;
00089 }
00090 bool
00091 Locator_XMLHandler::EnvVar::operator!= (const EnvVar& rhs) const
00092 {
00093 return ! (rhs == *this);
00094 }
00095