xref: /aoo41x/main/udkapi/com/sun/star/java/XJavaVM.idl (revision 408a4873)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23#ifndef __com_sun_star_java_XJavaVM_idl__
24#define __com_sun_star_java_XJavaVM_idl__
25
26#ifndef __com_sun_star_uno_XInterface_idl__
27#include <com/sun/star/uno/XInterface.idl>
28#endif
29
30//=============================================================================
31
32module com {  module sun {  module star {  module java {
33
34//=============================================================================
35
36// DocMerge from xml: interface com::sun::star::java::XJavaVM
37/** must be implemented by the user of the XJavaVM.
38
39    @deprecated
40    A UNO interface seems to be at the wrong abstraction level for this
41    functionality (also, the C++ classes <code>jvmaccess::VirtualMachine</code>
42    and <code>jvmaccess::UnoVirtualMachine</code> used by
43    <member scope="com::sun::star::java">XJavaVM::getJavaVM</member> are not
44    part of the public C++ UNO runtime API).  This should probably be replaced
45    by an appropriate C/C++ API.
46 */
47published interface XJavaVM: com::sun::star::uno::XInterface
48{
49	//-------------------------------------------------------------------------
50
51	// DocMerge from xml: method com::sun::star::java::XJavaVM::getJavaVM
52	/** returns the address of the Java Virtual Machine.
53
54		<p>If the VM is not already instantiated, it will be now.</p>
55
56        <p>If the <code>processID</code> is a normal 16-byte ID, the returned
57        <atom>any</atom> contains a JNI <code>JavaVM</code> pointer as a
58        <atom>long</atom> or <atom>hyper</atom> integer (depending on the
59        platform).  If the <code>processID</code> does not match the current
60        process, or if the VM cannot be instantiated for whatever reason, a
61        <void/> <atom>any</atom> is returned.</p>
62
63        <p>If the <code>processID</code> has an additional 17th byte of
64        value&nbsp;<code>0</code>, the returned <atom>any</atom> contains a
65        non&ndash;reference-counted pointer to a (reference-counted) instance of
66        the C++ <code>jvmaccess::VirtualMachine</code> class, always represented
67        as a <atom>hyper</atom> integer.  The pointer is guaranteed to be valid
68        as long as the reference to this
69        <type scope="com::sun::star::java">XJavaVM</type> is valid (but the
70        pointer should be converted into a reference-counted reference as soon
71        as possible).  Again, if the first 16 bytes of the
72        <code>processID</code> do not match the current process, or if the VM
73        cannot be instantiated for whatever reason, a <void/> <atom>any</atom>
74        is returned.</p>
75
76        <p>If the <code>processID</code> has an additional 17th byte of
77        value&nbsp;<code>1</code>, the returned <atom>any</atom> contains a
78        non&ndash;reference-counted pointer to a (reference-counted) instance of
79        the C++ <code>jvmaccess::UnoVirtualMachine</code> class, always
80        represented as a <atom>hyper</atom> integer.  The pointer is guaranteed
81        to be valid as long as the reference to this
82        <type scope="com::sun::star::java">XJavaVM</type> is valid.  Again, if
83        the first 16 bytes of the <code>processID</code> do not match the
84        current process, or if the VM cannot be instantiated for whatever
85        reason, a <void/> <atom>any</atom> is returned.</p>
86
87        <p>The first form (returning a JNI <code>JavaVM</code> pointer) is
88        mainly for backwards compatibility, new code should use the second form
89        (returning a pointer to a <code>jvmaccess::VirtualMachine</code>) if it
90        does not want to use the Java UNO environment, and it should use the
91        third form (returning a pointer to a
92        <code>jvmaccess::UnoVirtualMachine</code>) if it wants to use the Java
93        UNO environment.  For example, one advantage of using
94        <code>jvmaccess::VirtualMachine</code> instead of the raw
95        <code>JavaVM</code> pointer is that whenever you attach a native thread
96        to the Java virtual machine, that thread's context
97        <code>ClassLoader</code> (see
98        <code>java.lang.Thread.getContextClassLoader</code>) will automatically
99        be set to a meaningful value.</p>
100
101        @param processID
102        The process ID of the caller's process, possibly extended by a 17th byte
103        of value <code>0</code> or&nbsp;<code>1</code>.
104
105        @return
106        On success, the <atom>any</atom> contains a pointer represented as
107        <atom>long</atom> or <atom>hyper</atom>, otherwise the <atom>any</atom>
108        is <void/>.
109	 */
110	any getJavaVM( [in] sequence<byte> processID );
111
112	//-------------------------------------------------------------------------
113
114	// DocMerge from xml: method com::sun::star::java::XJavaVM::isVMStarted
115	/** returns <true/> if the VM is started successfully, otherwise <false/>.
116	 */
117	boolean isVMStarted();
118
119	//-------------------------------------------------------------------------
120
121	// DocMerge from xml: method com::sun::star::java::XJavaVM::isVMEnabled
122	/** Returns <true/> if the VM is enabled.
123
124		<p>It is only possible to get the VM, if this method return 0. </p>
125	 */
126	boolean isVMEnabled();
127
128};
129
130//=============================================================================
131
132}; }; }; };
133
134/*=============================================================================
135
136=============================================================================*/
137#endif
138