2
|
1 |
/*
|
|
2 |
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
*/
|
|
26 |
|
|
27 |
import javax.management.remote.rmi.RMIJRMPServerImpl;
|
|
28 |
import javax.management.remote.rmi.RMIServer;
|
|
29 |
|
|
30 |
public class ImplVersionCommand {
|
|
31 |
|
|
32 |
public static void main(String[] args) throws Exception {
|
|
33 |
|
|
34 |
// Create RMIJRMPServerImpl
|
|
35 |
//
|
|
36 |
System.out.println("Create RMIJRMPServerImpl");
|
|
37 |
RMIServer server = new RMIJRMPServerImpl(0, null, null, null);
|
|
38 |
|
|
39 |
// Get the JMX Remote impl version from RMIServer
|
|
40 |
//
|
|
41 |
System.out.println("Get JMX Remote implementation version from RMIServer");
|
|
42 |
String full_version = server.getVersion();
|
|
43 |
System.out.println("RMIServer.getVersion() = "+ full_version);
|
|
44 |
String impl_version = full_version.substring(
|
|
45 |
full_version.indexOf("java_runtime_")+"java_runtime_".length());
|
|
46 |
|
|
47 |
// Display JMX Remote impl version and Java Runtime version
|
|
48 |
//
|
|
49 |
System.out.println("JMX Remote implementation version = " +
|
|
50 |
impl_version);
|
|
51 |
System.out.println("Java Runtime implementation version = " +
|
|
52 |
args[0]);
|
|
53 |
|
|
54 |
// Check JMX Remote impl version vs. Java Runtime version
|
|
55 |
//
|
|
56 |
if (!impl_version.equals(args[0])) {
|
|
57 |
// Test FAILED
|
|
58 |
throw new IllegalArgumentException(
|
|
59 |
"***FAILED: JMX Remote and Java Runtime versions do NOT match***");
|
|
60 |
}
|
|
61 |
// Test OK!
|
|
62 |
System.out.println("JMX Remote and Java Runtime versions match.");
|
|
63 |
System.out.println("Bye! Bye!");
|
|
64 |
}
|
|
65 |
}
|