1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fwkbase.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_jvmfwk.hxx"
33 #include "rtl/ustring.hxx"
34 #include "rtl/ustrbuf.hxx"
35 #include "rtl/uri.hxx"
36 #include "osl/thread.hxx"
37 #include "osl/process.h"
38 #include "libxml/xpathInternals.h"
39 #include "osl/file.hxx"
40 #include "osl/module.hxx"
41 #include "framework.hxx"
42 #include "fwkutil.hxx"
43 #include "elements.hxx"
44 #include "fwkbase.hxx"
48 #define JAVASETTINGS "javasettings"
49 #define JAVASETTINGS_XML "javasettings.xml"
50 #define VENDORSETTINGS "javavendors.xml"
52 #define UNO_JAVA_JFW_PARAMETER "UNO_JAVA_JFW_PARAMETER_"
53 #define UNO_JAVA_JFW_JREHOME "UNO_JAVA_JFW_JREHOME"
54 #define UNO_JAVA_JFW_ENV_JREHOME "UNO_JAVA_JFW_ENV_JREHOME"
55 #define UNO_JAVA_JFW_CLASSPATH "UNO_JAVA_JFW_CLASSPATH"
56 #define UNO_JAVA_JFW_ENV_CLASSPATH "UNO_JAVA_JFW_ENV_CLASSPATH"
57 #define UNO_JAVA_JFW_CLASSPATH_URLS "UNO_JAVA_JFW_CLASSPATH_URLS"
58 #define UNO_JAVA_JFW_PARAMETERS "UNO_JAVA_JFW_PARAMETERS"
59 #define UNO_JAVA_JFW_VENDOR_SETTINGS "UNO_JAVA_JFW_VENDOR_SETTINGS"
60 #define UNO_JAVA_JFW_USER_DATA "UNO_JAVA_JFW_USER_DATA"
61 #define UNO_JAVA_JFW_SHARED_DATA "UNO_JAVA_JFW_SHARED_DATA"
62 #define UNO_JAVA_JFW_INSTALL_DATA "UNO_JAVA_JFW_INSTALL_DATA"
63 #define UNO_JAVA_JFW_INSTALL_EXPIRE "UNO_JAVA_JFW_INSTALL_EXPIRE"
64 #define DEFAULT_INSTALL_EXPIRATION 3600
68 bool g_bJavaSet
= false;
72 rtl::OString
getVendorSettingsPath(rtl::OUString
const & sURL
)
74 if (sURL
.getLength() == 0)
75 return rtl::OString();
76 rtl::OUString sSystemPathSettings
;
77 if (osl_getSystemPathFromFileURL(sURL
.pData
,
78 & sSystemPathSettings
.pData
) != osl_File_E_None
)
79 throw FrameworkException(
81 rtl::OString("[Java framework] Error in function "
82 "getVendorSettingsPath (fwkutil.cxx) "));
83 rtl::OString osSystemPathSettings
=
84 rtl::OUStringToOString(sSystemPathSettings
,osl_getThreadTextEncoding());
85 return osSystemPathSettings
;
88 rtl::OUString
getParam(const char * name
)
91 if (Bootstrap::get()->getFrom(rtl::OUString::createFromAscii(name
), retVal
))
93 #if OSL_DEBUG_LEVEL >=2
94 rtl::OString sValue
= rtl::OUStringToOString(retVal
, osl_getThreadTextEncoding());
95 fprintf(stderr
,"[Java framework] Using bootstrap parameter %s = %s.\n",
96 name
, sValue
.getStr());
102 rtl::OUString
getParamFirstUrl(const char * name
)
104 // Some parameters can consist of multiple URLs (separated by space
105 // characters, although trim() harmlessly also removes other white-space),
106 // of which only the first is used:
108 return getParam(name
).trim().getToken(0, ' ', i
);
114 VendorSettings::VendorSettings():
115 m_xmlDocVendorSettingsFileUrl(BootParams::getVendorSettings())
117 OString
sMsgExc("[Java framework] Error in constructor "
118 "VendorSettings::VendorSettings() (fwkbase.cxx)");
119 //Prepare the xml document and context
120 OString sSettingsPath
= getVendorSettingsPath(m_xmlDocVendorSettingsFileUrl
);
121 if (sSettingsPath
.getLength() == 0)
123 OString
sMsg("[Java framework] A vendor settings file was not specified."
124 "Check the bootstrap parameter " UNO_JAVA_JFW_VENDOR_SETTINGS
".");
125 OSL_ENSURE(0, sMsg
.getStr());
126 throw FrameworkException(JFW_E_CONFIGURATION
, sMsg
);
128 if (sSettingsPath
.getLength() > 0)
130 m_xmlDocVendorSettings
= xmlParseFile(sSettingsPath
.getStr());
131 if (m_xmlDocVendorSettings
== NULL
)
132 throw FrameworkException(
134 OString("[Java framework] Error while parsing file: ")
135 + sSettingsPath
+ OString("."));
137 m_xmlPathContextVendorSettings
= xmlXPathNewContext(m_xmlDocVendorSettings
);
138 int res
= xmlXPathRegisterNs(
139 m_xmlPathContextVendorSettings
, (xmlChar
*) "jf",
140 (xmlChar
*) NS_JAVA_FRAMEWORK
);
142 throw FrameworkException(JFW_E_ERROR
, sMsgExc
);
146 std::vector
<PluginLibrary
> VendorSettings::getPluginData()
148 OString
sExcMsg("[Java framework] Error in function VendorSettings::getVendorPluginURLs "
150 std::vector
<PluginLibrary
> vecPlugins
;
151 CXPathObjectPtr
result(xmlXPathEvalExpression(
152 (xmlChar
*)"/jf:javaSelection/jf:plugins/jf:library",
153 m_xmlPathContextVendorSettings
));
154 if (xmlXPathNodeSetIsEmpty(result
->nodesetval
))
155 throw FrameworkException(JFW_E_ERROR
, sExcMsg
);
157 //get the values of the library elements + vendor attribute
158 xmlNode
* cur
= result
->nodesetval
->nodeTab
[0];
162 //between library elements are also text elements
163 if (cur
->type
== XML_ELEMENT_NODE
)
165 CXmlCharPtr
sAttrVendor(xmlGetProp(cur
, (xmlChar
*) "vendor"));
166 CXmlCharPtr
sTextLibrary(
167 xmlNodeListGetString(m_xmlDocVendorSettings
,
168 cur
->xmlChildrenNode
, 1));
169 PluginLibrary plugin
;
170 OString
osVendor((sal_Char
*)(xmlChar
*) sAttrVendor
);
171 plugin
.sVendor
= OStringToOUString(osVendor
, RTL_TEXTENCODING_UTF8
);
173 //create the file URL to the library
174 OUString sUrl
= findPlugin(
175 m_xmlDocVendorSettingsFileUrl
, sTextLibrary
);
176 if (sUrl
.getLength() == 0)
178 OString sPlugin
= OUStringToOString(
179 sTextLibrary
, osl_getThreadTextEncoding());
180 throw FrameworkException(
182 "[Java framework] The file: " + sPlugin
+ " does not exist.");
186 vecPlugins
.push_back(plugin
);
193 VersionInfo
VendorSettings::getVersionInformation(const rtl::OUString
& sVendor
)
195 OSL_ASSERT(sVendor
.getLength() > 0);
196 VersionInfo aVersionInfo
;
197 OString osVendor
= OUStringToOString(sVendor
, RTL_TEXTENCODING_UTF8
);
199 OString sExpresion
= OString(
200 "/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
201 osVendor
+ OString("\"]/jf:minVersion");
203 CXPathObjectPtr xPathObjectMin
;
205 xmlXPathEvalExpression((xmlChar
*) sExpresion
.getStr(),
206 m_xmlPathContextVendorSettings
);
207 if (xmlXPathNodeSetIsEmpty(xPathObjectMin
->nodesetval
))
209 aVersionInfo
.sMinVersion
= OUString();
213 CXmlCharPtr sVersion
;
214 sVersion
= xmlNodeListGetString(
215 m_xmlDocVendorSettings
,
216 xPathObjectMin
->nodesetval
->nodeTab
[0]->xmlChildrenNode
, 1);
217 OString
osVersion((sal_Char
*)(xmlChar
*) sVersion
);
218 aVersionInfo
.sMinVersion
= OStringToOUString(
219 osVersion
, RTL_TEXTENCODING_UTF8
);
223 sExpresion
= OString("/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
224 osVendor
+ OString("\"]/jf:maxVersion");
225 CXPathObjectPtr xPathObjectMax
;
226 xPathObjectMax
= xmlXPathEvalExpression(
227 (xmlChar
*) sExpresion
.getStr(),
228 m_xmlPathContextVendorSettings
);
229 if (xmlXPathNodeSetIsEmpty(xPathObjectMax
->nodesetval
))
231 aVersionInfo
.sMaxVersion
= OUString();
235 CXmlCharPtr sVersion
;
236 sVersion
= xmlNodeListGetString(
237 m_xmlDocVendorSettings
,
238 xPathObjectMax
->nodesetval
->nodeTab
[0]->xmlChildrenNode
, 1);
239 OString
osVersion((sal_Char
*) (xmlChar
*) sVersion
);
240 aVersionInfo
.sMaxVersion
= OStringToOUString(
241 osVersion
, RTL_TEXTENCODING_UTF8
);
244 //Get excludeVersions
245 sExpresion
= OString("/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
246 osVendor
+ OString("\"]/jf:excludeVersions/jf:version");
247 CXPathObjectPtr xPathObjectVersions
;
248 xPathObjectVersions
=
249 xmlXPathEvalExpression((xmlChar
*) sExpresion
.getStr(),
250 m_xmlPathContextVendorSettings
);
251 if (!xmlXPathNodeSetIsEmpty(xPathObjectVersions
->nodesetval
))
253 xmlNode
* cur
= xPathObjectVersions
->nodesetval
->nodeTab
[0];
256 if (cur
->type
== XML_ELEMENT_NODE
)
258 if (xmlStrcmp(cur
->name
, (xmlChar
*) "version") == 0)
260 CXmlCharPtr sVersion
;
261 sVersion
= xmlNodeListGetString(
262 m_xmlDocVendorSettings
, cur
->xmlChildrenNode
, 1);
263 OString
osVersion((sal_Char
*)(xmlChar
*) sVersion
);
264 OUString usVersion
= OStringToOUString(
265 osVersion
, RTL_TEXTENCODING_UTF8
);
266 aVersionInfo
.addExcludeVersion(usVersion
);
275 std::vector
<OUString
> VendorSettings::getSupportedVendors()
277 std::vector
<rtl::OUString
> vecVendors
;
278 //get the nodeset for the library elements
279 jfw::CXPathObjectPtr result
;
280 result
= xmlXPathEvalExpression(
281 (xmlChar
*)"/jf:javaSelection/jf:plugins/jf:library",
282 m_xmlPathContextVendorSettings
);
283 if (xmlXPathNodeSetIsEmpty(result
->nodesetval
))
284 throw FrameworkException(
286 rtl::OString("[Java framework] Error in function getSupportedVendors (fwkutil.cxx)."));
288 //get the values of the library elements + vendor attribute
289 xmlNode
* cur
= result
->nodesetval
->nodeTab
[0];
292 //between library elements are also text elements
293 if (cur
->type
== XML_ELEMENT_NODE
)
295 jfw::CXmlCharPtr
sAttrVendor(xmlGetProp(cur
, (xmlChar
*) "vendor"));
296 vecVendors
.push_back(sAttrVendor
);
303 OUString
VendorSettings::getPluginLibrary(const OUString
& sVendor
)
305 OSL_ASSERT(sVendor
.getLength() > 0);
307 OString
sExcMsg("[Java framework] Error in function getPluginLibrary (fwkutil.cxx).");
308 OString sVendorsPath
= getVendorSettingsPath(m_xmlDocVendorSettingsFileUrl
);
309 OUStringBuffer
usBuffer(256);
310 usBuffer
.appendAscii("/jf:javaSelection/jf:plugins/jf:library[@vendor=\"");
311 usBuffer
.append(sVendor
);
312 usBuffer
.appendAscii("\"]/text()");
313 OUString ouExpr
= usBuffer
.makeStringAndClear();
314 OString sExpression
=
315 OUStringToOString(ouExpr
, osl_getThreadTextEncoding());
316 CXPathObjectPtr pathObjVendor
;
317 pathObjVendor
= xmlXPathEvalExpression(
318 (xmlChar
*) sExpression
.getStr(), m_xmlPathContextVendorSettings
);
319 if (xmlXPathNodeSetIsEmpty(pathObjVendor
->nodesetval
))
320 throw FrameworkException(JFW_E_ERROR
, sExcMsg
);
322 CXmlCharPtr xmlCharPlugin
;
324 xmlNodeListGetString(
325 m_xmlDocVendorSettings
,pathObjVendor
->nodesetval
->nodeTab
[0], 1);
327 //make an absolute file url from the relativ plugin URL
328 OUString sUrl
= findPlugin(m_xmlDocVendorSettingsFileUrl
, xmlCharPlugin
);
329 if (sUrl
.getLength() == 0)
331 OString sPlugin
= OUStringToOString(
332 xmlCharPlugin
, osl_getThreadTextEncoding());
333 throw FrameworkException(
335 "[Java framework] The file: " + sPlugin
+ " does not exist.");
340 ::std::vector
<OString
> BootParams::getVMParameters()
342 ::std::vector
<OString
> vecParams
;
344 for (sal_Int32 i
= 1; ; i
++)
347 OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_PARAMETER
)) +
348 OUString::valueOf(i
);
350 if (Bootstrap::get()->getFrom(sName
, sValue
) == sal_True
)
353 OUStringToOString(sValue
, osl_getThreadTextEncoding());
354 vecParams
.push_back(sParam
);
355 #if OSL_DEBUG_LEVEL >=2
356 rtl::OString sParamName
= rtl::OUStringToOString(sName
, osl_getThreadTextEncoding());
357 fprintf(stderr
,"[Java framework] Using bootstrap parameter %s"
358 " = %s.\n", sParamName
.getStr(), sParam
.getStr());
367 rtl::OUString
BootParams::getUserData()
369 return getParamFirstUrl(UNO_JAVA_JFW_USER_DATA
);
372 rtl::OUString
BootParams::getSharedData()
374 return getParamFirstUrl(UNO_JAVA_JFW_SHARED_DATA
);
377 rtl::OUString
BootParams::getInstallData()
379 return getParam(UNO_JAVA_JFW_INSTALL_DATA
);
383 rtl::OString
BootParams::getClasspath()
385 rtl::OString sClassPath
;
387 char szSep
[] = {SAL_PATHSEPARATOR
,0};
388 if (Bootstrap::get()->getFrom(
389 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH
)),
392 sClassPath
= rtl::OUStringToOString(
393 sCP
, osl_getThreadTextEncoding());
394 #if OSL_DEBUG_LEVEL >=2
395 fprintf(stderr
,"[Java framework] Using bootstrap parameter "
396 UNO_JAVA_JFW_CLASSPATH
" = %s.\n", sClassPath
.getStr());
400 rtl::OUString sEnvCP
;
401 if (Bootstrap::get()->getFrom(
402 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_CLASSPATH
)),
405 char * pCp
= getenv("CLASSPATH");
408 sClassPath
+= rtl::OString(szSep
) + rtl::OString(pCp
);
410 #if OSL_DEBUG_LEVEL >=2
411 fprintf(stderr
,"[Java framework] Using bootstrap parameter "
412 UNO_JAVA_JFW_ENV_CLASSPATH
" and class path is:\n %s.\n", pCp
? pCp
: "");
419 rtl::OUString
BootParams::getVendorSettings()
421 rtl::OUString sVendor
;
423 RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_VENDOR_SETTINGS
));
424 if (Bootstrap::get()->getFrom(sName
,sVendor
) == sal_True
)
426 //check the value of the bootstrap variable
427 jfw::FileStatus s
= checkFileURL(sVendor
);
430 //This bootstrap parameter can contain a relative URL
431 rtl::OUString sAbsoluteUrl
;
432 rtl::OUString sBaseDir
= getLibraryLocation();
433 if (File::getAbsoluteFileURL(sBaseDir
, sVendor
, sAbsoluteUrl
)
435 throw FrameworkException(
437 rtl::OString("[Java framework] Invalid value for bootstrap variable: "
438 UNO_JAVA_JFW_VENDOR_SETTINGS
));
439 sVendor
= sAbsoluteUrl
;
440 s
= checkFileURL(sVendor
);
441 if (s
== jfw::FILE_INVALID
|| s
== jfw::FILE_DOES_NOT_EXIST
)
443 throw FrameworkException(
445 rtl::OString("[Java framework] Invalid value for bootstrap variable: "
446 UNO_JAVA_JFW_VENDOR_SETTINGS
));
449 #if OSL_DEBUG_LEVEL >=2
450 rtl::OString sValue
= rtl::OUStringToOString(sVendor
, osl_getThreadTextEncoding());
451 fprintf(stderr
,"[Java framework] Using bootstrap parameter "
452 UNO_JAVA_JFW_VENDOR_SETTINGS
" = %s.\n", sValue
.getStr());
458 rtl::OUString
BootParams::getJREHome()
461 rtl::OUString sEnvJRE
;
462 sal_Bool bJRE
= Bootstrap::get()->getFrom(
463 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_JREHOME
)) ,sJRE
);
464 sal_Bool bEnvJRE
= Bootstrap::get()->getFrom(
465 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_JREHOME
)) ,sEnvJRE
);
467 if (bJRE
== sal_True
&& bEnvJRE
== sal_True
)
469 throw FrameworkException(
471 rtl::OString("[Java framework] Both bootstrap parameter "
472 UNO_JAVA_JFW_JREHOME
" and "
473 UNO_JAVA_JFW_ENV_JREHOME
" are set. However only one of them can be set."
474 "Check bootstrap parameters: environment variables, command line "
475 "arguments, rc/ini files for executable and java framework library."));
477 else if (bEnvJRE
== sal_True
)
479 const char * pJRE
= getenv("JAVA_HOME");
482 throw FrameworkException(
484 rtl::OString("[Java framework] Both bootstrap parameter "
485 UNO_JAVA_JFW_ENV_JREHOME
" is set, but the environment variable "
486 "JAVA_HOME is not set."));
488 rtl::OString
osJRE(pJRE
);
489 rtl::OUString usJRE
= rtl::OStringToOUString(osJRE
, osl_getThreadTextEncoding());
490 if (File::getFileURLFromSystemPath(usJRE
, sJRE
) != File::E_None
)
491 throw FrameworkException(
493 rtl::OString("[Java framework] Error in function BootParams::getJREHome() "
495 #if OSL_DEBUG_LEVEL >=2
496 fprintf(stderr
,"[Java framework] Using bootstrap parameter "
497 UNO_JAVA_JFW_ENV_JREHOME
" with JAVA_HOME = %s.\n", pJRE
);
500 else if (getMode() == JFW_MODE_DIRECT
501 && bEnvJRE
== sal_False
502 && bJRE
== sal_False
)
504 throw FrameworkException(
506 rtl::OString("[Java framework] The bootstrap parameter "
507 UNO_JAVA_JFW_ENV_JREHOME
" or " UNO_JAVA_JFW_JREHOME
508 " must be set in direct mode."));
511 #if OSL_DEBUG_LEVEL >=2
512 if (bJRE
== sal_True
)
514 rtl::OString sValue
= rtl::OUStringToOString(sJRE
, osl_getThreadTextEncoding());
515 fprintf(stderr
,"[Java framework] Using bootstrap parameter "
516 UNO_JAVA_JFW_JREHOME
" = %s.\n", sValue
.getStr());
522 rtl::OUString
BootParams::getClasspathUrls()
524 rtl::OUString sParams
;
525 Bootstrap::get()->getFrom(
526 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH_URLS
)),
528 #if OSL_DEBUG_LEVEL >=2
529 rtl::OString sValue
= rtl::OUStringToOString(sParams
, osl_getThreadTextEncoding());
530 fprintf(stderr
,"[Java framework] Using bootstrap parameter "
531 UNO_JAVA_JFW_CLASSPATH_URLS
" = %s.\n", sValue
.getStr());
536 ::sal_uInt32
BootParams::getInstallDataExpiration()
538 rtl::OUString sValue
;
539 Bootstrap::get()->getFrom(
540 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_INSTALL_EXPIRE
)),
543 #if OSL_DEBUG_LEVEL >=2
544 rtl::OString osValue
= rtl::OUStringToOString(sValue
, osl_getThreadTextEncoding());
545 fprintf(stderr
,"[Java framework] Using bootstrap parameter "
546 UNO_JAVA_JFW_INSTALL_EXPIRE
" = %s.\n", osValue
.getStr());
549 sal_Int64 nVal
= sValue
.toInt64();
552 #if OSL_DEBUG_LEVEL >=2
553 fprintf(stderr
,"[Java framework] Using default value for "
554 "UNO_JAVA_JFW_INSTALL_EXPIRE: %d \n", DEFAULT_INSTALL_EXPIRATION
);
556 return DEFAULT_INSTALL_EXPIRATION
;
560 return static_cast<sal_uInt32
>(nVal
);
566 static bool g_bMode
= false;
567 static JFW_MODE g_mode
= JFW_MODE_APPLICATION
;
569 if (g_bMode
== false)
571 //check if either of the "direct mode" bootstrap variables is set
572 bool bDirectMode
= true;
573 rtl::OUString sValue
;
574 const rtl::Bootstrap
* aBoot
= Bootstrap::get();
575 rtl::OUString
sJREHome(
576 RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_JREHOME
));
577 if (aBoot
->getFrom(sJREHome
, sValue
) == sal_False
)
579 rtl::OUString
sEnvJRE(
580 RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_JREHOME
));
581 if (aBoot
->getFrom(sEnvJRE
, sValue
) == sal_False
)
583 rtl::OUString
sClasspath(
584 RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_CLASSPATH
));
585 if (aBoot
->getFrom(sClasspath
, sValue
) == sal_False
)
587 rtl::OUString
sEnvClasspath(
588 RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_ENV_CLASSPATH
));
589 if (aBoot
->getFrom(sEnvClasspath
, sValue
) == sal_False
)
591 rtl::OUString sParams
= rtl::OUString(
592 RTL_CONSTASCII_USTRINGPARAM(UNO_JAVA_JFW_PARAMETER
)) +
593 rtl::OUString::valueOf((sal_Int32
)1);
594 if (aBoot
->getFrom(sParams
, sValue
) == sal_False
)
604 g_mode
= JFW_MODE_DIRECT
;
606 g_mode
= JFW_MODE_APPLICATION
;
613 rtl::OUString
getApplicationClassPath()
615 OSL_ASSERT(getMode() == JFW_MODE_APPLICATION
);
616 rtl::OUString retVal
;
617 rtl::OUString sParams
= BootParams::getClasspathUrls();
618 if (sParams
.getLength() == 0)
621 rtl::OUStringBuffer buf
;
623 char szClassPathSep
[] = {SAL_PATHSEPARATOR
,0};
626 ::rtl::OUString
token( sParams
.getToken( 0, ' ', index
).trim() );
627 if (token
.getLength())
629 ::rtl::OUString systemPathElement
;
630 oslFileError rc
= osl_getSystemPathFromFileURL(
631 token
.pData
, &systemPathElement
.pData
);
632 OSL_ASSERT( rc
== osl_File_E_None
);
633 if (rc
== osl_File_E_None
&& systemPathElement
.getLength() > 0)
635 if (buf
.getLength() > 0)
636 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM(
638 buf
.append( systemPathElement
);
643 return buf
.makeStringAndClear();
646 rtl::OString
makeClassPathOption(OUString
const & sUserClassPath
)
648 //Compose the class path
650 rtl::OUStringBuffer
sBufCP(4096);
651 char szSep
[] = {SAL_PATHSEPARATOR
,0};
653 // append all user selected jars to the class path
654 if (sUserClassPath
.getLength() > 0)
655 sBufCP
.append(sUserClassPath
);
657 //append all jar libraries and components to the class path
658 OUString sAppCP
= getApplicationClassPath();
659 if (sAppCP
.getLength())
661 if (sUserClassPath
.getLength())
662 sBufCP
.appendAscii(szSep
);
663 sBufCP
.append(sAppCP
);
666 sPaths
= rtl::OUStringToOString(
667 sBufCP
.makeStringAndClear(), osl_getThreadTextEncoding());
669 rtl::OString
sOptionClassPath("-Djava.class.path=");
670 sOptionClassPath
+= sPaths
;
671 return sOptionClassPath
;
674 rtl::OString
getUserSettingsPath()
676 return getSettingsPath(BootParams::getUserData());
679 rtl::OString
getSharedSettingsPath()
681 return getSettingsPath(BootParams::getSharedData());
684 rtl::OString
getInstallSettingsPath()
686 return getSettingsPath(BootParams::getInstallData());
689 rtl::OString
getSettingsPath( const rtl::OUString
& sURL
)
691 if (sURL
.getLength() == 0)
692 return rtl::OString();
694 if (osl_getSystemPathFromFileURL(sURL
.pData
,
695 & sPath
.pData
) != osl_File_E_None
)
696 throw FrameworkException(
697 JFW_E_ERROR
, rtl::OString(
698 "[Java framework] Error in function ::getSettingsPath (fwkbase.cxx)."));
699 return rtl::OUStringToOString(sPath
,osl_getThreadTextEncoding());
702 rtl::OString
getVendorSettingsPath()
704 return getVendorSettingsPath(BootParams::getVendorSettings());
707 void setJavaSelected()
712 bool wasJavaSelectedInSameProcess()
714 //g_setJavaProcId not set means no Java selected
715 if (g_bJavaSet
== true)