00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00038 #ifndef OW_EMBEDDEDCIMOMENVIRONMENT_HPP_INCLUDE_GUARD_
00039 #define OW_EMBEDDEDCIMOMENVIRONMENT_HPP_INCLUDE_GUARD_
00040 #define OW_DAEMON_NAME "owcimomd"
00041 #include "OW_config.h"
00042 #include "OW_Types.hpp"
00043 #include "OW_LogLevel.hpp"
00044 #include "OW_ServiceEnvironmentIFC.hpp"
00045 #include "OW_SharedLibrary.hpp"
00046 #include "OW_SortedVectorMap.hpp"
00047 #include "OW_Map.hpp"
00048 #include "OW_Array.hpp"
00049 #include "OW_SharedLibraryReference.hpp"
00050 #include "OW_DateTime.hpp"
00051 #include "OW_Mutex.hpp"
00052 #include "OW_CIMInstance.hpp"
00053 #include "OW_Reference.hpp"
00054 #include "OW_IntrusiveReference.hpp"
00055 #include "OW_ConfigFile.hpp"
00056 #include "OW_HashMap.hpp"
00057 #include "OW_SortedVectorSet.hpp"
00058 #include "OW_CimomCommonFwd.hpp"
00059 #include "OW_CimomServerFwd.hpp"
00060 #include "OW_CIMFwd.hpp"
00061
00062 namespace OW_NAMESPACE
00063 {
00064
00065 class OW_CIMOMCOMMON_API EmbeddedCIMOMEnvironment : public ServiceEnvironmentIFC
00066 {
00067 public:
00068 EmbeddedCIMOMEnvironment();
00069 ~EmbeddedCIMOMEnvironment();
00070 void init();
00071 virtual String getConfigItem(const String &name, const String& defRetVal="") const;
00072 virtual StringArray getMultiConfigItem(const String &itemName,
00073 const StringArray& defRetVal, const char* tokenizeSeparator) const;
00074
00075
00079 CIMOMHandleIFCRef getCIMOMHandle(OperationContext& context,
00080 EBypassProvidersFlag bypassProviders = E_USE_PROVIDERS,
00081 ELockingFlag locking = E_LOCKING) const;
00082
00083 enum ESendIndicationsFlag
00084 {
00085 E_DONT_SEND_INDICATIONS,
00086 E_SEND_INDICATIONS
00087 };
00088
00092 CIMOMHandleIFCRef getCIMOMHandle(OperationContext& context,
00093 ESendIndicationsFlag sendIndications,
00094 EBypassProvidersFlag bypassProviders = E_USE_PROVIDERS,
00095 ELockingFlag locking = E_LOCKING) const;
00096
00100
00101
00105 CIMOMHandleIFCRef getWQLFilterCIMOMHandle(const CIMInstance& inst,
00106 OperationContext& context) const;
00107
00108 virtual WQLIFCRef getWQLRef() const;
00109 virtual LoggerRef getLogger() const OW_DEPRECATED;
00110 virtual LoggerRef getLogger(const String& componentName) const;
00111 IndicationServerRef getIndicationServer() const;
00112 PollingManagerRef getPollingManager() const;
00113 void clearConfigItems();
00114 virtual void setConfigItem(const String &item, const String &value,
00115 EOverwritePreviousFlag overwritePrevious = E_OVERWRITE_PREVIOUS);
00116 void unloadProviders();
00117 void startServices();
00118 void shutdown();
00119 ProviderManagerRef getProviderManager() const;
00120 void unloadReqHandlers();
00121 IndicationRepLayerMediatorRef getIndicationRepLayerMediator() const;
00122 RepositoryIFCRef getRepository() const;
00123 AuthorizerManagerRef getAuthorizerManager() const;
00124
00125
00126
00127 static EmbeddedCIMOMEnvironmentRef& instance();
00128
00129 private:
00130 void _createLogger();
00131 void _loadConfigItemsFromFile(const String& filename);
00132 void _loadRequestHandlers();
00133 void _loadServices();
00134 void _createPollingManager();
00135 void _createIndicationServer();
00136 void _loadAuthorizer();
00137 void _createAuthorizerManager();
00138 void _sortServicesForDependencies();
00139
00140
00141 typedef ConfigFile::ConfigMap ConfigMap;
00142 typedef Reference<ConfigMap> ConfigMapRef;
00143 struct ReqHandlerData : public IntrusiveCountableBase
00144 {
00145 DateTime dt;
00146 RequestHandlerIFCRef rqIFCRef;
00147 String filename;
00148 };
00149 typedef IntrusiveReference<ReqHandlerData> ReqHandlerDataRef;
00150 typedef SortedVectorMap<String, ReqHandlerDataRef> ReqHandlerMap;
00151 mutable Mutex m_monitor;
00152 RepositoryIFCRef m_cimRepository;
00153 RepositoryIFCRef m_cimServer;
00154 AuthorizerIFCRef m_authorizer;
00155
00156 AuthorizerManagerRef m_authorizerManager;
00157
00158
00159 LoggerRef m_Logger;
00160 ConfigMapRef m_configItems;
00161 ProviderManagerRef m_providerManager;
00162 mutable SharedLibraryRef m_wqlLib;
00163 mutable SharedLibraryRef m_indicationRepLayerLib;
00164 PollingManagerRef m_pollingManager;
00165 IndicationServerRef m_indicationServer;
00166 bool m_indicationsDisabled;
00167 Array<SelectableIFCRef> m_selectables;
00168 Array<SelectableCallbackIFCRef> m_selectableCallbacks;
00169 mutable Array<ServiceIFCRef> m_services;
00170 mutable ReqHandlerMap m_reqHandlers;
00171 mutable Mutex m_reqHandlersLock;
00172 mutable Mutex m_indicationLock;
00173 mutable bool m_indicationRepLayerDisabled;
00174 mutable Mutex m_selectableLock;
00175
00176 enum EEnvState
00177 {
00178 E_STATE_INVALID,
00179 E_STATE_INITIALIZING,
00180 E_STATE_INITIALIZED,
00181 E_STATE_STARTING,
00182 E_STATE_STARTED,
00183 E_STATE_SHUTTING_DOWN,
00184 E_STATE_SHUTDOWN,
00185 E_STATE_UNLOADED
00186 };
00187
00188 static bool isLoaded(EEnvState s)
00189 {
00190 return s >= E_STATE_INITIALIZING && s <= E_STATE_SHUTDOWN;
00191 }
00192 static bool isInitialized(EEnvState s)
00193 {
00194 return s >= E_STATE_INITIALIZED && s <= E_STATE_STARTED;
00195 }
00196
00197 EEnvState m_state;
00198 mutable Mutex m_stateGuard;
00199 IndicationRepLayerMediatorRef m_indicationRepLayerMediatorRef;
00200
00201 static String COMPONENT_NAME;
00202 };
00203
00204 }
00205
00206 #endif