KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > agent > management > MXWrapper


1 /*
2  * Copyright (C) 2001 - 2003 ScalAgent Distributed Technologies
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  */

19 package fr.dyade.aaa.agent.management;
20
21 import java.io.*;
22 import java.util.*;
23
24 import org.objectweb.util.monolog.api.BasicLevel;
25 import org.objectweb.util.monolog.api.Logger;
26 import org.objectweb.util.monolog.api.LoggerFactory;
27
28 import fr.dyade.aaa.agent.Debug;
29
30 public class MXWrapper {
31   /**
32    * This property allow to configure the JMX server proxy, if it is
33    * null JMX is not used. A JMX server
34    */

35   public final static String ServerImpl = "MXServer";
36
37   public static MXServer mxserver = null;
38
39   public static void registerMBean(Object bean,
40                                    String domain,
41                                    String name) throws Exception {
42     if (mxserver == null) return;
43
44     Debug.getLogger(Debug.A3Debug).log(BasicLevel.WARN,
45                                        "registerMBean: " + name + " -> " + mxserver);
46
47     mxserver.registerMBean(bean, domain, name);
48   }
49
50   public static void unregisterMBean(String domain,
51                                      String name) throws Exception {
52     if (mxserver == null) return;
53
54     Debug.getLogger(Debug.A3Debug).log(BasicLevel.WARN,
55                                        "unregisterMBean: " + name + " -> " + mxserver);
56
57     mxserver.unregisterMBean(domain, name);
58   }
59
60   public static void setMXServer(MXServer server) {
61     Debug.getLogger(Debug.A3Debug).log(BasicLevel.INFO,
62                                        "setMXServer: " + server);
63
64     mxserver = server;
65   }
66 }
67
Popular Tags