Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / jvmfwk / inc / vendorbase.hxx
blobd5742783f5bcc2d6bc6c92885a40cbbb5c4302da
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 MIPS64
59 #ifdef OSL_BIGENDIAN
60 # define JFW_PLUGIN_ARCH "mips64"
61 #else
62 # define JFW_PLUGIN_ARCH "mips64el"
63 #endif
64 #elif defined S390X
65 #define JFW_PLUGIN_ARCH "s390x"
66 #elif defined S390
67 #define JFW_PLUGIN_ARCH "s390"
68 #elif defined ARM
69 #define JFW_PLUGIN_ARCH "arm"
70 #elif defined IA64
71 #define JFW_PLUGIN_ARCH "ia64"
72 #elif defined M68K
73 #define JFW_PLUGIN_ARCH "m68k"
74 #elif defined HPPA
75 #define JFW_PLUGIN_ARCH "parisc"
76 #elif defined AXP
77 #define JFW_PLUGIN_ARCH "alpha"
78 #elif defined AARCH64
79 #define JFW_PLUGIN_ARCH "aarch64"
80 #else // SPARC, INTEL, POWERPC, MIPS, MIPS64, ARM, IA64, M68K, HPPA, ALPHA
81 #error unknown platform
82 #endif // SPARC, INTEL, POWERPC, MIPS, MIPS64, ARM, IA64, M68K, HPPA, ALPHA
85 class MalformedVersionException : public std::exception
87 public:
88 MalformedVersionException();
90 MalformedVersionException(const MalformedVersionException &);
92 virtual ~MalformedVersionException();
94 MalformedVersionException & operator =(const MalformedVersionException &);
97 class VendorBase: public salhelper::SimpleReferenceObject
99 public:
100 VendorBase();
101 /* static char const* const * getJavaExePaths(int* size);
103 returns relative paths to the java executable as
104 file URLs.
106 For example "bin/java.exe". You need
107 to implement this function in a derived class, if
108 the paths differ. this implmentation provides for
109 Windows "bin/java.exe" and for Unix "bin/java".
110 The paths are relative file URLs. That is, they always
111 contain '/' even on windows. The paths are relative
112 to the installation directory of a JRE.
115 The signature of this function must correspond to
116 getJavaExePaths_func.
119 /* static rtl::Reference<VendorBase> createInstance();
121 creates an instance of this class. MUST be overridden
122 in a derived class.
123 ####################################################
124 OVERRIDE in derived class
125 ###################################################
126 @param
127 Key - value pairs of the system properties of the JRE.
130 const OUString & getVendor() const;
131 const OUString & getVersion() const;
132 const OUString & getHome() const;
133 const OUString & getRuntimeLibrary() const;
134 const OUString & getLibraryPath() const;
135 bool supportsAccessibility() const;
136 /* determines if prior to running java something has to be done,
137 like setting the LD_LIBRARY_PATH. This implementation checks
138 if an LD_LIBRARY_PATH (getLD_LIBRARY_PATH) needs to be set and
139 if so, needsRestart returns true.
141 bool needsRestart() const;
143 /* compares versions of this vendor. MUST be overridden
144 in a derived class.
145 ####################################################
146 OVERRIDE in derived class
147 ###################################################
148 @return
149 0 this.version == sSecond
150 1 this.version > sSecond
151 -1 this.version < sSEcond
153 @throw
154 MalformedVersionException if the version string was not recognized.
156 virtual int compareVersions(const OUString& sSecond) const = 0;
158 protected:
159 /* called automatically on the instance created by createInstance.
161 @return
162 true - the object could completely initialize.
163 false - the object could not completely initialize. In this case
164 it will be discarded by the caller.
166 virtual bool initialize(
167 std::vector<std::pair<OUString, OUString> > props);
169 /* returns relative file URLs to the runtime library.
170 For example "/bin/client/jvm.dll"
172 virtual char const* const* getRuntimePaths(int* size) = 0;
174 virtual char const* const* getLibraryPaths(int* size) = 0;
176 OUString m_sVendor;
177 OUString m_sVersion;
178 OUString m_sHome;
179 OUString m_sRuntimeLibrary;
180 OUString m_sLD_LIBRARY_PATH;
181 bool m_bAccessibility;
184 typedef rtl::Reference<VendorBase> (* createInstance_func) ();
185 friend rtl::Reference<VendorBase> createInstance(
186 createInstance_func pFunc,
187 const std::vector<std::pair<OUString, OUString> >& properties);
192 #endif
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */