/* -*- 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 .
*/
#ifdefined _WIN32 // The paths are used in libxml. On Windows, it takes UTF-8 paths.
constexpr rtl_TextEncoding PathEncoding() { return RTL_TEXTENCODING_UTF8; } #else
rtl_TextEncoding PathEncoding() { return osl_getThreadTextEncoding(); } #endif
OString getVendorSettingsPath(OUString const & sURL)
{ if (sURL.isEmpty()) return OString();
OUString sSystemPathSettings; if (osl_getSystemPathFromFileURL(sURL.pData,
& sSystemPathSettings.pData) != osl_File_E_None) throw FrameworkException(
JFW_E_ERROR, "[Java framework] Error in function getVendorSettingsPath (fwkbase.cxx) "_ostr);
OString osSystemPathSettings = OUStringToOString(sSystemPathSettings, PathEncoding()); return osSystemPathSettings;
}
OUString getParamFirstUrl(OUString const & name)
{ // Some parameters can consist of multiple URLs (separated by space // characters, although trim() harmlessly also removes other white-space), // of which only the first is used: return getParam(name).trim().getToken(0, ' ');
}
}//blind namespace
VendorSettings::VendorSettings()
{
OUString xmlDocVendorSettingsFileUrl(BootParams::getVendorSettings()); //Prepare the xml document and context
OString sSettingsPath = getVendorSettingsPath(xmlDocVendorSettingsFileUrl); if (sSettingsPath.isEmpty())
{
OString sMsg("[Java framework] A vendor settings file was not specified." "Check the bootstrap parameter " UNO_JAVA_JFW_VENDOR_SETTINGS "."_ostr);
SAL_WARN( "jfw", sMsg ); throw FrameworkException(JFW_E_CONFIGURATION, sMsg);
} if (sSettingsPath.isEmpty()) return;
if (bJRE && bEnvJRE)
{ throw FrameworkException(
JFW_E_CONFIGURATION, "[Java framework] Both bootstrap parameter "
UNO_JAVA_JFW_JREHOME" and "
UNO_JAVA_JFW_ENV_JREHOME" are set. However only one of them can be set." "Check bootstrap parameters: environment variables, command line " "arguments, rc/ini files for executable and java framework library."_ostr);
} elseif (bEnvJRE)
{ constchar * pJRE = getenv("JAVA_HOME"); if (pJRE == nullptr)
{ throw FrameworkException(
JFW_E_CONFIGURATION, "[Java framework] Both bootstrap parameter "
UNO_JAVA_JFW_ENV_JREHOME" is set, but the environment variable " "JAVA_HOME is not set."_ostr);
}
std::string_view osJRE(pJRE);
OUString usJRE = OStringToOUString(osJRE, osl_getThreadTextEncoding()); if (File::getFileURLFromSystemPath(usJRE, sJRE) != File::E_None) throw FrameworkException(
JFW_E_ERROR, "[Java framework] Error in function BootParams::getJREHome() " "(fwkbase.cxx)."_ostr);
SAL_INFO( "jfw.level2", "Using bootstrap parameter " UNO_JAVA_JFW_ENV_JREHOME " with JAVA_HOME = " << pJRE);
} elseif (getMode() == JFW_MODE_DIRECT && !bJRE)
{ throw FrameworkException(
JFW_E_CONFIGURATION, "[Java framework] The bootstrap parameter "
UNO_JAVA_JFW_ENV_JREHOME" or " UNO_JAVA_JFW_JREHOME " must be set in direct mode."_ostr);
}
OUStringBuffer buf;
sal_Int32 index = 0; do
{
OUString token( o3tl::trim(o3tl::getToken(sParams, 0, ' ', index )) ); if (!token.isEmpty())
{
OUString systemPathElement;
oslFileError rc = osl_getSystemPathFromFileURL(
token.pData, &systemPathElement.pData );
OSL_ASSERT( rc == osl_File_E_None ); if (rc == osl_File_E_None && !systemPathElement.isEmpty())
{ if (buf.getLength() > 0)
buf.append( SAL_PATHSEPARATOR );
buf.append( systemPathElement );
}
}
} while (index >= 0); return buf.makeStringAndClear();
}
OString makeClassPathOption(std::u16string_view sUserClassPath)
{ //Compose the class path
OString sPaths;
OUStringBuffer sBufCP(4096);
// append all user selected jars to the class path if (!sUserClassPath.empty())
sBufCP.append(sUserClassPath);
//append all jar libraries and components to the class path
OUString sAppCP = getApplicationClassPath(); if (!sAppCP.isEmpty())
{ if (!sUserClassPath.empty())
{
sBufCP.append(SAL_PATHSEPARATOR);
}
sBufCP.append(sAppCP);
}
sPaths = OUStringToOString(sBufCP, PathEncoding()); if (sPaths.isEmpty()) { return""_ostr;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.