136f55ffcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
336f55ffcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
436f55ffcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
536f55ffcSAndrew Rist  * distributed with this work for additional information
636f55ffcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
736f55ffcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
836f55ffcSAndrew Rist  * "License"); you may not use this file except in compliance
936f55ffcSAndrew Rist  * with the License.  You may obtain a copy of the License at
1036f55ffcSAndrew Rist  *
1136f55ffcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1236f55ffcSAndrew Rist  *
1336f55ffcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1436f55ffcSAndrew Rist  * software distributed under the License is distributed on an
1536f55ffcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1636f55ffcSAndrew Rist  * KIND, either express or implied.  See the License for the
1736f55ffcSAndrew Rist  * specific language governing permissions and limitations
1836f55ffcSAndrew Rist  * under the License.
1936f55ffcSAndrew Rist  *
2036f55ffcSAndrew Rist  *************************************************************/
2136f55ffcSAndrew Rist 
2236f55ffcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
258cb913c4SDamjan Jovanovic #include "precompiled_plugin.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "osl/thread.h"
28cdf0e10cSrcweir #include "sunjre.hxx"
29cdf0e10cSrcweir #include "sunversion.hxx"
30cdf0e10cSrcweir #include "diagnostics.h"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace std;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
35cdf0e10cSrcweir namespace jfw_plugin
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 
createInstance()38696f238bSAriel Constenla-Haile rtl::Reference<VendorBase> SunInfo::createInstance()
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     return new SunInfo;
41cdf0e10cSrcweir }
42cdf0e10cSrcweir 
getJavaExePaths(int * size)43cdf0e10cSrcweir char const* const* SunInfo::getJavaExePaths(int * size)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     static char const * ar[] = {
46cdf0e10cSrcweir #if defined(WNT) || defined(OS2)
47cdf0e10cSrcweir         "java.exe",
48cdf0e10cSrcweir         "bin/java.exe",
49cdf0e10cSrcweir         "jre/bin/java.exe"
50cdf0e10cSrcweir #elif UNX
51cdf0e10cSrcweir         "java",
52cdf0e10cSrcweir         "bin/java",
53cdf0e10cSrcweir         "jre/bin/java"
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir     };
56cdf0e10cSrcweir         *size = sizeof (ar) / sizeof (char*);
57cdf0e10cSrcweir     return ar;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
getRuntimePaths(int * size)60cdf0e10cSrcweir char const* const* SunInfo::getRuntimePaths(int * size)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     static char const* ar[]= {
63cdf0e10cSrcweir #if defined(WNT)
64cdf0e10cSrcweir         "/bin/client/jvm.dll",
65cdf0e10cSrcweir         "/bin/hotspot/jvm.dll",
663bdaae44SAriel Constenla-Haile         "/bin/classic/jvm.dll",
673bdaae44SAriel Constenla-Haile         "/bin/jrockit/jvm.dll"
68cdf0e10cSrcweir #elif defined(OS2)
69cdf0e10cSrcweir         "/bin/classic/jvm.dll",
700fff73caSYuri Dario         "/bin/client/jvm.dll",
713bdaae44SAriel Constenla-Haile         // TODO add jrockit here
7283f1bc14SHerbert Dürr #elif defined(MACOSX)
7383f1bc14SHerbert Dürr         "/lib/server/libjvm.dylib"
7483f1bc14SHerbert Dürr #elif defined(UNX)
75cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/client/libjvm.so",
76cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/server/libjvm.so",
773bdaae44SAriel Constenla-Haile         "/lib/" JFW_PLUGIN_ARCH "/classic/libjvm.so",
78*779db4a0SDamjan Jovanovic         "/lib/" JFW_PLUGIN_ARCH "/jrockit/libjvm.so",
79*779db4a0SDamjan Jovanovic         "/lib/server/libjvm.so" // > 1.8
80cdf0e10cSrcweir #endif
81cdf0e10cSrcweir     };
82cdf0e10cSrcweir     *size = sizeof(ar) / sizeof (char*);
83cdf0e10cSrcweir     return ar;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
getLibraryPaths(int * size)86cdf0e10cSrcweir char const* const* SunInfo::getLibraryPaths(int* size)
87cdf0e10cSrcweir {
88696f238bSAriel Constenla-Haile #ifdef UNX
89cdf0e10cSrcweir     static char const * ar[] = {
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/client",
92cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/native_threads",
93*779db4a0SDamjan Jovanovic         "/lib/" JFW_PLUGIN_ARCH,
94*779db4a0SDamjan Jovanovic         "/lib" // > 1.8
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     };
97cdf0e10cSrcweir     *size = sizeof(ar) / sizeof (char*);
98cdf0e10cSrcweir     return ar;
99cdf0e10cSrcweir #else
100cdf0e10cSrcweir     size = 0;
101cdf0e10cSrcweir     return NULL;
102cdf0e10cSrcweir #endif
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
compareVersions(const rtl::OUString & sSecond) const105cdf0e10cSrcweir int SunInfo::compareVersions(const rtl::OUString& sSecond) const
106cdf0e10cSrcweir {
107696f238bSAriel Constenla-Haile     rtl::OUString sFirst = getVersion();
108696f238bSAriel Constenla-Haile 
109cdf0e10cSrcweir     SunVersion version1(sFirst);
110ce15f79dSHerbert Dürr     JFW_ENSURE(version1, OUSTR("[Java framework] sunjavaplugin" SAL_DLLEXTENSION
111cdf0e10cSrcweir                                " does not know the version: ")
112696f238bSAriel Constenla-Haile                + sFirst + OUSTR(" as valid for a SUN/Oracle JRE."));
113cdf0e10cSrcweir     SunVersion version2(sSecond);
114cdf0e10cSrcweir     if ( ! version2)
115cdf0e10cSrcweir         throw MalformedVersionException();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     if(version1 == version2)
118cdf0e10cSrcweir         return 0;
119cdf0e10cSrcweir     if(version1 > version2)
120cdf0e10cSrcweir         return 1;
121cdf0e10cSrcweir     else
122cdf0e10cSrcweir         return -1;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 
126cdf0e10cSrcweir }
127