/* JFox, the OpenSource J2EE Application Server
 *
 * Copyright (C) 2002 huihoo.com
 * Distributable under GNU LGPL license
 * See the GNU Lesser General Public License for more details.
 */

package org.huihoo.jfox.xmlet;

import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;

import org.huihoo.jfox.jmx.adaptor.http.HtmlAdaptorServer;

/**
 * 
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class XMLetAgent {

	public static void main(String[] args) throws Exception {
    System.out.println("CREATE the MBeanServer.\n");
    MBeanServer server = MBeanServerFactory.createMBeanServer();

    XMLet xmlet = new XMLet();
    ObjectName xmletObjectName = new ObjectName(":Service=XMLet");
    server.registerMBean(xmlet,xmletObjectName);

    DirMLet dmlet = new DirMLet();
    dmlet.addPath("../conf");
    dmlet.setMLet(xmletObjectName);
    ObjectName dmletObjectName = new ObjectName(":Service=DirMLet");
    server.registerMBean(dmlet,dmletObjectName);

//    dmlet.init();
//    dmlet.start();

    ObjectName haName = new ObjectName("Adaptor:type=HtmlAdaptor,port=8088");
    HtmlAdaptorServer ha = new HtmlAdaptorServer();
    server.registerMBean(ha,haName);
    ha.setPort(8082);
    ha.start();
    Thread.sleep(1000L);
    System.out.println("Now,you can connect http://" + ha.getHost() + ":" + ha.getPort());

	}
}
