1 karl 1.3 //%2005////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.2 // 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 // IBM Corp.; EMC Corporation, The Open Group.
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.3 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 schuur 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
|
18 karl 1.2 //
|
19 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
25 karl 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
26 schuur 1.1 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Chip Vincent (cvincent@us.ibm.com)
31 //
32 // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
33 // Mike Day, IBM (mdday@us.ibm.com)
34 // Adrian Schuur, schuur@de.ibm.com
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
38 #ifndef Pegasus_JMPIProvider_h
39 #define Pegasus_JMPIProvider_h
40
41 #include "JMPIImpl.h"
42 #include <Pegasus/Common/Config.h>
43 #include <Pegasus/Common/IPC.h>
44 #include <Pegasus/Provider/CIMOMHandle.h>
45 #include <Pegasus/Provider/CIMInstanceProvider.h>
46 #include <Pegasus/Provider/CIMAssociationProvider.h>
47 schuur 1.1 #include <Pegasus/Provider/CIMMethodProvider.h>
48
49 //#include <Pegasus/ProviderManager2/CMPI/CMPIResolverModule.h>
50
51 #include <Pegasus/Server/Linkage.h>
52
53 PEGASUS_NAMESPACE_BEGIN
54
55 class JMPIProviderModule;
56 class CMPIResolverModule;
57
58 struct ProviderVector {
59 jclass jProviderClass;
60 jobject jProvider;
61 };
62
63 // The JMPIProvider class represents the logical provider extracted from a
64 // provider module. It is wrapped in a facade to stabalize the interface
65 // and is directly tied to a module.
66
67 class PEGASUS_SERVER_LINKAGE JMPIProvider :
68 schuur 1.1 public virtual CIMProvider
69 {
70 public:
71
72 enum Status
73 {
74 UNKNOWN,
75 INITIALIZING,
76 INITIALIZED,
77 TERMINATING,
78 TERMINATED
79 };
80
81 public:
82
83
84 class pm_service_op_lock {
85 private:
86 pm_service_op_lock(void);
87 public:
88 pm_service_op_lock(JMPIProvider *provider) : _provider(provider)
89 schuur 1.1 { _provider->protect(); }
90 ~pm_service_op_lock(void)
91 { _provider->unprotect(); }
92 JMPIProvider * _provider;
93 };
94
95 // typedef JMPIProviderFacade Base;
96
97 JMPIProvider(const String & name,
98 JMPIProviderModule *module,
99 ProviderVector *mv);
100 JMPIProvider(JMPIProvider*);
101
102 virtual ~JMPIProvider(void);
103
104 virtual void initialize(CIMOMHandle & cimom);
105
106 virtual Boolean tryTerminate(void);
107 virtual void terminate(void);
108 virtual void _terminate(void);
109
110 schuur 1.1 Status getStatus(void) const;
111 String getName(void) const;
112 void setResolver(CMPIResolverModule *rm) { _rm=rm; }
113
114 JMPIProviderModule *getModule(void) const;
115
116 // << Mon Oct 14 15:42:24 2002 mdd >> for use with DQueue template
117 // to allow conversion from using Array<>
118 Boolean operator == (const void *key) const;
119 Boolean operator == (const JMPIProvider & prov) const;
120
121 // virtual void get_idle_timer(struct timeval *);
122 // virtual void update_idle_timer(void);
123 // virtual Boolean pending_operation(void);
124 // virtual Boolean unload_ok(void);
125
126 // force provider manager to keep in memory
127 virtual void protect(void);
128 // allow provider manager to unload when idle
129 virtual void unprotect(void);
130
|
131 carolann.graves 1.4 /**
132 Increments the count of current subscriptions for this provider, and
133 determines if there were no current subscriptions before the increment.
134 If there were no current subscriptions before the increment, the first
135 subscription has been created, and the provider's enableIndications
136 method should be called.
137
138 @return True, if before the increment there were no current
139 subscriptions for this provider;
140 False, otherwise
141 */
142 Boolean testIfZeroAndIncrementSubscriptions ();
143
144 /**
145 Decrements the count of current subscriptions for this provider, and
146 determines if there are no current subscriptions after the decrement.
147 If there are no current subscriptions after the decrement, the last
148 subscription has been deleted, and the provider's disableIndications
149 method should be called.
150
151 @return True, if after the decrement there are no current subscriptions
152 carolann.graves 1.4 for this provider;
153 False, otherwise
154 */
155 Boolean decrementSubscriptionsAndTestIfZero ();
156
157 /**
158 Determines if there are current subscriptions for this provider.
159
160 @return True, if there is at least one current subscription
161 for this provider;
162 False, otherwise
163 */
164 Boolean testSubscriptions ();
165
166 /**
167 Resets the count of current subscriptions for the indication provider.
168 */
169 void resetSubscriptions ();
170
171 /**
172 Sets the provider instance for the provider.
173 carolann.graves 1.4
174 Note: the provider instance is set only for an indication provider, and
175 is set when a Create Subscription request is processed for the provider.
176
177 @param instance the Provider CIMInstance for the provider
178 */
179 void setProviderInstance (const CIMInstance & instance);
180
181 /**
182 Gets the provider instance for the provider.
183
184 Note: the provider instance is set only for an indication provider, and
185 only if a Create Subscription request has been processed for the
186 provider.
187
188 @return the Provider CIMInstance for the provider
189 */
190 CIMInstance getProviderInstance ();
191
|
192 schuur 1.1 protected:
193 Status _status;
194 JMPIProviderModule *_module;
195 ProviderVector miVector;
196 Boolean noUnload;
197 CIMClass *cachedClass;
198
199 private:
200 friend class JMPILocalProviderManager;
201 friend class JMPIProviderManager;
202 friend class ProviderManagerService;
203 // friend class OpProviderHolder;
204 CIMOMHandle *_cimom_handle;
205 void *jProviderClass,*jProvider;
206 String _name;
207 AtomicInt _no_unload;
208 CMPIResolverModule *_rm;
209 Uint32 _quantum;
210 AtomicInt _current_operations;
|
211 carolann.graves 1.4
212 /**
213 Count of current subscriptions for this provider. Access to this
214 data member is controlled by the _currentSubscriptionsLock.
215 */
216 Uint32 _currentSubscriptions;
217
218 /**
219 A mutex to control access to the _currentSubscriptions member variable.
220 Before any access (test, increment, decrement or reset) of the
221 _currentSubscriptions member variable, the _currentSubscriptionsMutex is
222 first locked.
223 */
224 Mutex _currentSubscriptionsMutex;
225
226 /**
227 The Provider CIMInstance for the provider.
228 The Provider CIMInstance is set only for indication providers, and only
229 if a Create Subscription request has been processed for the provider.
230 The Provider CIMInstance is needed in order to construct the
231 EnableIndicationsResponseHandler to send to the indication provider
232 carolann.graves 1.4 when the provider's enableIndications() method is called.
233 The Provider CIMInstance is needed in the
234 EnableIndicationsResponseHandler in order to construct the Process
235 Indication request when an indication is delivered by the provider.
236 The Provider CIMInstance is needed in the Process Indication request
237 to enable the Indication Service to determine if the provider that
238 generated the indication accepted a matching subscription.
239 */
240 CIMInstance _providerInstance;
|
241 schuur 1.1 //};
242
243
244 //
245 // Used to encapsulate the incrementing/decrementing of the _current_operations
246 // for a JMPIProvider so it won't be unloaded during operations.
247 //
248
249 class OpProviderHolder
250 {
251 private:
252 JMPIProvider* _provider;
253
254 public:
255 OpProviderHolder(): _provider( NULL )
256 {
257 }
258 OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
259 {
260 SetProvider( p._provider );
261 }
262 schuur 1.1 OpProviderHolder( JMPIProvider* p ): _provider( NULL )
263 {
264 SetProvider( p );
265 }
266 ~OpProviderHolder()
267 {
268 UnSetProvider();
269 }
270 JMPIProvider& GetProvider()
271 {
272 return(*_provider);
273 }
274
275 OpProviderHolder& operator=( const OpProviderHolder& x )
276 {
277 if(this == &x)
278 return(*this);
279 SetProvider( x._provider );
280
281 return(*this);
282 }
283 schuur 1.1
284 void SetProvider( JMPIProvider* p )
285 {
286 UnSetProvider();
287 if(p)
288 {
289 _provider = p;
290 _provider->_current_operations++;
291 }
292 }
293
294 void UnSetProvider()
295 {
296 if(_provider)
297 {
298 _provider->_current_operations--;
299 _provider = NULL;
300 }
301 }
302 };
303 };
304 schuur 1.1
305 PEGASUS_NAMESPACE_END
306
307 #endif
|