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 // Author: Chip Vincent (cvincent@us.ibm.com)
33 //
34 // Modified By:
|
35 kumpf 1.13 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
36 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
37 // Mike Day, IBM (mdday@us.ibm.com)
38 // Adrian Schuur, IBM (schuur@de.ibm.com)
|
39 joyce.j 1.10 // Josephine Eskaline Joyce (jojustin@in.ibm.com) for PEP#101
|
40 kumpf 1.13 // Sean Keenan, Hewlett-Packard Company <sean.keenan@hp.com>
41 // Roger Kumpf, Hewlett-Packard Company <roger_kumpf@hp.com>
|
42 aruran.ms 1.15 // Aruran, IBM (ashanmug@in.ibm.com) for Bug#4585
|
43 chip 1.1 //
44 //%/////////////////////////////////////////////////////////////////////////////
45
46 #include "ProviderModule.h"
47
48 #include <Pegasus/Common/FileSystem.h>
|
49 kumpf 1.13 #include <Pegasus/Common/MessageLoader.h>
|
50 chip 1.3
51 #ifdef PEGASUS_OS_OS400
|
52 kumpf 1.13 # include "CreateProviderOS400SystemState.h"
|
53 chip 1.3 #endif
|
54 chip 1.1
|
55 kumpf 1.13
|
56 chip 1.1 PEGASUS_NAMESPACE_BEGIN
57
|
58 kumpf 1.13 ProviderModule::ProviderModule(const String& fileName)
|
59 kumpf 1.17 : _refCount(0),
60 _library(fileName)
|
61 chip 1.1 {
62 }
63
|
64 kumpf 1.13 ProviderModule::~ProviderModule()
|
65 chip 1.1 {
66 }
67
|
68 kumpf 1.13 CIMProvider* ProviderModule::load(const String& providerName)
|
69 chip 1.1 {
70 // dynamically load the provider library
|
71 kumpf 1.17 if (!_library.isLoaded())
|
72 chip 1.1 {
|
73 kumpf 1.17 if (!_library.load())
|
74 kumpf 1.13 {
75 throw Exception(MessageLoaderParms(
76 "ProviderManager.ProviderModule.CANNOT_LOAD_LIBRARY",
77 "ProviderLoadFailure ($0:$1):Cannot load library, error: $2",
|
78 kumpf 1.17 _library.getFileName(),
|
79 kumpf 1.13 providerName,
|
80 kumpf 1.17 _library.getLoadErrorMessage()));
|
81 kumpf 1.13 }
|
82 chip 1.1 }
83
|
84 kumpf 1.13 // find library entry point
|
85 kumpf 1.17 CIMProvider * (*createProvider)(const String &) =
86 (CIMProvider* (*)(const String&))
87 _library.getSymbol("PegasusCreateProvider");
|
88 chip 1.1
|
89 kumpf 1.13 if (createProvider == 0)
|
90 chip 1.1 {
|
91 kumpf 1.13 throw Exception(MessageLoaderParms(
92 "ProviderManager.ProviderModule.ENTRY_POINT_NOT_FOUND",
|
93 chip 1.3 "ProviderLoadFailure ($0:$1):entry point not found.",
|
94 kumpf 1.17 _library.getFileName(),
|
95 chip 1.1 providerName));
96 }
97
98 // invoke the provider entry point
|
99 chip 1.3 #ifndef PEGASUS_OS_OS400
|
100 kumpf 1.17 CIMProvider* provider = createProvider(providerName);
|
101 chip 1.3 #else
102 // On OS/400, need to call a layer of code that does platform-specific
103 // checks before calling the provider
|
104 kumpf 1.17 CIMProvider* provider = OS400_CreateProvider(
|
105 kumpf 1.13 providerName.getCString(), createProvider, _fileName);
|
106 chip 1.3 #endif
107
|
108 chip 1.1 // test for the appropriate interface
|
109 kumpf 1.17 if (dynamic_cast<CIMProvider *>(provider) == 0)
|
110 chip 1.1 {
|
111 kumpf 1.13 throw Exception(MessageLoaderParms(
112 "ProviderManager.ProviderModule.PROVIDER_IS_NOT_A",
|
113 chip 1.3 "ProviderLoadFailure ($0:$1):provider is not a CIMProvider.",
|
114 kumpf 1.17 _library.getFileName(),
|
115 chip 1.3 providerName));
|
116 chip 1.1 }
|
117 kumpf 1.17
|
118 kumpf 1.13 _refCount++;
|
119 kumpf 1.17
|
120 chip 1.1 return(provider);
121 }
122
|
123 kumpf 1.13 void ProviderModule::unloadModule()
|
124 chip 1.1 {
|
125 mike 1.14 if (_refCount.decAndTestIfZero())
|
126 chip 1.1 {
|
127 kumpf 1.17 if (_library.isLoaded())
|
128 david.dillard 1.8 {
|
129 kumpf 1.17 _library.unload();
|
130 david.dillard 1.8 }
|
131 chip 1.1 }
132 }
133
134 PEGASUS_NAMESPACE_END
|