1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #if !defined INCLUDED_JFW_PLUGIN_VENDORBASE_HXX 29 #define INCLUDED_JFW_PLUGIN_VENDORBASE_HXX 30 31 #include "rtl/ustring.hxx" 32 #include "rtl/ref.hxx" 33 #include "osl/endian.h" 34 #include "salhelper/simplereferenceobject.hxx" 35 #include <vector> 36 37 namespace jfw_plugin 38 { 39 40 41 //Used by subclasses of VendorBase to build paths to Java runtime 42 #if defined(__sparcv9) 43 #define JFW_PLUGIN_ARCH "sparcv9" 44 #elif defined SPARC 45 #define JFW_PLUGIN_ARCH "sparc" 46 #elif defined X86_64 47 #define JFW_PLUGIN_ARCH "amd64" 48 #elif defined INTEL 49 #define JFW_PLUGIN_ARCH "i386" 50 #elif defined POWERPC64 51 #define JFW_PLUGIN_ARCH "ppc64" 52 #elif defined POWERPC 53 #define JFW_PLUGIN_ARCH "ppc" 54 #elif defined MIPS 55 #ifdef OSL_BIGENDIAN 56 # define JFW_PLUGIN_ARCH "mips" 57 #else 58 # define JFW_PLUGIN_ARCH "mips32" 59 #endif 60 #elif defined S390X 61 #define JFW_PLUGIN_ARCH "s390x" 62 #elif defined S390 63 #define JFW_PLUGIN_ARCH "s390" 64 #elif defined ARM 65 #define JFW_PLUGIN_ARCH "arm" 66 #elif defined IA64 67 #define JFW_PLUGIN_ARCH "ia64" 68 #elif defined M68K 69 #define JFW_PLUGIN_ARCH "m68k" 70 #elif defined HPPA 71 #define JFW_PLUGIN_ARCH "parisc" 72 #elif defined AXP 73 #define JFW_PLUGIN_ARCH "alpha" 74 #else // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA, ALPHA 75 #error unknown plattform 76 #endif // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA, ALPHA 77 78 79 class MalformedVersionException 80 { 81 public: 82 MalformedVersionException(); 83 84 MalformedVersionException(const MalformedVersionException &); 85 86 virtual ~MalformedVersionException(); 87 88 MalformedVersionException & operator =(const MalformedVersionException &); 89 }; 90 91 class VendorBase: public salhelper::SimpleReferenceObject 92 { 93 public: 94 VendorBase(); 95 /* returns relativ paths to the java executable as 96 file URLs. 97 98 For example "bin/java.exe". You need 99 to implement this function in a derived class, if 100 the paths differ. this implmentation provides for 101 Windows "bin/java.exe" and for Unix "bin/java". 102 The paths are relative file URLs. That is, they always 103 contain '/' even on windows. The paths are relative 104 to the installation directory of a JRE. 105 106 107 The signature of this function must correspond to 108 getJavaExePaths_func. 109 */ 110 static char const* const * getJavaExePaths(int* size); 111 112 /* creates an instance of this class. MUST be overridden 113 in a derived class. 114 #################################################### 115 OVERRIDE in derived class 116 ################################################### 117 @param 118 Key - value pairs of the system properties of the JRE. 119 */ 120 static rtl::Reference<VendorBase> createInstance(); 121 122 /* called automatically on the instance created by createInstance. 123 124 @return 125 true - the object could completely initialize. 126 false - the object could not completly initialize. In this case 127 it will be discarded by the caller. 128 */ 129 virtual bool initialize( 130 std::vector<std::pair<rtl::OUString, rtl::OUString> > props); 131 132 /* returns relative file URLs to the runtime library. 133 For example "/bin/client/jvm.dll" 134 */ 135 virtual char const* const* getRuntimePaths(int* size); 136 137 virtual char const* const* getLibraryPaths(int* size); 138 139 virtual const rtl::OUString & getVendor() const; 140 virtual const rtl::OUString & getVersion() const; 141 virtual const rtl::OUString & getHome() const; 142 virtual const rtl::OUString & getRuntimeLibrary() const; 143 virtual const rtl::OUString & getLibraryPaths() const; 144 virtual bool supportsAccessibility() const; 145 /* determines if prior to running java something has to be done, 146 like setting the LD_LIBRARY_PATH. This implementation checks 147 if an LD_LIBRARY_PATH (getLD_LIBRARY_PATH) needs to be set and 148 if so, needsRestart returns true. 149 */ 150 virtual bool needsRestart() const; 151 152 /* compares versions of this vendor. MUST be overridden 153 in a derived class. 154 #################################################### 155 OVERRIDE in derived class 156 ################################################### 157 @return 158 0 this.version == sSecond 159 1 this.version > sSecond 160 -1 this.version < sSEcond 161 162 @throw 163 MalformedVersionException if the version string was not recognized. 164 */ 165 virtual int compareVersions(const rtl::OUString& sSecond) const; 166 167 protected: 168 169 rtl::OUString m_sVendor; 170 rtl::OUString m_sVersion; 171 rtl::OUString m_sHome; 172 rtl::OUString m_sRuntimeLibrary; 173 rtl::OUString m_sLD_LIBRARY_PATH; 174 bool m_bAccessibility; 175 176 177 typedef rtl::Reference<VendorBase> (* createInstance_func) (); 178 friend rtl::Reference<VendorBase> createInstance( 179 createInstance_func pFunc, 180 std::vector<std::pair<rtl::OUString, rtl::OUString> > properties); 181 }; 182 183 } 184 185 #endif 186