Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Server_Repository Class Reference

Repository of Server_Infos. More...

#include <Server_Repository.h>

Collaboration diagram for Server_Repository:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Hash_Map_Entry<
ACE_CString, Server_Info * > 
HASH_IMR_ENTRY
typedef ACE_Hash_Map_Manager_Ex<
ACE_CString, Server_Info *,
ACE_Hash< ACE_CString >,
ACE_Equal_To< ACE_CString >,
ACE_Null_Mutex
HASH_IMR_MAP
typedef ACE_Hash_Map_Iterator_Ex<
ACE_CString, Server_Info *,
ACE_Hash< ACE_CString >,
ACE_Equal_To< ACE_CString >,
ACE_Null_Mutex
HASH_IMR_ITER

Public Methods

 Server_Repository (void)
 Default Constructor. More...

 ~Server_Repository (void)
 Destructor. More...

int init (void)
 Initializes the Server Repository. More...

int add (const ACE_CString POA_name, const ACE_CString logical_server_name, const ACE_CString startup_command, const ImplementationRepository::EnvironmentList environment_vars, const ACE_CString working_dir, const ImplementationRepository::ActivationMode activation)
 Add a new server to the Repository. More...

int update (const ACE_CString POA_name, const ACE_CString location, const ACE_CString server_object_ior)
 Update the associated process information. More...

int get_startup_info (const ACE_CString POA_name, ACE_CString &logical_server_name, ACE_CString &startup_command, ImplementationRepository::EnvironmentList &environment_vars, ACE_CString &working_dir, ImplementationRepository::ActivationMode &activation)
 Returns information related to startup. More...

int get_running_info (const ACE_CString POA_name, ACE_CString &location, ACE_CString &server_object_ior)
 Returns information related to a running copy. More...

int starting_up (const ACE_CString POA_name, int new_value)
 Checks the starting_up_ variable in the Server_Info and returns the previous value or -1 if the POA_name wasn't found. More...

int starting_up (const ACE_CString POA_name)
 Same as above but does not alter the value. More...

int remove (const ACE_CString POA_name)
 Removes the server from the Repository. More...

int write_to_xml (const ACE_CString POA_name, const ACE_CString logical_server_name, const ACE_CString startup_command, const ImplementationRepository::EnvironmentList environment_vars, const ACE_CString working_dir, const ImplementationRepository::ActivationMode activation)
 Write into the xml file. More...

HASH_IMR_ITERnew_iterator (void)
 Returns a new iterator that travels over the repository. More...

size_t get_repository_size (void)
 Returns the number of entries in the repository. More...


Private Attributes

HASH_IMR_MAP repository_
ACE_Configuration_Section_Key servers_
XML_ContentHandlerhandler_

Detailed Description

Repository of Server_Infos.

Handles the storage, updating, and startup of servers.

Definition at line 35 of file Server_Repository.h.


Member Typedef Documentation

typedef ACE_Hash_Map_Entry<ACE_CString, Server_Info *> Server_Repository::HASH_IMR_ENTRY
 

Definition at line 45 of file Server_Repository.h.

Referenced by ImR_Activator_i::list, ImR_Iterator::next_n, and ImR_Activator_i::run.

typedef ACE_Hash_Map_Iterator_Ex<ACE_CString, Server_Info *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex> Server_Repository::HASH_IMR_ITER
 

Definition at line 57 of file Server_Repository.h.

Referenced by ImR_Iterator::ImR_Iterator, and new_iterator.

typedef ACE_Hash_Map_Manager_Ex<ACE_CString, Server_Info *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex> Server_Repository::HASH_IMR_MAP
 

Definition at line 51 of file Server_Repository.h.


Constructor & Destructor Documentation

Server_Repository::Server_Repository void   
 

Default Constructor.

Definition at line 14 of file Server_Repository.cpp.

00015 {
00016 }

Server_Repository::~Server_Repository void   
 

Destructor.

Definition at line 19 of file Server_Repository.cpp.

00020 {
00021 }


Member Function Documentation

