JVMInfo* JVMChooser::getJvm(const tstring& javaHomePath, const tstring& binJvmDir) { JVMInfo* pJvmInfo = 0; try { tstring pathToJvm = javaHomePath + tstring(_T("\\bin\\")) + binJvmDir + tstring(_T("\\jvm.dll")); if( LocalUtilities::fileExists(pathToJvm) ) { pJvmInfo = new JVMInfo(); pJvmInfo->setJvmPath(pathToJvm); pJvmInfo->setJavaHomePath(javaHomePath); return pJvmInfo; } pathToJvm = javaHomePath + tstring(_T("\\jre\\bin\\")) + binJvmDir + tstring(_T("\\jvm.dll")); if( LocalUtilities::fileExists(pathToJvm) ) { pJvmInfo = new JVMInfo(); pJvmInfo->setJvmPath(pathToJvm); pJvmInfo->setJavaHomePath(javaHomePath + tstring(_T("\\jre"))); return pJvmInfo; } } catch(...) { DEBUG_SHOW( _T("Exception in JVMChooser.getJvm()") ); ErrHandler::severeError( _T("Error while getting the JVM from the Java home path and JVM type.") ); } return 0; }
JVMInfo* JVMChooser::getJvmFromCustomJvmPath() { JVMInfo* pJvmInfo = 0; try { if( !m_pProperties->getCustomJvmPath().empty() ) { if( LocalUtilities::fileExists(m_pProperties->getCustomJvmPath()) ) { pJvmInfo = new JVMInfo(); pJvmInfo->setJvmPath(m_pProperties->getCustomJvmPath()); return pJvmInfo; } else { throw tstring( _T("This JVM file could not be found: ") + m_pProperties->getCustomJvmPath() ); } } } catch(tstring& se) { DEBUG_SHOW( _T("Exception in JVMChooser.getJvmFromCustomJvmPath(): ") + se ); ErrHandler::severeError( se ); } catch(...) { DEBUG_SHOW( _T("Exception in JVMChooser.getJvmFromCustomJvmPath()") ); ErrHandler::severeError( _T("Error while getting the JVM from the custom jvm path setting.") ); } return 0; }
void JVMChooser::breakoutBinJvmDirs(vector<JVMInfo>* pVecJvmInfo) { try { vector<JVMInfo>* pAdditionsVecJvmInfo = new vector<JVMInfo>; // loop through all the JVMs, if there is a server JVM add to additions size_t top = pVecJvmInfo->size(); for( size_t j = 0; j < top; j++ ) { size_t i = top - j - 1; DEBUG_SHOW( _T("Top of first loop through JVMInfos") ); JVMInfo& jvmInfo = pVecJvmInfo->at(i); if( jvmInfo.existsJvmDLL(Properties::CLIENT_BIN_JVM_DIR) && jvmInfo.existsJvmDLL(Properties::SERVER_BIN_JVM_DIR) ) { JVMInfo* pNewJvmInfo = jvmInfo.partialClone(); pNewJvmInfo->setBinJvmDir(Properties::SERVER_BIN_JVM_DIR); pNewJvmInfo->setJvmPath(pNewJvmInfo->getJvmDLLPath(Properties::SERVER_BIN_JVM_DIR)); pAdditionsVecJvmInfo->push_back( *pNewJvmInfo ); jvmInfo.setBinJvmDir(Properties::CLIENT_BIN_JVM_DIR); jvmInfo.setJvmPath(jvmInfo.getJvmDLLPath(Properties::CLIENT_BIN_JVM_DIR)); } else if( jvmInfo.existsJvmDLL(Properties::CLIENT_BIN_JVM_DIR) ) { jvmInfo.setBinJvmDir(Properties::CLIENT_BIN_JVM_DIR); jvmInfo.setJvmPath(jvmInfo.getJvmDLLPath(Properties::CLIENT_BIN_JVM_DIR)); } else if( jvmInfo.existsJvmDLL(Properties::SERVER_BIN_JVM_DIR) ) { jvmInfo.setBinJvmDir(Properties::SERVER_BIN_JVM_DIR); jvmInfo.setJvmPath(jvmInfo.getJvmDLLPath(Properties::SERVER_BIN_JVM_DIR)); } else { pVecJvmInfo->erase(pVecJvmInfo->begin() + i); } } // add the additions which are the server JVMs for( unsigned int i=0; i < pAdditionsVecJvmInfo->size(); i++ ) { JVMInfo& jvmInfo = pAdditionsVecJvmInfo->at(i); pVecJvmInfo->push_back( jvmInfo ); } } catch(...) { DEBUG_SHOW( _T("Exception in JVMChooser.breakoutBinJvmDirs()") ); ErrHandler::severeError( _T("Error while separating out the different JVMs (client or server).") ); } }