xref: /AOO41X/main/jvmfwk/inc/jvmfwk/framework.h (revision 514f4c20bcebc1639918b6975cc4300e4484c27c)
1*514f4c20SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*514f4c20SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*514f4c20SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*514f4c20SAndrew Rist  * distributed with this work for additional information
6*514f4c20SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*514f4c20SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*514f4c20SAndrew Rist  * "License"); you may not use this file except in compliance
9*514f4c20SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*514f4c20SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*514f4c20SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*514f4c20SAndrew Rist  * software distributed under the License is distributed on an
15*514f4c20SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*514f4c20SAndrew Rist  * KIND, either express or implied.  See the License for the
17*514f4c20SAndrew Rist  * specific language governing permissions and limitations
18*514f4c20SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*514f4c20SAndrew Rist  *************************************************************/
21*514f4c20SAndrew Rist 
22*514f4c20SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir /** @HTML */
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #if !defined INCLUDED_JVMFWK_FRAMEWORK_H
27cdf0e10cSrcweir #define INCLUDED_JVMFWK_FRAMEWORK_H
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "rtl/ustring.h"
30cdf0e10cSrcweir #include "osl/mutex.h"
31cdf0e10cSrcweir #ifdef SOLAR_JAVA
32cdf0e10cSrcweir #include "jni.h"
33cdf0e10cSrcweir #else
34cdf0e10cSrcweir struct JavaVMOption;
35cdf0e10cSrcweir struct JavaVM;
36cdf0e10cSrcweir struct JNIEnv;
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #ifdef __cplusplus
40cdf0e10cSrcweir extern "C" {
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir /** @file
44cdf0e10cSrcweir     <p>This library can operate in two modes, application mode and direct mode.</p>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     <h2>Application Mode</h2>
48cdf0e10cSrcweir     In application mode the Java related settings are stored in files.
49cdf0e10cSrcweir     There are currently three files which need to be accessed. They are determined
50cdf0e10cSrcweir     by bootstrap parameters:</p>
51cdf0e10cSrcweir     <dl>
52cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_VENDOR_SETTINGS</dt>
53cdf0e10cSrcweir     <dd>contains vendor and version information about JREs as well as the
54cdf0e10cSrcweir     location of plugin-libraries which are responsible for providing information
55cdf0e10cSrcweir     about these JREs as well as starting the VMs.</dd>
56cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_USER_DATA</dt>
57cdf0e10cSrcweir     <dd>The file contains settings for a particular user. One can use the macro
58cdf0e10cSrcweir     $SYSUSERCONFIG in the URL which expands to a directory whery the user's data are
59cdf0e10cSrcweir     kept. On UNIX this would be the home directory and on Windows some sub-directory
60cdf0e10cSrcweir     of the &quot;Documents and Settings&quot; folder.The content of this file is an
61cdf0e10cSrcweir     implementation detail and may change in the future.</dd>
62cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_SHARED_DATA</dt>
63cdf0e10cSrcweir     <dd>The file contains settings valid for all users. If a user changes a setting
64cdf0e10cSrcweir     then it takes precedence over the setting from UNO_JAVA_JFW_SHARED_DATA.
65cdf0e10cSrcweir     The content of this file is an implementation detail and may change in the future.</dd>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_INSTALL_DATA</dt>
68cdf0e10cSrcweir     <dd><b>DEPRECATED. Support for this variable will soon be removed.</b><br>
69cdf0e10cSrcweir     The file contains settings for all users. A user cannot override these settings.
70cdf0e10cSrcweir     When this parameter is provided then UNO_JAVA_JFW_SHARED_DATA and UNO_JAVA_JFW_USER_DATA
71cdf0e10cSrcweir     are irrelevant. This parameter is intended for use during the setup. For example, to
72cdf0e10cSrcweir     install extensions which contain java components. If there is already a file at this
73cdf0e10cSrcweir     location then it will be overwritten if it is too old. The period of validatity is per
74cdf0e10cSrcweir     default one hour. This value can be overridden by the bootstrap parameter
75cdf0e10cSrcweir     UNO_JAVA_JFW_INSTALL_EXPIRE (<b>DEPRECATED</b>). Setting this variable to 1000 means
76cdf0e10cSrcweir     the settings file is only valid for 1000 seconds.
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     <p>If one would not use UNO_JAVA_JFW_INSTALL_DATA during setup then most probably
79cdf0e10cSrcweir     a user installation directory would be created in the home directory of root. This is
80cdf0e10cSrcweir     because, java settings are determined and stored on behalf of the current user. In other
81cdf0e10cSrcweir     words UNO_JAVA_JFW_USER_DATA would be used which points into the user installation.
82cdf0e10cSrcweir     </p>
83cdf0e10cSrcweir     <p>UNO_JAVA_JFW_INSTALL_DATA could point into the shared installation, provided that
84cdf0e10cSrcweir     only people with root rights can install OOo. Then one has to take care that the
85cdf0e10cSrcweir     installer removes this file when uninstalling.
86cdf0e10cSrcweir     </p>
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     The content of this file is an implementation detail and may change in the future.</dd>
90cdf0e10cSrcweir     </dl>
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     <p>The values for these parameters must be file URLs and include the file name, for
93cdf0e10cSrcweir     example:<br>
94cdf0e10cSrcweir     file:///d:/MyApp/javavendors.xml<br>
95cdf0e10cSrcweir     All files are XML files and must have the extension .xml.</p>
96cdf0e10cSrcweir     <p>
97cdf0e10cSrcweir     Modifying the shared settings is currently not supported by the framework. To provide
98cdf0e10cSrcweir     Java settings for all users one can run OOo and change the settings in the
99cdf0e10cSrcweir     options dialog. These settings are made persistent in the UNO_JAVA_JFW_USER_DATA.
100cdf0e10cSrcweir     The file can then be copied into the base installation.
101cdf0e10cSrcweir     Other users will use automatically these data but can override the settings in
102cdf0e10cSrcweir     the options dialog. This mechanism may change in the future.
103cdf0e10cSrcweir     </p>
104cdf0e10cSrcweir     <p>If shared Java settings are not supported by an application then it is not
105cdf0e10cSrcweir     necessary to specify the bootstrap parameter <code>UNO_JAVA_JFW_SHARED_DATA</code>.
106cdf0e10cSrcweir     </p>
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     <p>Setting the class path used by a Java VM should not be necesarry. The locations
109cdf0e10cSrcweir     of Jar files should be knows by a class loader. If a jar file depends on another
110cdf0e10cSrcweir     jar file then it can be referenced in the manifest file of the first jar. However,
111cdf0e10cSrcweir     a user may add jars to the class path by using this API. If it becomes necessary
112cdf0e10cSrcweir     to add files to the class path which is to be used by all users then one can use
113cdf0e10cSrcweir     the bootrap parameter UNO_JAVA_JFW_CLASSPATH_URLS. The value contains of file URLs
114cdf0e10cSrcweir     which must be separated by spaces.</p>
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     <h2>Direct Mode</h2>
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     <p>The direct mode is intended for a scenario where no configuration files
120cdf0e10cSrcweir     are available and a Java VM  shall be run. That is,
121cdf0e10cSrcweir     the files containing the user and shared settings are not specified by the
122cdf0e10cSrcweir     bootstrap parameters UNO_JAVA_JFW_SHARED_DATA and UNO_JAVA_JFW_USER_DATA.
123cdf0e10cSrcweir     For example, tools, such as regcomp, may use this  framework in a build
124cdf0e10cSrcweir     environment. Then one would want to use settings which have been specified
125cdf0e10cSrcweir     by the build environment. The framework would automatically use the
126cdf0e10cSrcweir     current settings when they change in the environment.
127cdf0e10cSrcweir     </p>
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     <p> Here are examples how regcomp could be invoked using bootstrap parameters:
130cdf0e10cSrcweir     </p>
131cdf0e10cSrcweir     <p>
132cdf0e10cSrcweir     regcomp -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2
133cdf0e10cSrcweir     -env:&quot;UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\jurt.jar&quot;
134cdf0e10cSrcweir     -register ....
135cdf0e10cSrcweir     </p>
136cdf0e10cSrcweir     <p>If UNO_JAVA_JFW_VENDOR_SETTINGS is not set then a plugin library must be specified. For example:</p>
137cdf0e10cSrcweir     <p>
138cdf0e10cSrcweir     regcomp -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2
139cdf0e10cSrcweir     -env:&quot;UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\jurt.jar&quot;
140cdf0e10cSrcweir     -env:UNO_JAVA_JFW_PLUGIN=file:\\solver\\bin\\sunjavaplugin.dll -register ....
141cdf0e10cSrcweir     </p>
142cdf0e10cSrcweir     <p>Additionall parameters for the Java VM can be provided. For every parameter
143cdf0e10cSrcweir     a seperate bootstrap parameter must be specified. The names are
144cdf0e10cSrcweir     <code>UNO_JAVA_JFW_PARAMETER_X</code>, where X is 1,2, .. n. For example:</p>
145cdf0e10cSrcweir     <p>
146cdf0e10cSrcweir     regcomp -env:UNO_JAVA_JFW_PARAMETER_1=-Xdebug
147cdf0e10cSrcweir     -env:UNO_JAVA_JFW_PARAMETER_2=-Xrunjdwp:transport=dt_socket,server=y,address=8100
148cdf0e10cSrcweir     -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2
149cdf0e10cSrcweir     -env:&quot;UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\jurt.jar&quot;
150cdf0e10cSrcweir     -register ....</p>
151cdf0e10cSrcweir     <p>
152cdf0e10cSrcweir     Here is a complete list of the bootstrap parameter for the direct mode:
153cdf0e10cSrcweir     </p>
154cdf0e10cSrcweir     <dl>
155cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_JREHOME</dt>
156cdf0e10cSrcweir     <dd>Specifies a file URL to a JRE installation.It must ALWAYS be specified
157cdf0e10cSrcweir     in direct mode</dd>
158cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_ENV_JREHOME</dt>
159cdf0e10cSrcweir     <dd>Setting this parameter, for example to &quot;1&quot; or &quot;true&quot;,
160cdf0e10cSrcweir     causes the framework to use the environment variable JAVA_HOME. It is expected
161cdf0e10cSrcweir     that JAVA_HOME contains a system path rather than a file URL. This parameter
162cdf0e10cSrcweir     and UNO_JAVA_JFW_JREHOME are mutually exclusive</dd>
163cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_CLASSPATH</dt>
164cdf0e10cSrcweir     <dd>Contains the class path which is to be used by the VM. Special character,
165cdf0e10cSrcweir     such as '\','{','}','$' must be preceded with '\'. See documentation about the
166cdf0e10cSrcweir     bootstrap parameter.</dd>
167cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_ENV_CLASSPATH</dt>
168cdf0e10cSrcweir     <dd>Setting this parameter,for example to &quot;1&quot; or &quot;true&quot;,
169cdf0e10cSrcweir     causes the framework to use the
170cdf0e10cSrcweir     environment variable CLASSPATH. If this variable and UNO_JAVA_JFW_CLASSPATH are
171cdf0e10cSrcweir     set then the class path is composed from UNO_JAVA_JFW_CLASSPATH and the environment
172cdf0e10cSrcweir     variable CLASSPATH.</dd>
173cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_PLUGIN</dt>
174cdf0e10cSrcweir     <dd>Specified a file URL to a plugin library. If this variable is provided
175cdf0e10cSrcweir     then a javavendors.xml is ignored. It must be provided if no
176cdf0e10cSrcweir     javavendors.xml is available.</dd>
177cdf0e10cSrcweir     <dt>UNO_JAVA_JFW_PARAMETER_X</dt>
178cdf0e10cSrcweir     <dd>Specifies a parameter for the Java VM. The X is replaced by
179cdf0e10cSrcweir     non-negative natural numbers starting with 1.</dd>
180cdf0e10cSrcweir     </dl>
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     <p>A note about bootstrap parameters. The implementation of the bootstrap
183cdf0e10cSrcweir     parameter mechanism interprets the characters '\', '$', '{', '}' as
184cdf0e10cSrcweir     escape characters. Thats why the Windows path contain double back-slashes.
185cdf0e10cSrcweir     One should also take into account that a console may have also special
186cdf0e10cSrcweir     escape characters.</p>
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     <h2>What mode is used</h2>
189cdf0e10cSrcweir     <p>
190cdf0e10cSrcweir     The default mode is application mode. If at least one bootstrap parameter
191cdf0e10cSrcweir     for the direct mode is provided then direct mode is used. </p>
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     <p>
194cdf0e10cSrcweir     All settings made by this API are done for the current user if not
195cdf0e10cSrcweir     mentioned differently.</p>
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     <h2>Other bootstrap variables</h2>
198cdf0e10cSrcweir     <dl>
199cdf0e10cSrcweir     <dt>JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY</dt>
200cdf0e10cSrcweir     <dd>This is a unofficial variable which was introduced to workaround external issues.
201cdf0e10cSrcweir     It may be removed in the future. By setting it to 1, the framework will not try to
202cdf0e10cSrcweir     find out if the system is configured to use accessibility tools or if a JRE has an
203cdf0e10cSrcweir     accessibiliy bridge installed</dd>
204cdf0e10cSrcweir     </dl>
205cdf0e10cSrcweir */
206cdf0e10cSrcweir 
207cdf0e10cSrcweir /** indicates that a JRE has an accessibility bridge installed.
208cdf0e10cSrcweir     <p>
209cdf0e10cSrcweir     The flag is used with JavaInfo::nFeatures.</p>
210cdf0e10cSrcweir  */
211cdf0e10cSrcweir #define JFW_FEATURE_ACCESSBRIDGE 0x1l
212cdf0e10cSrcweir /** indicates that there must be an environment set up before the Java process
213cdf0e10cSrcweir     runs.
214cdf0e10cSrcweir     <p>Therefore, when a Java is selected in OO then the office must be
215cdf0e10cSrcweir     restarted, so that the changes can take effect.</p>
216cdf0e10cSrcweir  */
217cdf0e10cSrcweir #define JFW_REQUIRE_NEEDRESTART  0x1l
218cdf0e10cSrcweir 
219cdf0e10cSrcweir /** error codes which are returned by functions of this API.
220cdf0e10cSrcweir  */
221cdf0e10cSrcweir typedef enum _javaFrameworkError
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     JFW_E_NONE,
224cdf0e10cSrcweir     JFW_E_ERROR,
225cdf0e10cSrcweir     JFW_E_INVALID_ARG,
226cdf0e10cSrcweir     JFW_E_NO_SELECT,
227cdf0e10cSrcweir     JFW_E_INVALID_SETTINGS,
228cdf0e10cSrcweir     JFW_E_NEED_RESTART,
229cdf0e10cSrcweir     JFW_E_RUNNING_JVM,
230cdf0e10cSrcweir     JFW_E_JAVA_DISABLED,
231cdf0e10cSrcweir     JFW_E_NO_PLUGIN,
232cdf0e10cSrcweir     JFW_E_NOT_RECOGNIZED,
233cdf0e10cSrcweir     JFW_E_FAILED_VERSION,
234cdf0e10cSrcweir     JFW_E_NO_JAVA_FOUND,
235cdf0e10cSrcweir     JFW_E_VM_CREATION_FAILED,
236cdf0e10cSrcweir     JFW_E_CONFIGURATION,
237cdf0e10cSrcweir     JFW_E_DIRECT_MODE
238cdf0e10cSrcweir } javaFrameworkError;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir /** an instance of this struct represents an installation of a Java
241cdf0e10cSrcweir     Runtime Environment (JRE).
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     <p>
244cdf0e10cSrcweir     Instances of this struct are created by the plug-in libraries which are used by
245cdf0e10cSrcweir     this framework (jvmfwk/vendorplugin.h). The memory of the instances is created
246cdf0e10cSrcweir     by <code>rtl_allocateMemory</code> (rtl/alloc.h). Therefore, the memory must
247cdf0e10cSrcweir     be freed by <code>rtl_freeMemory</code>. Also the contained members must be
248cdf0e10cSrcweir     freed particularly.
249cdf0e10cSrcweir     For convenience this API provides the function <code>jfw_freeJavaInfo</code>
250cdf0e10cSrcweir     which frees the objects properly. </p>
251cdf0e10cSrcweir  */
252cdf0e10cSrcweir struct _JavaInfo
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     /** contains the vendor.
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         <p>string must be the same as the one obtained from the
257cdf0e10cSrcweir         Java system property <code>java.vendor</code>.
258cdf0e10cSrcweir         </p>
259cdf0e10cSrcweir      */
260cdf0e10cSrcweir     rtl_uString *sVendor;
261cdf0e10cSrcweir     /** contains the file URL to the installation directory.
262cdf0e10cSrcweir     */
263cdf0e10cSrcweir     rtl_uString *sLocation;
264cdf0e10cSrcweir     /** contains the version of this Java distribution.
265cdf0e10cSrcweir 
266cdf0e10cSrcweir         <p>The version string  must adhere to the rules
267cdf0e10cSrcweir         about how a version string has to be formed. These rules may
268cdf0e10cSrcweir         be vendor-dependent. Essentially the strings must syntactically
269cdf0e10cSrcweir         equal the Java system property <code>java.version</code>.
270cdf0e10cSrcweir         </p>
271cdf0e10cSrcweir     */
272cdf0e10cSrcweir     rtl_uString *sVersion;
273cdf0e10cSrcweir     /** indicates supported special features.
274cdf0e10cSrcweir 
275cdf0e10cSrcweir         <p>For example, <code>JFW_FEATURE_ACCESSBRIDGE</code> indicates that
276cdf0e10cSrcweir         assistive technology tools are supported.</p>
277cdf0e10cSrcweir      */
278cdf0e10cSrcweir     sal_uInt64 nFeatures;
279cdf0e10cSrcweir     /** indicates requirments for running the java runtime.
280cdf0e10cSrcweir 
281cdf0e10cSrcweir         <p>For example, it may be necessary to prepare the environment before
282cdf0e10cSrcweir         the runtime is created. That could mean, setting the
283cdf0e10cSrcweir         <code>LD_LIBRARY_PATH</code>
284cdf0e10cSrcweir         when <code>nRequirements</code> contains the flag
285cdf0e10cSrcweir         <code>JFW_REQUIRE_NEEDRESTART</code></p>
286cdf0e10cSrcweir      */
287cdf0e10cSrcweir     sal_uInt64 nRequirements;
288cdf0e10cSrcweir     /** contains data needed for the creation of the java runtime.
289cdf0e10cSrcweir 
290cdf0e10cSrcweir         <p>There is no rule about the format and content of the sequence's
291cdf0e10cSrcweir         values. The plug-in libraries can put all data, necessary for
292cdf0e10cSrcweir         starting the java runtime into this sequence. </p>
293cdf0e10cSrcweir      */
294cdf0e10cSrcweir     sal_Sequence * arVendorData;
295cdf0e10cSrcweir };
296cdf0e10cSrcweir 
297cdf0e10cSrcweir typedef struct _JavaInfo JavaInfo;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir /** frees the memory of a <code>JavaInfo</code> object.
300cdf0e10cSrcweir     @param pInfo
301cdf0e10cSrcweir     The object which is to be freed. It can be NULL;
302cdf0e10cSrcweir  */
303cdf0e10cSrcweir void SAL_CALL jfw_freeJavaInfo(JavaInfo *pInfo);
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 
306cdf0e10cSrcweir /** compares two <code>JavaInfo</code> objects for equality.
307cdf0e10cSrcweir 
308cdf0e10cSrcweir    <p>Two <code>JavaInfo</code> objects are said to be equal if the contained
309cdf0e10cSrcweir    members of the first <code>JavaInfo</code> are equal to their counterparts
310cdf0e10cSrcweir    in the second <code>JavaInfo</code> object. The equality of the
311cdf0e10cSrcweir    <code>rtl_uString</code> members is determined
312cdf0e10cSrcweir    by the respective comparison function (see
313cdf0e10cSrcweir    <code>rtl::OUString::equals</code>).
314cdf0e10cSrcweir    Similiarly the equality of the <code>sal_Sequence</code> is
315cdf0e10cSrcweir    also determined by a comparison
316cdf0e10cSrcweir    function (see <code>rtl::ByteSequence::operator ==</code>). </p>
317cdf0e10cSrcweir    <p>
318cdf0e10cSrcweir    Both argument pointers  must be valid.</p>
319cdf0e10cSrcweir    @param pInfoA
320cdf0e10cSrcweir    the first argument.
321cdf0e10cSrcweir    @param pInfoB
322cdf0e10cSrcweir    the second argument which is compared with the first.
323cdf0e10cSrcweir    @return
324cdf0e10cSrcweir    sal_True - both object represent the same JRE.</br>
325cdf0e10cSrcweir    sal_False - the objects represend different JREs
326cdf0e10cSrcweir  */
327cdf0e10cSrcweir sal_Bool SAL_CALL jfw_areEqualJavaInfo(
328cdf0e10cSrcweir     JavaInfo const * pInfoA,JavaInfo const * pInfoB);
329cdf0e10cSrcweir 
330cdf0e10cSrcweir /** determines if a Java Virtual Machine is already running.
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     <p>As long as the the office and the JREs only support one
333cdf0e10cSrcweir     Virtual Machine per process the Java settings, particulary the
334cdf0e10cSrcweir     selected Java, are not effective immediatly after changing when
335cdf0e10cSrcweir     a VM has already been running. That is, if a JRE A was used to start
336cdf0e10cSrcweir     a VM and then a JRE B is selected, then JRE B will only be used
337cdf0e10cSrcweir     after a restart of the office.</p>
338cdf0e10cSrcweir     <p>
339cdf0e10cSrcweir     By determining if a VM is running, the user can be presented a message,
340cdf0e10cSrcweir     that the changed setting may not be effective immediately.</p>
341cdf0e10cSrcweir 
342cdf0e10cSrcweir     @param bRunning
343cdf0e10cSrcweir     [out] sal_True - a VM is running. <br/>
344cdf0e10cSrcweir     sal_False - no VM is running.
345cdf0e10cSrcweir 
346cdf0e10cSrcweir     @return
347cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
348cdf0e10cSrcweir     JFW_E_INVALID_ARG the parameter <code>bRunning</code> was NULL.
349cdf0e10cSrcweir */
350cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_isVMRunning(sal_Bool *bRunning);
351cdf0e10cSrcweir 
352cdf0e10cSrcweir /** detects a suitable JRE and configures the framework to use it.
353cdf0e10cSrcweir 
354cdf0e10cSrcweir     <p>Which JREs can be used is determined by the file javavendors.xml,
355cdf0e10cSrcweir     which contains version requirements, as well as information about available
356cdf0e10cSrcweir     plug-in libraries. Only these libraries are responsible for locating JRE
357cdf0e10cSrcweir     installations.</p>
358cdf0e10cSrcweir     <p>
359cdf0e10cSrcweir     JREs can be provided by different vendors. In order to find the JREs of
360cdf0e10cSrcweir     a certain vendor a plug-in library must be provided. There must be only one
361cdf0e10cSrcweir     library for one vendor. The names of locations of those libraries have to
362cdf0e10cSrcweir     be put into the javavendors.xml file.<br/>
363cdf0e10cSrcweir     The function uses the plug-in libraries to obtain information about JRE
364cdf0e10cSrcweir     installation and checks if they there is one among them that supports
365cdf0e10cSrcweir     a set of features (currently only accessibilty is possible). If none was
366cdf0e10cSrcweir     found then it also uses a list of paths, which have been registered
367cdf0e10cSrcweir     by <code>jfw_addJRELocation</code> or <code>jfw_setJRELocations</code>
368cdf0e10cSrcweir     to find JREs. Found JREs are examined in the same way.</p>
369cdf0e10cSrcweir     <p>
370cdf0e10cSrcweir     A JRE installation is only selected if it meets the version requirements.
371cdf0e10cSrcweir     Information about the selected JRE are made persistent so that
372cdf0e10cSrcweir     subsequent calls to <code>jfw_getSelectedJRE</code> returns this
373cdf0e10cSrcweir     information.</p>
374cdf0e10cSrcweir     <p>
375cdf0e10cSrcweir     While determining a proper JRE this function takes into account if a
376cdf0e10cSrcweir     user requires support for assistive technology tools. If user
377cdf0e10cSrcweir     need that support they have to set up their system accordingly. When support
378cdf0e10cSrcweir     for assistive technology is required, then the lists of
379cdf0e10cSrcweir     <code>JavaInfo</code> objects,
380cdf0e10cSrcweir     which are provided by the <code>getJavaInfo</code> functions of the plug-ins, are
381cdf0e10cSrcweir     examined for a suitable JRE. That is, the <code>JavaInfo</code> objects
382cdf0e10cSrcweir     from the list
383cdf0e10cSrcweir     obtained from the first plug-in, are examined. If no <code>JavaInfo</code>
384cdf0e10cSrcweir     object has the flag
385cdf0e10cSrcweir     <code>JFW_FEATURE_ACCESSBRIDGE</code> in the member <code>nFeatures</code>
386cdf0e10cSrcweir     then the
387cdf0e10cSrcweir     next plug-in is used to obtain a list of <code>JavaInfo</code> objects.
388cdf0e10cSrcweir     This goes on until a <code>JavaInfo</code> object was found which
389cdf0e10cSrcweir     represents a suitable JRE. Or neither plug-in provided such a
390cdf0e10cSrcweir     <code>JavaInfo</code> object. In that case the first
391cdf0e10cSrcweir     <code>JavaInfo</code> object from the first plug-in is used to determine
392cdf0e10cSrcweir     the JRE which is to be used.</p>
393cdf0e10cSrcweir     <p>
394cdf0e10cSrcweir     If there is no need for the support of assistive technology tools then
395cdf0e10cSrcweir     the first <code>JavaInfo</code> object from the list obtained by the
396cdf0e10cSrcweir     first plug-in is used. If this plug-in does not find any JREs then the
397cdf0e10cSrcweir     next plug-in is used, and so on.</p>
398cdf0e10cSrcweir 
399cdf0e10cSrcweir     @param ppInfo
400cdf0e10cSrcweir     [out] a <code>JavaInfo</code> pointer, representing the selected JRE.
401cdf0e10cSrcweir     The caller has to free it by calling <code>jfw_freeJavaInfo<code>. The
402cdf0e10cSrcweir     <code>JavaInfo</code> is for informational purposes only. It is not
403cdf0e10cSrcweir     necessary to call <code>jfw_setSelectedJRE</code> afterwards.<br/>
404cdf0e10cSrcweir     <code>ppInfo</code>can be NULL. If <code>*ppInfo</code> is not null, then it is
405cdf0e10cSrcweir     overwritten, without attempting to free <code>*ppInfo</code>.
406cdf0e10cSrcweir 
407cdf0e10cSrcweir     @return
408cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
409cdf0e10cSrcweir     JFW_E_ERROR an error occurred. <br/>
410cdf0e10cSrcweir     JFW_E_NO_PLUGIN a plug-in library could not be found.<br/>
411cdf0e10cSrcweir     JFW_E_NO_JAVA_FOUND no JRE was found that meets the requirements.</br>
412cdf0e10cSrcweir     JFW_E_DIRECT_MODE the function cannot be used in this mode. </br>
413cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
414cdf0e10cSrcweir     were not met.
415cdf0e10cSrcweir  */
416cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo);
417cdf0e10cSrcweir 
418cdf0e10cSrcweir /** provides information about all availabe JRE installations.
419cdf0e10cSrcweir 
420cdf0e10cSrcweir     <p>The function determines dynamically what JREs are available. It uses
421cdf0e10cSrcweir     the plug-in libraries to provide lists of available <code>JavaInfo</code>
422cdf0e10cSrcweir     objects where each object represents a JRE (see vendorplugin.h,
423cdf0e10cSrcweir     getAllJavaInfos). It also uses a list of paths, which have been registered
424cdf0e10cSrcweir     by <code>jfw_addJRELocation</code> or <code>jfw_setJRELocations</code>.
425cdf0e10cSrcweir     It is checked if the path still contains a valid JRE and if so the respective
426cdf0e10cSrcweir     <code>JavaInfo</code> object will be appended to the array unless there is
427cdf0e10cSrcweir     already an equal object.</p>
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     @param parInfo
430cdf0e10cSrcweir     [out] on returns it contains a pointer to an array of <code>JavaInfo</code>
431cdf0e10cSrcweir     pointers.
432cdf0e10cSrcweir     The caller must free the array with <code>rtl_freeMemory</code> and each
433cdf0e10cSrcweir     element of the array must be freed with <code>jfw_freeJavaInfo</code>.
434cdf0e10cSrcweir     @param pSize
435cdf0e10cSrcweir     [out] on return contains the size of array returned in <code>parInfo</code>.
436cdf0e10cSrcweir 
437cdf0e10cSrcweir     @return
438cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
439cdf0e10cSrcweir     JFW_E_INVALID_ARG at least on of the parameters was NULL<br/>
440cdf0e10cSrcweir     JFW_E_ERROR an error occurred. <br/>
441cdf0e10cSrcweir     JFW_E_NO_PLUGIN a plug-in library could not be found.<br/>
442cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
443cdf0e10cSrcweir     were not met.
444cdf0e10cSrcweir */
445cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_findAllJREs(
446cdf0e10cSrcweir     JavaInfo ***parInfo, sal_Int32 *pSize);
447cdf0e10cSrcweir 
448cdf0e10cSrcweir /** determines if a path points to a Java installation.
449cdf0e10cSrcweir 
450cdf0e10cSrcweir    <p>If the path belongs to a JRE installation then it returns the
451cdf0e10cSrcweir    respective <code>JavaInfo</code> object. The function uses the
452cdf0e10cSrcweir    <code>getJavaInfoByPath</code> function of the plug-ins to obtain the
453cdf0e10cSrcweir    <code>JavaInfo</code> object. Only if the JRE found at the specified location
454cdf0e10cSrcweir    meets the version requirements as specified in the javavendors.xml file a
455cdf0e10cSrcweir    <code>JavaInfo</code> object is returned.<br/>
456cdf0e10cSrcweir    <p>
457cdf0e10cSrcweir    The functions only checks if a JRE exists but does not modify any settings.
458cdf0e10cSrcweir    To make the found JRE the &quot;selected JRE&quot; one has
459cdf0e10cSrcweir    to call <code>jfw_setSelectedJRE</code>.</p>
460cdf0e10cSrcweir 
461cdf0e10cSrcweir    @param pPath
462cdf0e10cSrcweir    [in] a file URL to a directory.
463cdf0e10cSrcweir    @param pInfo
464cdf0e10cSrcweir    [out] the <code>JavaInfo</code> object which represents a JRE found at the
465cdf0e10cSrcweir    location specified by <code>pPath</code>
466cdf0e10cSrcweir 
467cdf0e10cSrcweir    @return
468cdf0e10cSrcweir    JFW_E_NONE function ran successfully.<br/>
469cdf0e10cSrcweir    JFW_E_INVALID_ARG at least on of the parameters was NULL<br/>
470cdf0e10cSrcweir    JFW_E_ERROR an error occurred. <br/>
471cdf0e10cSrcweir    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
472cdf0e10cSrcweir    were not met.</br>
473cdf0e10cSrcweir    JFW_E_NO_PLUGIN a plug-in library could not be found.<br/>
474cdf0e10cSrcweir    JFW_E_NOT_RECOGNIZED neither plug-in library could detect a JRE. <br/>
475cdf0e10cSrcweir    JFW_E_FAILED_VERSION a JRE was detected but if failed the version
476cdf0e10cSrcweir    requirements as determined by the javavendors.xml
477cdf0e10cSrcweir  */
478cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_getJavaInfoByPath(
479cdf0e10cSrcweir     rtl_uString *pPath, JavaInfo **ppInfo);
480cdf0e10cSrcweir 
481cdf0e10cSrcweir 
482cdf0e10cSrcweir /** starts a Java Virtual Machine (JVM).
483cdf0e10cSrcweir 
484cdf0e10cSrcweir     <p>The function uses the current settings to start a JVM. The actual
485cdf0e10cSrcweir     start-up code, however, is provided by the plug-in libraries. The setting
486cdf0e10cSrcweir     of the &quot;selected Java&quot; contains the information as to what vendor
487cdf0e10cSrcweir     the respective JRE comes from. In the javavendors.xml there is a mapping of
488cdf0e10cSrcweir     vendor names to the respective plug-in libraries.</p>
489cdf0e10cSrcweir     <p>
490cdf0e10cSrcweir     The function ultimately calls <code>startJavaVirtualMachine</code> from
491cdf0e10cSrcweir     the plug-in library.</p>
492cdf0e10cSrcweir     <p>
493cdf0e10cSrcweir     The <code>arOptions</code>
494cdf0e10cSrcweir     argument contains start arguments which are passed in JavaVMOption structures
495cdf0e10cSrcweir     to the VM during its creation. These
496cdf0e10cSrcweir     could be things, such as language settings, proxy settings or any other
497cdf0e10cSrcweir     properties which shall be obtainable by
498cdf0e10cSrcweir     <code>java.lang.System.getProperties</code>. One can also pass options which
499cdf0e10cSrcweir     have a certain meaning to the runtime behaviour such as -ea or -X... However,
500cdf0e10cSrcweir     one must be sure that these options can be interpreted by the VM.<br/>
501cdf0e10cSrcweir     The class path cannot be set this way. The class path is internally composed by
502cdf0e10cSrcweir     the paths to archives in a certain directory, which is preconfigured in
503cdf0e10cSrcweir     the internal data store and the respective user setting (see
504cdf0e10cSrcweir     <code>jfw_setUserClassPath</code>.</p>
505cdf0e10cSrcweir     <p>
506cdf0e10cSrcweir     If a JRE was selected at runtime which was different from the previous
507cdf0e10cSrcweir     setting and that JRE needs a prepared environment, for example an adapted
508cdf0e10cSrcweir     <code>LD_LIBRARY_PATH</code> environment variable, then the VM will not be
509cdf0e10cSrcweir     created and JFW_E_NEED_RESTART error is returned. If a VM is already running
510cdf0e10cSrcweir     then a JFW_E_RUNNING_JVM is returned.</p>
511cdf0e10cSrcweir 
512cdf0e10cSrcweir     @param arOptions
513cdf0e10cSrcweir     [in] the array containing additional start arguments or NULL.
514cdf0e10cSrcweir     @param nSize
515cdf0e10cSrcweir     [in] the size of the array <code>arOptions</code>.
516cdf0e10cSrcweir     @param ppVM
517cdf0e10cSrcweir     [out] the <code>JavaVM</code> pointer.
518cdf0e10cSrcweir     @param ppEnv
519cdf0e10cSrcweir     [out] the <code>JNIenv</code> pointer.
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     @return
522cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
523cdf0e10cSrcweir     JFW_E_INVALID_ARG <code>ppVM</code>, <code>ppEnv</code> are NULL or
524cdf0e10cSrcweir     <code>arOptions</code> was NULL but <code>nSize</code> was greater 0.<br/>
525cdf0e10cSrcweir     JFW_E_ERROR an error occurred. <br/>
526cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
527cdf0e10cSrcweir     were not met.</br>
528cdf0e10cSrcweir     JFW_E_NO_PLUGIN the plug-in library responsible for creating the VM
529cdf0e10cSrcweir     could not be found.<br/>
530cdf0e10cSrcweir     JFW_E_JAVA_DISABLED the use of Java is currently disabled. <br/>
531cdf0e10cSrcweir     JFW_E_NO_SELECT there is no JRE selected yet. <br/>
532cdf0e10cSrcweir     JFW_E_RUNNIN_JVM there is already a VM running.<br/>
533cdf0e10cSrcweir     JFW_E_INVALID_SETTINGS the javavendors.xml has been changed and no
534cdf0e10cSrcweir     JRE has been selected afterwards. <br/>
535cdf0e10cSrcweir     JFW_E_NEED_RESTART in the current process a different JRE has been selected
536cdf0e10cSrcweir     which needs a prepared environment, which has to be done before the office
537cdf0e10cSrcweir     process. Therefore the new JRE may not be used until the office was restarted.<br/>
538cdf0e10cSrcweir     JFW_E_NEED_RESTART is also returned when Java was disabled at the beginning and
539cdf0e10cSrcweir     then the user enabled it. If then the selected  JRE has the requirement
540cdf0e10cSrcweir     JFW_REQUIRE_NEEDRESTART then this error is returned. </br>
541cdf0e10cSrcweir     JFW_E_VM_CREATION_FAILED the creation of the JVM failed. The creation is performed
542cdf0e10cSrcweir     by a plug-in library and not by this API.
543cdf0e10cSrcweir     JFW_E_FAILED_VERSION the &quot;Default Mode&quot; is active. The JRE determined by
544cdf0e10cSrcweir     <code>JAVA_HOME</code>does not meet the version requirements.
545cdf0e10cSrcweir  */
546cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions,
547cdf0e10cSrcweir                                  sal_Int32 nSize, JavaVM **ppVM,
548cdf0e10cSrcweir                                  JNIEnv **ppEnv);
549cdf0e10cSrcweir 
550cdf0e10cSrcweir /** determines the JRE that is to be used.
551cdf0e10cSrcweir 
552cdf0e10cSrcweir     <p>When calling <code>jfw_startVM</code> then a VM is startet from
553cdf0e10cSrcweir     the JRE that is determined by this function.<br/>
554cdf0e10cSrcweir     It is not verified if the JRE represented by the <code>JavaInfo</code>
555cdf0e10cSrcweir     argument meets the requirements as specified by the javavendors.xml file.
556cdf0e10cSrcweir     However, usually one obtains the <code>JavaInfo</code> object from the
557cdf0e10cSrcweir     functions <code>jfw_findAllJREs</code> or <code>jfw_getJavaInfoByPath</code>,
558cdf0e10cSrcweir     which do verify the JREs and pass out only <code>JavaInfo</code> objects
559cdf0e10cSrcweir     which comply with the version requirements.</p>
560cdf0e10cSrcweir     <p>
561cdf0e10cSrcweir     If <code>pInfo</code> is NULL then the meaning is that no JRE will be
562cdf0e10cSrcweir     selected. <code>jfw_startVM</code> will then return
563cdf0e10cSrcweir     <code>JFW_E_NO_SELECT</code>.</p>
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     @param pInfo
566cdf0e10cSrcweir       [in] pointer to <code>JavaInfo</code> structure, containing data about a
567cdf0e10cSrcweir       JRE. The caller must still free <code>pInfo</code>.
568cdf0e10cSrcweir 
569cdf0e10cSrcweir     @return
570cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
571cdf0e10cSrcweir     JFW_E_ERROR An error occurred.<br/>
572cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
573cdf0e10cSrcweir     were not met.<br/>
574cdf0e10cSrcweir     JFW_E_DIRECT_MODE the function cannot be used in this mode.
575cdf0e10cSrcweir  */
576cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_setSelectedJRE(JavaInfo const *pInfo);
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 
579cdf0e10cSrcweir /** provides information about the JRE that is to be used.
580cdf0e10cSrcweir 
581cdf0e10cSrcweir     <p>If no JRE is currently selected then <code>ppInfo</code> will contain
582cdf0e10cSrcweir     NULL on return.</br>
583cdf0e10cSrcweir     If the value of the element <updated> in the javavendors.xml file was
584cdf0e10cSrcweir     changed since the time when the last Java was selected then this
585cdf0e10cSrcweir     function returns <code>JFW_E_INVALID_SETTINGS</code>. This could happen during
586cdf0e10cSrcweir     a product patch. Then new version requirements may be introduced, so that
587cdf0e10cSrcweir     the currently selected JRE may not meet these requirements anymore.
588cdf0e10cSrcweir     </p>
589cdf0e10cSrcweir     <p>In direct mode the function returns information about a JRE that was
590cdf0e10cSrcweir     set by the bootstrap parameter UNO_JAVA_JFW_JREHOME.
591cdf0e10cSrcweir     </p>
592cdf0e10cSrcweir     @param ppInfo
593cdf0e10cSrcweir     [out] on return it contains a pointer to a <code>JavaInfo</code> object
594cdf0e10cSrcweir     that represents the currently selected JRE. When <code>*ppInfo</code> is not
595cdf0e10cSrcweir     NULL then the function overwrites the pointer. It is not attempted to free
596cdf0e10cSrcweir     the pointer.
597cdf0e10cSrcweir 
598cdf0e10cSrcweir     @return
599cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
600cdf0e10cSrcweir     JFW_E_INVALIDARG <code>ppInfo</code> is a NULL.<br/>
601cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
602cdf0e10cSrcweir     were not met.<br/>
603cdf0e10cSrcweir     JFW_E_INVALID_SETTINGS the javavendors.xml has been changed and no
604cdf0e10cSrcweir     JRE has been selected afterwards. <br/>
605cdf0e10cSrcweir  */
606cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_getSelectedJRE(JavaInfo **ppInfo);
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 
609cdf0e10cSrcweir /** determines if Java can be used.
610cdf0e10cSrcweir 
611cdf0e10cSrcweir    <p>If <code>bEnabled</code> is <code>sal_False</code> then a call
612cdf0e10cSrcweir    to jfw_startVM will result in an error with the errorcode
613cdf0e10cSrcweir    <code>JFW_E_JAVA_DISABLED</code></p>
614cdf0e10cSrcweir 
615cdf0e10cSrcweir    @param bEnabled
616cdf0e10cSrcweir    [in] use of Java enabled/disabled.
617cdf0e10cSrcweir 
618cdf0e10cSrcweir    @return
619cdf0e10cSrcweir    JFW_E_NONE function ran successfully.<br/>
620cdf0e10cSrcweir    JFW_E_ERROR An error occurred.<br/>
621cdf0e10cSrcweir    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
622cdf0e10cSrcweir     were not met.<br/>
623cdf0e10cSrcweir    JFW_E_DIRECT_MODE the function cannot be used in this mode.
624cdf0e10cSrcweir  */
625cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_setEnabled(sal_Bool bEnabled);
626cdf0e10cSrcweir 
627cdf0e10cSrcweir /** provides the information if Java can be used.
628cdf0e10cSrcweir 
629cdf0e10cSrcweir     <p>That is if the user enabled or disabled the use of Java.
630cdf0e10cSrcweir     </p>
631cdf0e10cSrcweir 
632cdf0e10cSrcweir    @return
633cdf0e10cSrcweir    JFW_E_NONE function ran successfully.<br/>
634cdf0e10cSrcweir    JFW_E_INVALIDARG pbEnabled is NULL<br/>
635cdf0e10cSrcweir    JFW_E_ERROR An error occurred.<br/>
636cdf0e10cSrcweir    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
637cdf0e10cSrcweir     were not met.<br/>
638cdf0e10cSrcweir     JFW_E_DIRECT_MODE the function cannot be used in this mode.
639cdf0e10cSrcweir  */
640cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_getEnabled(sal_Bool *pbEnabled);
641cdf0e10cSrcweir 
642cdf0e10cSrcweir /** determines parameters which are passed to VM during its creation.
643cdf0e10cSrcweir 
644cdf0e10cSrcweir     <p>The strings must be exactly as they are passed on the command line.
645cdf0e10cSrcweir     For example, one could pass<br/>
646cdf0e10cSrcweir     -Xdebug <br/>
647cdf0e10cSrcweir     -Xrunjdw:transport=dt_socket,server=y,address=8000<br/>
648cdf0e10cSrcweir     in order to enable debugging support.
649cdf0e10cSrcweir     </p>
650cdf0e10cSrcweir 
651cdf0e10cSrcweir     @param arParameters
652cdf0e10cSrcweir     [in] contains the arguments. It can be NULL if nSize is 0.
653cdf0e10cSrcweir     @param nSize
654cdf0e10cSrcweir     [i] the size of <code>arArgs</code>
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     @return
657cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
658cdf0e10cSrcweir     JFW_E_INVALIDARG arArgs is NULL and nSize is not 0
659cdf0e10cSrcweir     JFW_E_ERROR An error occurred.<br/>
660cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
661cdf0e10cSrcweir     were not met.<br/>
662cdf0e10cSrcweir     JFW_E_DIRECT_MODE the function cannot be used in this mode.
663cdf0e10cSrcweir  */
664cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_setVMParameters(
665cdf0e10cSrcweir     rtl_uString **  arArgs, sal_Int32 nSize);
666cdf0e10cSrcweir 
667cdf0e10cSrcweir /** obtains the currently used start parameters.
668cdf0e10cSrcweir 
669cdf0e10cSrcweir     <p>The caller needs to free the returned array with
670cdf0e10cSrcweir     <code>rtl_freeMemory</code>. The contained strings must be released with
671cdf0e10cSrcweir     <code>rtl_uString_release</code>.
672cdf0e10cSrcweir     </p>
673cdf0e10cSrcweir 
674cdf0e10cSrcweir     @param parParameters
675cdf0e10cSrcweir     [out] on returns contains a pointer to the array of the start arguments.
676cdf0e10cSrcweir     If *parParameters is not NULL then the value is overwritten.
677cdf0e10cSrcweir     @param pSize
678cdf0e10cSrcweir     [out] on return contains the size of array returned in
679cdf0e10cSrcweir     <code>parParameters</code>
680cdf0e10cSrcweir 
681cdf0e10cSrcweir     @return
682cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
683cdf0e10cSrcweir     JFW_E_INVALIDARG parParameters or pSize are  NULL<br/>
684cdf0e10cSrcweir     JFW_E_ERROR An error occurred.<br/>
685cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
686cdf0e10cSrcweir     were not met.<br/>
687cdf0e10cSrcweir     JFW_E_DIRECT_MODE the function cannot be used in this mode.
688cdf0e10cSrcweir  */
689cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_getVMParameters(
690cdf0e10cSrcweir     rtl_uString *** parParameters,
691cdf0e10cSrcweir     sal_Int32 * pSize);
692cdf0e10cSrcweir 
693cdf0e10cSrcweir /** sets the user class path.
694cdf0e10cSrcweir 
695cdf0e10cSrcweir    <p>When the VM is started then it is passed the class path. The
696cdf0e10cSrcweir    class path also contains the user class path set by this function.
697cdf0e10cSrcweir    The paths contained in <code>pCP</code> must be separated with a
698cdf0e10cSrcweir    system dependent path separator.</p>
699cdf0e10cSrcweir 
700cdf0e10cSrcweir    @param pCP
701cdf0e10cSrcweir    [in] the user class path.
702cdf0e10cSrcweir 
703cdf0e10cSrcweir    @return
704cdf0e10cSrcweir    JFW_E_NONE function ran successfully.<br/>
705cdf0e10cSrcweir    JFW_E_INVALIDARG pCP is NULL.<br/>
706cdf0e10cSrcweir    JFW_E_ERROR An error occurred.<br/>
707cdf0e10cSrcweir    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
708cdf0e10cSrcweir     were not met.<br/>
709cdf0e10cSrcweir    JFW_E_DIRECT_MODE the function cannot be used in this mode.
710cdf0e10cSrcweir  */
711cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_setUserClassPath(rtl_uString * pCP);
712cdf0e10cSrcweir /** provides the value of the current user class path.
713cdf0e10cSrcweir 
714cdf0e10cSrcweir    <p>The function returns an empty string if no user class path is set.
715cdf0e10cSrcweir    </p>
716cdf0e10cSrcweir 
717cdf0e10cSrcweir    @param ppCP
718cdf0e10cSrcweir    [out] contains the user class path on return. If <code>*ppCP</code> was
719cdf0e10cSrcweir    not NULL then the value is overwritten. No attempt at freeing that string
720cdf0e10cSrcweir    is made.
721cdf0e10cSrcweir 
722cdf0e10cSrcweir    @return
723cdf0e10cSrcweir    JFW_E_NONE function ran successfully.<br/>
724cdf0e10cSrcweir    JFW_E_INVALIDARG ppCP is NULL.<br/>
725cdf0e10cSrcweir    JFW_E_ERROR An error occurred.<br/>
726cdf0e10cSrcweir    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
727cdf0e10cSrcweir     were not met.<br/>
728cdf0e10cSrcweir    JFW_E_DIRECT_MODE the function cannot be used in this mode.
729cdf0e10cSrcweir  */
730cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_getUserClassPath(rtl_uString ** ppCP);
731cdf0e10cSrcweir 
732cdf0e10cSrcweir /** saves the location of a JRE.
733cdf0e10cSrcweir 
734cdf0e10cSrcweir     <p>When <code>jfw_findAllJREs</code> is called then the paths added by this
735cdf0e10cSrcweir     function are evaluated. If the location still represents a
736cdf0e10cSrcweir     JRE then a <code>JavaInfo</code> object is created which is returned along
737cdf0e10cSrcweir     with all other <code>JavaInfo</code> objects by
738cdf0e10cSrcweir     <code>jfw_findAllJREs</code>. If the location
739cdf0e10cSrcweir     cannot be recognized then the location string is ignored. </p>
740cdf0e10cSrcweir     <p>
741cdf0e10cSrcweir     A validation if <code>sLocation</code> points to a JRE is not
742cdf0e10cSrcweir     performed. To do that one has to use <code>jfw_getJavaInfoByPath</code>.
743cdf0e10cSrcweir     </p>
744cdf0e10cSrcweir     <p>
745cdf0e10cSrcweir     Adding a path that is already stored causes no error.</p>
746cdf0e10cSrcweir 
747cdf0e10cSrcweir     @param sLocation
748cdf0e10cSrcweir     [in] file URL to a directory which contains a JRE.
749cdf0e10cSrcweir 
750cdf0e10cSrcweir     @return
751cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
752cdf0e10cSrcweir     JFW_E_INVALIDARG sLocation is NULL.<br/>
753cdf0e10cSrcweir     JFW_E_ERROR An error occurred.<br/>
754cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
755cdf0e10cSrcweir     were not met.<br/>
756cdf0e10cSrcweir     JFW_E_DIRECT_MODE the function cannot be used in this mode.
757cdf0e10cSrcweir     @see jfw_setJRELocations
758cdf0e10cSrcweir  */
759cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_addJRELocation(rtl_uString * sLocation);
760cdf0e10cSrcweir 
761cdf0e10cSrcweir /** saves the locations of a number of JREs.
762cdf0e10cSrcweir 
763cdf0e10cSrcweir     <p>
764cdf0e10cSrcweir     The function does not verify if the paths points to JRE. However,
765cdf0e10cSrcweir     it makes sure that every path is unique. That is, if the array
766cdf0e10cSrcweir     contains strings which are the same then only one is stored.</p>
767cdf0e10cSrcweir     <p>
768cdf0e10cSrcweir     If <code>arLocations</code> is NULL or it has the length null (nSize = 0)
769cdf0e10cSrcweir     then all previously stored paths are deleted. Otherwise,
770cdf0e10cSrcweir     the old values are overwritten.</p>
771cdf0e10cSrcweir 
772cdf0e10cSrcweir     @param arLocations
773cdf0e10cSrcweir     [in] array of paths to locations of JREs.
774cdf0e10cSrcweir 
775cdf0e10cSrcweir     @param nSize
776cdf0e10cSrcweir     [in] the size of the array <code>arLocations</code>
777cdf0e10cSrcweir 
778cdf0e10cSrcweir     @return
779cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
780cdf0e10cSrcweir     JFW_E_INVALIDARG arLocation is NULL and nSize is not null.<br/>
781cdf0e10cSrcweir     JFW_E_ERROR An error occurred.<br/>
782cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
783cdf0e10cSrcweir     were not met.<br/>
784cdf0e10cSrcweir     JFW_E_DIRECT_MODE the function cannot be used in this mode.
785cdf0e10cSrcweir     @see jfw_addJRELocations
786cdf0e10cSrcweir  */
787cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_setJRELocations(
788cdf0e10cSrcweir     rtl_uString ** arLocations, sal_Int32 nSize);
789cdf0e10cSrcweir /** obtains an array containing paths to JRE installations.
790cdf0e10cSrcweir 
791cdf0e10cSrcweir     <p>
792cdf0e10cSrcweir     It is not guaranteed that the returned paths represent
793cdf0e10cSrcweir     a valid JRE. One can use <code>jfw_getJavaInfoByPath</code> to check this.
794cdf0e10cSrcweir     </p>
795cdf0e10cSrcweir 
796cdf0e10cSrcweir     @param parLocations
797cdf0e10cSrcweir     [out] on return it contains the array of paths.
798cdf0e10cSrcweir     @param pSize
799cdf0e10cSrcweir     [out] on return it contains the size of the array <code>parLocations</code>.
800cdf0e10cSrcweir 
801cdf0e10cSrcweir     @return
802cdf0e10cSrcweir     JFW_E_NONE function ran successfully.<br/>
803cdf0e10cSrcweir     JFW_E_INVALIDARG parLocation is NULL or pSize is NULL.<br/>
804cdf0e10cSrcweir     JFW_E_ERROR An error occurred.<br/>
805cdf0e10cSrcweir     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
806cdf0e10cSrcweir     were not met.<br/>
807cdf0e10cSrcweir     JFW_E_DIRECT_MODE the function cannot be used in this mode.
808cdf0e10cSrcweir  */
809cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_getJRELocations(
810cdf0e10cSrcweir     rtl_uString *** parLocations, sal_Int32 * pSize);
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 
813cdf0e10cSrcweir /** checks if the installation of the jre still exists.
814cdf0e10cSrcweir 
815cdf0e10cSrcweir     This function checks if the JRE described by pInfo still
816cdf0e10cSrcweir     exists. The check must be very quick because it is called by javaldx
817cdf0e10cSrcweir     (Linux, Solaris) at start up.
818cdf0e10cSrcweir 
819cdf0e10cSrcweir     @param pInfo
820cdf0e10cSrcweir         [in]  the JavaInfo object with information about the JRE.
821cdf0e10cSrcweir     @param pp_exist
822cdf0e10cSrcweir         [out] the parameter is set to either sal_True or sal_False. The value is
823cdf0e10cSrcweir         only valid if the function returns JFW_E_NONE.
824cdf0e10cSrcweir 
825cdf0e10cSrcweir    @return
826cdf0e10cSrcweir     JFW_E_NONE the function ran successfully.</br>
827cdf0e10cSrcweir     JFW_E_ERROR an error occurred during execution.</br>
828cdf0e10cSrcweir     JFW_E_INVALID_ARG pInfo contains invalid data</br>
829cdf0e10cSrcweir     JFW_E_NO_PLUGIN a plug-in library could not be found.<br/>
830cdf0e10cSrcweir  */
831cdf0e10cSrcweir javaFrameworkError SAL_CALL jfw_existJRE(const JavaInfo *pInfo, sal_Bool *exist);
832cdf0e10cSrcweir 
833cdf0e10cSrcweir 
834cdf0e10cSrcweir /** locks this API so that it cannot be used by other threads.
835cdf0e10cSrcweir 
836cdf0e10cSrcweir     <p>If a different thread called this function before then the
837cdf0e10cSrcweir     current call is blocked until the other thread has called
838cdf0e10cSrcweir     <code>jfw_unlock()</code>. The function should be called if one
839cdf0e10cSrcweir     needs an exact snapshot of the current settings. Then the settings
840cdf0e10cSrcweir     are retrieved one by one without risk that the settings may be changed
841cdf0e10cSrcweir     by a different thread. Similiary if one needs to make settings which
842cdf0e10cSrcweir     should become effective at the same time then <code>jfw_lock</code>
843cdf0e10cSrcweir     should be called. That is, <code>jfw_startVM</code> which uses the
844cdf0e10cSrcweir     settings cannot be called before all settings have be made.</p>
845cdf0e10cSrcweir     <p>
846cdf0e10cSrcweir     The only functions which are not effected by <code>jfw_lock</code> are
847cdf0e10cSrcweir     <code>jfw_freeJavaInfo</code> and <code>jfw_areEqualJavaInfo</code>.
848cdf0e10cSrcweir  */
849cdf0e10cSrcweir void SAL_CALL jfw_lock();
850cdf0e10cSrcweir 
851cdf0e10cSrcweir /** unlocks this API.
852cdf0e10cSrcweir 
853cdf0e10cSrcweir     <p>This function is called after <code>jfw_lock</code>. It allows other
854cdf0e10cSrcweir     threads to use this API concurrently.</p>
855cdf0e10cSrcweir */
856cdf0e10cSrcweir void SAL_CALL jfw_unlock();
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 
859cdf0e10cSrcweir #ifdef __cplusplus
860cdf0e10cSrcweir }
861cdf0e10cSrcweir #endif
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 
864cdf0e10cSrcweir #endif
865