int Server_Repository::add const ACE_CString    POA_name,
const ACE_CString    logical_server_name,
const ACE_CString    startup_command,
const ImplementationRepository::EnvironmentList    environment_vars,
const ACE_CString    working_dir,
const ImplementationRepository::ActivationMode    activation
 

Add a new server to the Repository.

Definition at line 117 of file Server_Repository.cpp.

References ACE_CString, ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_TCHAR, ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info *, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::bind, ACE_OS::fclose, ACE_OS::fgets, ACE_OS::fopen, ACE_OS::fprintf, ACE_Singleton::instance, LM_DEBUG, LM_ERROR, Repository_Configuration::open_section, repository_, Repository_Configuration::set_integer_value, Repository_Configuration::set_string_value, ACE_OS_String::strcmp, and ACE_OS_String::strstr.

Referenced by init.

00125 {
00126   ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
00127 
00128   if (ACE_OS::strcmp (mode, "x") != 0)
00129     {
00130 
00131       Repository_Configuration *config = OPTIONS::instance ()->config ();
00132 
00133       // @@ Add this to the persistent configuration; environment_vars??
00134       ACE_Configuration_Section_Key server;
00135       config->open_section (this->servers_,
00136                             POA_name.c_str(),
00137                             1,
00138                             server);
00139 
00140       config->set_string_value (server,
00141                                 ACE_LIB_TEXT ("LogicalServer"),
00142                                 logical_server_name);
00143 
00144       config->set_string_value (server,
00145                                 ACE_LIB_TEXT ("StartupCommand"),
00146                                 startup_command);
00147 
00148       config->set_string_value (server,
00149                                 ACE_LIB_TEXT ("WorkingDir"),
00150                                 working_dir);
00151 
00152       config->set_integer_value (server,
00153                                  ACE_LIB_TEXT ("Activation"),
00154                                  activation);
00155 
00156       Server_Info *new_server = 0;
00157       ACE_NEW_RETURN (new_server,
00158                       Server_Info (POA_name,
00159                                    logical_server_name,
00160                                    startup_command,
00161                                    environment_vars,
00162                                    working_dir,
00163                                    activation),
00164                       -1);
00165 
00166       return this->repository_.bind (POA_name,
00167                                      new_server);
00168     }
00169   else
00170     {
00171       /// XML mode: So, write into file.
00172       ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
00173 
00174       FILE *fp = ACE_OS::fopen (filename, "r");
00175 
00176       ACE_TCHAR buffer[4096];
00177       ACE_TCHAR *found;
00178 
00179       while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
00180         {
00181           /// Obviously, we need to/can update only if we find an
00182           /// entry for it in the xml file.
00183           found = ACE_OS::strstr (buffer, POA_name.c_str ());
00184 
00185           if (found)
00186             {
00187               /// An entry found for the POA_name. So, dont
00188               /// add it again.
00189               ACE_DEBUG ((LM_DEBUG,
00190                           "The %s is already added.\n", POA_name.c_str ()));
00191 
00192               ACE_OS::fclose (fp);
00193 
00194               return 0;
00195             }
00196         }
00197 
00198       /// If control comes here, it means this server isnt added already.
00199       fp = ACE_OS::fopen (filename, "a");
00200 
00201       if (fp == 0)
00202         {
00203           ACE_ERROR_RETURN ((LM_ERROR,
00204                              "Coudnt open the file to append\n"),
00205                             -1);
00206         }
00207 
00208       ACE_CString server_info = "<SERVER_INFORMATION>";
00209       server_info += "<Server>";
00210       server_info += POA_name.c_str ();
00211       server_info += "</Server>\n<StartupOptions>\n<Command_Line>";
00212       server_info += startup_command;
00213       server_info += "</Command_Line>\n<WorkingDir>";
00214       server_info += working_dir;
00215       server_info += "</WorkingDir>\n<Activation>";
00216       server_info += OPTIONS::instance ()->convert_str (activation);
00217       server_info += "</Activation>\n</StartupOptions>\n</SERVER_INFORMATION>\n";
00218 
00219       ACE_OS::fprintf (fp,
00220                        server_info.c_str ());
00221       ACE_OS::fclose (fp);
00222 
00223       return 0;
00224     }
00225 }

