(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 chip  1.1  PEGASUS_NAMESPACE_BEGIN
 40            
 41 kumpf 1.13 ProviderModule::ProviderModule(const String& fileName)
 42 kumpf 1.18     : _library(fileName)
 43 chip  1.1  {
 44            }
 45            
 46 kumpf 1.13 ProviderModule::~ProviderModule()
 47 chip  1.1  {
 48            }
 49            
 50 kumpf 1.13 CIMProvider* ProviderModule::load(const String& providerName)
 51 chip  1.1  {
 52                // dynamically load the provider library
 53 kumpf 1.18     if (!_library.load())
 54 chip  1.1      {
 55 kumpf 1.18         throw Exception(MessageLoaderParms(
 56                        "ProviderManager.ProviderModule.CANNOT_LOAD_LIBRARY",
 57                        "ProviderLoadFailure ($0:$1):Cannot load library, error: $2",
 58                        _library.getFileName(),
 59                        providerName,
 60                        _library.getLoadErrorMessage()));
 61 chip  1.1      }
 62            
 63 kumpf 1.13     // find library entry point
 64 kumpf 1.19     CIMProvider * (*createProvider)(const String&) =
 65 kumpf 1.17         (CIMProvider* (*)(const String&))
 66                        _library.getSymbol("PegasusCreateProvider");
 67 chip  1.1  
 68 kumpf 1.13     if (createProvider == 0)
 69 chip  1.1      {
 70 kumpf 1.18         _library.unload();
 71 kumpf 1.13         throw Exception(MessageLoaderParms(
 72                        "ProviderManager.ProviderModule.ENTRY_POINT_NOT_FOUND",
 73 chip  1.3              "ProviderLoadFailure ($0:$1):entry point not found.",
 74 kumpf 1.17             _library.getFileName(),
 75 chip  1.1              providerName));
 76                }
 77            
 78                // invoke the provider entry point
 79 kumpf 1.17     CIMProvider* provider = createProvider(providerName);
 80 chip  1.3  
 81 chip  1.1      // test for the appropriate interface
 82 kumpf 1.17     if (dynamic_cast<CIMProvider *>(provider) == 0)
 83 chip  1.1      {
 84 kumpf 1.18         _library.unload();
 85 kumpf 1.13         throw Exception(MessageLoaderParms(
 86                        "ProviderManager.ProviderModule.PROVIDER_IS_NOT_A",
 87 chip  1.3              "ProviderLoadFailure ($0:$1):provider is not a CIMProvider.",
 88 kumpf 1.17             _library.getFileName(),
 89 chip  1.3              providerName));
 90 chip  1.1      }
 91 kumpf 1.17 
 92 kumpf 1.19     return provider;
 93 chip  1.1  }
 94            
 95 kumpf 1.13 void ProviderModule::unloadModule()
 96 chip  1.1  {
 97 kumpf 1.18     _library.unload();
 98 chip  1.1  }
 99            
100            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2