KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jmx > ManagementReprLoader


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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,v 1.3 2005/04/22 11:14:27 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.jonas.jmx;
26
27 /**
28  *
29  * @author Adriana Danes
30  *
31  * This class allows to load a suitable ManagementRepr in the JonasMaanagementRepr
32  * class. This operation is necessary to initilize and then possibly change the
33  * management context. A management context is characterized by data allowing
34  * to manage a JOnAS app server instance:
35  * <ul>
36  * <li>domain name (currently cann not switch from a domain to another)
37  * <li>server name
38  * <li>MBeanServerConnection allowing to connect to the managed server's JMX server
39  * </ul>
40  */

41 public class ManagementReprLoader {
42     private ManagementReprLoader() {
43         super();
44     }
45     /**
46      * Create a ManagementRepr for the given server, than update JonasManagementRepr
47      * @param serverName the name of the server to be managed
48      */

49     public static void loadServerRepr(String JavaDoc serverName) {
50         ManagementRepr repr = null;
51         if (serverName == null) {
52             repr = ManagementReprFactory.getManagementRepr();
53         } else {
54             repr = ManagementReprFactory.getManagementRepr(serverName);
55             if (((ManagementReprImplJSR160) repr).getMBeanServerConnection() == null) {
56                 // Could not create JSR 160 MnagementRepr
57
// Create a ManagementReprImpl for the current server
58
repr = ManagementReprFactory.getManagementRepr();
59             }
60         }
61         JonasManagementRepr.setRepr(repr);
62     }
63 }
Popular Tags