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 mark.hamzy 1.6 //
|
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 konrad.r 1.5 class OpProviderHolder;
204 friend class OpProviderHolder;
|
205 schuur 1.1 CIMOMHandle *_cimom_handle;
206 void *jProviderClass,*jProvider;
207 String _name;
208 AtomicInt _no_unload;
209 CMPIResolverModule *_rm;
210 Uint32 _quantum;
211 AtomicInt _current_operations;
|
212 mark.hamzy 1.6 mutable Mutex _statusMutex;
|
213 carolann.graves 1.4
214 /**
215 Count of current subscriptions for this provider. Access to this
216 data member is controlled by the _currentSubscriptionsLock.
217 */
218 Uint32 _currentSubscriptions;
219
220 /**
221 A mutex to control access to the _currentSubscriptions member variable.
222 Before any access (test, increment, decrement or reset) of the
223 _currentSubscriptions member variable, the _currentSubscriptionsMutex is
224 first locked.
225 */
226 Mutex _currentSubscriptionsMutex;
227
228 /**
229 The Provider CIMInstance for the provider.
230 The Provider CIMInstance is set only for indication providers, and only
231 if a Create Subscription request has been processed for the provider.
232 The Provider CIMInstance is needed in order to construct the
233 EnableIndicationsResponseHandler to send to the indication provider
234 carolann.graves 1.4 when the provider's enableIndications() method is called.
235 The Provider CIMInstance is needed in the
236 EnableIndicationsResponseHandler in order to construct the Process
237 Indication request when an indication is delivered by the provider.
238 The Provider CIMInstance is needed in the Process Indication request
239 to enable the Indication Service to determine if the provider that
240 generated the indication accepted a matching subscription.
241 */
242 CIMInstance _providerInstance;
|
243 schuur 1.1 //};
244
245
246 //
247 // Used to encapsulate the incrementing/decrementing of the _current_operations
248 // for a JMPIProvider so it won't be unloaded during operations.
249 //
250
251 class OpProviderHolder
252 {
253 private:
254 JMPIProvider* _provider;
255
256 public:
257 OpProviderHolder(): _provider( NULL )
258 {
259 }
260 OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
261 {
262 SetProvider( p._provider );
263 }
264 schuur 1.1 OpProviderHolder( JMPIProvider* p ): _provider( NULL )
265 {
266 SetProvider( p );
267 }
268 ~OpProviderHolder()
269 {
270 UnSetProvider();
271 }
272 JMPIProvider& GetProvider()
273 {
274 return(*_provider);
275 }
276
277 OpProviderHolder& operator=( const OpProviderHolder& x )
278 {
279 if(this == &x)
280 return(*this);
281 SetProvider( x._provider );
282
283 return(*this);
284 }
285 schuur 1.1
286 void SetProvider( JMPIProvider* p )
287 {
288 UnSetProvider();
289 if(p)
290 {
291 _provider = p;
292 _provider->_current_operations++;
293 }
294 }
295
296 void UnSetProvider()
297 {
298 if(_provider)
299 {
300 _provider->_current_operations--;
301 _provider = NULL;
302 }
303 }
304 };
305 };
306 schuur 1.1
307 PEGASUS_NAMESPACE_END
308
309 #endif
|