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

📄 jmpiimpl.h

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 H
📖 第 1 页 / 共 2 页
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// 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// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================////%/////////////////////////////////////////////////////////////////////////////#ifndef _Provider_JMPIImpl_h#define _Provider_JMPIImpl_h#include <Pegasus/Common/Config.h>#include <jni.h>#ifdef PEGASUS_PLATFORM_LINUX_GENERIC_GNU#if defined (__GNUC__) && GCC_VERSION >= 40000// If gcc is compiled with -fvisibility=hidden then JMPI is broken.  This is because// the JNI h file defines JNIEXPORT as empty since the default is visible.#undef  JNIEXPORT#define JNIEXPORT __attribute__ ((visibility("default")))#endif#endif#include <stdio.h>#include <stdlib.h>#include <string.h>#include <Pegasus/Common/String.h>#include <Pegasus/Common/System.h>#include <Pegasus/Common/HashTable.h>#include <Pegasus/Common/CIMType.h>#include <Pegasus/Common/Mutex.h>#include <Pegasus/ProviderManager2/JMPI/Linkage.h>PEGASUS_NAMESPACE_BEGIN#define NULL_CHECK0(e) if ((e) == 0) return 0 //added by Andy#define NULL_CHECK(e) if ((e) == 0) return //added by Andy#define Catch(jEnv) \   catch(CIMException & e) { \      JMPIjvm::cacheIDs(jEnv); \      jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewISt,(jint)e.getCode(),jEnv->NewStringUTF(e.getMessage().getCString())); \      jEnv->Throw((jthrowable)ev); \   } \   catch(Exception & e) { \      JMPIjvm::cacheIDs(jEnv);\      jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewISt,(jint)1,jEnv->NewStringUTF(e.getMessage().getCString())); \      jEnv->Throw((jthrowable)ev); \   } \   catch(...)  { \      JMPIjvm::cacheIDs(jEnv); \      jobject ev=jEnv->NewObject(JMPIjvm::jv.CIMExceptionClassRef,JMPIjvm::jv.CIMExceptionNewISt,(jint)1,jEnv->NewStringUTF("Exception: Unknown")); \      jEnv->Throw((jthrowable)ev); \   }typedef struct {  int         clsIndex;  const char *methodName;  const char *signature;} METHOD_STRUCT;typedef struct jvmVector {   int                  initRc;   JavaVM              *jvm;   JNIEnv              *env;   jclass              *classRefs;   jmethodID           *instMethodIDs;   jmethodID           *staticMethodIDs;   const METHOD_STRUCT *instanceMethodNames;} JvmVector;class PEGASUS_JMPIPM_LINKAGE JMPIjvm { public:   static int trace;   static JavaVM *jvm;   static JvmVector jv;   JMPIjvm();  ~JMPIjvm();   static JNIEnv* attachThread(JvmVector **jvp);   static void detachThread();   static jobject getProvider(JNIEnv *env, const char *cn, jclass *cls) ;   static jobject getProvider(JNIEnv *env, String jar, String cln, const char *cn, jclass *cls) ;   static void checkException(JNIEnv *env);   static jstring NewPlatformString(JNIEnv *env,char *s);   static jobjectArray NewPlatformStringArray(JNIEnv *env,char **strv, int strc);   static int cacheIDs(JNIEnv *env);   static int destroyJVM(); private:   static jclass getGlobalClassRef(JNIEnv *env, const char* name);   static int initJVM();   typedef HashTable<String,jclass,EqualFunc<String>,HashFunc<String> >  ClassTable;   typedef HashTable<String,jobject,EqualFunc<String>,HashFunc<String> > ObjectTable;   static ClassTable  _classTable;   static ObjectTable _objectTable;   static Mutex _initMutex;};class _nameSpace { public:   _nameSpace();   _nameSpace(String hn);   _nameSpace(String hn, String ns);   int port();   String hostName();   String nameSpace();   int port_;   String protocol_;   String hostName_;   String nameSpace_;};class _dataType {   public:   _dataType (int          type,              int          size,              Boolean      reference,              Boolean      null,              Boolean      array,              String&      refClass,              Boolean      fromProperty)      : _type(type),        _size(size),        _reference(reference),        _array(array),        _refClass(refClass),        _fromProperty(fromProperty)   {   }   _dataType (int          type)      : _type(type),        _size(1),        _reference(false),        _array(false),        _refClass(String::EMPTY),        _fromProperty(false)   {   }   _dataType (int          type,              int          size)      : _type(type),        _size(size),        _reference(false),        _array(true),        _refClass(String::EMPTY),        _fromProperty(true)   {   }   _dataType (int          type,              const String ref)       : _type(type),         _size(0),         _reference(true),         _array(false),         _refClass(ref),         _fromProperty(true)   {   }   static int convertCTypeToJavaType (CIMType cType, bool *pfSuccess)   {      static int cTypeToJType[]=      /*  CIMType.h                CIMDataType.java          CIMTYPE_BOOLEAN,     0   public static final int BOOLEAN   =      10;          CIMTYPE_UINT8,       1   public static final int UINT8     =       1;          CIMTYPE_SINT8,       2   public static final int SINT8     =       2;          CIMTYPE_UINT16,      3   public static final int UINT16    =       3;          CIMTYPE_SINT16,      4   public static final int SINT16    =       4;          CIMTYPE_UINT32,      5   public static final int UINT32    =       5;          CIMTYPE_SINT32,      6   public static final int SINT32    =       6;          CIMTYPE_UINT64,      7   public static final int UINT64    =       7;          CIMTYPE_SINT64,      8   public static final int SINT64    =       8;          CIMTYPE_REAL32,      9   public static final int REAL32    =      11;          CIMTYPE_REAL64,     10   public static final int REAL64    =      12;          CIMTYPE_CHAR16,     11   public static final int CHAR16    =      14;          CIMTYPE_STRING,     12   public static final int STRING    =       9;          CIMTYPE_DATETIME,   13   public static final int DATETIME  =      13;          CIMTYPE_REFERENCE,  14   public static final int REFERENCE = 0x20+ 1;          CIMTYPE_OBJECT      15   public static final int OBJECT    =      15;      */      //  p:      0  1  2  3  4  5  6  7  8  9 10 11 12 13 14     15      {/* j: */  10, 1, 2, 3, 4, 5, 6, 7, 8,11,12,14, 9,13,0x20+1,15};      if ((int)cType < (int)CIMTYPE_BOOLEAN || (int)cType > (int)CIMTYPE_OBJECT)      {         *pfSuccess = false;

⌨️ 快捷键说明

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