com/scalagent/jmx/JMXRIHttpService.java

00001 /*
00002  * Copyright (C) 2001 - 2005 ScalAgent Distributed Technologies
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or any later version.
00008  * 
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00017  * USA.
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 }

Generated on Tue Sep 16 16:14:22 2008 for joram by  doxygen 1.5.0