#include <Locator_Options.h>
Collaboration diagram for Options:
Public Types | |
enum | SERVICE_COMMAND { SC_NONE, SC_INSTALL, SC_REMOVE } |
enum | RepoMode { REPO_NONE, REPO_XML_FILE, REPO_HEAP_FILE, REPO_REGISTRY } |
Public Member Functions | |
Options () | |
int | init (int argc, char *argv[]) |
Parse the command-line arguments and initialize the options. | |
int | init_from_registry () |
This version should only be used when run as an nt service. | |
bool | service (void) const |
Service Mode. | |
unsigned int | debug (void) const |
Debug level for the Implementation Repository. | |
const ACE_TString & | ior_filename (void) const |
Returns the file where the IOR should be stored. | |
bool | multicast (void) const |
Will we listen for multicast location requests? | |
SERVICE_COMMAND | service_command (void) const |
The nt service command to run (install/remove). | |
int | save_registry_options () |
const char * | cmdline (void) const |
const ACE_TString & | persist_file_name (void) const |
bool | readonly (void) const |
Do we allow modifications to the servers? | |
RepoMode | repository_mode (void) const |
bool | repository_erase (void) const |
Do we wish to clear out the repository. | |
ACE_Time_Value | startup_timeout (void) const |
Returns the timeout value for program starting. | |
ACE_Time_Value | ping_interval (void) const |
Private Member Functions | |
int | parse_args (int &argc, char *argv[]) |
Parses and pulls out arguments for the ImR. | |
void | print_usage (void) const |
Print the usage information. | |
int | run_service_command (const ACE_TString &cmdline) |
Run a service command. | |
int | load_registry_options () |
Private Attributes | |
RepoMode | repo_mode_ |
bool | erase_repo_ |
unsigned int | debug_ |
Debug level. | |
ACE_TString | ior_output_file_ |
File where the IOR of the server object is stored. | |
bool | multicast_ |
Will we listen for multicast location requests? | |
bool | service_ |
Are we running as a service? | |
ACE_Time_Value | ping_interval_ |
The amount of time between successive "are you started yet?" pings. | |
ACE_Time_Value | startup_timeout_ |
The amount of time to wait for a server to response after starting it. | |
bool | readonly_ |
Can the server_repository be modified? | |
SERVICE_COMMAND | service_command_ |
SC_NONE, SC_INSTALL, SC_REMOVE, ... | |
ACE_CString | cmdline_ |
Our extra command line arguments. | |
ACE_TString | persist_file_name_ |
The persistent XML file name. |
This is where all the settings for TAO's Implementation Repository are stored.
Definition at line 34 of file Locator_Options.h.
|
Definition at line 44 of file Locator_Options.h.
00044 { 00045 REPO_NONE, 00046 REPO_XML_FILE, 00047 REPO_HEAP_FILE, 00048 REPO_REGISTRY 00049 }; |
|
Definition at line 38 of file Locator_Options.h.
00038 { 00039 SC_NONE, 00040 SC_INSTALL, 00041 SC_REMOVE 00042 }; |
|
Definition at line 31 of file Locator_Options.cpp. References DEFAULT_PING_INTERVAL, and DEFAULT_START_TIMEOUT.
00032 : repo_mode_ (REPO_NONE) 00033 , erase_repo_ (false) 00034 , debug_ (1) 00035 , multicast_ (false) 00036 , service_ (false) 00037 , ping_interval_(DEFAULT_PING_INTERVAL) 00038 , startup_timeout_(DEFAULT_START_TIMEOUT) 00039 , readonly_ (false) 00040 , service_command_(SC_NONE) 00041 { 00042 } |
|
Definition at line 467 of file Locator_Options.cpp.
00467 { 00468 return this->cmdline_.c_str (); 00469 } |
|
Debug level for the Implementation Repository.
Definition at line 443 of file Locator_Options.cpp.
00444 { 00445 return this->debug_; 00446 } |
|
Parse the command-line arguments and initialize the options.
Definition at line 212 of file Locator_Options.cpp. References ACE_CString, and parse_args(). Referenced by ImR_Locator_Loader::init(), and main().
00213 { 00214 // Make an initial pass through and grab the arguments that we recognize. 00215 // This may also run the commands to install or remove the nt service. 00216 int result = this->parse_args (argc, argv); 00217 if (result != 0) 00218 { 00219 return result; 00220 } 00221 00222 for (int i = 0; i < argc; ++i) 00223 { 00224 this->cmdline_ += ACE_CString (argv[i]) + ACE_CString (" "); 00225 } 00226 return 0; 00227 } |
|
This version should only be used when run as an nt service.
Definition at line 230 of file Locator_Options.cpp. References load_registry_options(). Referenced by Locator_NT_Service::svc().
00231 { 00232 this->load_registry_options (); 00233 return 0; 00234 } |
|
Returns the file where the IOR should be stored.
Definition at line 449 of file Locator_Options.cpp.
00450 { 00451 return this->ior_output_file_; 00452 } |
|
Definition at line 326 of file Locator_Options.cpp. References ACE_ASSERT, ACE_TCHAR, ACE_Time_Value::msec(), multicast_, persist_file_name_, readonly_, repo_mode_, ACE_Time_Value::sec(), SERVICE_REG_PATH, and SERVICE_REG_ROOT. Referenced by init_from_registry().
00327 { 00328 #if defined (ACE_WIN32) 00329 HKEY key = 0; 00330 // Create or open the parameters key 00331 LONG err = ACE_TEXT_RegOpenKeyEx (SERVICE_REG_ROOT, 00332 SERVICE_REG_PATH, 00333 0, 00334 KEY_READ, 00335 &key 00336 ); 00337 if (err != ERROR_SUCCESS) 00338 { 00339 // If there aren't any saved parameters, then that's ok. 00340 return 0; 00341 } 00342 ACE_TCHAR tmpstr[4096]; 00343 DWORD sz = sizeof (tmpstr); 00344 DWORD type = 0; 00345 err = ACE_TEXT_RegQueryValueEx (key, "ORBInitOptions", 0, &type, 00346 (LPBYTE) tmpstr, &sz); 00347 if (err == ERROR_SUCCESS) 00348 { 00349 ACE_ASSERT (type == REG_SZ); 00350 tmpstr[sz - 1] = '\0'; 00351 this->cmdline_ = tmpstr; 00352 } 00353 00354 sz = sizeof(tmpstr); 00355 err = ACE_TEXT_RegQueryValueEx (key, "IORFile", 0, &type, 00356 (LPBYTE) tmpstr, &sz); 00357 if (err == ERROR_SUCCESS) 00358 { 00359 ACE_ASSERT (type == REG_SZ); 00360 tmpstr[sz - 1] = '\0'; 00361 this->ior_output_file_ = tmpstr; 00362 } 00363 00364 sz = sizeof(debug_); 00365 err = ACE_TEXT_RegQueryValueEx (key, "DebugLevel", 0, &type, 00366 (LPBYTE) &this->debug_ , &sz); 00367 if (err == ERROR_SUCCESS) 00368 { 00369 ACE_ASSERT (type == REG_DWORD); 00370 } 00371 00372 DWORD tmp = 0; 00373 sz = sizeof(tmp); 00374 err = ACE_TEXT_RegQueryValueEx (key, "PingInterval", 0, &type, 00375 (LPBYTE) &tmp, &sz); 00376 if (err == ERROR_SUCCESS) 00377 { 00378 ACE_ASSERT (type == REG_DWORD); 00379 ping_interval_.msec (tmp); 00380 } 00381 00382 tmp = 0; 00383 sz = sizeof(tmp); 00384 err = ACE_TEXT_RegQueryValueEx (key, "Lock", 0, &type, 00385 (LPBYTE) &tmp, &sz); 00386 if (err == ERROR_SUCCESS) 00387 { 00388 ACE_ASSERT (type == REG_DWORD); 00389 readonly_ = tmp != 0; 00390 } 00391 00392 sz = sizeof(this->repo_mode_); 00393 err = ACE_TEXT_RegQueryValueEx (key, "PersistType", 0, &type, 00394 (LPBYTE) &this->repo_mode_, &sz); 00395 if (err == ERROR_SUCCESS) 00396 { 00397 ACE_ASSERT (type == REG_DWORD); 00398 } 00399 00400 tmp = 0; 00401 sz = sizeof(tmp); 00402 err = ACE_TEXT_RegQueryValueEx (key, "Timeout", 0, &type, 00403 (LPBYTE) &tmp, &sz); 00404 if (err == ERROR_SUCCESS) 00405 { 00406 ACE_ASSERT (type == REG_DWORD); 00407 this->startup_timeout_.sec (tmp); 00408 } 00409 00410 tmp = 0; 00411 sz = sizeof(tmp); 00412 err = ACE_TEXT_RegQueryValueEx (key, "Multicast", 0, &type, 00413 (LPBYTE) &tmp, &sz); 00414 if (err == ERROR_SUCCESS) 00415 { 00416 ACE_ASSERT (type == REG_DWORD); 00417 this->multicast_ = tmp != 0; 00418 } 00419 00420 sz = sizeof(tmpstr); 00421 err = ACE_TEXT_RegQueryValueEx (key, "PersistFile", 0, &type, 00422 (LPBYTE) tmpstr, &sz); 00423 if (err == ERROR_SUCCESS) 00424 { 00425 ACE_ASSERT (type == REG_SZ); 00426 tmpstr[sz - 1] = '\0'; 00427 this->persist_file_name_ = tmpstr; 00428 } 00429 00430 err = ::RegCloseKey (key); 00431 ACE_ASSERT (err == ERROR_SUCCESS); 00432 #endif 00433 return 0; 00434 } |
|
Will we listen for multicast location requests?
Definition at line 455 of file Locator_Options.cpp. References multicast_.
00456 { 00457 return this->multicast_; 00458 } |
|
Parses and pulls out arguments for the ImR.
Definition at line 45 of file Locator_Options.cpp. References ACE_Arg_Shifter, ACE_ERROR, ACE_TEXT, ACE_Time_Value, ACE_OS::atoi(), erase_repo_, LM_ERROR, multicast_, persist_file_name_, print_usage(), readonly_, REPO_HEAP_FILE, repo_mode_, REPO_REGISTRY, REPO_XML_FILE, and ACE_OS::strcasecmp(). Referenced by init().
00046 { 00047 ACE_Arg_Shifter shifter (argc, argv); 00048 00049 while (shifter.is_anything_left ()) 00050 { 00051 if (ACE_OS::strcasecmp (shifter.get_current (), 00052 ACE_TEXT ("-c")) == 0) 00053 { 00054 shifter.consume_arg (); 00055 00056 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00057 { 00058 ACE_ERROR ((LM_ERROR, "Error: -c option needs a command\n")); 00059 this->print_usage (); 00060 return -1; 00061 } 00062 00063 if (ACE_OS::strcasecmp (shifter.get_current (), 00064 ACE_TEXT ("install")) == 0) 00065 { 00066 this->service_command_ = SC_INSTALL; 00067 } 00068 else if (ACE_OS::strcasecmp (shifter.get_current (), 00069 ACE_TEXT ("remove")) == 0) 00070 { 00071 this->service_command_ = SC_REMOVE; 00072 } 00073 else 00074 { 00075 ACE_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current())); 00076 this->print_usage (); 00077 return -1; 00078 } 00079 } 00080 else if (ACE_OS::strcasecmp (shifter.get_current (), 00081 ACE_TEXT ("-d")) == 0) 00082 { 00083 shifter.consume_arg (); 00084 00085 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00086 { 00087 ACE_ERROR ((LM_ERROR, "Error: -d option needs a debuglevel\n")); 00088 this->print_usage (); 00089 return -1; 00090 } 00091 00092 this->debug_ = ACE_OS::atoi (shifter.get_current ()); 00093 } 00094 else if (ACE_OS::strcasecmp (shifter.get_current (), 00095 ACE_TEXT ("-m")) == 0) 00096 { 00097 this->multicast_ = true; 00098 } 00099 else if (ACE_OS::strcasecmp (shifter.get_current (), 00100 ACE_TEXT ("-o")) == 0) 00101 { 00102 shifter.consume_arg (); 00103 00104 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00105 { 00106 ACE_ERROR ((LM_ERROR, "Error: -o option needs a filename\n")); 00107 this->print_usage (); 00108 return -1; 00109 } 00110 this->ior_output_file_ = shifter.get_current(); 00111 } 00112 else if (ACE_OS::strcasecmp (shifter.get_current (), 00113 ACE_TEXT ("-s")) == 0) 00114 { 00115 // Run as a service 00116 this->service_ = true; 00117 } 00118 else if ((ACE_OS::strcasecmp (shifter.get_current (), 00119 ACE_TEXT ("-?")) == 0) 00120 || (ACE_OS::strcasecmp (shifter.get_current (), 00121 ACE_TEXT ("-h")) == 0)) 00122 { 00123 this->print_usage (); 00124 return 1; 00125 } 00126 else if (ACE_OS::strcasecmp (shifter.get_current (), 00127 ACE_TEXT ("-l")) == 0) 00128 { 00129 this->readonly_ = true; 00130 } 00131 else if (ACE_OS::strcasecmp (shifter.get_current (), 00132 ACE_TEXT ("-p")) == 0) 00133 { 00134 shifter.consume_arg (); 00135 00136 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00137 { 00138 ACE_ERROR ((LM_ERROR, "Error: -p option needs a filename\n")); 00139 this->print_usage (); 00140 return -1; 00141 } 00142 00143 this->persist_file_name_ = shifter.get_current (); 00144 this->repo_mode_ = REPO_HEAP_FILE; 00145 } 00146 else if (ACE_OS::strcasecmp (shifter.get_current (), 00147 ACE_TEXT ("-r")) == 0) 00148 { 00149 this->repo_mode_ = REPO_REGISTRY; 00150 } 00151 else if (ACE_OS::strcasecmp (shifter.get_current (), 00152 ACE_TEXT ("-x")) == 0) 00153 { 00154 shifter.consume_arg (); 00155 00156 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00157 { 00158 ACE_ERROR ((LM_ERROR, "Error: -x option needs a filename\n")); 00159 this->print_usage (); 00160 return -1; 00161 } 00162 00163 this->persist_file_name_ = shifter.get_current (); 00164 this->repo_mode_ = REPO_XML_FILE; 00165 } 00166 else if (ACE_OS::strcasecmp (shifter.get_current (), 00167 ACE_TEXT ("-e")) == 0) 00168 { 00169 this->erase_repo_ = true; 00170 } 00171 else if (ACE_OS::strcasecmp (shifter.get_current (), 00172 ACE_TEXT ("-t")) == 0) 00173 { 00174 shifter.consume_arg (); 00175 00176 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00177 { 00178 ACE_ERROR ((LM_ERROR, "Error: -t option needs a value\n")); 00179 this->print_usage (); 00180 return -1; 00181 } 00182 this->startup_timeout_ = 00183 ACE_Time_Value (ACE_OS::atoi (shifter.get_current ())); 00184 } 00185 else if (ACE_OS::strcasecmp (shifter.get_current (), 00186 ACE_TEXT ("-v")) == 0) 00187 { 00188 shifter.consume_arg (); 00189 00190 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00191 { 00192 ACE_ERROR ((LM_ERROR, "Error: -v option needs a value\n")); 00193 this->print_usage (); 00194 return -1; 00195 } 00196 this->ping_interval_ = 00197 ACE_Time_Value (0, 1000 * ACE_OS::atoi (shifter.get_current ())); 00198 } 00199 else 00200 { 00201 shifter.ignore_arg (); 00202 continue; 00203 } 00204 00205 shifter.consume_arg (); 00206 } 00207 00208 return 0; 00209 } |
|
File that contains the activator related information that the persistent locator has to save. Definition at line 472 of file Locator_Options.cpp. References persist_file_name_. Referenced by Locator_Repository::init().
00472 { 00473 return this->persist_file_name_; 00474 } |
|
If the server hasn't been verified for a while, then we'll ping it. Note : No timers are currently used. We simply ping() during indirect invocations, if this interval has elapsed. Definition at line 483 of file Locator_Options.cpp.
00484 { 00485 return this->ping_interval_; 00486 } |
|
Print the usage information.
Definition at line 238 of file Locator_Options.cpp. References ACE_ERROR, and LM_ERROR. Referenced by parse_args().
00239 { 00240 ACE_ERROR ((LM_ERROR, 00241 "Usage:\n" 00242 "\n" 00243 "ImR_Locator [-c cmd] [-d 0|1|2] [-m] [-o file]\n" 00244 " [-r|-p file|-x file] [-s] [-t secs] [-v secs]\n" 00245 " -c command Runs nt service commands ('install' or 'remove')\n" 00246 " -d level Sets the debug level (default 1)\n" 00247 " -l Lock the database\n" 00248 " -m Turn on multicast\n" 00249 " -o file Outputs the ImR's IOR to a file\n" 00250 " -p file Use file for storing/loading settings\n" 00251 " -x file Use XML file for storing/loading setting\n" 00252 " -r Use the registry for storing/loading settings\n" 00253 " -t secs Server startup timeout.(Default=60s)\n" 00254 " -v msecs Server verification interval.(Default=10s)\n" 00255 )); 00256 } |
|
Do we allow modifications to the servers?
Definition at line 501 of file Locator_Options.cpp. References readonly_.
00502 { 00503 return this->readonly_; 00504 } |
|
Do we wish to clear out the repository.
Definition at line 495 of file Locator_Options.cpp. References erase_repo_. Referenced by Locator_Repository::init().
00496 { 00497 return this->erase_repo_; 00498 } |
|
Definition at line 489 of file Locator_Options.cpp. References repo_mode_. Referenced by Locator_Repository::init().
00490 { 00491 return this->repo_mode_; 00492 } |
|
Run a service command.
|
|
Definition at line 259 of file Locator_Options.cpp. References ACE_ASSERT, ACE_Time_Value::msec(), multicast_, persist_file_name_, readonly_, repo_mode_, ACE_Time_Value::sec(), SERVICE_REG_PATH, and SERVICE_REG_ROOT. Referenced by run_service_command().
00260 { 00261 #if defined (ACE_WIN32) 00262 HKEY key = 0; 00263 // Create or open the parameters key 00264 LONG err = ACE_TEXT_RegCreateKeyEx (SERVICE_REG_ROOT, 00265 SERVICE_REG_PATH, 00266 0, 00267 "", // class 00268 REG_OPTION_NON_VOLATILE, 00269 KEY_ALL_ACCESS, 00270 NULL, 00271 &key, 00272 NULL 00273 ); 00274 if (err != ERROR_SUCCESS) 00275 { 00276 return -1; 00277 } 00278 err = ACE_TEXT_RegSetValueEx (key, "ORBInitOptions", 0, REG_SZ, 00279 (LPBYTE) this->cmdline_.c_str (), this->cmdline_.length () + 1); 00280 ACE_ASSERT (err == ERROR_SUCCESS); 00281 00282 err = ACE_TEXT_RegSetValueEx (key, "IORFile", 0, REG_SZ, 00283 (LPBYTE) ior_output_file_.c_str (), ior_output_file_.length () + 1); 00284 ACE_ASSERT (err == ERROR_SUCCESS); 00285 00286 err = ACE_TEXT_RegSetValueEx (key, "DebugLevel", 0, REG_DWORD, 00287 (LPBYTE) &debug_ , sizeof (debug_)); 00288 ACE_ASSERT(err == ERROR_SUCCESS); 00289 00290 err = ACE_TEXT_RegSetValueEx (key, "PersistFile", 0, REG_SZ, 00291 (LPBYTE) this->persist_file_name_.c_str (), this->persist_file_name_.length () + 1); 00292 ACE_ASSERT (err == ERROR_SUCCESS); 00293 00294 DWORD tmp = this->ping_interval_.msec (); 00295 err = ACE_TEXT_RegSetValueEx (key, "PingInterval", 0, REG_DWORD, 00296 (LPBYTE) &tmp, sizeof (DWORD)); 00297 ACE_ASSERT (err == ERROR_SUCCESS); 00298 00299 tmp = this->readonly_ ? 1 : 0; 00300 err = ACE_TEXT_RegSetValueEx (key, "Lock", 0, REG_DWORD, 00301 (LPBYTE) &tmp, sizeof (DWORD)); 00302 ACE_ASSERT (err == ERROR_SUCCESS); 00303 00304 tmp = this->repo_mode_; 00305 err = ACE_TEXT_RegSetValueEx (key, "PersistType", 0, REG_DWORD, 00306 (LPBYTE) &tmp, sizeof (DWORD)); 00307 ACE_ASSERT (err == ERROR_SUCCESS); 00308 00309 tmp = this->startup_timeout_.sec(); 00310 err = ACE_TEXT_RegSetValueEx (key, "Timeout", 0, REG_DWORD, 00311 (LPBYTE) &tmp, sizeof (DWORD)); 00312 ACE_ASSERT (err == ERROR_SUCCESS); 00313 00314 tmp = multicast_ ? 1 : 0; 00315 err = ACE_TEXT_RegSetValueEx (key, "Multicast", 0, REG_DWORD, 00316 (LPBYTE) &tmp, sizeof (DWORD)); 00317 ACE_ASSERT (err == ERROR_SUCCESS); 00318 00319 err = ::RegCloseKey (key); 00320 ACE_ASSERT (err == ERROR_SUCCESS); 00321 #endif 00322 return 0; 00323 } |
|
Service Mode.
Definition at line 437 of file Locator_Options.cpp. Referenced by main().
00438 { 00439 return this->service_; 00440 } |
|
The nt service command to run (install/remove).
Definition at line 461 of file Locator_Options.cpp. Referenced by run_service_command().
00462 { 00463 return this->service_command_; 00464 } |
|
Returns the timeout value for program starting.
Definition at line 477 of file Locator_Options.cpp.
00478 { 00479 return this->startup_timeout_; 00480 } |
|
Our extra command line arguments.
Definition at line 141 of file Locator_Options.h. |
|
Debug level.
Definition at line 117 of file Locator_Options.h. |
|
Definition at line 114 of file Locator_Options.h. Referenced by parse_args(), and repository_erase(). |
|
File where the IOR of the server object is stored.
Definition at line 120 of file Locator_Options.h. |
|
Will we listen for multicast location requests?
Definition at line 123 of file Locator_Options.h. Referenced by load_registry_options(), multicast(), parse_args(), and save_registry_options(). |
|
The persistent XML file name.
Definition at line 144 of file Locator_Options.h. Referenced by load_registry_options(), parse_args(), persist_file_name(), and save_registry_options(). |
|
The amount of time between successive "are you started yet?" pings.
Definition at line 129 of file Locator_Options.h. |
|
Can the server_repository be modified?
Definition at line 135 of file Locator_Options.h. Referenced by load_registry_options(), parse_args(), readonly(), and save_registry_options(). |
|
Definition at line 111 of file Locator_Options.h. Referenced by load_registry_options(), parse_args(), repository_mode(), and save_registry_options(). |
|
Are we running as a service?
Definition at line 126 of file Locator_Options.h. |
|
SC_NONE, SC_INSTALL, SC_REMOVE, ...
Definition at line 138 of file Locator_Options.h. |
|
The amount of time to wait for a server to response after starting it.
Definition at line 132 of file Locator_Options.h. |