size_t Server_Repository::get_repository_size void   
 

Returns the number of entries in the repository.

Definition at line 729 of file Server_Repository.cpp.

References ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info *, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::current_size, and repository_.

00730 {
00731   return this->repository_.current_size ();
00732 }

int Server_Repository::get_running_info const ACE_CString    POA_name,
ACE_CString   location,
ACE_CString   server_object_ior
 

Returns information related to a running copy.

Definition at line 370 of file Server_Repository.cpp.

References ACE_CString, ACE_TCHAR, ACE_OS::fgets, ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info *, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::find, ACE_OS::fopen, Server_Info::get_running_info, XML_ContentHandler::get_running_information, handler_, ACE_Singleton::instance, repository_, ACE_OS_String::strcmp, and ACE_OS_String::strstr.

00373 {
00374   ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
00375 
00376   if (ACE_OS::strcmp (mode, "x") != 0)
00377     {
00378 
00379       Server_Info *server;
00380       int retval = this->repository_.find (POA_name,
00381                                            server);
00382 
00383       // Only fill in data if it was found
00384       if (retval == 0)
00385         {
00386           server->get_running_info (location,
00387                                     server_object_ior);
00388         }
00389 
00390       return retval;
00391     }
00392   else
00393     {
00394       /// XML mode
00395       ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
00396 
00397       FILE *fp = ACE_OS::fopen (filename, "r");
00398 
00399       ACE_TCHAR buffer[4096];
00400       ACE_TCHAR *found;
00401 
00402       while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
00403         {
00404           found = ACE_OS::strstr (buffer, POA_name.c_str ());
00405 
00406           if (found)
00407             {
00408               /// Found an entry for the POA_name. So, we can proceed.
00409               this->handler_->get_running_information (POA_name,
00410                                                        location,
00411                                                        server_object_ior);
00412               return 0;
00413             }
00414         }
00415       /// If control comes here.. implies, there is no entry for the
00416       /// POA_name.
00417       return -1;
00418     }
00419 }

int Server_Repository::get_startup_info const ACE_CString    POA_name,
ACE_CString   logical_server_name,
ACE_CString   startup_command,
ImplementationRepository::EnvironmentList   environment_vars,
ACE_CString   working_dir,
ImplementationRepository::ActivationMode   activation
 

Returns information related to startup.

Definition at line 285 of file Server_Repository.cpp.

References ACE_CString, ACE_NEW_RETURN, ACE_TCHAR, ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info *, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::find, Server_Info::get_startup_info, XML_ContentHandler::get_startup_information, handler_, ACE_Singleton::instance, repository_, and ACE_OS_String::strcmp.

00293 {
00294   ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
00295 
00296   if (ACE_OS::strcmp (mode, "x") != 0)
00297     {
00298 
00299       Server_Info *server;
00300       int retval = this->repository_.find (POA_name, server);
00301 
00302       // Only fill in data if it was found
00303       if (retval == 0)
00304         {
00305           server->get_startup_info (logical_server_name,
00306                                     startup_command,
00307                                     environment_vars,
00308                                     working_dir,
00309                                     activation);
00310         }
00311 
00312       return retval;
00313     }
00314   else
00315     {
00316       ACEXML_FileCharStream *fstm = 0;
00317       ACE_NEW_RETURN (fstm,
00318                       ACEXML_FileCharStream (),
00319                       1);
00320 
00321 
00322       if (fstm->open (OPTIONS::instance ()->file_name ()) != 0)
00323         {
00324           cerr << "Fail to open XML file: trial.xml " << endl;
00325           return 1;
00326         }
00327 
00328       /// XML case
00329       this->handler_ =
00330         new XML_ContentHandler (POA_name.c_str ());
00331 
00332       ACEXML_Parser parser;
00333 
00334       ACEXML_InputSource input(fstm);
00335 
00336       parser.setContentHandler (this->handler_);
00337       parser.setDTDHandler (this->handler_);
00338       parser.setErrorHandler (this->handler_);
00339       parser.setEntityResolver (this->handler_);
00340 
00341       ACEXML_TRY_NEW_ENV
00342         {
00343           parser.parse (&input ACEXML_ENV_ARG_PARAMETER);
00344           ACEXML_TRY_CHECK;
00345         }
00346       ACEXML_CATCH (ACEXML_Exception, ex)
00347         {
00348           ex.print();
00349           return -1;
00350         }
00351       ACEXML_ENDTRY;
00352 
00353       ACE_CString activation_mode;
00354 
00355       this->handler_->get_startup_information (logical_server_name,
00356                                                startup_command,
00357                                                working_dir,
00358                                                activation_mode);
00359 
00360       activation = OPTIONS::instance ()->convert_mode (activation_mode.c_str ());
00361 
00362       return 0;
00363     }
00364 }

