OW_CIMOMEnvironment.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00036 #ifndef OW_CIMOMENVIRONMENT_HPP_INCLUDE_GUARD_
00037 #define OW_CIMOMENVIRONMENT_HPP_INCLUDE_GUARD_
00038 #define OW_DAEMON_NAME "owcimomd"
00039 #include "OW_config.h"
00040 #include "OW_Types.hpp"
00041 #include "OW_LogLevel.hpp"
00042 #include "OW_ServiceEnvironmentIFC.hpp"
00043 #include "OW_SharedLibrary.hpp"
00044 #include "OW_SortedVectorMap.hpp"
00045 #include "OW_Map.hpp"
00046 #include "OW_Array.hpp"
00047 #include "OW_SharedLibraryReference.hpp"
00048 #include "OW_DateTime.hpp"
00049 #include "OW_Mutex.hpp"
00050 #include "OW_CIMInstance.hpp"
00051 #include "OW_Reference.hpp"
00052 #include "OW_IntrusiveReference.hpp"
00053 #include "OW_ConfigFile.hpp"
00054 #include "OW_HashMap.hpp"
00055 #include "OW_SortedVectorSet.hpp"
00056 #include "OW_CimomCommonFwd.hpp"
00057 #include "OW_CimomServerFwd.hpp"
00058 #include "OW_CIMFwd.hpp"
00059 
00060 namespace OW_NAMESPACE
00061 {
00062 
00063 class OW_CIMOMCOMMON_API CIMOMEnvironment : public ServiceEnvironmentIFC
00064 {
00065 public:
00066    CIMOMEnvironment();
00067    ~CIMOMEnvironment();
00068    void init();
00069    virtual bool authenticate(String &userName, const String &info,
00070       String &details, OperationContext& context) const;
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    // from ServiceEnvironmentIFC
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    //virtual CIMOMHandleIFCRef getRepositoryCIMOMHandle(OperationContext& context) const;
00101 
00105    CIMOMHandleIFCRef getWQLFilterCIMOMHandle(const CIMInstance& inst,
00106       OperationContext& context) const;
00107 
00108    virtual WQLIFCRef getWQLRef() const;
00109    virtual RequestHandlerIFCRef getRequestHandler(const String &id) const;
00110    virtual LoggerRef getLogger() const OW_DEPRECATED;
00111    virtual LoggerRef getLogger(const String& componentName) const;
00112    IndicationServerRef getIndicationServer() const;
00113    PollingManagerRef getPollingManager() const;
00114    void clearConfigItems();
00115    virtual void setConfigItem(const String &item, const String &value,
00116       EOverwritePreviousFlag overwritePrevious = E_OVERWRITE_PREVIOUS);
00117    virtual void addSelectable(const SelectableIFCRef& obj,
00118       const SelectableCallbackIFCRef& cb);
00119    virtual void removeSelectable(const SelectableIFCRef& obj);
00120    void unloadProviders();
00121    void startServices();
00122    void shutdown();
00123    ProviderManagerRef getProviderManager() const;
00124    void runSelectEngine() const;
00125    void exportIndication(const CIMInstance& instance,
00126       const String& instNS);
00127    void unloadReqHandlers();
00128    IndicationRepLayerMediatorRef getIndicationRepLayerMediator() const;
00129    RepositoryIFCRef getRepository() const;
00130    AuthorizerManagerRef getAuthorizerManager() const;
00131 
00132 
00133    // do not use this unless absolutely necessary!
00134    static CIMOMEnvironmentRef& instance();
00135 
00136 private:
00137    void _createLogger();
00138    void _loadConfigItemsFromFile(const String& filename);
00139    void _loadRequestHandlers();
00140    void _loadServices();
00141    void _createAuthManager();
00142    void _createPollingManager();
00143    void _createIndicationServer();
00144    SharedLibraryRepositoryIFCRef _getIndicationRepLayer(const RepositoryIFCRef& rref) const;
00145    void _clearSelectables();
00146    void _loadAuthorizer();
00147    void _createAuthorizerManager();
00148    void _sortServicesForDependencies();
00149 
00150    // Types
00151    typedef ConfigFile::ConfigMap ConfigMap;
00152    typedef Reference<ConfigMap> ConfigMapRef;
00153    struct ReqHandlerData : public IntrusiveCountableBase
00154    {
00155       DateTime dt;
00156       RequestHandlerIFCRef rqIFCRef;
00157       String filename;
00158    };
00159    typedef IntrusiveReference<ReqHandlerData> ReqHandlerDataRef;
00160    typedef SortedVectorMap<String, ReqHandlerDataRef> ReqHandlerMap;
00161    mutable Mutex m_monitor;
00162    RepositoryIFCRef m_cimRepository;
00163    RepositoryIFCRef m_cimServer;
00164    AuthorizerIFCRef m_authorizer;
00165 
00166    AuthorizerManagerRef m_authorizerManager;
00167    //AuthorizerIFCRef m_authorizer;
00168 
00169    AuthManagerRef m_authManager;
00170    LoggerRef m_Logger;
00171    ConfigMapRef m_configItems;
00172    ProviderManagerRef m_providerManager;
00173    mutable SharedLibraryRef m_wqlLib;
00174    mutable SharedLibraryRef m_indicationRepLayerLib;
00175    PollingManagerRef m_pollingManager;
00176    IndicationServerRef m_indicationServer;
00177    bool m_indicationsDisabled;
00178    Array<SelectableIFCRef> m_selectables;
00179    Array<SelectableCallbackIFCRef> m_selectableCallbacks;
00180    mutable Array<ServiceIFCRef> m_services;
00181    mutable ReqHandlerMap m_reqHandlers;
00182    mutable Mutex m_reqHandlersLock;
00183    mutable Mutex m_indicationLock;
00184    mutable bool m_indicationRepLayerDisabled;
00185    mutable Mutex m_selectableLock;
00186    
00187    enum EEnvState
00188    {
00189       E_STATE_INVALID,
00190       E_STATE_INITIALIZING,
00191       E_STATE_INITIALIZED,
00192       E_STATE_STARTING,
00193       E_STATE_STARTED,
00194       E_STATE_SHUTTING_DOWN,
00195       E_STATE_SHUTDOWN,
00196       E_STATE_UNLOADED
00197    };
00198 
00199    static bool isLoaded(EEnvState s)
00200    {
00201       return s >= E_STATE_INITIALIZING && s <= E_STATE_SHUTDOWN;
00202    }
00203    static bool isInitialized(EEnvState s)
00204    {
00205       return s >= E_STATE_INITIALIZED && s <= E_STATE_STARTED;
00206    }
00207 
00208    EEnvState m_state;
00209    mutable Mutex m_stateGuard;
00210    IndicationRepLayerMediatorRef m_indicationRepLayerMediatorRef;
00211 
00212    static String COMPONENT_NAME;
00213 };
00214 
00215 } // end namespace OW_NAMESPACE
00216 
00217 #endif

Generated on Thu Feb 9 08:47:53 2006 for openwbem by  doxygen 1.4.6