00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _CORBACONTEXT_H_
00035 #define _CORBACONTEXT_H_
00036
00037
00038
00039
00040 #include <string>
00041
00042
00043 #include <ace/Reactor.h>
00044
00045 #include <chrono.h>
00046 #include <configuration.h>
00047 #include <dbsession.h>
00048 #include <filelocklog.h>
00049 #include <osbmsgcat.h>
00050
00051
00052 namespace OSB_DB {
00053 class Session;
00054 }
00055
00056 #define VERSION_STR "OSB Administration Server 4.01"
00057 #define COMPILED_STR "\n(" SYSTEM ", " ORACLE_VERSION ")\n" \
00058 "Compiled " __DATE__ " on " HOSTNAME "\n"
00059
00060
00061
00062
00063 namespace OSB_CORBA {
00064
00075 class CorbaContext
00076 {
00077 public:
00079 CorbaContext()
00080 : sessionCtrl_(true),
00081 msgCatInit_(true),
00082 logger_(4)
00083 {
00084 OSB_LIB::Log::setInstance(&logger_);
00085 }
00086
00088
00089
00090 OSB_DB::SessionCtrl sessionCtrl_;
00092 OSB_LIB::MsgCat::Init msgCatInit_;
00094
00103 void initialise(OSB_DB::Session& session);
00104
00106
00107
00108 OSB_APP::FileLockLog logger_;
00110 bool openLog(
00111 const std::string& app,
00112 const std::string& dir
00113 );
00121 std::string logPath() const;
00123 void closeLog();
00125
00133 struct Config {
00135 Config() : hostExist(false),
00136 hostName("localhost"),
00137 portNo("0"),
00138 logDir(".") {}
00139
00141 bool hostExist;
00142
00144 std::string hostName;
00145 std::string portNo;
00146
00148 std::string logDir;
00149 };
00150
00152 Config config;
00153
00155 const Config configDefaults;
00156
00163 struct Option {
00165 Option()
00166 : debugLevel(2), verbose(false) {}
00168 int debugLevel;
00170 bool verbose;
00171 };
00172
00174 Option option;
00175
00177 std::string appName_;
00179 OSB_LIB::ModuleId module_;
00180
00182 void checkNlsLang();
00183
00185 int handleArgs(int argc, char** argv);
00186
00192 void printHeader(const std::string& tag);
00193
00195 void printTrailer();
00196
00198 void printUsage();
00199
00201 void printNamingServiceInfo();
00202 private:
00212 long readConfig(OSB_DB::Session& session, std::ostream& strm);
00213 };
00214
00215
00216
00217 class SignalHandler : public ACE_Event_Handler {
00218 public:
00219 SignalHandler(CorbaContext::Option& option);
00220
00221 private:
00222 int handle_signal(int signum, siginfo_t*, ucontext_t*);
00223
00224 private:
00225 CorbaContext::Option& option_;
00226 };
00227 }
00228
00229
00230 namespace {
00231
00232 template <typename T1, typename T2>
00233 void handleRcSwitch(
00234 OSB_LIB::ModuleConfig::RetConvert rc,
00235 T1* cfg,
00236 T1 min,
00237 const T2& dft,
00238 std::ostream& strm
00239 )
00240 {
00241 switch (rc) {
00242 case OSB_LIB::ModuleConfig::rcNotFound:
00243 strm << "Warning: Not configured, using default of "
00244 << dft;
00245 break;
00246
00247 case OSB_LIB::ModuleConfig::rcTypeMismatch:
00248 strm << "Warning: Type mismatch, using default of "
00249 << dft;
00250 break;
00251
00252 case OSB_LIB::ModuleConfig::rcErrConvert:
00253 strm << "Warning: Error on convert, using default of "
00254 << dft;
00255 break;
00256
00257 case OSB_LIB::ModuleConfig::rcSuccess:
00258 if (*cfg < min) {
00259 *cfg = dft;
00260 strm << "Warning: Value must be at least "
00261 << min << ", using default of "
00262 << dft;
00263 }
00264 else {
00265 strm << *cfg;
00266 }
00267 break;
00268 }
00269 }
00270 }
00271 #endif // #ifndef _CORBACONTEXT_H_