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
25cdf0e10cSrcweir #include "precompiled_jvmfwk.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 
38696f238bSAriel Constenla-Haile rtl::Reference<VendorBase> SunInfo::createInstance()
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     return new SunInfo;
41cdf0e10cSrcweir }
42cdf0e10cSrcweir 
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 
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",
66*3bdaae44SAriel Constenla-Haile         "/bin/classic/jvm.dll",
67*3bdaae44SAriel Constenla-Haile         "/bin/jrockit/jvm.dll"
68cdf0e10cSrcweir #elif defined(OS2)
69cdf0e10cSrcweir         "/bin/classic/jvm.dll",
70*3bdaae44SAriel Constenla-Haile         // TODO add jrockit here
71cdf0e10cSrcweir #elif UNX
72cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/client/libjvm.so",
73cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/server/libjvm.so",
74*3bdaae44SAriel Constenla-Haile         "/lib/" JFW_PLUGIN_ARCH "/classic/libjvm.so",
75*3bdaae44SAriel Constenla-Haile         "/lib/" JFW_PLUGIN_ARCH "/jrockit/libjvm.so"
76cdf0e10cSrcweir #endif
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     };
79cdf0e10cSrcweir     *size = sizeof(ar) / sizeof (char*);
80cdf0e10cSrcweir     return ar;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir char const* const* SunInfo::getLibraryPaths(int* size)
84cdf0e10cSrcweir {
85696f238bSAriel Constenla-Haile #ifdef UNX
86cdf0e10cSrcweir     static char const * ar[] = {
87cdf0e10cSrcweir 
88cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/client",
89cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/native_threads",
90cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     };
93cdf0e10cSrcweir     *size = sizeof(ar) / sizeof (char*);
94cdf0e10cSrcweir     return ar;
95cdf0e10cSrcweir #else
96cdf0e10cSrcweir     size = 0;
97cdf0e10cSrcweir     return NULL;
98cdf0e10cSrcweir #endif
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir int SunInfo::compareVersions(const rtl::OUString& sSecond) const
102cdf0e10cSrcweir {
103696f238bSAriel Constenla-Haile     rtl::OUString sFirst = getVersion();
104696f238bSAriel Constenla-Haile 
105cdf0e10cSrcweir     SunVersion version1(sFirst);
106cdf0e10cSrcweir     JFW_ENSURE(version1, OUSTR("[Java framework] sunjavaplugin"SAL_DLLEXTENSION
107cdf0e10cSrcweir                                " does not know the version: ")
108696f238bSAriel Constenla-Haile                + sFirst + OUSTR(" as valid for a SUN/Oracle JRE."));
109cdf0e10cSrcweir     SunVersion version2(sSecond);
110cdf0e10cSrcweir     if ( ! version2)
111cdf0e10cSrcweir         throw MalformedVersionException();
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     if(version1 == version2)
114cdf0e10cSrcweir         return 0;
115cdf0e10cSrcweir     if(version1 > version2)
116cdf0e10cSrcweir         return 1;
117cdf0e10cSrcweir     else
118cdf0e10cSrcweir         return -1;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122cdf0e10cSrcweir }
123