(file) Return to JMPIProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / JMPI

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2