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

Diff for /pegasus/src/Pegasus/ProviderManager2/JMPI/JMPIProvider.cpp between version 1.2 and 1.20

version 1.2, 2004/06/25 15:23:31 version 1.20, 2008/06/19 17:57:10
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 21 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Chip Vincent (cvincent@us.ibm.com)  
 //  
 // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)  
 //              Mike Day, IBM (mdday@us.ibm.com)  
 //              Adrian Schuur, schuur@de.ibm.com  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "JMPIProvider.h" #include "JMPIProvider.h"
Line 38 
Line 40 
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
   #include "Convert.h"
  
 // set current operations to 1 to prevent an unload // set current operations to 1 to prevent an unload
 // until the provider has had a chance to initialize // until the provider has had a chance to initialize
 JMPIProvider::JMPIProvider(const String & name, JMPIProvider::JMPIProvider(const String & name,
                    JMPIProviderModule *module,                    JMPIProviderModule *module,
                    ProviderVector *mv)                    ProviderVector *mv)
    : _module(module), _cimom_handle(0), _name(name),  
      _no_unload(0), _rm(0)  
 { {
      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
          "JMPIProvider::JMPIProvider(name, module, mv)");
   
      _module               = module;
      _cimom_handle         = 0;
      _java_cimom_handle    = new CIMOMHandle ();
      _name                 = name;
      _no_unload            = false;
    _current_operations = 1;    _current_operations = 1;
      _currentSubscriptions = 0;
    miVector=*mv;    miVector=*mv;
    jProvider=mv->jProvider;    jProvider=mv->jProvider;
    jProviderClass=mv->jProviderClass;    jProviderClass=mv->jProviderClass;
    noUnload=false;    noUnload=false;
    cachedClass=NULL;    cachedClass=NULL;
   
      PEG_METHOD_EXIT();
 } }
  
 JMPIProvider::JMPIProvider(JMPIProvider *pr) JMPIProvider::JMPIProvider(JMPIProvider *pr)
   : _module(pr->_module), _cimom_handle(0), _name(pr->_name),  
     _no_unload(0), _rm(0)  
 { {
      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
          "JMPIProvider::JMPIProvider(pr)");
   
      _module               = pr->_module;
      _cimom_handle         = 0;
      _java_cimom_handle    = new CIMOMHandle ();
      _name                 = pr->_name;
      _no_unload            = pr->noUnload;
    _current_operations = 1;    _current_operations = 1;
      _currentSubscriptions = 0;
    miVector=pr->miVector;    miVector=pr->miVector;
    _cimom_handle=new CIMOMHandle();  
    noUnload=pr->noUnload;    noUnload=pr->noUnload;
    cachedClass=NULL;    cachedClass=NULL;
   
      PEG_METHOD_EXIT();
 } }
  
 JMPIProvider::~JMPIProvider(void) JMPIProvider::~JMPIProvider(void)
 { {
      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
          "JMPIProvider::~JMPIProvider");
   
      delete _java_cimom_handle;
    delete cachedClass;    delete cachedClass;
   
      PEG_METHOD_EXIT();
 } }
  
 JMPIProvider::Status JMPIProvider::getStatus(void) const JMPIProvider::Status JMPIProvider::getStatus(void) const
 { {
       AutoMutex lock(_statusMutex);
     return(_status);     return(_status);
 } }
  
