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

📄 java_vm.h

📁 封装了C++调用Java功能的功能!JNI,javaVM
💻 H
字号:
/*-  @filedef
-*  
-*  	@copyright (c) 2006 XW
-*  
-*  @description:
-*  		负责创建和销毁JVM	
-*  
-*  @create :
-*  	@date	:  2006-11-2
-*  	@time	:  16:31:22
-*  	@author	: XiaoWei
-*  
-*  
-*  @file		: JAVA_VM.h
-*  @version	: 1.0.0.0
-*  @note		: <JAVA_VM>
-*  
-*/
#if !defined(__JAVA_VM_H__)
#define		__JAVA_VM_H__
#pragma warning(disable:4786)
#include <map>
#include <vector>
#include "JNI_Object.h"
#include "JAVA_Debug.h"
#include <string>
#include "JAVA_Class.h"
 
/*-  @typedef
-*  
-*  @class 	:  JAVA_VM
-*  
-*  @description:
-*  		JAVA vm	
-*  
-*  @create :
-*   	@date	:  2006-11-2
-*   	@time	:  16:31:22
-*   	@author	:  XiaoWei
-*  
-*/
class JAVA_VM  
{
public:
	static JAVA_VM*	getInstance();

	typedef    std::map<long,JNI_Env*>  _ID2Env;
	typedef		_ID2Env::iterator		_ID2EnvIt;

	typedef  std::map<std_string,JAVA_Class>		_ClassMap;
	typedef	 _ClassMap::iterator					_ClassMapIt;

	typedef  std::vector<std_string>			_StrVec;
	typedef	 _StrVec::iterator					_StrVecIt;
public:	
	void				endSubThread();
	JNI_Env *			startSubThread();
	~JAVA_VM();
	bool				startVM(long _Ver = JNI_VERSION_1_4);
	bool				endVM();
	JNI_VM *			getVM()const;
	JNI_Env*			getEnv();
	bool				loadjarLibrary(const char * _lpFile); 
	bool				getClassForNew(const char* _lpClassSig,JAVA_Class & _class);

	
private:
	JAVA_VM();
	JNI_Env*			m_lpMainEnv;	
	JNI_VM*				m_lpVM;
	std_string			m_jar;
	std_string			m_strOldClassPath;
	_ID2Env				m_EnvMap;
	long				m_MainThreadID;

private:	 
	_ClassMap			m_ClassMap; 
	_StrVec				m_StrVec;
	
protected:
	std_string   _getJarPath(const char* __lpJarFile);

private://disable
	void		__getPathEnv();
	std_string	__getJarPath(const char* __lpJarFile);
	bool		__isFileExist(const char* __lpFileName);
	JAVA_VM(const JAVA_VM&);
	JAVA_VM& operator=(const JAVA_VM&);
};

#endif // !defined(__JAVA_VM_H__)

⌨️ 快捷键说明

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