int Server_Repository::init void   
 

Initializes the Server Repository.

Definition at line 27 of file Server_Repository.cpp.

References ACE_CString, ACE_DEBUG, ACE_LIB_TEXT, ACE_TCHAR, ACE_TEXT, add, Repository_Configuration::enumerate_sections, Repository_Configuration::get_integer_value, Repository_Configuration::get_string_value, ACE_Singleton::instance, LM_DEBUG, Repository_Configuration::open_section, Repository_Configuration::root_section, servers_, and ACE_OS_String::strcmp.

Referenced by ImR_Activator_i::init.

00028 {
00029   ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
00030 
00031   if (ACE_OS::strcmp (mode, "x") != 0)
00032     {
00033       Repository_Configuration *config = OPTIONS::instance ()->config ();
00034 
00035       // NON-XML mode
00036 
00037       // iterate through the list of registered servers and register them
00038       config->open_section (config->root_section (),
00039                             ACE_LIB_TEXT ("Servers"),
00040                             1,
00041                             this->servers_);
00042       int index = 0;
00043       ACE_CString name;
00044 
00045       while (config->enumerate_sections (servers_, index, name) == 0)
00046         {
00047           ACE_CString logical, startup, working_dir;
00048           u_int activation_val = 0;
00049           ImplementationRepository::ActivationMode activation;
00050 
00051           ImplementationRepository::EnvironmentList environment_vars;
00052 
00053           ACE_Configuration_Section_Key server_key;
00054           int error = 0;
00055 
00056           error += config->open_section (this->servers_,
00057                                          name.c_str(),
00058                                          0,
00059                                          server_key);
00060 
00061           error += config->get_string_value (server_key,
00062                                              ACE_LIB_TEXT ("LogicalServer"),
00063                                              logical);
00064 
00065           error += config->get_string_value (server_key,
00066                                              ACE_LIB_TEXT ("StartupCommand"),
00067                                              startup);
00068 
00069           error += config->get_string_value (server_key,
00070                                              ACE_LIB_TEXT ("WorkingDir"),
00071                                              working_dir);
00072 
00073           error += config->get_integer_value (server_key,
00074                                               ACE_LIB_TEXT ("Activation"),
00075                                               activation_val);
00076 
00077           activation =
00078             ACE_static_cast (ImplementationRepository::ActivationMode,
00079                              activation_val);
00080 
00081           // Maybe environments variables?? need a straightforward
00082           // way to store env vars.
00083 
00084           if (error != 0)
00085             {              ACE_DEBUG ((LM_DEBUG,
00086                           ACE_TEXT ("Error reading configuration data for ")
00087                           ACE_TEXT ("service '%s',skipping\n"),
00088                           name.c_str ()));
00089             }
00090           else
00091             {
00092               this->add (name,
00093                          logical,
00094                          startup,
00095                          environment_vars,
00096                          working_dir,
00097                          activation);
00098             }
00099 
00100           index++;
00101         }
00102     }
00103   else
00104     {
00105       /// @@ Not quite sure what I want to do here .. leave for
00106       /// now. I guess similar stuff like check if that particular
00107       /// server info exists etc.
00108     }
00109 
00110   return 0;
00111 }

