1 karl 1.6 //%2005////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.5 // 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.6 // 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.8 //
|
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 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // 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 mark.hamzy 1.8 // Adrian Schuur, schuur@de.ibm.com
|
35 schuur 1.1 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
38 #include "JMPIProvider.h"
39
40 #include <Pegasus/Common/Tracer.h>
41 #include <Pegasus/ProviderManager2/JMPI/JMPIProvider.h>
42 #include <Pegasus/ProviderManager2/JMPI/JMPIProviderModule.h>
43
44 PEGASUS_NAMESPACE_BEGIN
|
45 schuur 1.2 PEGASUS_USING_STD;
|
46 schuur 1.1
|
47 mark.hamzy 1.9 #ifdef PEGASUS_DEBUG
48 #define DDD(x) if (JMPIjvm::trace) x;
49 #else
50 #define DDD(x)
51 #endif
52
|
53 mark.hamzy 1.8 #include "Convert.h"
|
54 schuur 1.1
55 // set current operations to 1 to prevent an unload
56 // until the provider has had a chance to initialize
57 JMPIProvider::JMPIProvider(const String & name,
58 JMPIProviderModule *module,
59 ProviderVector *mv)
60 : _module(module), _cimom_handle(0), _name(name),
61 _no_unload(0), _rm(0)
62 {
63 _current_operations = 1;
|
64 carolann.graves 1.7 _currentSubscriptions = 0;
|
65 schuur 1.1 miVector=*mv;
66 jProvider=mv->jProvider;
67 jProviderClass=mv->jProviderClass;
68 noUnload=false;
69 cachedClass=NULL;
70 }
71
72 JMPIProvider::JMPIProvider(JMPIProvider *pr)
73 : _module(pr->_module), _cimom_handle(0), _name(pr->_name),
74 _no_unload(0), _rm(0)
75 {
76 _current_operations = 1;
|
77 carolann.graves 1.7 _currentSubscriptions = 0;
|
78 schuur 1.1 miVector=pr->miVector;
79 _cimom_handle=new CIMOMHandle();
80 noUnload=pr->noUnload;
81 cachedClass=NULL;
82 }
83
84 JMPIProvider::~JMPIProvider(void)
85 {
86 delete cachedClass;
87 }
88
89 JMPIProvider::Status JMPIProvider::getStatus(void) const
90 {
|
91 mark.hamzy 1.10 AutoMutex lock(_statusMutex);
|
92 schuur 1.1 return(_status);
93 }
94
95 JMPIProviderModule *JMPIProvider::getModule(void) const
96 {
97 return(_module);
98 }
99
100 String JMPIProvider::getName(void) const
101 {
102 return(_name);
103 }
104
105 void JMPIProvider::initialize(CIMOMHandle& cimom)
106 {
|
107 mark.hamzy 1.9 _status = INITIALIZING;
108 _cimom_handle = &cimom;
109
110 DDD(PEGASUS_STD(cout)<<"--- JMPIProvider::Initialize()"<<PEGASUS_STD(endl));
|
111 schuur 1.1
|
112 mark.hamzy 1.9 JvmVector *jv = 0;
113 JNIEnv *env = JMPIjvm::attachThread(&jv);
|
114 schuur 1.3
|
115 mark.hamzy 1.9 // public abstract void initialize (org.pegasus.jmpi.CIMOMHandle ch)
116 // throws org.pegasus.jmpi.CIMException
117 jmethodID id = env->GetMethodID((jclass)jProviderClass,
118 "initialize",
119 "(Lorg/pegasus/jmpi/CIMOMHandle;)V");
|
120 mark.hamzy 1.8
|
121 mark.hamzy 1.10 DDD(PEGASUS_STD(cout)
122 <<"--- JMPIProvider::Initialize:id = "
123 <<PEGASUS_STD(hex)
124 <<(int)id
125 <<PEGASUS_STD(dec)
126 <<PEGASUS_STD(endl));
127
|
128 schuur 1.1 JMPIjvm::checkException(env);
|
129 schuur 1.3
|
130 mark.hamzy 1.10 if (id != NULL)
131 {
132 jstring jName = env->NewStringUTF(_name.getCString());
133
134 JMPIjvm::checkException(env);
|
135 mark.hamzy 1.9
|
136 mark.hamzy 1.10 jint jCimomRef = DEBUG_ConvertCToJava (CIMOMHandle*, jint, &cimom);
137 jobject jch = env->NewObject(jv->CIMOMHandleClassRef,
138 JMPIjvm::jv.CIMOMHandleNewISt,
139 jCimomRef,
140 jName);
141
142 JMPIjvm::checkException(env);
|
143 schuur 1.3
|
144 mark.hamzy 1.10 env->CallVoidMethod((jobject)jProvider,id,jch);
|
145 mark.hamzy 1.8
|
146 mark.hamzy 1.10 JMPIjvm::checkException(env);
147 }
148 env->ExceptionClear();
|
149 schuur 1.3
|
150 schuur 1.1 JMPIjvm::detachThread();
151
|
152 mark.hamzy 1.9 _status = INITIALIZED;
|
153 schuur 1.1 _current_operations = 0;
154 }
155
156 Boolean JMPIProvider::tryTerminate(void)
157 {
158 return false;
159 }
160
161 void JMPIProvider::_terminate(void)
162 {
163 }
164
165
166 void JMPIProvider::terminate(void)
167 {
168 }
169
170 Boolean JMPIProvider::operator == (const void *key) const
171 {
172 if( (void *)this == key)
173 return true;
174 schuur 1.1 return false;
175 }
176
177 Boolean JMPIProvider::operator == (const JMPIProvider &prov) const
178 {
179 if(String::equalNoCase(_name, prov._name))
180 return true;
181 return false;
182 }
183 /*
184 void JMPIProvider::get_idle_timer(struct timeval *t)
185 {
186 if(t && _cimom_handle)
187 _cimom_handle->get_idle_timer(t);
188 }
189
190 void JMPIProvider::update_idle_timer(void)
191 {
192 if(_cimom_handle)
193 _cimom_handle->update_idle_timer();
194 }
195 schuur 1.1
196 Boolean JMPIProvider::pending_operation(void)
197 {
198 if(_cimom_handle)
199 return _cimom_handle->pending_operation();
200 return false;
201 }
202
203
204 Boolean JMPIProvider::unload_ok(void)
205 {
206 return false;
207 }
208 */
209 // force provider manager to keep in memory
210 void JMPIProvider::protect(void)
211 {
212 // _no_unload++;
213 }
214
215 // allow provider manager to unload when idle
216 schuur 1.1 void JMPIProvider::unprotect(void)
217 {
218 // _no_unload--;
219 }
220
|
221 carolann.graves 1.7 Boolean JMPIProvider::testIfZeroAndIncrementSubscriptions ()
222 {
223 AutoMutex lock (_currentSubscriptionsMutex);
224 Boolean isZero = (_currentSubscriptions == 0);
225 _currentSubscriptions++;
226
227 return isZero;
228 }
229
230 Boolean JMPIProvider::decrementSubscriptionsAndTestIfZero ()
231 {
232 AutoMutex lock (_currentSubscriptionsMutex);
233 _currentSubscriptions--;
234 Boolean isZero = (_currentSubscriptions == 0);
235
236 return isZero;
237 }
238
239 Boolean JMPIProvider::testSubscriptions ()
240 {
241 AutoMutex lock (_currentSubscriptionsMutex);
242 carolann.graves 1.7 Boolean currentSubscriptions = (_currentSubscriptions > 0);
243
244 return currentSubscriptions;
245 }
246
247 void JMPIProvider::resetSubscriptions ()
248 {
249 AutoMutex lock (_currentSubscriptionsMutex);
250 _currentSubscriptions = 0;
251 }
252
253 void JMPIProvider::setProviderInstance (const CIMInstance & instance)
254 {
255 _providerInstance = instance;
256 }
257
258 CIMInstance JMPIProvider::getProviderInstance ()
259 {
260 return _providerInstance;
261 }
262
|
263 schuur 1.1 PEGASUS_NAMESPACE_END
|