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 mike 1.20.6.1 /*
53 BOOKMARK3:
54 */
55 std::cout << "ProviderModule::load[" << providerName << "]" << std::endl;
56
|
57 chip 1.1 // 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.19 CIMProvider * (*createProvider)(const String&) =
|
70 kumpf 1.17 (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 kumpf 1.17 CIMProvider* provider = createProvider(providerName);
|
85 chip 1.3
|
86 chip 1.1 // test for the appropriate interface
|
87 kumpf 1.17 if (dynamic_cast<CIMProvider *>(provider) == 0)
|
88 chip 1.1 {
|
89 kumpf 1.18 _library.unload();
|
90 kumpf 1.13 throw Exception(MessageLoaderParms(
91 "ProviderManager.ProviderModule.PROVIDER_IS_NOT_A",
|
92 chip 1.3 "ProviderLoadFailure ($0:$1):provider is not a CIMProvider.",
|
93 kumpf 1.17 _library.getFileName(),
|
94 chip 1.3 providerName));
|
95 chip 1.1 }
|
96 kumpf 1.17
|
97 kumpf 1.19 return provider;
|
98 chip 1.1 }
99
|
100 kumpf 1.13 void ProviderModule::unloadModule()
|
101 chip 1.1 {
|
102 kumpf 1.18 _library.unload();
|
103 chip 1.1 }
104
105 PEGASUS_NAMESPACE_END
|