Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_JVMACCESS_UNOVIRTUALMACHINE_HXX
21 : #define INCLUDED_JVMACCESS_UNOVIRTUALMACHINE_HXX
22 :
23 : #include <jvmaccess/jvmaccessdllapi.h>
24 : #include <sal/config.h>
25 : #include <salhelper/simplereferenceobject.hxx>
26 : #include <rtl/ref.hxx>
27 :
28 : namespace jvmaccess {
29 :
30 : class VirtualMachine;
31 :
32 : /** An encapsulating wrapper around a Java virtual machine and an appropriate
33 : UNO class loader.
34 : */
35 : class JVMACCESS_DLLPUBLIC UnoVirtualMachine: public salhelper::SimpleReferenceObject {
36 : public:
37 : /** An exception indicating failure to create a UnoVirtualMachine.
38 : */
39 : class JVMACCESS_DLLPUBLIC CreationException
40 : {
41 : public:
42 : CreationException();
43 :
44 : CreationException(CreationException const &);
45 :
46 : virtual ~CreationException();
47 :
48 : CreationException & operator =(CreationException const &);
49 : };
50 :
51 : /** Create a wrapper around a Java virtual machine and an appropriate UNO
52 : class loader.
53 :
54 : @param virtualMachine
55 : A Java virtual machine wrapper. Must not be null.
56 :
57 : @param classLoader
58 : A local or global JNI reference, relative to the given virtualMachine,
59 : to an appropriate UNO class loader instance. Must not be null. This
60 : parameter should be of type jobject, not void *, but the exact
61 : definition of jobject is different for different JDK versions, so that
62 : the mangled C++ name of the constructor would depend on the JDK version
63 : used at compile time.
64 :
65 : @exception CreationException
66 : Thrown in case creation fails (due to a JNI problem).
67 : */
68 : UnoVirtualMachine(
69 : rtl::Reference< jvmaccess::VirtualMachine > const & virtualMachine,
70 : void * classLoader);
71 :
72 : /** Get the Java virtual machine wrapper.
73 :
74 : @return
75 : The Java virtual machine wrapper. Will never be null.
76 : */
77 186 : rtl::Reference< jvmaccess::VirtualMachine > getVirtualMachine() const { return m_virtualMachine;}
78 :
79 : /** Get the UNO class loader.
80 :
81 : @return
82 : A global JNI reference to the UNO class loader. (The JNI reference must
83 : not be deleted by client code.) Will never be null. This should be of
84 : type jobject, not void *, but the exact definition of jobject is
85 : different for different JDK versions, so that the mangled C++ name of
86 : the function would depend on the JDK version used at compile time.
87 : */
88 212 : void * getClassLoader() const { return m_classLoader;}
89 :
90 : private:
91 : UnoVirtualMachine(UnoVirtualMachine &); // not defined
92 : void operator =(UnoVirtualMachine &); // not defined
93 :
94 : virtual ~UnoVirtualMachine();
95 :
96 : rtl::Reference< jvmaccess::VirtualMachine > m_virtualMachine;
97 : void * m_classLoader;
98 : };
99 :
100 : }
101 :
102 : #endif
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|