diff options
Diffstat (limited to 'jvmfwk/inc')
-rw-r--r-- | jvmfwk/inc/fwkbase.hxx | 134 | ||||
-rw-r--r-- | jvmfwk/inc/libxmlutil.hxx | 98 | ||||
-rw-r--r-- | jvmfwk/inc/vendorplugin.hxx | 94 |
3 files changed, 254 insertions, 72 deletions
diff --git a/jvmfwk/inc/fwkbase.hxx b/jvmfwk/inc/fwkbase.hxx new file mode 100644 index 000000000000..8fe077b79a28 --- /dev/null +++ b/jvmfwk/inc/fwkbase.hxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_JVMFWK_INC_FWKBASE_HXX +#define INCLUDED_JVMFWK_INC_FWKBASE_HXX + +#include <sal/config.h> + +#include <boost/optional.hpp> + +#include <rtl/ustring.hxx> +#include "elements.hxx" +#include "libxmlutil.hxx" + +namespace jfw +{ + +class VendorSettings +{ + OUString m_xmlDocVendorSettingsFileUrl; + CXmlDocPtr m_xmlDocVendorSettings; + CXPathContextPtr m_xmlPathContextVendorSettings; + +public: + VendorSettings(); + + boost::optional<VersionInfo> getVersionInformation(const OUString & sVendor) const; + + ::std::vector< OUString> getSupportedVendors() const; +}; + +/* The class offers functions to retrieve verified bootstrap parameters. + */ +namespace BootParams +{ + +/* Gets the file URL to the JRE which has been determined by the + bootstrap parameter UNO_JAVA_JFW_JREHOME or UNO_JAVA_JFW_ENV_JREHOME. + + In direct mode either of them must be set. If not an exception is thrown. +*/ +OUString getJREHome(); + +::std::vector< OString> getVMParameters(); + +OUString getUserData(); + +OUString getSharedData(); + +/* returns the file URL to the vendor settings xml file. + */ +OUString getVendorSettings(); + +/* User the parameter UNO_JAVA_JFW_CLASSPATH and UNO_JAVA_JFW_ENV_CLASSPATH + to compose a classpath + */ +OString getClasspath(); + +OUString getClasspathUrls(); + +} //end namespace + + +enum JFW_MODE +{ + JFW_MODE_APPLICATION, + + JFW_MODE_DIRECT +}; + +JFW_MODE getMode(); + +/** creates the -Djava.class.path option with the complete classpath, including + the paths which are set by UNO_JAVA_JFW_CLASSPATH_URLS. + */ +OString makeClassPathOption(OUString const & sUserClassPath); + +OString getSettingsPath( const OUString & sURL); + +/** Get the system path to the javasettings.xml + Converts the URL returned from getUserSettingsURL to a + Systempath. An empty string is returned if the file + does not exist. + @throws FrameworkException + */ +OString getUserSettingsPath(); + +/** Returns the system path of the share settings file. + Returns a valid string or throws an exception. + @throws FrameworkException + */ +OString getSharedSettingsPath(); + +/* returns a valid string or throws an exception. + @throws FrameworkException + */ +OString getVendorSettingsPath(); + +/** Called from writeJavaInfoData. It sets the process identifier. When +java is to be started, then the current id is compared to the one set by +this function. If they are identical then the Java was selected in the +same process. If that Java needs a prepared environment, such as a +LD_LIBRARY_PATH, then it must not be started in this process. +*/ +void setJavaSelected(); + +/** Determines if the currently selected Java was set in this process. + + @see setProcessId() + */ +bool wasJavaSelectedInSameProcess(); +/* Only for application mode. + */ +OUString getApplicationClassPath(); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/jvmfwk/inc/libxmlutil.hxx b/jvmfwk/inc/libxmlutil.hxx new file mode 100644 index 000000000000..078d285ac78f --- /dev/null +++ b/jvmfwk/inc/libxmlutil.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_JVMFWK_INC_LIBXMLUTIL_HXX +#define INCLUDED_JVMFWK_INC_LIBXMLUTIL_HXX + +#include <libxml/parser.h> +#include <libxml/xpath.h> +#include <rtl/ustring.hxx> + +namespace jfw +{ +class CXPathObjectPtr +{ + xmlXPathObject* _object; + CXPathObjectPtr & operator = (const CXPathObjectPtr&) = delete; + CXPathObjectPtr(const CXPathObjectPtr&) = delete; +public: + CXPathObjectPtr(); + ~CXPathObjectPtr(); + /** Takes ownership of xmlXPathObject + */ + CXPathObjectPtr & operator = (xmlXPathObject* pObj); + xmlXPathObject* operator -> () { return _object;} + operator xmlXPathObject* () const { return _object;} +}; + + +class CXPathContextPtr +{ + xmlXPathContext* _object; + + CXPathContextPtr(const jfw::CXPathContextPtr&) = delete; + CXPathContextPtr & operator = (const CXPathContextPtr&) = delete; +public: + CXPathContextPtr(); + explicit CXPathContextPtr(xmlXPathContextPtr aContext); + CXPathContextPtr & operator = (xmlXPathContextPtr pObj); + ~CXPathContextPtr(); + operator xmlXPathContext* () const { return _object;} +}; + + +class CXmlDocPtr +{ + xmlDoc* _object; + + CXmlDocPtr(const CXmlDocPtr&) = delete; + +public: + CXmlDocPtr & operator = (const CXmlDocPtr&); + CXmlDocPtr(); + explicit CXmlDocPtr(xmlDoc* aDoc); + /** Takes ownership of xmlDoc + */ + CXmlDocPtr & operator = (xmlDoc* pObj); + ~CXmlDocPtr(); + operator xmlDoc* () const { return _object;} +}; + + +class CXmlCharPtr +{ + xmlChar* _object; + + CXmlCharPtr(const CXmlCharPtr&) = delete; + CXmlCharPtr & operator = (const CXmlCharPtr&) = delete; +public: + CXmlCharPtr(); + explicit CXmlCharPtr(xmlChar* aDoc); + explicit CXmlCharPtr(const OUString &); + ~CXmlCharPtr(); + CXmlCharPtr & operator = (xmlChar* pObj); + operator xmlChar* () const { return _object;} + operator OUString (); + operator OString () { return OString(reinterpret_cast<sal_Char*>(_object));} +}; + + +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/jvmfwk/inc/vendorplugin.hxx b/jvmfwk/inc/vendorplugin.hxx index f370f1123375..0aa6d84276e3 100644 --- a/jvmfwk/inc/vendorplugin.hxx +++ b/jvmfwk/inc/vendorplugin.hxx @@ -28,10 +28,10 @@ #include <memory> #include <vector> -#include <utility> -#include "elements.hxx" #include "vendorbase.hxx" +namespace jfw { class VendorSettings; } + /** @file <p> @@ -56,7 +56,6 @@ enum class javaPluginError WrongVersionFormat, FailedVersion, NoJre, - WrongVendor, WrongArch, VmCreationFailed }; @@ -64,26 +63,14 @@ enum class javaPluginError /** obtains information about installations of Java Runtime Environments (JREs). - <p>The function gathers information about available JREs which have the same - vendor as determined by the <code>sVendor</code> parameter. Only information + <p>The function gathers information about available JREs. Only information about those JREs which match the version requirements are returned. These - requirements are specified by the parameters <code>sMinVersion</code>, - <code>sMaxVersion</code> and <code>arExcludeList</code>. + requirements are specified by the parameter <code>vendorSettings</code>. </p> <p> The JavaInfo structures returned in <code>parJavaInfo</code> should be ordered according to their version. The one, representing a JRE with the highest version should be the first in the array. </p> - @param sVendor - [in] only JREs from this vendor are examined. This parameter always contains - a vendor string. That is, the string it is not empty. - @param sMinVersion - [in] represents the minimum version of a JRE. The string can be empty. - @param sMaxVersion - [in] represents the maximum version of a JRE. The string can be empty. - @param arExcludeList - [in] contains a list of "bad" versions. JREs which have one of these - versions must not be returned by this function. @param parJavaInfo [out] if the function runs successfully then <code>parJavaInfo</code> contains on return a vector of pointers to <code>JavaInfo</code> objects. @@ -91,40 +78,25 @@ enum class javaPluginError @return javaPluginError::NONE the function ran successfully.</br> javaPluginError::Error an error occurred during execution.</br> - javaPluginError::InvalidArg an argument was not valid.</br> javaPluginError::WrongVersionFormat the version strings in - <code>sMinVersion,sMaxVersion,arExcludeList</code> are not recognized as valid + <code>vendorSettings</code> are not recognized as valid version strings. */ javaPluginError jfw_plugin_getAllJavaInfos( bool checkJavaHomeAndPath, - OUString const& sVendor, - OUString const& sMinVersion, - OUString const& sMaxVersion, - std::vector<OUString> const & arExcludeList, + jfw::VendorSettings const & vendorSettings, std::vector<std::unique_ptr<JavaInfo>> * parJavaInfo, std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos); /** obtains information for a JRE at a given location. - <p>If the given location belongs to a JRE whoose vendor matches the - sVendor argument and the JRE has a version which meets the requirements as - specified by <code>sMinVersion, sMaxVersion, arExcludeList</code> then - this function shall return a JavaInfo object for this JRE if this implementation - supports this vendor.</p> + <p>If the given location belongs to a JRE + and the JRE has a version which meets the requirements as + specified by <code>vendorSettings</code> then + this function shall return a JavaInfo object for this JRE.</p> @param sLocation [in] a file URL to the directory of the JRE. - @param sVendor - [in] a name of a vendor. This parameter always contains - a vendor string. That is, the string it is not empty. - @param sMinVersion - [in] represents the minimum version of a JRE. - @param sMaxVersion - [in] represents the maximum version of a JRE. - @param arExcludeList - [in] contains a list of "bad" versions. JREs which have one of these - versions must not be returned by this function. @param ppInfo [out] if the function runs successfully then <code>ppInfo</code> contains on return a pointer to a <code>JavaInfo</code> object. @@ -134,37 +106,23 @@ javaPluginError jfw_plugin_getAllJavaInfos( javaPluginError::Error an error occurred during execution.</br> javaPluginError::InvalidArg an argument was not valid. For example, sLocation is an empty string.</br> - javaPluginError::WrongVersionFormat the version strings in - <code>sMinVersion,sMaxVersion,arExcludeList</code> are not recognized as valid - version strings. javaPluginError::FailedVersion there is a JRE at the given location but it does not meet the version requirements. - javaPluginError::NoJre no JRE could be detected at the given location. However, that - does not mean necessarily that there is no JRE. There could be a JRE but it has - a vendor which is not supported by this API implementation. + javaPluginError::NoJre no JRE could be detected at the given location. */ javaPluginError jfw_plugin_getJavaInfoByPath( OUString const& sLocation, - OUString const& sVendor, - OUString const& sMinVersion, - OUString const& sMaxVersion, - std::vector<OUString> const &arExcludeList, + jfw::VendorSettings const & vendorSettings, std::unique_ptr<JavaInfo> * ppInfo); /** obtains information for a JRE referenced by the JAVA_HOME environment variable. - <p>If the JAVA_HOME environment variable is set and points to a JRE whoose vendor - matches the requirements given by vecVendorInfos (i.e. it has a vendor that is - given in vecVendorInfos and the version requirements for the vendor are met), + <p>If the JAVA_HOME environment variable is set and points to a JRE that + matches the requirements given by vendorSettings (i.e. + the version requirements, if any, for the vendor are met), then this function shall return a JavaInfo object for this JRE.</p> - @param vecVendorInfos - [in] vector specifying the vendor and version requirements that the JRE must fulfill. - The vector contains pairs of vendors and the respective version requirements - for those vendors. The JRE must support the requirements of one given pair in the - vector (i.e. it must be of one of the vendors and meet the version requirements - - minVersion, maxVersion, excludeVersions - for that specific vendor). @param ppInfo [out] if the JAVA_HOME environment variable is set and points to a suitable JRE, then <code>ppInfo</code> contains @@ -173,12 +131,12 @@ javaPluginError jfw_plugin_getJavaInfoByPath( @return javaPluginError::NONE the function ran successfully.</br> javaPluginError::NoJre no suitable JRE could be detected at the given location. However, that - does not mean necessarily that there is no JRE. There could be a JRE but it has - a vendor which is not supported by this API implementation or it does not + does not mean necessarily that there is no JRE. There could be a JRE but + it does not meet the version requirements. */ javaPluginError jfw_plugin_getJavaInfoFromJavaHome( - std::vector<std::pair<OUString, jfw::VersionInfo>> const& vecVendorInfos, + jfw::VendorSettings const & vendorSettings, std::unique_ptr<JavaInfo> * ppInfo, std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos); @@ -187,20 +145,14 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome( whose executable is in the PATH. <p>The function gathers information about available JREs which are on the PATH - (PATH environment variable) and meet the vendor and version requirements given by - <code>vecVendorInfos</code> (i.e. they have a vendor that is given in - <code>vecVendorInfos</code> and the version requirements for the vendor are met). + (PATH environment variable) and meet the version requirements given by + <code>vendorSettings</code> (i.e. + the version requirements, if any, for the vendor are met). </p> <p> The JavaInfo structures returned in <code>vecJavaInfosFromPath</code> should be ordered according to their occurrence in the PATH. The one that is the first one on the PATH is also the first element in the vector.</p> - @param vecVendorInfos - [in] vector specifying the vendor and version requirements that the JRE must fulfill. - The vector contains pairs of vendors and the respective version requirements - for those vendors. The JRE must support the requirements of one given pair in the - vector (i.e. it must be of one of the vendors and meet the version requirements - - minVersion, maxVersion, excludeVersions - for that specific vendor). @param vecJavaInfosFromPath [out] if the function runs successfully then <code>vecJavaInfosFromPath</code> contains on return a vector of pointers to <code>JavaInfo</code> objects. @@ -216,7 +168,7 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome( */ javaPluginError jfw_plugin_getJavaInfosFromPath( - std::vector<std::pair<OUString, jfw::VersionInfo>> const& vecVendorInfos, + jfw::VendorSettings const & vendorSettings, std::vector<std::unique_ptr<JavaInfo>> & vecJavaInfosFromPath, std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos); @@ -256,8 +208,6 @@ javaPluginError jfw_plugin_getJavaInfosFromPath( @return javaPluginError::NONE the function ran successfully.</br> javaPluginError::Error an error occurred during execution.</br> - javaPluginError::WrongVendor the <code>JavaInfo</code> object was not created - in by this library and the VM cannot be started.</br> JFW_PLUGIN_E_VM_CREATION_FAILED a VM could not be created. The error was caused by the JRE. */ |