Environment.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ENVIRONMENT_H
00018 #define ENVIRONMENT_H
00019
00020 #include <axutil_platform_auto_sense.h>
00021 #include <WSFDefines.h>
00022 #include <axutil_env.h>
00023 #include <string>
00024 #include <map>
00025
00034 namespace wso2wsf
00035 {
00045 class TLSKey
00046 {
00047 private:
00048 #ifdef WIN32
00049 DWORD tls_key;
00050 #else
00051 pthread_key_t tls_key;
00052 #endif
00053 public:
00057 TLSKey()
00058 {
00059 #ifdef WIN32
00060 if ((tls_key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
00061 ExitProcess(0);
00062 #else
00063 pthread_key_create(&tls_key, NULL);
00064 #endif
00065 }
00069 #ifdef WIN32
00070 DWORD getTLSKey()
00071 #else
00072 pthread_key_t getTLSKey()
00073 #endif
00074 {
00075 return tls_key;
00076 }
00080 ~TLSKey()
00081 {
00082 #ifdef WIN32
00083 TlsFree(tls_key);
00084 #else
00085 pthread_key_delete(tls_key);
00086 #endif
00087 }
00088 };
00089
00097 class Environment
00098 {
00099
00100 private:
00104 static TLSKey key;
00105 public:
00109 static std::string _logFileName;
00113 static axutil_log_levels_t _logLevel;
00117 Environment();
00122 static WSF_EXTERN void WSF_CALL setEnv(const axutil_env_t *env);
00126 static WSF_EXTERN const axutil_env_t* WSF_CALL getEnv();
00130 static WSF_EXTERN void WSF_CALL removeEnv();
00134 static WSF_EXTERN void WSF_CALL switchToGlobalPool();
00138 static WSF_EXTERN void WSF_CALL switchToLocalPool();
00151 static WSF_EXTERN void WSF_CALL initialize(std::string logFileName, axutil_log_levels_t logLevel);
00155 WSF_CALL ~Environment();
00156 };
00158 }
00159
00160 #endif // ENVIRONMENT_H