/* 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.mx;

import java.util.Properties;

import org.huihoo.jfox.jndi.NamingServiceImpl;
import org.huihoo.jfox.system.ServiceWrapper;
import org.huihoo.jfox.system.State;

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

public class NamingServiceMX implements ServiceMX {
  private int port = 1099;
  private ServiceWrapper sw = null;

  public NamingServiceMX() {

  }

  public void mx_setPort(int port){
    this.port = port;
  }

  public int mx_getPort(){
    return port;
  }

  public void mx_start() {
    sw = new ServiceWrapper(NamingServiceImpl.class.getName(),port);
    try {
      sw.init();
      sw.start();
    }
    catch(Exception e){
      e.printStackTrace();
    }
  }

  public void mx_stop(){
    try {
      sw.stop();
      sw.destroy();
    }
    catch(Exception e){
      e.printStackTrace();
    }
  }

  public State mx_getStat(){
    return sw.getState();
  }

  public Properties getOperationDescriptions() {
    return null;
  }

  public Object getSource() {
    return sw;
  }

  public String getMxDescription() {
    return "JNDI Implementaion";
  }

  public static void main(String[] args) {

  }
}