/* 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.jfox.tm.TransactionManagerService;
import org.huihoo.jfox.system.State;

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

public class TransactionManagerServiceMX implements ServiceMX {
  private TransactionManagerService tmService = null;

  public void mx_start() {
    tmService = new TransactionManagerService();
    try {
      tmService.init();
      tmService.start();
    }
    catch(Exception e){
      e.printStackTrace();
    }
  }

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

  public int mx_getNumTransactions() {
    return tmService.getNumTransactions();
  }

  public int mx_getNumSuspendedTransactions() {
    return tmService.getNumSuspendedTransactions();
  }

  public Properties getOperationDescriptions() {
    return null;
  }

  public Object getSource() {
    return tmService;
  }

  public String getMxDescription() {
    return "TransactionManager Service";
  }

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

  public static void main(String[] args) {

  }
}