(file) Return to ProviderModule.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / Default

  1 karl  1.16 //%2006////////////////////////////////////////////////////////////////////////
  2 chip  1.1  //
  3 karl  1.7  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.4  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.7  // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.11 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.16 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 chip  1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15            // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18            // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20 karl  1.4  // 
 21 chip  1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            #include "ProviderModule.h"
 35            
 36            #include <Pegasus/Common/FileSystem.h>
 37 kumpf 1.13 #include <Pegasus/Common/MessageLoader.h>
 38 chip  1.3  
 39            #ifdef PEGASUS_OS_OS400
 40 kumpf 1.13 # include "CreateProviderOS400SystemState.h"
 41 chip  1.3  #endif
 42 chip  1.1  
 43 kumpf 1.13 
 44 chip  1.1  PEGASUS_NAMESPACE_BEGIN
 45            
 46 kumpf 1.13 ProviderModule::ProviderModule(const String& fileName)
 47 kumpf 1.18     : _library(fileName)
 48 chip  1.1  {
 49            }
 50            
 51 kumpf 1.13 ProviderModule::~ProviderModule()
 52 chip  1.1  {
 53            }
 54            
 55 kumpf 1.13 CIMProvider* ProviderModule::load(const String& providerName)
 56 chip  1.1  {
 57                // dynamically load the provider library
 58 kumpf 1.18     if (!_library.load())
 59 chip  1.1      {
 60 kumpf 1.18         throw Exception(MessageLoaderParms(
 61                        "ProviderManager.ProviderModule.CANNOT_LOAD_LIBRARY",
 62                        "ProviderLoadFailure ($0:$1):Cannot load library, error: $2",
 63                        _library.getFileName(),
 64                        providerName,
 65                        _library.getLoadErrorMessage()));
 66 chip  1.1      }
 67            
 68 kumpf 1.13     // find library entry point
 69 kumpf 1.17     CIMProvider * (*createProvider)(const String &) =
 70                    (CIMProvider* (*)(const String&))
 71                        _library.getSymbol("PegasusCreateProvider");
 72 chip  1.1  
 73 kumpf 1.13     if (createProvider == 0)
 74 chip  1.1      {
 75 kumpf 1.18         _library.unload();
 76 kumpf 1.13         throw Exception(MessageLoaderParms(
 77                        "ProviderManager.ProviderModule.ENTRY_POINT_NOT_FOUND",
 78 chip  1.3              "ProviderLoadFailure ($0:$1):entry point not found.",
 79 kumpf 1.17             _library.getFileName(),
 80 chip  1.1              providerName));
 81                }
 82            
 83                // invoke the provider entry point
 84 chip  1.3  #ifndef PEGASUS_OS_OS400
 85 kumpf 1.17     CIMProvider* provider = createProvider(providerName);
 86 chip  1.3  #else
 87                // On OS/400, need to call a layer of code that does platform-specific
 88                // checks before calling the provider
 89 kumpf 1.17     CIMProvider* provider = OS400_CreateProvider(
 90 kumpf 1.13         providerName.getCString(), createProvider, _fileName);
 91 chip  1.3  #endif
 92            
 93 chip  1.1      // test for the appropriate interface
 94 kumpf 1.17     if (dynamic_cast<CIMProvider *>(provider) == 0)
 95 chip  1.1      {
 96 kumpf 1.18         _library.unload();
 97 kumpf 1.13         throw Exception(MessageLoaderParms(
 98                        "ProviderManager.ProviderModule.PROVIDER_IS_NOT_A",
 99 chip  1.3              "ProviderLoadFailure ($0:$1):provider is not a CIMProvider.",
100 kumpf 1.17             _library.getFileName(),
101 chip  1.3              providerName));
102 chip  1.1      }
103 kumpf 1.17 
104 chip  1.1      return(provider);
105            }
106            
107 kumpf 1.13 void ProviderModule::unloadModule()
108 chip  1.1  {
109 kumpf 1.18     _library.unload();
110 chip  1.1  }
111            
112            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2