Line 89 
Line 116 
 void JMPIProvider::initialize(CIMOMHandle& cimom) void JMPIProvider::initialize(CIMOMHandle& cimom)
 { {
     _status = INITIALIZING;     _status = INITIALIZING;
   
     _cimom_handle=&cimom;     _cimom_handle=&cimom;
     JvmVector *jv;  
     if (JMPIjvm::trace)      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
        cerr<<"--- JMPIProvider::Initialize()"<<endl;          "JMPIProvider::Initialize");
   
       JvmVector *jv  = 0;
     JNIEnv *env=JMPIjvm::attachThread(&jv);     JNIEnv *env=JMPIjvm::attachThread(&jv);
     jmethodID id=env->GetMethodID((jclass)jProviderClass,"initialize",  
       if (!env)
       {
          PEG_TRACE_CSTRING( TRC_PROVIDERMANAGER, Tracer::LEVEL1,
              "JMPIProvider:"
                  "Could not initialize the JVM (Java Virtual Machine) "
                  "runtime environment.");
   
           PEG_METHOD_EXIT();
           throw PEGASUS_CIM_EXCEPTION_L(
               CIM_ERR_FAILED,
               MessageLoaderParms(
                   "ProviderManager.JMPI.JMPIProvider.INIT_JVM_FAILED",
                   "Could not initialize the JVM (Java Virtual Machine)"
                       " runtime environment."));
       }
   
       // public abstract void initialize (org.pegasus.jmpi.CIMOMHandle ch)
       //        throws org.pegasus.jmpi.CIMException
       jmethodID id = env->GetMethodID((jclass)jProviderClass,
                                       "initialize",
        "(Lorg/pegasus/jmpi/CIMOMHandle;)V");        "(Lorg/pegasus/jmpi/CIMOMHandle;)V");
   
       PEG_TRACE(( TRC_PROVIDERMANAGER, Tracer::LEVEL4,
           "JVM id = %X",(long)id));
   
       JMPIjvm::checkException(env);
   
       if (id != NULL)
       {
          jstring jName = env->NewStringUTF(_name.getCString());
   
          JMPIjvm::checkException(env);
   
          jlong jCimomRef = DEBUG_ConvertCToJava(
                                CIMOMHandle*,
                                jlong,
                                _java_cimom_handle);
          jobject jch       = env->NewObject(jv->CIMOMHandleClassRef,
                                             JMPIjvm::jv.CIMOMHandleNewJSt,
                                             jCimomRef,
                                             jName);
   
          JMPIjvm::checkException(env);
   
          env->CallVoidMethod((jobject)jProvider,id,jch);
   
     JMPIjvm::checkException(env);     JMPIjvm::checkException(env);
     jobject hdl=env->NewObject(jv->CIMOMHandleClassRef,jv->CIMOMHandleNewI,(jint)&cimom);      }
     env->CallVoidMethod((jobject)jProvider,id,hdl);      env->ExceptionClear();
   
     JMPIjvm::detachThread();     JMPIjvm::detachThread();
  
     _status = INITIALIZED;     _status = INITIALIZED;
     _current_operations = 0;     _current_operations = 0;
   
       PEG_METHOD_EXIT();
       return;
 } }
  
 Boolean JMPIProvider::tryTerminate(void) Boolean JMPIProvider::tryTerminate(void)
Line 120 
Line 197 
 { {
 } }
  
 Boolean JMPIProvider::operator == (const void *key) const  /*
   Boolean JMPIProvider::unload_ok(void)
 { {
    if( (void *)this == key)  
       return true;  
    return false;    return false;
 } }
   */
 Boolean JMPIProvider::operator == (const JMPIProvider &prov) const  //   force provider manager to keep in memory
   void JMPIProvider::protect(void)
 { {
    if(String::equalNoCase(_name, prov._name))    // _no_unload++;
       return true;  
    return false;  
 } }
 /*  
 void JMPIProvider::get_idle_timer(struct timeval *t)  // allow provider manager to unload when idle
   void JMPIProvider::unprotect(void)
 { {
    if(t && _cimom_handle)    // _no_unload--;
       _cimom_handle->get_idle_timer(t);  
 } }
  
 void JMPIProvider::update_idle_timer(void)  Boolean JMPIProvider::testIfZeroAndIncrementSubscriptions ()
 { {
    if(_cimom_handle)      AutoMutex lock (_currentSubscriptionsMutex);
       _cimom_handle->update_idle_timer();      Boolean isZero = (_currentSubscriptions == 0);
       _currentSubscriptions++;
   
       return isZero;
 } }
  
 Boolean JMPIProvider::pending_operation(void)  Boolean JMPIProvider::decrementSubscriptionsAndTestIfZero ()
 { {
    if(_cimom_handle)      AutoMutex lock (_currentSubscriptionsMutex);
       return _cimom_handle->pending_operation();      _currentSubscriptions--;
    return false;      Boolean isZero = (_currentSubscriptions == 0);
   
       return isZero;
 } }
  
   Boolean JMPIProvider::testSubscriptions ()
   {
       AutoMutex lock (_currentSubscriptionsMutex);
       Boolean currentSubscriptions = (_currentSubscriptions > 0);
  
 Boolean JMPIProvider::unload_ok(void)      return currentSubscriptions;
   }
   
   void JMPIProvider::resetSubscriptions ()
 { {
    return false;      AutoMutex lock (_currentSubscriptionsMutex);
       _currentSubscriptions = 0;
 } }
 */  
 //   force provider manager to keep in memory  void JMPIProvider::setProviderInstance (const CIMInstance & instance)
 void JMPIProvider::protect(void)  
 { {
   // _no_unload++;      _providerInstance = instance;
 } }
  
 // allow provider manager to unload when idle  CIMInstance JMPIProvider::getProviderInstance ()
 void JMPIProvider::unprotect(void)  
 { {
   // _no_unload--;      return _providerInstance;
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.20

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2