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.arm;
20
21 import jgroup.core.arm.ReplicationManager;
22 import jgroup.core.registry.DependableRegistry;
23 import jgroup.core.registry.RegistryFactory;
24 import jgroup.relacs.config.AppConfig;
25 import jgroup.util.Abort;
26
27 /**
28 * Client program for accessing the Replication Manager.
29 *
30 * @author Hein Meling
31 * @since Jgroup 1.2
32 */
33 public class ManagementClient
34 {
35
36 public static void main(String argv[])
37 throws Exception
38 {
39 /*
40 * Obtain a proxy for the dependable registry running in the
41 * distributed system described in the config.xml file.
42 */
43 DependableRegistry dregistry = RegistryFactory.getRegistry();
44
45 /*
46 * Retrieve a proxy for an object group implementing the
47 * ReplicationManager interface registered under the name
48 * "ReplicationManager".
49 */
50 ReplicationManager replicaManager =
51 (ReplicationManager) dregistry.lookup("Jgroup/ReplicationManager");
52 System.out.println("Successful lookup: ReplicationManager");
53
54 AppConfig app = null;
55 String clazz = System.getProperty("arm.deploy.class");
56 if (clazz != null && clazz.length() > 0) {
57 app = AppConfig.getApplication(clazz);
58 }
59
60 try {
61 if (argv[0].equals("create")) {
62 System.out.println("Creating group: " + app);
63 replicaManager.createGroup(app);
64 } else if (argv[0].equals("remove")) {
65 System.out.println("Removing group: " + app);
66 replicaManager.removeGroup(app);
67 }
68 } catch (Exception exception) {
69 throw new Abort("Failed to create server", exception);
70 }
71 System.exit(0);
72 }
73
74 } // END ManagementClient