1 /*
2 * Copyright (c) 1998, 2008, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
41
42 final static int NAME_SERVICE_TIME_OUT = 12000;
43
44 static TCPEndpoint ep = null;
45
46 /**
47 * main, lookup remote object and tell it the rmi
48 * hostname of this client vm.
49 */
50 public static void main (String args[]) {
51
52 // start a registry and register a copy of this in it.
53 TellServerName tell;
54 String hostname = null;
55
56 try {
57 hostname = retrieveServerName();
58 System.err.println("Client host name: " +
59 hostname);
60
61 tell = (TellServerName) Naming.lookup("rmi://:" +
62 TestLibrary.REGISTRY_PORT
63 + "/CheckFQDN");
64 tell.tellServerName(hostname);
65 System.err.println("client has exited");
66
67 } catch (Exception e ) {
68 throw new RuntimeException(e.getMessage());
69 }
70 System.exit(0);
71 }
72
73 /* what is the rmi hostname for this vm? */
74 public static String retrieveServerName () {
75 try {
76
77 CheckFQDNClient chk = new CheckFQDNClient();
78
79 synchronized(chk) {
80 (new Thread (chk)).start();
81 chk.wait(NAME_SERVICE_TIME_OUT);
82 }
|
1 /*
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
41
42 final static int NAME_SERVICE_TIME_OUT = 12000;
43
44 static TCPEndpoint ep = null;
45
46 /**
47 * main, lookup remote object and tell it the rmi
48 * hostname of this client vm.
49 */
50 public static void main (String args[]) {
51
52 // start a registry and register a copy of this in it.
53 TellServerName tell;
54 String hostname = null;
55
56 try {
57 hostname = retrieveServerName();
58 System.err.println("Client host name: " +
59 hostname);
60
61 int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port"));
62 tell = (TellServerName) Naming.lookup("rmi://:" +
63 registryPort
64 + "/CheckFQDN");
65 tell.tellServerName(hostname);
66 System.err.println("client has exited");
67
68 } catch (Exception e ) {
69 throw new RuntimeException(e.getMessage());
70 }
71 System.exit(0);
72 }
73
74 /* what is the rmi hostname for this vm? */
75 public static String retrieveServerName () {
76 try {
77
78 CheckFQDNClient chk = new CheckFQDNClient();
79
80 synchronized(chk) {
81 (new Thread (chk)).start();
82 chk.wait(NAME_SERVICE_TIME_OUT);
83 }
|