1*5ac42e1fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5ac42e1fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5ac42e1fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5ac42e1fSAndrew Rist * distributed with this work for additional information 6*5ac42e1fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5ac42e1fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5ac42e1fSAndrew Rist * "License"); you may not use this file except in compliance 9*5ac42e1fSAndrew Rist * with the License. You may obtain a copy of the License at 10*5ac42e1fSAndrew Rist * 11*5ac42e1fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5ac42e1fSAndrew Rist * 13*5ac42e1fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5ac42e1fSAndrew Rist * software distributed under the License is distributed on an 15*5ac42e1fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5ac42e1fSAndrew Rist * KIND, either express or implied. See the License for the 17*5ac42e1fSAndrew Rist * specific language governing permissions and limitations 18*5ac42e1fSAndrew Rist * under the License. 19*5ac42e1fSAndrew Rist * 20*5ac42e1fSAndrew Rist *************************************************************/ 21*5ac42e1fSAndrew Rist 22*5ac42e1fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #if !defined INCLUDED_JFW_PLUGIN_VENDORBASE_HXX 25cdf0e10cSrcweir #define INCLUDED_JFW_PLUGIN_VENDORBASE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "rtl/ustring.hxx" 28cdf0e10cSrcweir #include "rtl/ref.hxx" 29cdf0e10cSrcweir #include "osl/endian.h" 30cdf0e10cSrcweir #include "salhelper/simplereferenceobject.hxx" 31cdf0e10cSrcweir #include <vector> 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace jfw_plugin 34cdf0e10cSrcweir { 35cdf0e10cSrcweir 36cdf0e10cSrcweir 37cdf0e10cSrcweir //Used by subclasses of VendorBase to build paths to Java runtime 38cdf0e10cSrcweir #if defined(__sparcv9) 39cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "sparcv9" 40cdf0e10cSrcweir #elif defined SPARC 41cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "sparc" 42cdf0e10cSrcweir #elif defined X86_64 43cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "amd64" 44cdf0e10cSrcweir #elif defined INTEL 45cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "i386" 46cdf0e10cSrcweir #elif defined POWERPC64 47cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "ppc64" 48cdf0e10cSrcweir #elif defined POWERPC 49cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "ppc" 50cdf0e10cSrcweir #elif defined MIPS 51cdf0e10cSrcweir #ifdef OSL_BIGENDIAN 52cdf0e10cSrcweir # define JFW_PLUGIN_ARCH "mips" 53cdf0e10cSrcweir #else 54cdf0e10cSrcweir # define JFW_PLUGIN_ARCH "mips32" 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir #elif defined S390X 57cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "s390x" 58cdf0e10cSrcweir #elif defined S390 59cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "s390" 60cdf0e10cSrcweir #elif defined ARM 61cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "arm" 62cdf0e10cSrcweir #elif defined IA64 63cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "ia64" 64cdf0e10cSrcweir #elif defined M68K 65cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "m68k" 66cdf0e10cSrcweir #elif defined HPPA 67cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "parisc" 68cdf0e10cSrcweir #elif defined AXP 69cdf0e10cSrcweir #define JFW_PLUGIN_ARCH "alpha" 70cdf0e10cSrcweir #else // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA, ALPHA 71cdf0e10cSrcweir #error unknown plattform 72cdf0e10cSrcweir #endif // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA, ALPHA 73cdf0e10cSrcweir 74cdf0e10cSrcweir 75cdf0e10cSrcweir class MalformedVersionException 76cdf0e10cSrcweir { 77cdf0e10cSrcweir public: 78cdf0e10cSrcweir MalformedVersionException(); 79cdf0e10cSrcweir 80cdf0e10cSrcweir MalformedVersionException(const MalformedVersionException &); 81cdf0e10cSrcweir 82cdf0e10cSrcweir virtual ~MalformedVersionException(); 83cdf0e10cSrcweir 84cdf0e10cSrcweir MalformedVersionException & operator =(const MalformedVersionException &); 85cdf0e10cSrcweir }; 86cdf0e10cSrcweir 87cdf0e10cSrcweir class VendorBase: public salhelper::SimpleReferenceObject 88cdf0e10cSrcweir { 89cdf0e10cSrcweir public: 90cdf0e10cSrcweir VendorBase(); 91cdf0e10cSrcweir /* returns relativ paths to the java executable as 92cdf0e10cSrcweir file URLs. 93cdf0e10cSrcweir 94cdf0e10cSrcweir For example "bin/java.exe". You need 95cdf0e10cSrcweir to implement this function in a derived class, if 96cdf0e10cSrcweir the paths differ. this implmentation provides for 97cdf0e10cSrcweir Windows "bin/java.exe" and for Unix "bin/java". 98cdf0e10cSrcweir The paths are relative file URLs. That is, they always 99cdf0e10cSrcweir contain '/' even on windows. The paths are relative 100cdf0e10cSrcweir to the installation directory of a JRE. 101cdf0e10cSrcweir 102cdf0e10cSrcweir 103cdf0e10cSrcweir The signature of this function must correspond to 104cdf0e10cSrcweir getJavaExePaths_func. 105cdf0e10cSrcweir */ 106cdf0e10cSrcweir static char const* const * getJavaExePaths(int* size); 107cdf0e10cSrcweir 108cdf0e10cSrcweir /* creates an instance of this class. MUST be overridden 109cdf0e10cSrcweir in a derived class. 110cdf0e10cSrcweir #################################################### 111cdf0e10cSrcweir OVERRIDE in derived class 112cdf0e10cSrcweir ################################################### 113cdf0e10cSrcweir @param 114cdf0e10cSrcweir Key - value pairs of the system properties of the JRE. 115cdf0e10cSrcweir */ 116cdf0e10cSrcweir static rtl::Reference<VendorBase> createInstance(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir /* called automatically on the instance created by createInstance. 119cdf0e10cSrcweir 120cdf0e10cSrcweir @return 121cdf0e10cSrcweir true - the object could completely initialize. 122cdf0e10cSrcweir false - the object could not completly initialize. In this case 123cdf0e10cSrcweir it will be discarded by the caller. 124cdf0e10cSrcweir */ 125cdf0e10cSrcweir virtual bool initialize( 126cdf0e10cSrcweir std::vector<std::pair<rtl::OUString, rtl::OUString> > props); 127cdf0e10cSrcweir 128cdf0e10cSrcweir /* returns relative file URLs to the runtime library. 129cdf0e10cSrcweir For example "/bin/client/jvm.dll" 130cdf0e10cSrcweir */ 131cdf0e10cSrcweir virtual char const* const* getRuntimePaths(int* size); 132cdf0e10cSrcweir 133cdf0e10cSrcweir virtual char const* const* getLibraryPaths(int* size); 134cdf0e10cSrcweir 135cdf0e10cSrcweir virtual const rtl::OUString & getVendor() const; 136cdf0e10cSrcweir virtual const rtl::OUString & getVersion() const; 137cdf0e10cSrcweir virtual const rtl::OUString & getHome() const; 138cdf0e10cSrcweir virtual const rtl::OUString & getRuntimeLibrary() const; 139cdf0e10cSrcweir virtual const rtl::OUString & getLibraryPaths() const; 140cdf0e10cSrcweir virtual bool supportsAccessibility() const; 141cdf0e10cSrcweir /* determines if prior to running java something has to be done, 142cdf0e10cSrcweir like setting the LD_LIBRARY_PATH. This implementation checks 143cdf0e10cSrcweir if an LD_LIBRARY_PATH (getLD_LIBRARY_PATH) needs to be set and 144cdf0e10cSrcweir if so, needsRestart returns true. 145cdf0e10cSrcweir */ 146cdf0e10cSrcweir virtual bool needsRestart() const; 147cdf0e10cSrcweir 148cdf0e10cSrcweir /* compares versions of this vendor. MUST be overridden 149cdf0e10cSrcweir in a derived class. 150cdf0e10cSrcweir #################################################### 151cdf0e10cSrcweir OVERRIDE in derived class 152cdf0e10cSrcweir ################################################### 153cdf0e10cSrcweir @return 154cdf0e10cSrcweir 0 this.version == sSecond 155cdf0e10cSrcweir 1 this.version > sSecond 156cdf0e10cSrcweir -1 this.version < sSEcond 157cdf0e10cSrcweir 158cdf0e10cSrcweir @throw 159cdf0e10cSrcweir MalformedVersionException if the version string was not recognized. 160cdf0e10cSrcweir */ 161cdf0e10cSrcweir virtual int compareVersions(const rtl::OUString& sSecond) const; 162cdf0e10cSrcweir 163cdf0e10cSrcweir protected: 164cdf0e10cSrcweir 165cdf0e10cSrcweir rtl::OUString m_sVendor; 166cdf0e10cSrcweir rtl::OUString m_sVersion; 167cdf0e10cSrcweir rtl::OUString m_sHome; 168cdf0e10cSrcweir rtl::OUString m_sRuntimeLibrary; 169cdf0e10cSrcweir rtl::OUString m_sLD_LIBRARY_PATH; 170cdf0e10cSrcweir bool m_bAccessibility; 171cdf0e10cSrcweir 172cdf0e10cSrcweir 173cdf0e10cSrcweir typedef rtl::Reference<VendorBase> (* createInstance_func) (); 174cdf0e10cSrcweir friend rtl::Reference<VendorBase> createInstance( 175cdf0e10cSrcweir createInstance_func pFunc, 176cdf0e10cSrcweir std::vector<std::pair<rtl::OUString, rtl::OUString> > properties); 177cdf0e10cSrcweir }; 178cdf0e10cSrcweir 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir #endif 182