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

  1 karl  1.5 //%2004////////////////////////////////////////////////////////////////////////
  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 schuur 1.1 //
 10            // Permission is hereby granted, free of charge, to any person obtaining a copy
 11            // of this software and associated documentation files (the "Software"), to
 12            // deal in the Software without restriction, including without limitation the
 13            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 14            // sell copies of the Software, and to permit persons to whom the Software is
 15            // furnished to do so, subject to the following conditions:
 16 karl   1.5 // 
 17 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 18            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 19            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 20            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 21            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 23            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 24            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 25            //
 26            //==============================================================================
 27            //
 28            // Author: Chip Vincent (cvincent@us.ibm.com)
 29            //
 30            // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
 31            //              Mike Day, IBM (mdday@us.ibm.com)
 32            //              Adrian Schuur, schuur@de.ibm.com 
 33            //
 34            //%/////////////////////////////////////////////////////////////////////////////
 35            
 36            #include "JMPIProvider.h"
 37            
 38 schuur 1.1 #include <Pegasus/Common/Tracer.h>
 39            #include <Pegasus/ProviderManager2/JMPI/JMPIProvider.h>
 40            #include <Pegasus/ProviderManager2/JMPI/JMPIProviderModule.h>
 41            
 42            PEGASUS_NAMESPACE_BEGIN
 43 schuur 1.2 PEGASUS_USING_STD;
 44 schuur 1.1 
 45            
 46            // set current operations to 1 to prevent an unload
 47            // until the provider has had a chance to initialize
 48            JMPIProvider::JMPIProvider(const String & name,
 49            		   JMPIProviderModule *module,
 50            		   ProviderVector *mv)
 51               : _module(module), _cimom_handle(0), _name(name),
 52                 _no_unload(0), _rm(0)
 53            {
 54               _current_operations = 1;
 55               miVector=*mv;
 56               jProvider=mv->jProvider;
 57               jProviderClass=mv->jProviderClass;
 58               noUnload=false;
 59               cachedClass=NULL;
 60            }
 61            
 62            JMPIProvider::JMPIProvider(JMPIProvider *pr)
 63              : _module(pr->_module), _cimom_handle(0), _name(pr->_name),
 64                _no_unload(0), _rm(0)
 65 schuur 1.1 {
 66               _current_operations = 1;
 67               miVector=pr->miVector;
 68               _cimom_handle=new CIMOMHandle();
 69               noUnload=pr->noUnload;
 70               cachedClass=NULL;
 71            }
 72            
 73            JMPIProvider::~JMPIProvider(void)
 74            {
 75               delete cachedClass;
 76            }
 77            
 78            JMPIProvider::Status JMPIProvider::getStatus(void) const
 79            {
 80                return(_status);
 81            }
 82            
 83            JMPIProviderModule *JMPIProvider::getModule(void) const
 84            {
 85                return(_module);
 86 schuur 1.1 }
 87            
 88            String JMPIProvider::getName(void) const
 89            {
 90                return(_name);
 91            }
 92            
 93            void JMPIProvider::initialize(CIMOMHandle& cimom)
 94            {
 95                _status = INITIALIZING;
 96            
 97                _cimom_handle=&cimom;
 98                JvmVector *jv;
 99 schuur 1.4 #ifdef PEGASUS_DEBUG
100 schuur 1.2     if (JMPIjvm::trace)
101                   cerr<<"--- JMPIProvider::Initialize()"<<endl;
102 schuur 1.4 #endif
103 schuur 1.3 
104 schuur 1.1     JNIEnv *env=JMPIjvm::attachThread(&jv);
105 schuur 1.3     
106 schuur 1.1     jmethodID id=env->GetMethodID((jclass)jProviderClass,"initialize",
107                   "(Lorg/pegasus/jmpi/CIMOMHandle;)V");
108                JMPIjvm::checkException(env);
109 schuur 1.3 
110                jstring jName=env->NewStringUTF(_name.getCString());
111                JMPIjvm::checkException(env);
112            
113                jobject hdl=env->NewObject(jv->CIMOMHandleClassRef,jv->CIMOMHandleNewI,(jint)&cimom,jName);
114 schuur 1.1     env->CallVoidMethod((jobject)jProvider,id,hdl);
115 schuur 1.3 
116 schuur 1.1     JMPIjvm::detachThread();
117            
118                _status = INITIALIZED;
119                _current_operations = 0;
120            }
121            
122            Boolean JMPIProvider::tryTerminate(void)
123            {
124                return false;
125            }
126            
127            void JMPIProvider::_terminate(void)
128            {
129            }
130            
131            
132            void JMPIProvider::terminate(void)
133            {
134            }
135            
136            Boolean JMPIProvider::operator == (const void *key) const
137 schuur 1.1 {
138               if( (void *)this == key)
139                  return true;
140               return false;
141            }
142            
143            Boolean JMPIProvider::operator == (const JMPIProvider &prov) const
144            {
145               if(String::equalNoCase(_name, prov._name))
146                  return true;
147               return false;
148            }
149            /*
150            void JMPIProvider::get_idle_timer(struct timeval *t)
151            {
152               if(t && _cimom_handle)
153                  _cimom_handle->get_idle_timer(t);
154            }
155            
156            void JMPIProvider::update_idle_timer(void)
157            {
158 schuur 1.1    if(_cimom_handle)
159                  _cimom_handle->update_idle_timer();
160            }
161            
162            Boolean JMPIProvider::pending_operation(void)
163            {
164               if(_cimom_handle)
165                  return _cimom_handle->pending_operation();
166               return false;
167            }
168            
169            
170            Boolean JMPIProvider::unload_ok(void)
171            {
172               return false;
173            }
174            */
175            //   force provider manager to keep in memory
176            void JMPIProvider::protect(void)
177            {
178              // _no_unload++;
179 schuur 1.1 }
180            
181            // allow provider manager to unload when idle
182            void JMPIProvider::unprotect(void)
183            {
184              // _no_unload--;
185            }
186            
187            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2