bump product version to 5.0.4.1
[LibreOffice.git] / jvmfwk / inc / vendorbase.hxx
bloba01db566c4c10634f447eea0471175af026291ba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_VENDORBASE_HXX
21 #define INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_VENDORBASE_HXX
23 #include "config_java.h"
25 #include "rtl/ustring.hxx"
26 #include "rtl/ref.hxx"
27 #include "osl/endian.h"
28 #include "salhelper/simplereferenceobject.hxx"
29 #include <vector>
31 namespace jfw_plugin
35 //Used by subclasses of VendorBase to build paths to Java runtime
36 #if defined(JAVA_ARCH)
37 #define JFW_PLUGIN_ARCH JAVA_ARCH
38 #elif defined(__sparcv9)
39 #define JFW_PLUGIN_ARCH "sparcv9"
40 #elif defined SPARC
41 #define JFW_PLUGIN_ARCH "sparc"
42 #elif defined X86_64
43 #define JFW_PLUGIN_ARCH "amd64"
44 #elif defined INTEL
45 #define JFW_PLUGIN_ARCH "i386"
46 #elif defined POWERPC64
47 #define JFW_PLUGIN_ARCH "ppc64"
48 #elif defined POWERPC
49 #define JFW_PLUGIN_ARCH "ppc"
50 #elif defined MIPS
51 #ifdef OSL_BIGENDIAN
52 # define JFW_PLUGIN_ARCH "mips"
53 #else
54 /* FIXME: do JDKs have some JDK-specific define? This is for
55 OpenJDK at least, but probably not true for Lemotes JDK */
56 # define JFW_PLUGIN_ARCH "mipsel"
57 #endif
58 #elif defined S390X
59 #define JFW_PLUGIN_ARCH "s390x"
60 #elif defined S390
61 #define JFW_PLUGIN_ARCH "s390"
62 #elif defined ARM
63 #define JFW_PLUGIN_ARCH "arm"
64 #elif defined IA64
65 #define JFW_PLUGIN_ARCH "ia64"
66 #elif defined M68K
67 #define JFW_PLUGIN_ARCH "m68k"
68 #elif defined HPPA
69 #define JFW_PLUGIN_ARCH "parisc"
70 #elif defined AXP
71 #define JFW_PLUGIN_ARCH "alpha"
72 #elif defined AARCH64
73 #define JFW_PLUGIN_ARCH "aarch64"
74 #else // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA, ALPHA
75 #error unknown platform
76 #endif // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA, ALPHA
79 class MalformedVersionException
81 public:
82 MalformedVersionException();
84 MalformedVersionException(const MalformedVersionException &);
86 virtual ~MalformedVersionException();
88 MalformedVersionException & operator =(const MalformedVersionException &);
91 class VendorBase: public salhelper::SimpleReferenceObject
93 public:
94 VendorBase();
95 /* static char const* const * getJavaExePaths(int* size);
97 returns relative paths to the java executable as
98 file URLs.
100 For example "bin/java.exe". You need
101 to implement this function in a derived class, if
102 the paths differ. this implmentation provides for
103 Windows "bin/java.exe" and for Unix "bin/java".
104 The paths are relative file URLs. That is, they always
105 contain '/' even on windows. The paths are relative
106 to the installation directory of a JRE.
109 The signature of this function must correspond to
110 getJavaExePaths_func.
113 /* static rtl::Reference<VendorBase> createInstance();
115 creates an instance of this class. MUST be overridden
116 in a derived class.
117 ####################################################
118 OVERRIDE in derived class
119 ###################################################
120 @param
121 Key - value pairs of the system properties of the JRE.
124 const OUString & getVendor() const;
125 const OUString & getVersion() const;
126 const OUString & getHome() const;
127 const OUString & getRuntimeLibrary() const;
128 const OUString & getLibraryPath() const;
129 bool supportsAccessibility() const;
130 /* determines if prior to running java something has to be done,
131 like setting the LD_LIBRARY_PATH. This implementation checks
132 if an LD_LIBRARY_PATH (getLD_LIBRARY_PATH) needs to be set and
133 if so, needsRestart returns true.
135 bool needsRestart() const;
137 /* compares versions of this vendor. MUST be overridden
138 in a derived class.
139 ####################################################
140 OVERRIDE in derived class
141 ###################################################
142 @return
143 0 this.version == sSecond
144 1 this.version > sSecond
145 -1 this.version < sSEcond
147 @throw
148 MalformedVersionException if the version string was not recognized.
150 virtual int compareVersions(const OUString& sSecond) const = 0;
152 protected:
153 /* called automatically on the instance created by createInstance.
155 @return
156 true - the object could completely initialize.
157 false - the object could not completely initialize. In this case
158 it will be discarded by the caller.
160 virtual bool initialize(
161 std::vector<std::pair<OUString, OUString> > props);
163 /* returns relative file URLs to the runtime library.
164 For example "/bin/client/jvm.dll"
166 virtual char const* const* getRuntimePaths(int* size) = 0;
168 virtual char const* const* getLibraryPaths(int* size) = 0;
170 OUString m_sVendor;
171 OUString m_sVersion;
172 OUString m_sHome;
173 OUString m_sRuntimeLibrary;
174 OUString m_sLD_LIBRARY_PATH;
175 bool m_bAccessibility;
178 typedef rtl::Reference<VendorBase> (* createInstance_func) ();
179 friend rtl::Reference<VendorBase> createInstance(
180 createInstance_func pFunc,
181 std::vector<std::pair<OUString, OUString> > properties);
186 #endif
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */