1 karl 1.7 //%2006////////////////////////////////////////////////////////////////////////
|
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 karl 1.7 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 schuur 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 mark.hamzy 1.8 //
|
21 schuur 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 karl 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
28 schuur 1.1 // 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: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
35 // Mike Day, IBM (mdday@us.ibm.com)
36 // Adrian Schuur, schuur@de.ibm.com
37 //
38 //%/////////////////////////////////////////////////////////////////////////////
39
40 #ifndef Pegasus_JMPIProvider_h
41 #define Pegasus_JMPIProvider_h
42
43 #include "JMPIImpl.h"
44 #include <Pegasus/Common/Config.h>
45 #include <Pegasus/Common/IPC.h>
46 #include <Pegasus/Provider/CIMOMHandle.h>
47 #include <Pegasus/Provider/CIMInstanceProvider.h>
48 #include <Pegasus/Provider/CIMAssociationProvider.h>
49 schuur 1.1 #include <Pegasus/Provider/CIMMethodProvider.h>
50
51 //#include <Pegasus/ProviderManager2/CMPI/CMPIResolverModule.h>
52
53 #include <Pegasus/Server/Linkage.h>
54
55 PEGASUS_NAMESPACE_BEGIN
56
57 class JMPIProviderModule;
58 class CMPIResolverModule;
59
60 struct ProviderVector {
61 jclass jProviderClass;
62 jobject jProvider;
63 };
64
65 // The JMPIProvider class represents the logical provider extracted from a
66 // provider module. It is wrapped in a facade to stabalize the interface
67 // and is directly tied to a module.
68
69 class PEGASUS_SERVER_LINKAGE JMPIProvider :
70 schuur 1.1 public virtual CIMProvider
71 {
72 public:
73
74 enum Status
75 {
76 UNKNOWN,
77 INITIALIZING,
78 INITIALIZED,
79 TERMINATING,
80 TERMINATED
81 };
82
83 public:
84
85
86 class pm_service_op_lock {
87 private:
88 pm_service_op_lock(void);
89 public:
90 pm_service_op_lock(JMPIProvider *provider) : _provider(provider)
91 schuur 1.1 { _provider->protect(); }
92 ~pm_service_op_lock(void)
93 { _provider->unprotect(); }
94 JMPIProvider * _provider;
95 };
96
97 // typedef JMPIProviderFacade Base;
98
99 JMPIProvider(const String & name,
100 JMPIProviderModule *module,
101 ProviderVector *mv);
102 JMPIProvider(JMPIProvider*);
103
104 virtual ~JMPIProvider(void);
105
106 virtual void initialize(CIMOMHandle & cimom);
107
108 virtual Boolean tryTerminate(void);
109 virtual void terminate(void);
110 virtual void _terminate(void);
111
112 schuur 1.1 Status getStatus(void) const;
113 String getName(void) const;
114 void setResolver(CMPIResolverModule *rm) { _rm=rm; }
115
116 JMPIProviderModule *getModule(void) const;
117
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 konrad.r 1.5 class OpProviderHolder;
204 friend class OpProviderHolder;
|
205 mark.hamzy 1.8 mutable Mutex _cimomMutex;
206 /* NOTE: This is a C++ provider only handle which is currently
207 ** used for calls to ->getClass (). getClass returns
208 ** immediately with data and is therefore safe to lock.
209 */
|
210 schuur 1.1 CIMOMHandle *_cimom_handle;
|
211 mark.hamzy 1.8 /* NOTE: This is the java provider's handle and is left
212 ** untouched.
213 */
214 CIMOMHandle *_java_cimom_handle;
|
215 schuur 1.1 void *jProviderClass,*jProvider;
216 String _name;
217 AtomicInt _no_unload;
218 CMPIResolverModule *_rm;
219 Uint32 _quantum;
220 AtomicInt _current_operations;
|
221 mark.hamzy 1.6 mutable Mutex _statusMutex;
|
222 carolann.graves 1.4
223 /**
224 Count of current subscriptions for this provider. Access to this
225 data member is controlled by the _currentSubscriptionsLock.
226 */
227 Uint32 _currentSubscriptions;
228
229 /**
230 A mutex to control access to the _currentSubscriptions member variable.
231 Before any access (test, increment, decrement or reset) of the
232 _currentSubscriptions member variable, the _currentSubscriptionsMutex is
233 first locked.
234 */
235 Mutex _currentSubscriptionsMutex;
236
237 /**
238 The Provider CIMInstance for the provider.
239 The Provider CIMInstance is set only for indication providers, and only
240 if a Create Subscription request has been processed for the provider.
241 The Provider CIMInstance is needed in order to construct the
242 EnableIndicationsResponseHandler to send to the indication provider
243 carolann.graves 1.4 when the provider's enableIndications() method is called.
244 The Provider CIMInstance is needed in the
245 EnableIndicationsResponseHandler in order to construct the Process
246 Indication request when an indication is delivered by the provider.
247 The Provider CIMInstance is needed in the Process Indication request
248 to enable the Indication Service to determine if the provider that
249 generated the indication accepted a matching subscription.
250 */
251 CIMInstance _providerInstance;
|
252 schuur 1.1 //};
253
254
255 //
256 // Used to encapsulate the incrementing/decrementing of the _current_operations
257 // for a JMPIProvider so it won't be unloaded during operations.
258 //
259
260 class OpProviderHolder
261 {
262 private:
263 JMPIProvider* _provider;
264
265 public:
266 OpProviderHolder(): _provider( NULL )
267 {
268 }
269 OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
270 {
271 SetProvider( p._provider );
272 }
273 schuur 1.1 OpProviderHolder( JMPIProvider* p ): _provider( NULL )
274 {
275 SetProvider( p );
276 }
277 ~OpProviderHolder()
278 {
279 UnSetProvider();
280 }
281 JMPIProvider& GetProvider()
282 {
283 return(*_provider);
284 }
285
286 OpProviderHolder& operator=( const OpProviderHolder& x )
287 {
288 if(this == &x)
289 return(*this);
290 SetProvider( x._provider );
291
292 return(*this);
293 }
294 schuur 1.1
295 void SetProvider( JMPIProvider* p )
296 {
297 UnSetProvider();
298 if(p)
299 {
300 _provider = p;
301 _provider->_current_operations++;
302 }
303 }
304
305 void UnSetProvider()
306 {
307 if(_provider)
308 {
309 _provider->_current_operations--;
310 _provider = NULL;
311 }
312 }
313 };
314 };
315 schuur 1.1
316 PEGASUS_NAMESPACE_END
317
318 #endif
|