1 19 package com.scalagent.jmx; 20 21 import java.io.*; 22 import java.util.*; 23 24 import com.sun.jdmk.comm.*; 25 import javax.management.*; 26 27 import org.objectweb.util.monolog.api.BasicLevel; 28 import org.objectweb.util.monolog.api.Logger; 29 import org.objectweb.util.monolog.api.LoggerFactory; 30 31 import fr.dyade.aaa.util.Debug; 32 import fr.dyade.aaa.util.management.MXWrapper; 33 34 42 public class JMXRIHttpService { 43 static HtmlAdaptorServer adapterServer = null; 44 45 51 public static void init(String args, 52 boolean firstTime) throws Exception { 53 int port = 8082; 54 if (args != null && args.length()!=0) { 55 try { 56 port = Integer.parseInt(args); 57 } catch (NumberFormatException exc) {} 58 } 59 60 try { 61 adapterServer = new HtmlAdaptorServer(); 62 adapterServer.setPort(port); 63 MXWrapper.registerMBean(adapterServer, 64 "JMXRIHttpService", 65 "name=htmladapter,port=" + port); 66 67 startService(); 68 } catch (Exception exc) { 69 Debug.getLogger("com.scalagent.jmx").log( 70 BasicLevel.ERROR, "JMXRIService initialization failed", exc); 71 throw exc; 72 } 73 } 74 75 public static void startService() { 76 Debug.getLogger("com.scalagent.jmx").log(BasicLevel.DEBUG, 77 "JMXRIHttpService.startService"); 78 79 adapterServer.start(); 80 } 81 82 public static void stopService() { 83 Debug.getLogger("com.scalagent.jmx").log(BasicLevel.DEBUG, 84 "JMXRIHttpService.stopService"); 85 86 adapterServer.stop(); 87 } 88 89 } 90 | Popular Tags |