⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testjre.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
   jlong          jcpv         = DEBUG_ConvertCToJava (CIMParamValue *, jlong, cpv);   jobject        jCIMArgument = jEnv->NewObject (JMPIjvm::jv.CIMArgumentClassRef,                                                  JMPIjvm::jv.CIMArgumentNewJ,                                                  DEBUG_ConvertJavaToC (jlong, CIMParamValue *, jcpv));   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMArgument" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMArgument)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMArgument" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMArgument" << PEGASUS_STD (endl);   }   CIMClass *cc        = new CIMClass (CIMName ("bob"));   jlong     jcc       = DEBUG_ConvertCToJava (CIMClass *, jlong, cc);   jobject   jCIMClass = jEnv->NewObject (JMPIjvm::jv.CIMClassClassRef,                                          JMPIjvm::jv.CIMClassNewJ,                                          DEBUG_ConvertJavaToC (jlong, CIMClass *, jcc));   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMClass" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMClass)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMClass" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMClass" << PEGASUS_STD (endl);   }   jobject jCIMFlavor = jEnv->NewObject (JMPIjvm::jv.CIMFlavorClassRef,                                         JMPIjvm::jv.CIMFlavorNewI,                                         1);   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMFlavor" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMFlavor)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMFlavor" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMFlavor" << PEGASUS_STD (endl);   }   CIMInstance *ci           = new CIMInstance (CIMName ("bob"));   jlong        jci          = DEBUG_ConvertCToJava (CIMInstance *, jlong, ci);   jobject      jCIMInstance = jEnv->NewObject (JMPIjvm::jv.CIMInstanceClassRef,                                                JMPIjvm::jv.CIMInstanceNewJ,                                                DEBUG_ConvertJavaToC (jlong, CIMInstance *, jci));   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMInstance" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMInstance)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMInstance" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMInstance" << PEGASUS_STD (endl);   }   CIMClass  *cc2        = new CIMClass (CIMName ("bob"));   CIMObject *co         = new CIMObject (*cc2);   jlong      jco        = DEBUG_ConvertCToJava (CIMObject *, jlong, co);   jobject    jCIMObject = jEnv->NewObject (JMPIjvm::jv.CIMObjectClassRef,                                            JMPIjvm::jv.CIMObjectNewJZ,                                            jco,                                            (jboolean)true);   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMObject" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMObject)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMObject" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMObject" << PEGASUS_STD (endl);   }   CIMObjectPath *cop            = new CIMObjectPath (String ("bob"));   jlong          jcop           = DEBUG_ConvertCToJava (CIMObjectPath *, jlong, cop);   jobject        jCIMObjectPath = jEnv->NewObject (JMPIjvm::jv.CIMObjectPathClassRef,                                                    JMPIjvm::jv.CIMObjectPathNewJ,                                                    DEBUG_ConvertJavaToC (jlong, CIMObjectPath *, jcop));   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMObjectPath" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMObjectPath)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMObjectPath" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMObjectPath" << PEGASUS_STD (endl);   }   Uint32 ui32CVInit = 77;   CIMProperty *cp           = new CIMProperty (CIMName ("bobprop"),                                                CIMValue (ui32CVInit));   jlong        jcp          = DEBUG_ConvertCToJava (CIMProperty *, jlong, cp);   jobject      jCIMProperty = jEnv->NewObject (JMPIjvm::jv.CIMPropertyClassRef,                                                JMPIjvm::jv.CIMPropertyNewJ,                                                DEBUG_ConvertJavaToC (jlong, CIMProperty *, jcp));   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMProperty" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMProperty)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMProperty" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMProperty" << PEGASUS_STD (endl);   }   Uint64 ui64CVInit = 42;   CIMQualifier *cq            = new CIMQualifier (CIMName ("bob"),                                                   CIMValue (ui64CVInit));   jlong         jcq           = DEBUG_ConvertCToJava (CIMQualifier *, jlong, cq);   jobject       jCIMQualifier = jEnv->NewObject (JMPIjvm::jv.CIMQualifierClassRef,                                                  JMPIjvm::jv.CIMQualifierNewJ,                                                  DEBUG_ConvertJavaToC (jlong, CIMQualifier *, jcq));   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMQualifier" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMQualifier)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMQualifier" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMQualifier" << PEGASUS_STD (endl);   }   Uint8 ui8CVInit = 0;   CIMValue *cv        = new CIMValue (ui8CVInit);   jlong     jcv       = DEBUG_ConvertCToJava (CIMValue *, jlong, cv);   jobject   jCIMValue = jEnv->NewObject (JMPIjvm::jv.CIMValueClassRef,                                          JMPIjvm::jv.CIMValueNewJ,                                          DEBUG_ConvertJavaToC (jlong, CIMValue *, jcv));   if (jEnv->ExceptionOccurred ())   {      DDD(jEnv->ExceptionDescribe ());      DDD(jEnv->ExceptionClear ());      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMValue" << PEGASUS_STD (endl);      return 1;   }   else if (!jCIMValue)   {      PEGASUS_STD (cout) << "testJVM: FAILURE: Create CIMValue" << PEGASUS_STD (endl);      return 1;   }   else   {      PEGASUS_STD (cout) << "testJVM: SUCCESS: Create CIMValue" << PEGASUS_STD (endl);   }   // OperationContextNewJ   // SelectExpNewJ   // ---------------------------------------------------------------------   // ---------------------------------------------------------------------   {      ConfigManager *manager      = ConfigManager::getInstance ();      String         pegasusHome  = String::EMPTY;// BEGIN: Copy from src/Server/cimserver.cpp//        It would have been nice if this were part of ConfigManager.#ifdef PEGASUS_OS_OS400      VFYPTRS_INCDCL;               // VFYPTRS local variables      // verify pointers#pragma exception_handler (qsyvp_excp_hndlr,qsyvp_excp_comm_area,0,_C2_MH_ESCAPE)      for( int arg_index = 1; arg_index < argc; arg_index++ ){         VFYPTRS(VERIFY_SPP_NULL(argv[arg_index]));      }#pragma disable_handler      // Convert the args to ASCII      for(Uint32 i = 0;i< argc;++i)      {         EtoA(argv[i]);      }      // Initialize Pegasus home to the shipped OS/400 directory.      pegasusHome = OS400_DEFAULT_PEGASUS_HOME;#endif#ifndef PEGASUS_OS_TYPE_WINDOWS      //      // Get environment variables:      //#ifdef PEGASUS_OS_OS400#pragma convert(37)      const char* tmp = getenv("PEGASUS_HOME");#pragma convert(0)      char home[256] = {0};      if (tmp && strlen(tmp) < 256)      {        strcpy(home, tmp);        EtoA(home);        pegasusHome = home;      }#else#if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)      pegasusHome = AIX_RELEASE_PEGASUS_HOME;#elif !defined(PEGASUS_USE_RELEASE_DIRS) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)      const char* tmp = getenv("PEGASUS_HOME");      if (tmp)      {         pegasusHome = tmp;      }#endif#endif      FileSystem::translateSlashes(pegasusHome);#else      // windows only      // Determine the absolute path to the running program      char exe_pathname[_MAX_PATH] = {0};      char home_pathname[_MAX_PATH] = {0};      if(0 != GetModuleFileName(NULL, exe_pathname, sizeof(exe_pathname)))      {        // Pegasus home search rules:        // - look in registry (if set)        // - if not found, look in PEGASUS_HOME (if set)        // - if not found, use exe directory minus one level        bool found_reg = _getRegInfo("home", home_pathname);        if (found_reg == true)          {            // Make sure home matches            String current_home(home_pathname);            String current_exe(exe_pathname);            current_home.toLower();            current_exe.toLower();            Uint32 pos = current_exe.find(current_home);            if (pos != PEG_NOT_FOUND)              {                pegasusHome = home_pathname;              }            else              {                found_reg = false;              }          }        if (found_reg == false)          {            const char* tmp = getenv("PEGASUS_HOME");            if (tmp)              {                pegasusHome = tmp;              }            else              {                // ASSUMPTION: At a minimum, the cimserver program is running                // from a "bin" directory                pegasusHome = FileSystem::extractFilePath(exe_pathname);                pegasusHome.remove(pegasusHome.size()-1, 1);                pegasusHome = FileSystem::extractFilePath(pegasusHome);                pegasusHome.remove(pegasusHome.size()-1, 1);              }          }      }#endif      //      // Set the value for pegasusHome property      //      ConfigManager::setPegasusHome(pegasusHome);// END      String         path         = ConfigManager::getHomedPath (manager->getCurrentValue ("providerDir"));      ProviderVector pv           = { 0, 0 };      String         fileName;      String         className;      String         providerName;      // Windows returns two paths, must pick the correct one!#ifdef PEGASUS_OS_TYPE_WINDOWS      PEGASUS_STD(cerr)<<"testJVM: path = \"" << path <<"\""<<PEGASUS_STD(endl);      String winPath = path;      do      {         String winPathPart;         String testJarLocation;         Uint32 posDelim        = 0;         posDelim = winPath.find (FileSystem::getPathDelimiter ());         if (posDelim != PEG_NOT_FOUND)         {            winPathPart = winPath.subString (posDelim + 1);            winPath.remove (posDelim);         }         else         {            winPathPart = winPath;            winPath     = "";         }         PEGASUS_STD(cerr)<<"testJVM: winPathPart = \"" << winPathPart <<"\""<<PEGASUS_STD(endl);         testJarLocation = winPathPart + "/JMPIExpAssociationProvider.jar";         FileSystem::translateSlashes (testJarLocation);         if (FileSystem::exists (testJarLocation))         {            PEGASUS_STD(cerr)<<"testJVM: Found!"<<PEGASUS_STD(endl);            path = winPathPart;            break;         }      } while (winPath.size () > 0);#endif      fileName  = path + "/JMPIExpAssociationProvider.jar";      className = "Associations/JMPIExpAssociationProvider";      FileSystem::translateSlashes (fileName);      providerName = fileName + ":" + className;      if (!FileSystem::exists (fileName))      {         PEGASUS_STD(cerr)<<"testJVM: FAILURE: \"" << fileName <<"\" does not exist!"<<PEGASUS_STD(endl);         return 1;      }      pv.jProvider = JMPIjvm::getProvider (jEnv,                                           fileName,                                           className,                                           providerName.getCString (),                                           &pv.jProviderClass);      if (  !pv.jProvider         || !pv.jProviderClass         )      {         PEGASUS_STD (cout) << "testJVM: FAILURE: Create Provider" << PEGASUS_STD (endl);         return 1;      }      else      {         PEGASUS_STD (cout) << "testJVM: SUCCESS: Create Provider" << PEGASUS_STD (endl);      }   }   // ---------------------------------------------------------------------   JMPIjvm::detachThread ();   jv->jvm->DestroyJavaVM ();   PEGASUS_STD(cerr)<<"testJVM: SUCCESS"<<PEGASUS_STD(endl);   return 0;}intmain (int argc, char *argv[]){#ifdef PEGASUS_DEBUG   if (getenv ("PEGASUS_JMPI_TRACE"))      trace = 1;   else      trace = 0;#else   trace = 0;#endif   printEnvironmentVariables ();   return testJVM ();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -