2010-10-14 01:30:07 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-11-09 07:00:36 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 04:27:08 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-11-09 07:00:36 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-11-09 07:00:36 -06:00
|
|
|
*
|
2008-04-11 04:27:08 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-11-09 07:00:36 -06:00
|
|
|
*
|
2008-04-11 04:27:08 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-11-09 07:00:36 -06:00
|
|
|
*
|
2008-04-11 04:27:08 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-11-09 07:00:36 -06:00
|
|
|
*
|
2008-04-11 04:27:08 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-11-09 07:00:36 -06:00
|
|
|
*
|
2008-04-11 04:27:08 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-11-09 07:00:36 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 11:48:06 -05:00
|
|
|
|
2004-11-09 07:00:36 -06:00
|
|
|
#include "rtl/ustring.hxx"
|
|
|
|
#include "rtl/ustrbuf.hxx"
|
|
|
|
#include "rtl/uri.hxx"
|
|
|
|
#include "osl/thread.hxx"
|
|
|
|
#include "osl/process.h"
|
|
|
|
#include "libxml/xpathInternals.h"
|
|
|
|
#include "osl/file.hxx"
|
|
|
|
#include "osl/module.hxx"
|
|
|
|
#include "framework.hxx"
|
|
|
|
#include "fwkutil.hxx"
|
|
|
|
#include "elements.hxx"
|
|
|
|
#include "fwkbase.hxx"
|
|
|
|
|
|
|
|
using namespace osl;
|
2011-03-02 14:53:12 -06:00
|
|
|
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::rtl::OUStringBuffer;
|
|
|
|
using ::rtl::OString;
|
|
|
|
using ::rtl::OUStringToOString;
|
|
|
|
using ::rtl::OStringToOUString;
|
2004-11-09 07:00:36 -06:00
|
|
|
#define JAVASETTINGS "javasettings"
|
|
|
|
#define JAVASETTINGS_XML "javasettings.xml"
|
|
|
|
#define VENDORSETTINGS "javavendors.xml"
|
|
|
|
|
|
|
|
#define UNO_JAVA_JFW_PARAMETER "UNO_JAVA_JFW_PARAMETER_"
|
|
|
|
#define UNO_JAVA_JFW_JREHOME "UNO_JAVA_JFW_JREHOME"
|
|
|
|
#define UNO_JAVA_JFW_ENV_JREHOME "UNO_JAVA_JFW_ENV_JREHOME"
|
|
|
|
#define UNO_JAVA_JFW_CLASSPATH "UNO_JAVA_JFW_CLASSPATH"
|
|
|
|
#define UNO_JAVA_JFW_ENV_CLASSPATH "UNO_JAVA_JFW_ENV_CLASSPATH"
|
|
|
|
#define UNO_JAVA_JFW_CLASSPATH_URLS "UNO_JAVA_JFW_CLASSPATH_URLS"
|
|
|
|
#define UNO_JAVA_JFW_PARAMETERS "UNO_JAVA_JFW_PARAMETERS"
|
|
|
|
#define UNO_JAVA_JFW_VENDOR_SETTINGS "UNO_JAVA_JFW_VENDOR_SETTINGS"
|
|
|
|
#define UNO_JAVA_JFW_USER_DATA "UNO_JAVA_JFW_USER_DATA"
|
|
|
|
#define UNO_JAVA_JFW_SHARED_DATA "UNO_JAVA_JFW_SHARED_DATA"
|
2007-06-13 01:57:54 -05:00
|
|
|
#define UNO_JAVA_JFW_INSTALL_DATA "UNO_JAVA_JFW_INSTALL_DATA"
|
|
|
|
#define UNO_JAVA_JFW_INSTALL_EXPIRE "UNO_JAVA_JFW_INSTALL_EXPIRE"
|
|
|
|
#define DEFAULT_INSTALL_EXPIRATION 3600
|
2004-11-09 07:00:36 -06:00
|
|
|
|
|
|
|
namespace jfw
|
|
|
|
{
|
|
|
|
bool g_bJavaSet = false;
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
rtl::OString getVendorSettingsPath(rtl::OUString const & sURL)
|
|
|
|
{
|
2012-01-04 07:38:41 -06:00
|
|
|
if (sURL.isEmpty())
|
2007-06-13 01:57:54 -05:00
|
|
|
return rtl::OString();
|
|
|
|
rtl::OUString sSystemPathSettings;
|
|
|
|
if (osl_getSystemPathFromFileURL(sURL.pData,
|
|
|
|
& sSystemPathSettings.pData) != osl_File_E_None)
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_ERROR,
|
|
|
|
rtl::OString("[Java framework] Error in function "
|
2011-03-24 09:35:20 -05:00
|
|
|
"getVendorSettingsPath (fwkbase.cxx) "));
|
2007-06-13 01:57:54 -05:00
|
|
|
rtl::OString osSystemPathSettings =
|
|
|
|
rtl::OUStringToOString(sSystemPathSettings,osl_getThreadTextEncoding());
|
|
|
|
return osSystemPathSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString getParam(const char * name)
|
|
|
|
{
|
|
|
|
rtl::OUString retVal;
|
|
|
|
if (Bootstrap::get()->getFrom(rtl::OUString::createFromAscii(name), retVal))
|
|
|
|
{
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
rtl::OString sValue = rtl::OUStringToOString(retVal, osl_getThreadTextEncoding());
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter %s = %s.\n",
|
|
|
|
name, sValue.getStr());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2008-03-18 06:22:17 -05:00
|
|
|
rtl::OUString getParamFirstUrl(const char * 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:
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
return getParam(name).trim().getToken(0, ' ', i);
|
|
|
|
}
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
}//blind namespace
|
|
|
|
|
2005-06-17 04:12:18 -05:00
|
|
|
|
|
|
|
VendorSettings::VendorSettings():
|
|
|
|
m_xmlDocVendorSettingsFileUrl(BootParams::getVendorSettings())
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
OString sMsgExc("[Java framework] Error in constructor "
|
|
|
|
"VendorSettings::VendorSettings() (fwkbase.cxx)");
|
2004-12-16 04:47:49 -06:00
|
|
|
//Prepare the xml document and context
|
2007-06-13 01:57:54 -05:00
|
|
|
OString sSettingsPath = getVendorSettingsPath(m_xmlDocVendorSettingsFileUrl);
|
2012-01-04 07:38:41 -06:00
|
|
|
if (sSettingsPath.isEmpty())
|
2004-12-16 04:47:49 -06:00
|
|
|
{
|
|
|
|
OString sMsg("[Java framework] A vendor settings file was not specified."
|
|
|
|
"Check the bootstrap parameter " UNO_JAVA_JFW_VENDOR_SETTINGS ".");
|
2011-03-12 05:10:42 -06:00
|
|
|
OSL_FAIL(sMsg.getStr());
|
2004-12-16 04:47:49 -06:00
|
|
|
throw FrameworkException(JFW_E_CONFIGURATION, sMsg);
|
|
|
|
}
|
2012-01-04 07:38:41 -06:00
|
|
|
if (!sSettingsPath.isEmpty())
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
m_xmlDocVendorSettings = xmlParseFile(sSettingsPath.getStr());
|
|
|
|
if (m_xmlDocVendorSettings == NULL)
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_ERROR,
|
|
|
|
OString("[Java framework] Error while parsing file: ")
|
|
|
|
+ sSettingsPath + OString("."));
|
|
|
|
|
|
|
|
m_xmlPathContextVendorSettings = xmlXPathNewContext(m_xmlDocVendorSettings);
|
|
|
|
int res = xmlXPathRegisterNs(
|
|
|
|
m_xmlPathContextVendorSettings, (xmlChar*) "jf",
|
|
|
|
(xmlChar*) NS_JAVA_FRAMEWORK);
|
|
|
|
if (res == -1)
|
|
|
|
throw FrameworkException(JFW_E_ERROR, sMsgExc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<PluginLibrary> VendorSettings::getPluginData()
|
|
|
|
{
|
|
|
|
OString sExcMsg("[Java framework] Error in function VendorSettings::getVendorPluginURLs "
|
|
|
|
"(fwkbase.cxx).");
|
|
|
|
std::vector<PluginLibrary> vecPlugins;
|
|
|
|
CXPathObjectPtr result(xmlXPathEvalExpression(
|
|
|
|
(xmlChar*)"/jf:javaSelection/jf:plugins/jf:library",
|
|
|
|
m_xmlPathContextVendorSettings));
|
|
|
|
if (xmlXPathNodeSetIsEmpty(result->nodesetval))
|
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
|
|
|
//get the values of the library elements + vendor attribute
|
|
|
|
xmlNode* cur = result->nodesetval->nodeTab[0];
|
|
|
|
|
|
|
|
while (cur != NULL)
|
|
|
|
{
|
|
|
|
//between library elements are also text elements
|
|
|
|
if (cur->type == XML_ELEMENT_NODE)
|
|
|
|
{
|
|
|
|
CXmlCharPtr sAttrVendor(xmlGetProp(cur, (xmlChar*) "vendor"));
|
|
|
|
CXmlCharPtr sTextLibrary(
|
|
|
|
xmlNodeListGetString(m_xmlDocVendorSettings,
|
|
|
|
cur->xmlChildrenNode, 1));
|
|
|
|
PluginLibrary plugin;
|
|
|
|
OString osVendor((sal_Char*)(xmlChar*) sAttrVendor);
|
|
|
|
plugin.sVendor = OStringToOUString(osVendor, RTL_TEXTENCODING_UTF8);
|
|
|
|
|
|
|
|
//create the file URL to the library
|
2005-06-17 04:12:18 -05:00
|
|
|
OUString sUrl = findPlugin(
|
|
|
|
m_xmlDocVendorSettingsFileUrl, sTextLibrary);
|
2012-01-04 07:38:41 -06:00
|
|
|
if (sUrl.isEmpty())
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
OString sPlugin = OUStringToOString(
|
|
|
|
sTextLibrary, osl_getThreadTextEncoding());
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_CONFIGURATION,
|
|
|
|
"[Java framework] The file: " + sPlugin + " does not exist.");
|
|
|
|
}
|
|
|
|
plugin.sPath = sUrl;
|
|
|
|
|
|
|
|
vecPlugins.push_back(plugin);
|
|
|
|
}
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
return vecPlugins;
|
|
|
|
}
|
|
|
|
|
|
|
|
VersionInfo VendorSettings::getVersionInformation(const rtl::OUString & sVendor)
|
|
|
|
{
|
2012-01-04 07:38:41 -06:00
|
|
|
OSL_ASSERT(!sVendor.isEmpty());
|
2004-11-09 07:00:36 -06:00
|
|
|
VersionInfo aVersionInfo;
|
|
|
|
OString osVendor = OUStringToOString(sVendor, RTL_TEXTENCODING_UTF8);
|
|
|
|
//Get minVersion
|
|
|
|
OString sExpresion = OString(
|
|
|
|
"/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
|
|
|
|
osVendor + OString("\"]/jf:minVersion");
|
|
|
|
|
|
|
|
CXPathObjectPtr xPathObjectMin;
|
|
|
|
xPathObjectMin =
|
|
|
|
xmlXPathEvalExpression((xmlChar*) sExpresion.getStr(),
|
|
|
|
m_xmlPathContextVendorSettings);
|
|
|
|
if (xmlXPathNodeSetIsEmpty(xPathObjectMin->nodesetval))
|
|
|
|
{
|
|
|
|
aVersionInfo.sMinVersion = OUString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CXmlCharPtr sVersion;
|
|
|
|
sVersion = xmlNodeListGetString(
|
|
|
|
m_xmlDocVendorSettings,
|
|
|
|
xPathObjectMin->nodesetval->nodeTab[0]->xmlChildrenNode, 1);
|
|
|
|
OString osVersion((sal_Char*)(xmlChar*) sVersion);
|
|
|
|
aVersionInfo.sMinVersion = OStringToOUString(
|
|
|
|
osVersion, RTL_TEXTENCODING_UTF8);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get maxVersion
|
|
|
|
sExpresion = OString("/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
|
|
|
|
osVendor + OString("\"]/jf:maxVersion");
|
|
|
|
CXPathObjectPtr xPathObjectMax;
|
|
|
|
xPathObjectMax = xmlXPathEvalExpression(
|
|
|
|
(xmlChar*) sExpresion.getStr(),
|
|
|
|
m_xmlPathContextVendorSettings);
|
|
|
|
if (xmlXPathNodeSetIsEmpty(xPathObjectMax->nodesetval))
|
|
|
|
{
|
|
|
|
aVersionInfo.sMaxVersion = OUString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CXmlCharPtr sVersion;
|
|
|
|
sVersion = xmlNodeListGetString(
|
|
|
|
m_xmlDocVendorSettings,
|
|
|
|
xPathObjectMax->nodesetval->nodeTab[0]->xmlChildrenNode, 1);
|
|
|
|
OString osVersion((sal_Char*) (xmlChar*) sVersion);
|
|
|
|
aVersionInfo.sMaxVersion = OStringToOUString(
|
|
|
|
osVersion, RTL_TEXTENCODING_UTF8);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get excludeVersions
|
|
|
|
sExpresion = OString("/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
|
|
|
|
osVendor + OString("\"]/jf:excludeVersions/jf:version");
|
|
|
|
CXPathObjectPtr xPathObjectVersions;
|
|
|
|
xPathObjectVersions =
|
|
|
|
xmlXPathEvalExpression((xmlChar*) sExpresion.getStr(),
|
|
|
|
m_xmlPathContextVendorSettings);
|
|
|
|
if (!xmlXPathNodeSetIsEmpty(xPathObjectVersions->nodesetval))
|
|
|
|
{
|
|
|
|
xmlNode* cur = xPathObjectVersions->nodesetval->nodeTab[0];
|
|
|
|
while (cur != NULL)
|
|
|
|
{
|
|
|
|
if (cur->type == XML_ELEMENT_NODE )
|
|
|
|
{
|
|
|
|
if (xmlStrcmp(cur->name, (xmlChar*) "version") == 0)
|
|
|
|
{
|
|
|
|
CXmlCharPtr sVersion;
|
|
|
|
sVersion = xmlNodeListGetString(
|
|
|
|
m_xmlDocVendorSettings, cur->xmlChildrenNode, 1);
|
|
|
|
OString osVersion((sal_Char*)(xmlChar*) sVersion);
|
|
|
|
OUString usVersion = OStringToOUString(
|
|
|
|
osVersion, RTL_TEXTENCODING_UTF8);
|
|
|
|
aVersionInfo.addExcludeVersion(usVersion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aVersionInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<OUString> VendorSettings::getSupportedVendors()
|
|
|
|
{
|
|
|
|
std::vector<rtl::OUString> vecVendors;
|
|
|
|
//get the nodeset for the library elements
|
|
|
|
jfw::CXPathObjectPtr result;
|
|
|
|
result = xmlXPathEvalExpression(
|
|
|
|
(xmlChar*)"/jf:javaSelection/jf:plugins/jf:library",
|
|
|
|
m_xmlPathContextVendorSettings);
|
|
|
|
if (xmlXPathNodeSetIsEmpty(result->nodesetval))
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_ERROR,
|
2011-03-24 09:35:20 -05:00
|
|
|
rtl::OString("[Java framework] Error in function getSupportedVendors (fwkbase.cxx)."));
|
2004-11-09 07:00:36 -06:00
|
|
|
|
|
|
|
//get the values of the library elements + vendor attribute
|
|
|
|
xmlNode* cur = result->nodesetval->nodeTab[0];
|
|
|
|
while (cur != NULL)
|
|
|
|
{
|
|
|
|
//between library elements are also text elements
|
|
|
|
if (cur->type == XML_ELEMENT_NODE)
|
|
|
|
{
|
|
|
|
jfw::CXmlCharPtr sAttrVendor(xmlGetProp(cur, (xmlChar*) "vendor"));
|
|
|
|
vecVendors.push_back(sAttrVendor);
|
|
|
|
}
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
return vecVendors;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString VendorSettings::getPluginLibrary(const OUString& sVendor)
|
|
|
|
{
|
2012-01-04 07:38:41 -06:00
|
|
|
OSL_ASSERT(!sVendor.isEmpty());
|
2004-11-09 07:00:36 -06:00
|
|
|
|
2011-03-24 09:35:20 -05:00
|
|
|
OString sExcMsg("[Java framework] Error in function getPluginLibrary (fwkbase.cxx).");
|
2005-06-17 04:12:18 -05:00
|
|
|
OString sVendorsPath = getVendorSettingsPath(m_xmlDocVendorSettingsFileUrl);
|
2004-11-09 07:00:36 -06:00
|
|
|
OUStringBuffer usBuffer(256);
|
|
|
|
usBuffer.appendAscii("/jf:javaSelection/jf:plugins/jf:library[@vendor=\"");
|
|
|
|
usBuffer.append(sVendor);
|
|
|
|
usBuffer.appendAscii("\"]/text()");
|
|
|
|
OUString ouExpr = usBuffer.makeStringAndClear();
|
|
|
|
OString sExpression =
|
|
|
|
OUStringToOString(ouExpr, osl_getThreadTextEncoding());
|
|
|
|
CXPathObjectPtr pathObjVendor;
|
|
|
|
pathObjVendor = xmlXPathEvalExpression(
|
|
|
|
(xmlChar*) sExpression.getStr(), m_xmlPathContextVendorSettings);
|
|
|
|
if (xmlXPathNodeSetIsEmpty(pathObjVendor->nodesetval))
|
|
|
|
throw FrameworkException(JFW_E_ERROR, sExcMsg);
|
|
|
|
|
|
|
|
CXmlCharPtr xmlCharPlugin;
|
|
|
|
xmlCharPlugin =
|
|
|
|
xmlNodeListGetString(
|
|
|
|
m_xmlDocVendorSettings,pathObjVendor->nodesetval->nodeTab[0], 1);
|
|
|
|
|
2011-03-24 09:38:25 -05:00
|
|
|
//make an absolute file url from the relative plugin URL
|
2005-06-17 04:12:18 -05:00
|
|
|
OUString sUrl = findPlugin(m_xmlDocVendorSettingsFileUrl, xmlCharPlugin);
|
2012-01-04 07:38:41 -06:00
|
|
|
if (sUrl.isEmpty())
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
OString sPlugin = OUStringToOString(
|
|
|
|
xmlCharPlugin, osl_getThreadTextEncoding());
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_CONFIGURATION,
|
|
|
|
"[Java framework] The file: " + sPlugin + " does not exist.");
|
|
|
|
}
|
|
|
|
return sUrl;
|
|
|
|
}
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
::std::vector<OString> BootParams::getVMParameters()
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
2007-06-13 01:57:54 -05:00
|
|
|
::std::vector<OString> vecParams;
|
2004-11-09 07:00:36 -06:00
|
|
|
|
|
|
|
for (sal_Int32 i = 1; ; i++)
|
|
|
|
{
|
|
|
|
OUString sName =
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_PARAMETER)) +
|
|
|
|
OUString::valueOf(i);
|
|
|
|
OUString sValue;
|
2007-06-13 01:57:54 -05:00
|
|
|
if (Bootstrap::get()->getFrom(sName, sValue) == sal_True)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
OString sParam =
|
|
|
|
OUStringToOString(sValue, osl_getThreadTextEncoding());
|
|
|
|
vecParams.push_back(sParam);
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
rtl::OString sParamName = rtl::OUStringToOString(sName, osl_getThreadTextEncoding());
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter %s"
|
|
|
|
" = %s.\n", sParamName.getStr(), sParam.getStr());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return vecParams;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString BootParams::getUserData()
|
|
|
|
{
|
2008-03-18 06:22:17 -05:00
|
|
|
return getParamFirstUrl(UNO_JAVA_JFW_USER_DATA);
|
2004-11-09 07:00:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString BootParams::getSharedData()
|
|
|
|
{
|
2008-03-18 06:22:17 -05:00
|
|
|
return getParamFirstUrl(UNO_JAVA_JFW_SHARED_DATA);
|
2004-11-09 07:00:36 -06:00
|
|
|
}
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
rtl::OUString BootParams::getInstallData()
|
|
|
|
{
|
|
|
|
return getParam(UNO_JAVA_JFW_INSTALL_DATA);
|
|
|
|
}
|
2004-11-09 07:00:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
rtl::OString BootParams::getClasspath()
|
|
|
|
{
|
|
|
|
rtl::OString sClassPath;
|
|
|
|
rtl::OUString sCP;
|
|
|
|
char szSep[] = {SAL_PATHSEPARATOR,0};
|
2007-06-13 01:57:54 -05:00
|
|
|
if (Bootstrap::get()->getFrom(
|
2004-11-09 07:00:36 -06:00
|
|
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH)),
|
|
|
|
sCP) == sal_True)
|
|
|
|
{
|
|
|
|
sClassPath = rtl::OUStringToOString(
|
|
|
|
sCP, osl_getThreadTextEncoding());
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter "
|
|
|
|
UNO_JAVA_JFW_CLASSPATH " = %s.\n", sClassPath.getStr());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString sEnvCP;
|
2007-06-13 01:57:54 -05:00
|
|
|
if (Bootstrap::get()->getFrom(
|
2004-11-09 07:00:36 -06:00
|
|
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_CLASSPATH)),
|
|
|
|
sEnvCP) == sal_True)
|
|
|
|
{
|
|
|
|
char * pCp = getenv("CLASSPATH");
|
|
|
|
if (pCp)
|
|
|
|
{
|
|
|
|
sClassPath += rtl::OString(szSep) + rtl::OString(pCp);
|
|
|
|
}
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter "
|
2004-12-16 04:47:49 -06:00
|
|
|
UNO_JAVA_JFW_ENV_CLASSPATH " and class path is:\n %s.\n", pCp ? pCp : "");
|
2004-11-09 07:00:36 -06:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return sClassPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString BootParams::getVendorSettings()
|
|
|
|
{
|
|
|
|
rtl::OUString sVendor;
|
|
|
|
rtl::OUString sName(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_VENDOR_SETTINGS));
|
2007-06-13 01:57:54 -05:00
|
|
|
if (Bootstrap::get()->getFrom(sName ,sVendor) == sal_True)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
//check the value of the bootstrap variable
|
|
|
|
jfw::FileStatus s = checkFileURL(sVendor);
|
|
|
|
if (s != FILE_OK)
|
|
|
|
{
|
|
|
|
//This bootstrap parameter can contain a relative URL
|
|
|
|
rtl::OUString sAbsoluteUrl;
|
|
|
|
rtl::OUString sBaseDir = getLibraryLocation();
|
|
|
|
if (File::getAbsoluteFileURL(sBaseDir, sVendor, sAbsoluteUrl)
|
|
|
|
!= File::E_None)
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_CONFIGURATION,
|
|
|
|
rtl::OString("[Java framework] Invalid value for bootstrap variable: "
|
|
|
|
UNO_JAVA_JFW_VENDOR_SETTINGS));
|
|
|
|
sVendor = sAbsoluteUrl;
|
|
|
|
s = checkFileURL(sVendor);
|
|
|
|
if (s == jfw::FILE_INVALID || s == jfw::FILE_DOES_NOT_EXIST)
|
|
|
|
{
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_CONFIGURATION,
|
|
|
|
rtl::OString("[Java framework] Invalid value for bootstrap variable: "
|
|
|
|
UNO_JAVA_JFW_VENDOR_SETTINGS));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
rtl::OString sValue = rtl::OUStringToOString(sVendor, osl_getThreadTextEncoding());
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter "
|
|
|
|
UNO_JAVA_JFW_VENDOR_SETTINGS" = %s.\n", sValue.getStr());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return sVendor;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString BootParams::getJREHome()
|
|
|
|
{
|
|
|
|
rtl::OUString sJRE;
|
|
|
|
rtl::OUString sEnvJRE;
|
2007-06-13 01:57:54 -05:00
|
|
|
sal_Bool bJRE = Bootstrap::get()->getFrom(
|
2004-11-09 07:00:36 -06:00
|
|
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_JREHOME)) ,sJRE);
|
2007-06-13 01:57:54 -05:00
|
|
|
sal_Bool bEnvJRE = Bootstrap::get()->getFrom(
|
2004-11-09 07:00:36 -06:00
|
|
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_JREHOME)) ,sEnvJRE);
|
|
|
|
|
|
|
|
if (bJRE == sal_True && bEnvJRE == sal_True)
|
|
|
|
{
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_CONFIGURATION,
|
|
|
|
rtl::OString("[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."));
|
|
|
|
}
|
|
|
|
else if (bEnvJRE == sal_True)
|
|
|
|
{
|
|
|
|
const char * pJRE = getenv("JAVA_HOME");
|
|
|
|
if (pJRE == NULL)
|
|
|
|
{
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_CONFIGURATION,
|
|
|
|
rtl::OString("[Java framework] Both bootstrap parameter "
|
|
|
|
UNO_JAVA_JFW_ENV_JREHOME" is set, but the environment variable "
|
|
|
|
"JAVA_HOME is not set."));
|
|
|
|
}
|
|
|
|
rtl::OString osJRE(pJRE);
|
|
|
|
rtl::OUString usJRE = rtl::OStringToOUString(osJRE, osl_getThreadTextEncoding());
|
|
|
|
if (File::getFileURLFromSystemPath(usJRE, sJRE) != File::E_None)
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_ERROR,
|
|
|
|
rtl::OString("[Java framework] Error in function BootParams::getJREHome() "
|
|
|
|
"(fwkbase.cxx)."));
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter "
|
|
|
|
UNO_JAVA_JFW_ENV_JREHOME" with JAVA_HOME = %s.\n", pJRE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if (getMode() == JFW_MODE_DIRECT
|
|
|
|
&& bEnvJRE == sal_False
|
|
|
|
&& bJRE == sal_False)
|
|
|
|
{
|
|
|
|
throw FrameworkException(
|
|
|
|
JFW_E_CONFIGURATION,
|
|
|
|
rtl::OString("[Java framework] The bootstrap parameter "
|
|
|
|
UNO_JAVA_JFW_ENV_JREHOME" or " UNO_JAVA_JFW_JREHOME
|
|
|
|
" must be set in direct mode."));
|
|
|
|
}
|
|
|
|
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
if (bJRE == sal_True)
|
|
|
|
{
|
|
|
|
rtl::OString sValue = rtl::OUStringToOString(sJRE, osl_getThreadTextEncoding());
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter "
|
|
|
|
UNO_JAVA_JFW_JREHOME" = %s.\n", sValue.getStr());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return sJRE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString BootParams::getClasspathUrls()
|
|
|
|
{
|
|
|
|
rtl::OUString sParams;
|
2007-06-13 01:57:54 -05:00
|
|
|
Bootstrap::get()->getFrom(
|
2004-11-09 07:00:36 -06:00
|
|
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH_URLS)),
|
|
|
|
sParams);
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
rtl::OString sValue = rtl::OUStringToOString(sParams, osl_getThreadTextEncoding());
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter "
|
|
|
|
UNO_JAVA_JFW_CLASSPATH_URLS " = %s.\n", sValue.getStr());
|
|
|
|
#endif
|
|
|
|
return sParams;
|
|
|
|
}
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
::sal_uInt32 BootParams::getInstallDataExpiration()
|
|
|
|
{
|
|
|
|
rtl::OUString sValue;
|
|
|
|
Bootstrap::get()->getFrom(
|
|
|
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_INSTALL_EXPIRE)),
|
|
|
|
sValue);
|
|
|
|
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
rtl::OString osValue = rtl::OUStringToOString(sValue, osl_getThreadTextEncoding());
|
|
|
|
fprintf(stderr,"[Java framework] Using bootstrap parameter "
|
|
|
|
UNO_JAVA_JFW_INSTALL_EXPIRE " = %s.\n", osValue.getStr());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sal_Int64 nVal = sValue.toInt64();
|
|
|
|
if (0 == nVal)
|
|
|
|
{
|
|
|
|
#if OSL_DEBUG_LEVEL >=2
|
|
|
|
fprintf(stderr,"[Java framework] Using default value for "
|
|
|
|
"UNO_JAVA_JFW_INSTALL_EXPIRE: %d \n", DEFAULT_INSTALL_EXPIRATION);
|
|
|
|
#endif
|
|
|
|
return DEFAULT_INSTALL_EXPIRATION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return static_cast<sal_uInt32>(nVal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-09 07:00:36 -06:00
|
|
|
JFW_MODE getMode()
|
|
|
|
{
|
|
|
|
static bool g_bMode = false;
|
|
|
|
static JFW_MODE g_mode = JFW_MODE_APPLICATION;
|
|
|
|
|
|
|
|
if (g_bMode == false)
|
|
|
|
{
|
|
|
|
//check if either of the "direct mode" bootstrap variables is set
|
|
|
|
bool bDirectMode = true;
|
|
|
|
rtl::OUString sValue;
|
2007-06-13 01:57:54 -05:00
|
|
|
const rtl::Bootstrap * aBoot = Bootstrap::get();
|
2004-11-09 07:00:36 -06:00
|
|
|
rtl::OUString sJREHome(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_JREHOME));
|
2007-06-13 01:57:54 -05:00
|
|
|
if (aBoot->getFrom(sJREHome, sValue) == sal_False)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
rtl::OUString sEnvJRE(
|
2005-06-17 04:12:18 -05:00
|
|
|
RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_JREHOME));
|
2007-06-13 01:57:54 -05:00
|
|
|
if (aBoot->getFrom(sEnvJRE, sValue) == sal_False)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
rtl::OUString sClasspath(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH));
|
2007-06-13 01:57:54 -05:00
|
|
|
if (aBoot->getFrom(sClasspath, sValue) == sal_False)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
rtl::OUString sEnvClasspath(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_CLASSPATH));
|
2007-06-13 01:57:54 -05:00
|
|
|
if (aBoot->getFrom(sEnvClasspath, sValue) == sal_False)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
2004-12-16 04:47:49 -06:00
|
|
|
rtl::OUString sParams = rtl::OUString(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_PARAMETER)) +
|
|
|
|
rtl::OUString::valueOf((sal_Int32)1);
|
2007-06-13 01:57:54 -05:00
|
|
|
if (aBoot->getFrom(sParams, sValue) == sal_False)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
2004-12-16 04:47:49 -06:00
|
|
|
bDirectMode = false;
|
2004-11-09 07:00:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bDirectMode)
|
|
|
|
g_mode = JFW_MODE_DIRECT;
|
|
|
|
else
|
|
|
|
g_mode = JFW_MODE_APPLICATION;
|
|
|
|
g_bMode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString getApplicationClassPath()
|
|
|
|
{
|
|
|
|
OSL_ASSERT(getMode() == JFW_MODE_APPLICATION);
|
|
|
|
rtl::OUString retVal;
|
|
|
|
rtl::OUString sParams = BootParams::getClasspathUrls();
|
2012-01-04 07:38:41 -06:00
|
|
|
if (sParams.isEmpty())
|
2004-11-09 07:00:36 -06:00
|
|
|
return retVal;
|
|
|
|
|
|
|
|
rtl::OUStringBuffer buf;
|
|
|
|
sal_Int32 index = 0;
|
|
|
|
char szClassPathSep[] = {SAL_PATHSEPARATOR,0};
|
|
|
|
do
|
|
|
|
{
|
|
|
|
::rtl::OUString token( sParams.getToken( 0, ' ', index ).trim() );
|
2012-01-04 07:38:41 -06:00
|
|
|
if (!token.isEmpty())
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
::rtl::OUString systemPathElement;
|
|
|
|
oslFileError rc = osl_getSystemPathFromFileURL(
|
|
|
|
token.pData, &systemPathElement.pData );
|
|
|
|
OSL_ASSERT( rc == osl_File_E_None );
|
2012-01-04 07:38:41 -06:00
|
|
|
if (rc == osl_File_E_None && !systemPathElement.isEmpty())
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
if (buf.getLength() > 0)
|
|
|
|
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
szClassPathSep) );
|
|
|
|
buf.append( systemPathElement );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (index >= 0);
|
|
|
|
return buf.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
rtl::OString makeClassPathOption(OUString const & sUserClassPath)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
|
|
|
//Compose the class path
|
|
|
|
rtl::OString sPaths;
|
|
|
|
rtl::OUStringBuffer sBufCP(4096);
|
|
|
|
char szSep[] = {SAL_PATHSEPARATOR,0};
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
// append all user selected jars to the class path
|
2012-01-04 07:38:41 -06:00
|
|
|
if (!sUserClassPath.isEmpty())
|
2007-06-13 01:57:54 -05:00
|
|
|
sBufCP.append(sUserClassPath);
|
|
|
|
|
|
|
|
//append all jar libraries and components to the class path
|
|
|
|
OUString sAppCP = getApplicationClassPath();
|
2012-01-04 07:38:41 -06:00
|
|
|
if (!sAppCP.isEmpty())
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
2012-01-04 07:38:41 -06:00
|
|
|
if (!sUserClassPath.isEmpty())
|
2007-06-13 01:57:54 -05:00
|
|
|
sBufCP.appendAscii(szSep);
|
|
|
|
sBufCP.append(sAppCP);
|
2004-11-09 07:00:36 -06:00
|
|
|
}
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
sPaths = rtl::OUStringToOString(
|
|
|
|
sBufCP.makeStringAndClear(), osl_getThreadTextEncoding());
|
|
|
|
|
2004-11-09 07:00:36 -06:00
|
|
|
rtl::OString sOptionClassPath("-Djava.class.path=");
|
|
|
|
sOptionClassPath += sPaths;
|
|
|
|
return sOptionClassPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OString getUserSettingsPath()
|
|
|
|
{
|
2007-06-13 01:57:54 -05:00
|
|
|
return getSettingsPath(BootParams::getUserData());
|
2004-11-09 07:00:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OString getSharedSettingsPath()
|
|
|
|
{
|
2007-06-13 01:57:54 -05:00
|
|
|
return getSettingsPath(BootParams::getSharedData());
|
|
|
|
}
|
2004-11-09 07:00:36 -06:00
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
rtl::OString getInstallSettingsPath()
|
|
|
|
{
|
|
|
|
return getSettingsPath(BootParams::getInstallData());
|
2004-11-09 07:00:36 -06:00
|
|
|
}
|
|
|
|
|
2007-06-13 01:57:54 -05:00
|
|
|
rtl::OString getSettingsPath( const rtl::OUString & sURL)
|
2004-11-09 07:00:36 -06:00
|
|
|
{
|
2012-01-04 07:38:41 -06:00
|
|
|
if (sURL.isEmpty())
|
2004-11-09 07:00:36 -06:00
|
|
|
return rtl::OString();
|
2007-06-13 01:57:54 -05:00
|
|
|
rtl::OUString sPath;
|
2004-11-09 07:00:36 -06:00
|
|
|
if (osl_getSystemPathFromFileURL(sURL.pData,
|
2007-06-13 01:57:54 -05:00
|
|
|
& sPath.pData) != osl_File_E_None)
|
2004-11-09 07:00:36 -06:00
|
|
|
throw FrameworkException(
|
2007-06-13 01:57:54 -05:00
|
|
|
JFW_E_ERROR, rtl::OString(
|
|
|
|
"[Java framework] Error in function ::getSettingsPath (fwkbase.cxx)."));
|
|
|
|
return rtl::OUStringToOString(sPath,osl_getThreadTextEncoding());
|
2004-11-09 07:00:36 -06:00
|
|
|
}
|
|
|
|
|
2005-06-17 04:12:18 -05:00
|
|
|
rtl::OString getVendorSettingsPath()
|
|
|
|
{
|
|
|
|
return getVendorSettingsPath(BootParams::getVendorSettings());
|
|
|
|
}
|
2004-11-09 07:00:36 -06:00
|
|
|
|
|
|
|
void setJavaSelected()
|
|
|
|
{
|
|
|
|
g_bJavaSet = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wasJavaSelectedInSameProcess()
|
|
|
|
{
|
|
|
|
//g_setJavaProcId not set means no Java selected
|
|
|
|
if (g_bJavaSet == true)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2010-10-14 01:30:07 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|