diff options
author | Joachim Lingner <jl@openoffice.org> | 2004-04-23 07:40:39 +0000 |
---|---|---|
committer | Joachim Lingner <jl@openoffice.org> | 2004-04-23 07:40:39 +0000 |
commit | 99eb720ef1526a525a6e4d3c41fd1437b5127662 (patch) | |
tree | 2ae09876719b6e961e16c2fcbb17ce76c4a12965 /jvmfwk | |
parent | 8fb8381bf81e4fb58699b589ede7b34ceaaae3f1 (diff) |
#i20052# fixed bug when writing JavaInfo element and jfw_findAndSelectJRE now uses also manually selected paths
Diffstat (limited to 'jvmfwk')
-rw-r--r-- | jvmfwk/inc/jvmfwk/framework.h | 12 | ||||
-rw-r--r-- | jvmfwk/source/elements.cxx | 5 | ||||
-rw-r--r-- | jvmfwk/source/framework.cxx | 91 |
3 files changed, 98 insertions, 10 deletions
diff --git a/jvmfwk/inc/jvmfwk/framework.h b/jvmfwk/inc/jvmfwk/framework.h index e52cebc4cd7e..aa7a0520fa84 100644 --- a/jvmfwk/inc/jvmfwk/framework.h +++ b/jvmfwk/inc/jvmfwk/framework.h @@ -2,9 +2,9 @@ * * $RCSfile: framework.h,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jl $ $Date: 2004-04-22 12:52:38 $ + * last change: $Author: jl $ $Date: 2004-04-23 08:40:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -230,7 +230,13 @@ javaFrameworkError SAL_CALL jfw_isVMRunning(sal_Bool *bRunning); JREs can be provided by different vendors. In order to find the JREs of a certain vendor a plug-in library must be provided. There must be only one library for one vendor. The names of locations of those libraries have to - be put into the javavendors.xml file.</p> + be put into the javavendors.xml file.<br/> + The function uses the plug-in libraries to obtain information about JRE + installation and checks if they there is one among them that supports + a set of features (currently only accessibilty is possible). If none was + found then it also uses a list of paths, which have been registered + by <code>jfw_addJRELocation</code> or <code>jfw_setJRELocations</code> + to find JREs. Found JREs are examined in the same way.</p> <p> A JRE installation is only selected if it meets the version requirements. Information about the selected JRE are made persistent so that diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index 7f19697ff7c8..4260578bf0e3 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -2,9 +2,9 @@ * * $RCSfile: elements.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jl $ $Date: 2004-04-21 09:30:35 $ + * last change: $Author: jl $ $Date: 2004-04-23 08:40:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -712,6 +712,7 @@ CNodeJavaInfo::CNodeJavaInfo(const JavaInfo * pInfo, { if (pInfo != NULL) { + m_bEmptyNode = false; sAttrVendorUpdate = sUpdated; sVendor = pInfo->sVendor; sLocation = pInfo->sLocation; diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 1bfdd41dfd22..adf60c1778a6 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -2,9 +2,9 @@ * * $RCSfile: framework.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jl $ $Date: 2004-04-22 12:52:40 $ + * last change: $Author: jl $ $Date: 2004-04-23 08:40:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -134,7 +134,7 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi if (errcode != JFW_E_NONE) return errcode; - const std::vector<rtl::OString> vecJRELocations = + const std::vector<rtl::OString>& vecJRELocations = node.getJRELocations(); //Use every plug-in library to get Java installations. typedef std::vector<jfw::PluginLibrary>::const_iterator ci_pl; @@ -413,7 +413,12 @@ javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOpti return JFW_E_NONE; } - +/** We do not use here jfw_findAllJREs and then check if a JavaInfo + meets the requirements, because that means using all plug-ins, which + may take quite a while. The implementation uses one plug-in and if + it already finds a suitable JRE then it is done and does not need to + load another plug-in + */ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) { osl::MutexGuard guard(jfw::getFwkMutex()); @@ -444,7 +449,6 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) if (errcode != JFW_E_NONE) return errcode; - //Use every plug-in library to get Java installations. At the first usable //Java the loop will break typedef std::vector<jfw::PluginLibrary>::const_iterator ci_pl; @@ -520,6 +524,83 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) //All Java installations found by the current plug-in lib //do not provide the required features. Try the next plug-in } + if ((JavaInfo*) aCurrentInfo == NULL) + {//The plug-ins did not find a suitable Java. Now try the paths which have been + //added manually. + //get the list of paths to jre locations which have been added manually + jfw::CNodeJava node; + errcode = node.loadFromSettings(); + if (errcode != JFW_E_NONE) + return errcode; + const std::vector<rtl::OString> & vecJRELocations = + node.getJRELocations(); + //use every plug-in to determine the JavaInfo objects + bool bInfoFound = false; + for (ci_pl i = vecPlugins.begin(); i != vecPlugins.end(); i++) + { + const jfw::PluginLibrary & library = *i; + jfw::VersionInfo versionInfo; + errcode = jfw::getVersionInformation(doc, context, library.sVendor, + & versionInfo); + if (errcode != JFW_E_NONE) + return JFW_E_CONFIG_READWRITE; + osl::Module pluginLib(library.sPath); + if (pluginLib.is() == sal_False) + return JFW_E_NO_PLUGIN; + //Check if the current plugin can detect JREs at the location + // of the paths added by jfw_setJRELocations or jfw_addJRELocation + //get the function from the plugin + getJavaInfoByPath_ptr getJavaInfoByPathFunc = + (getJavaInfoByPath_ptr) pluginLib.getSymbol( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("getJavaInfoByPath"))); + + OSL_ASSERT(getJavaInfoByPathFunc); + if (getJavaInfoByPathFunc == NULL) + return JFW_E_ERROR; + + typedef std::vector<rtl::OString>::const_iterator citLoc; + for (citLoc i = vecJRELocations.begin(); + i != vecJRELocations.end(); i++) + { + rtl::OUString sLocation = + rtl::OStringToOUString(*i, RTL_TEXTENCODING_UTF8); + JavaInfo* pInfo = NULL; + javaPluginError err = (*getJavaInfoByPathFunc)( + sLocation.pData, + versionInfo.sMinVersion.pData, + versionInfo.sMaxVersion.pData, + versionInfo.getExcludeVersions(), + versionInfo.getExcludeVersionSize(), + & pInfo); + if (err == JFW_PLUGIN_E_NO_JRE) + continue; + if (err == JFW_PLUGIN_E_FAILED_VERSION) + continue; + else if (err !=JFW_PLUGIN_E_NONE) + return JFW_E_ERROR; + + if (pInfo) + { + //We remember the very first installation in aCurrentInfo + if (aCurrentInfo.getLocation().getLength() == 0) + aCurrentInfo = pInfo; + // compare features + // If the user does not require any features (nFeatureFlags = 0) + // then the first installation is used + if ((pInfo->nFeatures & nFeatureFlags) == nFeatureFlags) + { + //the just found Java implements all required features + //currently there is only accessibility!!! + aCurrentInfo = pInfo; + bInfoFound = true; + break; + } + } + }//end iterate over paths + if (bInfoFound == true) + break; + }// end iterate plug-ins + } if ((JavaInfo*) aCurrentInfo) { rtl::OString sSettings = jfw::getUserSettingsPath(); |