diff options
Diffstat (limited to 'jvmfwk/source/framework.cxx')
-rw-r--r-- | jvmfwk/source/framework.cxx | 273 |
1 files changed, 93 insertions, 180 deletions
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index a748d77cff37..8d870fd335ae 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -35,7 +35,7 @@ #include "framework.hxx" #include <fwkutil.hxx> #include <elements.hxx> -#include "fwkbase.hxx" +#include <fwkbase.hxx> namespace { @@ -59,8 +59,6 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI osl::MutexGuard guard(jfw::FwkMutex::get()); jfw::VendorSettings aVendorSettings; - std::vector<OUString> vecVendors = - aVendorSettings.getSupportedVendors(); //Add the JavaInfos found by jfw_plugin_getAllJavaInfos to the vector std::vector<std::unique_ptr<JavaInfo>> vecInfo; //get the list of paths to jre locations which have been @@ -68,69 +66,47 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI const jfw::MergedSettings settings; const std::vector<OUString>& vecJRELocations = settings.getJRELocations(); - //Use every plug-in library to get Java installations. - for (auto const & vendor: vecVendors) - { - jfw::VersionInfo versionInfo = - aVendorSettings.getVersionInformation(vendor); + //Use all plug-in libraries to get Java installations. + std::vector<std::unique_ptr<JavaInfo>> arInfos; + std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos; + javaPluginError plerr = jfw_plugin_getAllJavaInfos( + true, + aVendorSettings, + & arInfos, + infos); - //get all installations of one vendor according to minVersion, - //maxVersion and excludeVersions - std::vector<std::unique_ptr<JavaInfo>> arInfos; - std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos; - javaPluginError plerr = jfw_plugin_getAllJavaInfos( - true, - vendor, - versionInfo.sMinVersion, - versionInfo.sMaxVersion, - versionInfo.vecExcludeVersions, - & arInfos, - infos); + if (plerr != javaPluginError::NONE) + return JFW_E_ERROR; - if (plerr != javaPluginError::NONE) - return JFW_E_ERROR; + for (auto & j: arInfos) + vecInfo.push_back(std::move(j)); - for (auto & j: arInfos) - vecInfo.push_back(std::move(j)); + //Check if any plugin can detect JREs at the location + // of the paths added by jfw_addJRELocation + //Check every manually added location + for (auto const & ii: vecJRELocations) + { + std::unique_ptr<JavaInfo> aInfo; + plerr = jfw_plugin_getJavaInfoByPath( + ii, + aVendorSettings, + &aInfo); + if (plerr == javaPluginError::NoJre) + continue; + if (plerr == javaPluginError::FailedVersion) + continue; + else if (plerr != javaPluginError::NONE) + return JFW_E_ERROR; - //Check if the current plugin can detect JREs at the location - // of the paths added by jfw_addJRELocation - //Check every manually added location - for (auto const & ii: vecJRELocations) + // Was this JRE already added? + if (std::none_of( + vecInfo.begin(), vecInfo.end(), + [&aInfo](std::unique_ptr<JavaInfo> const & info) { + return areEqualJavaInfo( + info.get(), aInfo.get()); + })) { - std::unique_ptr<JavaInfo> aInfo; - plerr = jfw_plugin_getJavaInfoByPath( - ii, - vendor, - versionInfo.sMinVersion, - versionInfo.sMaxVersion, - versionInfo.vecExcludeVersions, - &aInfo); - if (plerr == javaPluginError::NoJre) - continue; - if (plerr == javaPluginError::FailedVersion) - continue; - else if (plerr != javaPluginError::NONE) - return JFW_E_ERROR; - - // Was this JRE already added? Different plugins could detect - // the same JRE. Also make sure vecInfo contains only JavaInfos - // for the vendors for which there is a javaSelection/plugins/ - // library entry in the javavendors.xml; jfw_getJavaInfoByPath - // can return a JavaInfo of any vendor: - if ((std::none_of( - vecInfo.begin(), vecInfo.end(), - [&aInfo](std::unique_ptr<JavaInfo> const & info) { - return areEqualJavaInfo( - info.get(), aInfo.get()); - })) - && (std::find( - vecVendors.begin(), vecVendors.end(), - aInfo->sVendor) - != vecVendors.end())) - { - vecInfo.push_back(std::move(aInfo)); - } + vecInfo.push_back(std::move(aInfo)); } } @@ -304,7 +280,6 @@ javaFrameworkError jfw_startVM( g_pJavaVM = pVm; *ppVM = pVm; } - OSL_ASSERT(plerr != javaPluginError::WrongVendor); } catch (const jfw::FrameworkException& e) { @@ -343,25 +318,13 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) // get list of vendors for Java installations jfw::VendorSettings aVendorSettings; - std::vector<OUString> vecVendors = - aVendorSettings.getSupportedVendors(); - - // save vendors and respective version requirements pair-wise in a vector - std::vector<std::pair<OUString, jfw::VersionInfo>> versionInfos; - for (auto const & vendor : vecVendors) - { - jfw::VersionInfo versionInfo = - aVendorSettings.getVersionInformation(vendor); - - versionInfos.emplace_back(vendor, versionInfo); - } std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos; // first inspect Java installation that the JAVA_HOME // environment variable points to (if it is set) if (jfw_plugin_getJavaInfoFromJavaHome( - versionInfos, &aCurrentInfo, infos) + aVendorSettings, &aCurrentInfo, infos) == javaPluginError::NONE) { // compare features @@ -379,7 +342,7 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) { std::vector<std::unique_ptr<JavaInfo>> vecJavaInfosFromPath; if (jfw_plugin_getJavaInfosFromPath( - versionInfos, vecJavaInfosFromPath, infos) + aVendorSettings, vecJavaInfosFromPath, infos) == javaPluginError::NONE) { for (auto & pJInfo: vecJavaInfosFromPath) @@ -405,31 +368,20 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) // if no suitable Java installation has been found yet: - // first iterate over all vendors to find a suitable Java installation, + // first use jfw_plugin_getAllJavaInfos to find a suitable Java installation, // then try paths that have been added manually if (!bInfoFound) { - //Use every vendor to get Java installations. At the first usable - //Java the loop will break - for (auto const & vendor : vecVendors) + //get all installations + std::vector<std::unique_ptr<JavaInfo>> arInfos; + javaPluginError plerr = jfw_plugin_getAllJavaInfos( + false, + aVendorSettings, + & arInfos, + infos); + + if (plerr == javaPluginError::NONE) { - jfw::VersionInfo versionInfo = - aVendorSettings.getVersionInformation(vendor); - - //get all installations of one vendor according to minVersion, - //maxVersion and excludeVersions - std::vector<std::unique_ptr<JavaInfo>> arInfos; - javaPluginError plerr = jfw_plugin_getAllJavaInfos( - false, - vendor, - versionInfo.sMinVersion, - versionInfo.sMaxVersion, - versionInfo.vecExcludeVersions, - & arInfos, - infos); - - if (plerr != javaPluginError::NONE) - continue; //iterate over all installations to find the best which has //all features for (auto & pJInfo: arInfos) @@ -442,7 +394,6 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) //the just found Java implements all required features //currently there is only accessibility!!! aCurrentInfo = std::move(pJInfo); - bInfoFound = true; break; } else if (!aCurrentInfo) @@ -452,12 +403,8 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) aCurrentInfo = std::move(pJInfo); } } - - if (bInfoFound) - break; - //All Java installations found by the current plug-in lib - //do not provide the required features. Try the next plug-in } + if (!aCurrentInfo) {//The plug-ins did not find a suitable Java. Now try the paths which have been //added manually. @@ -466,53 +413,41 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) //node.loadFromSettings(); const std::vector<OUString> & vecJRELocations = settings.getJRELocations(); - //use every plug-in to determine the JavaInfo objects - for (auto const & vendor : vecVendors) + //use all plug-ins to determine the JavaInfo objects + for (auto const & JRELocation : vecJRELocations) { - jfw::VersionInfo versionInfo = - aVendorSettings.getVersionInformation(vendor); - - for (auto const & JRELocation : vecJRELocations) + std::unique_ptr<JavaInfo> aInfo; + javaPluginError err = jfw_plugin_getJavaInfoByPath( + JRELocation, + aVendorSettings, + &aInfo); + if (err == javaPluginError::NoJre) + continue; + if (err == javaPluginError::FailedVersion) + continue; + else if (err !=javaPluginError::NONE) + return JFW_E_ERROR; + + if (aInfo) { - std::unique_ptr<JavaInfo> aInfo; - javaPluginError err = jfw_plugin_getJavaInfoByPath( - JRELocation, - vendor, - versionInfo.sMinVersion, - versionInfo.sMaxVersion, - versionInfo.vecExcludeVersions, - &aInfo); - if (err == javaPluginError::NoJre) - continue; - if (err == javaPluginError::FailedVersion) - continue; - else if (err !=javaPluginError::NONE) - return JFW_E_ERROR; - - if (aInfo) + // compare features + // If the user does not require any features (nFeatureFlags = 0) + // then the first installation is used + if ((aInfo->nFeatures & nFeatureFlags) == nFeatureFlags) { - // compare features - // If the user does not require any features (nFeatureFlags = 0) - // then the first installation is used - if ((aInfo->nFeatures & nFeatureFlags) == nFeatureFlags) - { - //the just found Java implements all required features - //currently there is only accessibility!!! - aCurrentInfo = std::move(aInfo); - bInfoFound = true; - break; - } - else if (!aCurrentInfo) - { - // We remember the very first installation in - // aCurrentInfo: - aCurrentInfo = std::move(aInfo); - } + //the just found Java implements all required features + //currently there is only accessibility!!! + aCurrentInfo = std::move(aInfo); + break; } - }//end iterate over paths - if (bInfoFound) - break; - }// end iterate plug-ins + else if (!aCurrentInfo) + { + // We remember the very first installation in + // aCurrentInfo: + aCurrentInfo = std::move(aInfo); + } + } + }//end iterate over paths } } if (aCurrentInfo) @@ -623,43 +558,21 @@ javaFrameworkError jfw_getJavaInfoByPath(OUString const & pPath, std::unique_ptr osl::MutexGuard guard(jfw::FwkMutex::get()); jfw::VendorSettings aVendorSettings; - std::vector<OUString> vecVendors = - aVendorSettings.getSupportedVendors(); - //Use every plug-in library to determine if the path represents a - //JRE. If a plugin recognized it then the loop will break - for (auto const & vendor : vecVendors) - { - jfw::VersionInfo versionInfo = - aVendorSettings.getVersionInformation(vendor); - - //ask the plugin if this is a JRE. - //If so check if it meets the version requirements. - //Only if it does return a JavaInfo - javaPluginError plerr = jfw_plugin_getJavaInfoByPath( - pPath, - vendor, - versionInfo.sMinVersion, - versionInfo.sMaxVersion, - versionInfo.vecExcludeVersions, - ppInfo); + //ask all plugins if this is a JRE. + //If so check if it meets the version requirements. + //Only if it does return a JavaInfo + javaPluginError plerr = jfw_plugin_getJavaInfoByPath( + pPath, + aVendorSettings, + ppInfo); - if (plerr == javaPluginError::NONE) - { - break; - } - else if(plerr == javaPluginError::FailedVersion) - {//found JRE but it has the wrong version - ppInfo->reset(); - errcode = JFW_E_FAILED_VERSION; - break; - } - else if (plerr == javaPluginError::NoJre) - {// plugin does not recognize this path as belonging to JRE - continue; - } - OSL_ASSERT(false); + if(plerr == javaPluginError::FailedVersion) + {//found JRE but it has the wrong version + ppInfo->reset(); + errcode = JFW_E_FAILED_VERSION; } + OSL_ASSERT(plerr == javaPluginError::NONE || plerr == javaPluginError::NoJre); if (!*ppInfo && errcode != JFW_E_FAILED_VERSION) errcode = JFW_E_NOT_RECOGNIZED; } |