01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2006 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas.webapp.jonasadmin.jonasserver;
25:
26: import java.util.ArrayList;
27:
28: import javax.management.ObjectName;
29:
30: import org.objectweb.jonas.jmx.JonasManagementRepr;
31:
32: /**
33: * Helper class which manipulates CMI MBean for registry content
34: * @author Adriana Danes
35: *
36: */
37: public class CmiRegistryResource {
38:
39: public static final String PREFIX = "REG_";
40: /**
41: * local node
42: */
43: public static final String LOCAL = "local";
44:
45: public static ArrayList getCmiRegistry(ObjectName cmiOn,
46: String serverName) {
47: ArrayList result = new ArrayList();
48:
49: // distributed registry
50: String[] regList = (String[]) JonasManagementRepr.getAttribute(
51: cmiOn, "registry", serverName);
52: for (int i = 0; i < regList.length; i++) {
53: if (regList[i].startsWith(PREFIX)) {
54: regList[i] = regList[i].substring(PREFIX.length());
55: String[] tab = regList[i].split("->");
56: ArrayList l = new ArrayList(2);
57: l.add(tab[0]);
58: l.add(tab[1]);
59: result.add(l);
60: }
61: }
62: // local registry
63: String[] localRegList = (String[]) JonasManagementRepr
64: .getAttribute(cmiOn, "localRegistry", serverName);
65: for (int i = 0; i < localRegList.length; i++) {
66: ArrayList l = new ArrayList(2);
67: l.add(localRegList[i]);
68: l.add(LOCAL);
69: result.add(l);
70: }
71:
72: return result;
73: }
74: }
|