1 /*
2 * Copyright (c) 1998-2002 The Jgroup Team.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 *
17 */
18
19 package jgroup.test.hello;
20
21 import jgroup.core.registry.DependableRegistry;
22 import jgroup.core.registry.RegistryFactory;
23
24 /**
25 * Client program for Hello
26 *
27 * @author Alberto Montresor
28 * @author Hein Meling
29 * @since Jgroup 0.1
30 */
31 public class NotifyClient
32 {
33
34 public static void main(String argv[])
35 throws Exception
36 {
37 /*
38 * Obtain a proxy for the depedable registry running in the
39 * distributed system described in the config.xml file.
40 */
41 DependableRegistry registry = RegistryFactory.getRegistry();
42
43 /*
44 * Print the number of groups registered in the dependable registry
45 */
46 String[] bindings = registry.list();
47 System.out.println("Number of elements: " + bindings.length);
48
49 /*
50 * Retrieve a proxy for an object group implementing the Hello
51 * interface registered under the name "Jgroup/NotifyServer".
52 */
53 Hello server = (Hello) registry.lookup("Jgroup/NotifyServer");
54
55 /*
56 * Invoking method sayHello, which returns an object of type Answer
57 * containing a string produced by the contacted object plus
58 * the time at which the groups members installed the last view.
59 */
60 for (int i = 0; i < 20; i++) {
61 Answer answer = server.sayHello();
62 System.out.println(answer);
63 }
64
65 /*
66 * There may be several threads blocking (e.g., the threads pooling
67 * for registry instances), thus we just exit everything.
68 */
69 System.exit(0);
70 }
71
72 } // END NotifyClient