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 24 #if !defined INCLUDED_JFW_PLUGIN_VENDORBASE_HXX 25 #define INCLUDED_JFW_PLUGIN_VENDORBASE_HXX 26 27 #include "rtl/ustring.hxx" 28 #include "rtl/ref.hxx" 29 #include "osl/endian.h" 30 #include "salhelper/simplereferenceobject.hxx" 31 #include <vector> 32 33 namespace jfw_plugin 34 { 35 36 37 //Used by subclasses of VendorBase to build paths to Java runtime 38 #if 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 # define JFW_PLUGIN_ARCH "mips32" 55 #endif 56 #elif defined S390X 57 #define JFW_PLUGIN_ARCH "s390x" 58 #elif defined S390 59 #define JFW_PLUGIN_ARCH "s390" 60 #elif defined AARCH64 61 #define JFW_PLUGIN_ARCH "aarch64" 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 #else // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA, ALPHA 73 #error unknown platform 74 #endif // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA, ALPHA 75 76 77 class MalformedVersionException 78 { 79 public: 80 MalformedVersionException(); 81 82 MalformedVersionException(const MalformedVersionException &); 83 84 virtual ~MalformedVersionException(); 85 86 MalformedVersionException & operator =(const MalformedVersionException &); 87 }; 88 89 class VendorBase: public salhelper::SimpleReferenceObject 90 { 91 public: 92 VendorBase(); 93 /* returns relativ paths to the java executable as 94 file URLs. 95 96 For example "bin/java.exe". You need 97 to implement this function in a derived class, if 98 the paths differ. This implementation provides for 99 Windows "bin/java.exe" and for Unix "bin/java". 100 The paths are relative file URLs. That is, they always 101 contain '/' even on windows. The paths are relative 102 to the installation directory of a JRE. 103 104 105 The signature of this function must correspond to 106 getJavaExePaths_func. 107 */ 108 static char const* const * getJavaExePaths(int* size); 109 110 /* creates an instance of this class. MUST be overridden 111 in a derived class. 112 #################################################### 113 OVERRIDE in derived class 114 ################################################### 115 @param 116 Key - value pairs of the system properties of the JRE. 117 */ 118 static rtl::Reference<VendorBase> createInstance(); 119 120 /* called automatically on the instance created by createInstance. 121 122 @return 123 true - the object could completely initialize. 124 false - the object could not completely initialize. In this case 125 it will be discarded by the caller. 126 */ 127 virtual bool initialize( 128 std::vector<std::pair<rtl::OUString, rtl::OUString> > props); 129 130 /* returns relative file URLs to the runtime library. 131 For example "/bin/client/jvm.dll" 132 */ 133 virtual char const* const* getRuntimePaths(int* size); 134 135 virtual char const* const* getLibraryPaths(int* size); 136 137 virtual const rtl::OUString & getVendor() const; 138 virtual const rtl::OUString & getVersion() const; 139 virtual const rtl::OUString & getHome() const; 140 virtual const rtl::OUString & getRuntimeLibrary() const; 141 virtual const rtl::OUString & getLibraryPaths() const; 142 virtual bool supportsAccessibility() const; 143 /* determines if prior to running java something has to be done, 144 like setting the LD_LIBRARY_PATH. This implementation checks 145 if an LD_LIBRARY_PATH (getLD_LIBRARY_PATH) needs to be set and 146 if so, needsRestart returns true. 147 */ 148 virtual bool needsRestart() const; 149 150 /* compares versions of this vendor. MUST be overridden 151 in a derived class. 152 #################################################### 153 OVERRIDE in derived class 154 ################################################### 155 @return 156 0 this.version == sSecond 157 1 this.version > sSecond 158 -1 this.version < sSEcond 159 160 @throw 161 MalformedVersionException if the version string was not recognized. 162 */ 163 virtual int compareVersions(const rtl::OUString& sSecond) const; 164 165 protected: 166 167 rtl::OUString m_sVendor; 168 rtl::OUString m_sVersion; 169 rtl::OUString m_sHome; 170 rtl::OUString m_sRuntimeLibrary; 171 rtl::OUString m_sLD_LIBRARY_PATH; 172 bool m_bAccessibility; 173 174 175 typedef rtl::Reference<VendorBase> (* createInstance_func) (); 176 friend rtl::Reference<VendorBase> createInstance( 177 createInstance_func pFunc, 178 std::vector<std::pair<rtl::OUString, rtl::OUString> > properties); 179 }; 180 181 } 182 183 #endif 184