Server_Repository::HASH_IMR_ITER * Server_Repository::new_iterator void   
 

Returns a new iterator that travels over the repository.

Definition at line 715 of file Server_Repository.cpp.

References ACE_NEW_RETURN, and HASH_IMR_ITER.

00716 {
00717   HASH_IMR_ITER *hash_iter = 0;
00718   ACE_NEW_RETURN (hash_iter,
00719                   Server_Repository::HASH_IMR_ITER (this->repository_),
00720                   0);
00721 
00722   return hash_iter;
00723 }

int Server_Repository::remove const ACE_CString    POA_name
 

Removes the server from the Repository.

Definition at line 538 of file Server_Repository.cpp.

References ACE_CString, ACE_TCHAR, ACE_OS::fclose, ACE_OS::fgets, ACE_OS::fopen, ACE_OS::fprintf, ACE_Singleton::instance, Repository_Configuration::remove_section, repository_, ACE_OS_String::strcmp, ACE_OS_String::strstr, ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info *, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::unbind, and ACE_OS::unlink.

00539 {
00540   ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
00541 
00542   if (ACE_OS::strcmp (mode, "x") != 0)
00543     {
00544       Repository_Configuration *config = OPTIONS::instance ()->config ();
00545 
00546       // Remove the persistent configuration information
00547       config->remove_section (this->servers_,
00548                               POA_name.c_str(),
00549                               1);
00550 
00551       return this->repository_.unbind (POA_name);
00552     }
00553   else
00554     {
00555       /// XML mode
00556       ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
00557 
00558       FILE *fp = ACE_OS::fopen (filename, "r");
00559 
00560       /// Have a temporary file
00561       CORBA::String_var temp_file = "temporary_file";
00562 
00563       FILE *fp_temp = ACE_OS::fopen (temp_file.in (), "w");
00564 
00565       ACE_TCHAR buffer[4096];
00566 
00567       int remove_section = 0;
00568       ACE_TCHAR *found;
00569       // int dtd_section = 0;
00570 
00571       while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
00572         {
00573           if (remove_section == 0)
00574             {
00575               found = ACE_OS::strstr (buffer, POA_name.c_str ());
00576 
00577               if (!found)
00578                 {
00579                   ACE_OS::fprintf (fp_temp,
00580                                    buffer);
00581                 }
00582               else
00583                 {
00584                   remove_section = 1;
00585                 }
00586             }
00587           else
00588             {
00589               found = ACE_OS::strstr (buffer, "</SERVER_INFORMATION>");
00590 
00591               if (found)
00592                 remove_section = 0;
00593             }
00594         }
00595 
00596       ACE_OS::fclose (fp_temp);
00597       ACE_OS::fclose (fp);
00598 
00599       // Now copy the temporary file to the original file.
00600       fp_temp = ACE_OS::fopen (temp_file.in (), "r");
00601 
00602       fp = ACE_OS::fopen (filename, "w");
00603 
00604       while (ACE_OS::fgets (buffer, sizeof (buffer), fp_temp))
00605         {
00606           ACE_OS::fprintf (fp,
00607                            buffer);
00608         }
00609 
00610       ACE_OS::fclose (fp);
00611       ACE_OS::fclose (fp_temp);
00612       ACE_OS::unlink (temp_file.in ());
00613       return 0;
00614     }
00615   /*
00616             /// There is no support for DTD in the XML parser as of
00617             /// now. Will uncomment this part when the support is
00618             /// added.
00619 
00620             if (dtd_section == 0)
00621             {
00622             found = ACE_OS::strstr (buffer, "]>");
00623 
00624             if (found)
00625             {
00626             dtd_section = 1;
00627             remove_section = 0;
00628             }
00629 
00630             ACE_OS::fprintf (fp_temp,
00631             buffer);
00632             }
00633             else
00634             {
00635             if (remove_section == 0)
00636             {
00637             found = ACE_OS::strstr (buffer, POA_name.c_str ());
00638 
00639             if (!found)
00640             {
00641             ACE_OS::fprintf (fp_temp,
00642             buffer);
00643             }
00644             else
00645             {
00646             remove_section = 1;
00647             }
00648             }
00649             else
00650             {
00651             found = ACE_OS::strstr (buffer, "</SERVER_INFORMATION>");
00652 
00653             if (found)
00654             remove_section = 0;
00655             }
00656             }
00657 
00658             }
00659             ACE_OS::fclose (fp_temp);
00660             ACE_OS::fclose (fp);
00661 
00662             // Now copy the temporary file to the original file.
00663             fp_temp = ACE_OS::fopen (temp_file, "r");
00664 
00665             fp = ACE_OS::fopen (filename, "w");
00666 
00667             while (ACE_OS::fgets (buffer, 4096, fp_temp))
00668             {
00669             ACE_OS::fprintf (fp,
00670             buffer);
00671             }
00672 
00673             ACE_OS::fclose (fp);
00674             ACE_OS::fclose (fp_temp);
00675             ACE_OS::unlink (temp_file);
00676             }
00677           */
00678 }

