00001
00025 package org.objectweb.jonas.management;
00026
00027 import org.apache.commons.modeler.Registry;
00028 import org.objectweb.jonas.server.Server;
00029
00030
00031 import org.objectweb.jonas.common.Log;
00032
00033
00034 import org.objectweb.util.monolog.api.Logger;
00035 import org.objectweb.util.monolog.api.BasicLevel;
00036
00041 public class JonasMBeanTools {
00042
00043
00044
00045 private final static String[] PACKAGE_DESCRIPTORS = {
00046 "org.objectweb.jonas.server", "org.objectweb.jonas.ear",
00047 "org.objectweb.jonas.container", "org.objectweb.jonas.naming",
00048 "org.objectweb.jonas.mail",
00049 "org.objectweb.jonas.resource", "org.objectweb.jonas.jtm",
00050 "org.objectweb.jonas.dbm"};
00051
00052
00053
00054 private static Registry s_Registry = null;
00055 private static Logger s_Logger = Log.getLogger(Log.JONAS_MANAGEMENT_PREFIX);
00056
00057
00058
00064 public synchronized static Registry getRegistry() {
00065
00066 if (s_Registry == null) {
00067
00068 s_Registry = Registry.getRegistry(null, null);
00069 ClassLoader cl = Server.class.getClassLoader();
00070
00071
00072 for (int i = 0; i < PACKAGE_DESCRIPTORS.length; i++) {
00073 s_Registry.loadDescriptors(PACKAGE_DESCRIPTORS[i], cl);
00074 }
00075
00076
00077 if (s_Logger.isLoggable(BasicLevel.DEBUG) == true) {
00078 String s;
00079 String[] as = s_Registry.findManagedBeans();
00080 s_Logger.log(BasicLevel.DEBUG, ">>> List of all MBeans descriptors");
00081 for (int i = 0; i < as.length; i++) {
00082 s = ">>> " + i + ") " + as[i];
00083 s_Logger.log(BasicLevel.DEBUG, s);
00084 }
00085 s_Logger.log(BasicLevel.DEBUG, "<<< List of all MBeans descriptors");
00086 }
00087 }
00088 return (s_Registry);
00089 }
00090
00091 }