01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 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: ManagementReprLoader.java 9680 2006-10-06 12:08:33Z danesa $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas.jmx;
25:
26: import javax.management.MBeanServerConnection;
27:
28: import org.objectweb.jonas.common.Log;
29: import org.objectweb.util.monolog.api.Logger;
30:
31: /**
32: *
33: * @author Adriana Danes
34: *
35: * This class allows to load a suitable ManagementRepr in the JonasMaanagementRepr
36: * class. This operation is necessary to initilize and then possibly change the
37: * management context. A management context is characterized by data allowing
38: * to manage a JOnAS app server instance:
39: * <ul>
40: * <li>domain name (currently cann not switch from a domain to another)
41: * <li>server name
42: * <li>MBeanServerConnection allowing to connect to the managed server's JMX server
43: * </ul>
44: */
45: public class ManagementReprLoader {
46: /**
47: * Logger
48: */
49: private static Logger logger = Log
50: .getLogger("org.objectweb.jonas.jmx");
51:
52: /**
53: * This method is used to switch from a managed server to another.
54: * It creates a ManagementRepr for the given server, then update JonasManagementRepr.
55: * @param serverName the name of the server to be managed
56: * @param currentServerName the name of the server which is currently managed
57: */
58: /*
59: public static void loadServerRepr(String serverName, String currentServerName) {
60: ManagementRepr repr = null;
61: if (serverName == null) {
62: repr = ManagementReprFactory.getManagementRepr();
63: } else {
64: repr = ManagementReprFactory.getManagementRepr(serverName);
65: if (((ManagementReprImplJSR160) repr).getMBeanServerConnection() == null) {
66: // Could not create JSR 160 MnagementRepr
67: // Create a ManagementReprImpl for the current server
68: repr = ManagementReprFactory.getManagementRepr(currentServerName);
69: }
70: }
71: JonasManagementRepr.setRepr(repr);
72: }*/
73: /**
74: * Create a ManagementRepr for the given server, then update JonasManagementRepr
75: * @param serverName the name of the server to be managed
76: */
77: public static void loadServerRepr(String serverName) {
78: ManagementRepr repr = ManagementReprFactory
79: .getManagementRepr(serverName);
80: if (((ManagementReprImplJSR160) repr)
81: .getMBeanServerConnection() != null) {
82: JonasManagementRepr.addServerRepr(serverName, repr);
83: }
84: }
85: /**
86: * Update the JonasManagementRepr datastructure () in order to easilly invoke
87: * operations on MBeans corresponding to a managed server in domain/cluster
88: * @param serverName
89: * @param connection
90: */
91: /*
92: public static void loadServerReprForCluster(String serverName, MBeanServerConnection connection) {
93: ManagementRepr repr = ManagementReprFactory.getManagementRepr(serverName, connection);
94: if (repr != null) {
95: JonasManagementRepr.addServerRepr(serverName, repr);
96: }
97: }*/
98: }
|