int Server_Repository::starting_up const ACE_CString    POA_name
 

Same as above but does not alter the value.

Definition at line 483 of file Server_Repository.cpp.

References ACE_CString, ACE_TCHAR, ACE_OS::fgets, ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info *, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::find, ACE_OS::fopen, XML_ContentHandler::get_startup_value, handler_, ACE_Singleton::instance, repository_, Server_Info::starting_up_, ACE_OS_String::strcmp, and ACE_OS_String::strstr.

00484 {
00485   ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
00486 
00487   if (ACE_OS::strcmp (mode, "x") != 0)
00488     {
00489       Server_Info *server;
00490 
00491       int retval = this->repository_.find (POA_name,
00492                                            server);
00493 
00494       // Only fill in data if it was found
00495       if (retval == 0)
00496         {
00497           retval = server->starting_up_;
00498         }
00499 
00500       return retval;
00501     }
00502   else
00503     {
00504       /// XML mode
00505       ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
00506 
00507       FILE *fp = ACE_OS::fopen (filename, "r");
00508 
00509       ACE_TCHAR buffer[4096];
00510       ACE_TCHAR *found;
00511 
00512       while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
00513         {
00514           found = ACE_OS::strstr (buffer, POA_name.c_str ());
00515 
00516           if (found)
00517             {
00518               int retval;
00519 
00520               /// Found an entry for the POA_name. So, we can proceed.
00521               this->handler_->get_startup_value (POA_name,
00522                                                  retval);
00523 
00524               return retval;
00525             }
00526         }
00527 
00528       /// If control comes here.. implies, there is no entry for the
00529       /// POA_name.
00530       return -1;
00531     }
00532 }

int Server_Repository::starting_up const ACE_CString    POA_name,
int    new_value
 

Checks the starting_up_ variable in the Server_Info and returns the previous value or -1 if the POA_name wasn't found.

Definition at line 426 of file Server_Repository.cpp.

References ACE_CString, ACE_TCHAR, ACE_OS::fgets, ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info *, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::find, ACE_OS::fopen, XML_ContentHandler::get_startup_value, handler_, ACE_Singleton::instance, repository_, XML_ContentHandler::set_startup_value, Server_Info::starting_up_, ACE_OS_String::strcmp, and ACE_OS_String::strstr.

00428 {
00429   ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
00430 
00431   if (ACE_OS::strcmp (mode, "x") != 0)
00432     {
00433       Server_Info *server;
00434       int retval = this->repository_.find (POA_name,
00435                                            server);
00436 
00437       // Only fill in data if it was found
00438       if (retval == 0)
00439         {
00440           retval = server->starting_up_;
00441           server->starting_up_ = new_value;
00442         }
00443 
00444       return retval;
00445     }
00446   else
00447     {
00448       /// XML mode
00449       ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
00450 
00451       FILE *fp = ACE_OS::fopen (filename, "r");
00452 
00453       ACE_TCHAR buffer[4096];
00454       ACE_TCHAR *found;
00455 
00456       while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
00457         {
00458           found = ACE_OS::strstr (buffer, POA_name.c_str ());
00459 
00460           if (found)
00461             {
00462               int retval;
00463 
00464               /// Found an entry for the POA_name. So, we can proceed.
00465               this->handler_->get_startup_value (POA_name,
00466                                                  retval);
00467 
00468               this->handler_->set_startup_value (POA_name,
00469                                                  new_value);
00470 
00471               return retval;
00472             }
00473         }
00474       /// If control comes here.. implies, there is no entry for the
00475       /// POA_name.
00476       return -1;
00477     }
00478 }

