1 /*2 * Jalisto - JAva LIght STOrage3 * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com4 * 5 * This library is free software; you can redistribute it and/or6 * modify it under the terms of the GNU Lesser General Public7 * License as published by the Free Software Foundation; either8 * version 2.1 of the License, or (at your option) any later version.9 * 10 * This library is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13 * Lesser General Public License for more details.14 * 15 * You should have received a copy of the GNU Lesser General Public16 * License along with this library; if not, write to the Free Software17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.18 * 19 * Xcalia20 * 71, rue Desnouettes21 * 75014 Paris - France22 * http://www.xcalia.com23 */24 package org.objectweb.jalisto.se.jmx.server.jdmk;25 26 public class JalistoMbeanServerJdmkImpl {27 }28 29 // extends Thread implements FdbMBeanServer {30 //}31 //32 // public static void main(String[] args) {33 // String propertiesPath = "fdb.properties";34 // try {35 // propertiesPath = args[0];36 // } catch (Exception e) {37 // System.out.println("Cannot find properties path argument, use default value = " + propertiesPath);38 // }39 //40 // FdbMbeanServerJdmkImpl fdbServer = new FdbMbeanServerJdmkImpl();41 // fdbServer.init(propertiesPath);42 // fdbServer.run();43 // }44 //45 // public FdbMbeanServerJdmkImpl() {46 // }47 //48 // public void init(String propertiesPath) {49 // this.propertiesPath = propertiesPath;50 // this.mbeanServer = MBeanServerFactory.createMBeanServer();51 // this.props = InternalFdbFactory.getProperties(propertiesPath);52 //53 // //TODO use FdbProperties54 // enlistFdbHtmlServer(5555);55 // enlistFdbHtmlConnector(0);56 // enlistFdbRmiConnector(8086);57 // }58 //59 // public void run() {60 // registerMBean(mbeanServer, CacheAdmin.class.getName());61 // registerMBean(mbeanServer, MemoryAdmin.class.getName());62 // registerMBean(mbeanServer, ClassDescriptionAdmin.class.getName());63 //64 // System.out.println("FileDB JDMK MBean server is OK");65 // }66 //67 // public void addSession(String s) {68 // }69 //70 // private void enlistFdbHtmlServer(int port) {71 // try {72 // CommunicatorServer htmlAdaptor = new HtmlAdaptorServer(); // default constructor: sets port to default 808273 // htmlAdaptor.setPort(port);74 // mbeanServer.registerMBean(htmlAdaptor, null);75 // htmlAdaptor.start();76 // while (htmlAdaptor.getState() == CommunicatorServer.STARTING) {77 // sleep(100);78 // }79 // if (htmlAdaptor.getState() != CommunicatorServer.ONLINE) {80 // throw new MBeanAdminException("Cannot start the FileDB HTML adaptor server");81 // }82 // } catch (DatabaseException fdbde) {83 // throw fdbde;84 // } catch (Exception e) {85 // throw new MBeanAdminException("Could not create the FileDB HTML mbeanServer", e);86 // }87 // System.out.println("FileDB JDMK HtmlAdaptorServer started...");88 // }89 //90 // private void enlistFdbHtmlConnector(int port) {91 // try {92 // String HttpConnectorClassName = "com.sun.jdmk.comm.HttpConnectorServer";93 // // let the HTTP connector server provides its default object name and port number (8081)94 // ObjectInstance httpConnectorInstance = mbeanServer.createMBean(HttpConnectorClassName, null);95 // mbeanServer.invoke(httpConnectorInstance.getObjectName(), "start", new Object[0], new String[0]);96 // while (new Integer(CommunicatorServer.STARTING).equals97 // (mbeanServer.getAttribute(httpConnectorInstance.getObjectName(), "State"))) {98 // sleep(100);99 // }100 // if (!(new Integer(CommunicatorServer.ONLINE).equals101 // (mbeanServer.getAttribute(httpConnectorInstance.getObjectName(), "State")))) {102 // throw new MBeanAdminException("Cannot start the FileDB HTML mbean connector");103 // }104 // } catch (DatabaseException fdbde) {105 // throw fdbde;106 // } catch (Exception e) {107 // throw new MBeanAdminException("Could not create the FileDB HTML mbean connector", e);108 // }109 // System.out.println("FileDB JDMK HttpConnectorServer started...");110 // }111 //112 // private void enlistFdbRmiConnector(int port) {113 // Object[] params = {new Integer(port)}; // param is RMI port number to use114 // String[] signature = {"int"}; //115 // try {116 // String RmiConnectorClassName = "com.sun.jdmk.comm.RmiConnectorServer";117 // CommunicatorServer rmiConnector = (CommunicatorServer) mbeanServer.instantiate(RmiConnectorClassName, params, signature);118 // // We provides an object name for the RMI connector server119 // // (which is actually the same as the one which would have been provided by default if we had passed null)120 // ObjectName rmiConnObjName = new ObjectName(ServiceName.DOMAIN + ":" + ServiceName.RMI_CONNECTOR_SERVER);121 // ObjectInstance rmiConnectorInstance = mbeanServer.registerMBean(rmiConnector, rmiConnObjName);122 // rmiConnector.start();123 // while (rmiConnector.getState() == CommunicatorServer.STARTING) {124 // sleep(100);125 // }126 // if (rmiConnector.getState() != CommunicatorServer.ONLINE) {127 // throw new MBeanAdminException("Cannot start the FileDB RMI mbean connector");128 // }129 // } catch (DatabaseException fdbde) {130 // throw fdbde;131 // } catch (Exception e) {132 // throw new MBeanAdminException("Could not create the FileDB RMI mbean connector", e);133 // }134 // System.out.println("FileDB JDMK RmiConnectorServer started...");135 // }136 //137 // private void registerMBean(MBeanServer server, String mbeanClassName) {138 // try {139 // Object[] params = new Object[1];140 // params[0] = propertiesPath;141 // String[] signature = new String[1];142 // signature[0] = "java.lang.String";143 // ObjectName mbeanObjectName =144 // new ObjectName(server.getDefaultDomain() + ":type=" + mbeanClassName);145 // server.createMBean(mbeanClassName,146 // mbeanObjectName,147 // params,148 // signature);149 // } catch (RuntimeErrorException e) {150 // e.getTargetError().printStackTrace();151 // throw new MBeanAdminException(e);152 // } catch (Exception e) {153 // throw new MBeanAdminException(e);154 // }155 // }156 //157 // private String propertiesPath;158 // private FdbProperties props;159 // private MBeanServer mbeanServer;160 //}161