00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 package com.scalagent.jmx;
00020
00021 import java.io.*;
00022 import java.util.*;
00023
00024 import com.sun.jdmk.comm.*;
00025 import javax.management.*;
00026
00027 import org.objectweb.util.monolog.api.BasicLevel;
00028 import org.objectweb.util.monolog.api.Logger;
00029 import org.objectweb.util.monolog.api.LoggerFactory;
00030
00031 import fr.dyade.aaa.util.Debug;
00032 import fr.dyade.aaa.util.management.MXWrapper;
00033
00042 public class JMXRIHttpService {
00043 static HtmlAdaptorServer adapterServer = null;
00044
00051 public static void init(String args,
00052 boolean firstTime) throws Exception {
00053 int port = 8082;
00054 if (args != null && args.length()!=0) {
00055 try {
00056 port = Integer.parseInt(args);
00057 } catch (NumberFormatException exc) {}
00058 }
00059
00060 try {
00061 adapterServer = new HtmlAdaptorServer();
00062 adapterServer.setPort(port);
00063 MXWrapper.registerMBean(adapterServer,
00064 "JMXRIHttpService",
00065 "name=htmladapter,port=" + port);
00066
00067 startService();
00068 } catch (Exception exc) {
00069 Debug.getLogger("com.scalagent.jmx").log(
00070 BasicLevel.ERROR, "JMXRIService initialization failed", exc);
00071 throw exc;
00072 }
00073 }
00074
00075 public static void startService() {
00076 Debug.getLogger("com.scalagent.jmx").log(BasicLevel.DEBUG,
00077 "JMXRIHttpService.startService");
00078
00079 adapterServer.start();
00080 }
00081
00082 public static void stopService() {
00083 Debug.getLogger("com.scalagent.jmx").log(BasicLevel.DEBUG,
00084 "JMXRIHttpService.stopService");
00085
00086 adapterServer.stop();
00087 }
00088
00089 }