int Server_Repository::update const ACE_CString    POA_name,
const ACE_CString    location,
const ACE_CString    server_object_ior
 

Update the associated process information.

Definition at line 230 of file Server_Repository.cpp.

References ACE_CString, ACE_TCHAR, ACE_OS::fgets, ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info *, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex >::find, ACE_OS::fopen, handler_, ACE_Singleton::instance, repository_, ACE_OS_String::strcmp, ACE_OS_String::strstr, Server_Info::update_running_info, and XML_ContentHandler::update_running_information.

00233 {
00234   ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
00235 
00236   if (ACE_OS::strcmp (mode, "x") != 0)
00237     {
00238       Server_Info *server;
00239       int retval = this->repository_.find (POA_name,
00240                                            server);
00241 
00242       // Only fill in data if it was found
00243       if (retval == 0)
00244         {
00245           server->update_running_info (location,
00246                                        server_object_ior);
00247         }
00248 
00249       return retval;
00250     }
00251   else
00252     {
00253       /// XML mode
00254       ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
00255 
00256       FILE *fp = ACE_OS::fopen (filename, "r+");
00257 
00258       ACE_TCHAR buffer[4096];
00259 
00260       ACE_TCHAR *found;
00261 
00262       while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
00263         {
00264           /// Obviously, we need to/can update only if we find an
00265           /// entry for it in the xml file.
00266           found = ACE_OS::strstr (buffer, POA_name.c_str ());
00267 
00268           if (found)
00269             {
00270               /// found an entry. So, need to update the entry
00271               /// information.
00272               this->handler_->update_running_information (POA_name,
00273                                                           location,
00274                                                           server_object_ior);
00275               return 0;
00276             }
00277         }
00278       return -1;
00279     }
00280 }

int Server_Repository::write_to_xml const ACE_CString    POA_name,
const ACE_CString    logical_server_name,
const ACE_CString    startup_command,
const ImplementationRepository::EnvironmentList    environment_vars,
const ACE_CString    working_dir,
const ImplementationRepository::ActivationMode    activation
 

Write into the xml file.

Definition at line 682 of file Server_Repository.cpp.

References ACE_CString.

00689 {
00690   /*
00691     ACE_TCHAR *filename = "trial.xml";
00692 
00693     ACE_Configuration_Heap *heap = 0;
00694     ACE_NEW_RETURN (heap, ACE_Configuration_Heap, -1);
00695 
00696     if (heap->open (filename) != 0)
00697     {
00698     ACE_ERROR ((LM_ERROR,
00699     ACE_TEXT ("Error: Opening persistent heap file '%s'\n"),
00700     filename));
00701     }
00702 
00703     heap->open_section (heap->root_section (),
00704     "Trail_Servers",
00705     1,
00706 
00707   */
00708   return 0;
00709 }


Member Data Documentation

XML_ContentHandler* Server_Repository::handler_ [private]
 

Definition at line 119 of file Server_Repository.h.

Referenced by get_running_info, get_startup_info, starting_up, and update.

HASH_IMR_MAP Server_Repository::repository_ [private]
 

Definition at line 117 of file Server_Repository.h.

Referenced by add, get_repository_size, get_running_info, get_startup_info, remove, starting_up, and update.

ACE_Configuration_Section_Key Server_Repository::servers_ [private]
 

Definition at line 118 of file Server_Repository.h.

Referenced by init.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 20:04:28 2003 for TAO_Implementation_Repository by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002