package org.omg.CosTransactions;

import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.InvokeHandler;
import org.omg.CORBA.portable.ResponseHandler;

import org.omg.CORBA.portable.ObjectImpl;


/**
 * org.omg.CosTransactions.Control Server Stub generated by the Idl2Java Compiler 3.1 of Jonathan
 */



public class _ControlImplBase extends ObjectImpl implements org.omg.CosTransactions.Control, InvokeHandler {
	ControlOperations _cont;
	private static String[] _ids = { org.omg.CosTransactions.ControlHelper.id() };

	public _ControlImplBase() {
				super();
				_cont = this;
	}

	public _ControlImplBase(ControlOperations continuation) {
				super();
				_cont = continuation;
	}


	protected int _getMethodSwitchKey(String _methName) {
				switch(_methName.charAt(4)) {
					case 't' :  return 0;  //method get_terminator coded as get_terminator
					case 'c' :  return 1;  //method get_coordinator coded as get_coordinator
					default: return -1; // should never occur !!!
				}
	}


	public OutputStream _invoke(String _method,InputStream _istream,ResponseHandler _handler){
			switch(_getMethodSwitchKey(_method)) {
	case 0 : //method : get_terminator
				{
			//in and inout arguments unmarshaling
			OutputStream _ostream;
			try {
				//operation invocation on the target interface
				org.omg.CosTransactions.Terminator _ret;
				_ret = _cont.get_terminator();
				_ostream = _handler.createReply();
				//out and inout arguments marshaling
				_ostream.write_Object(_ret);
			} catch (org.omg.CosTransactions.Unavailable _e) {
				_ostream=_handler.createExceptionReply();
				String _eString="IDL:omg.org/CosTransactions/Unavailable:1.0";
				_ostream.write_string(_eString);
				org.omg.CosTransactions.UnavailableHelper.write(_ostream,_e);
			}
				return _ostream;
				}
	case 1 : //method : get_coordinator
				{
			//in and inout arguments unmarshaling
			OutputStream _ostream;
			try {
				//operation invocation on the target interface
				org.omg.CosTransactions.Coordinator _ret;
				_ret = _cont.get_coordinator();
				_ostream = _handler.createReply();
				//out and inout arguments marshaling
				_ostream.write_Object(_ret);
			} catch (org.omg.CosTransactions.Unavailable _e) {
				_ostream=_handler.createExceptionReply();
				String _eString="IDL:omg.org/CosTransactions/Unavailable:1.0";
				_ostream.write_string(_eString);
				org.omg.CosTransactions.UnavailableHelper.write(_ostream,_e);
			}
				return _ostream;
				}
	default : // unknown method name
				throw new BAD_OPERATION();
	}

	}
	public org.omg.CosTransactions.Terminator get_terminator() throws org.omg.CosTransactions.Unavailable {
				if (_cont == this) {
				   throw new org.omg.CORBA.NO_IMPLEMENT("Method get_terminator not implemented by servant.");				}
				return _cont.get_terminator();
	}

	public org.omg.CosTransactions.Coordinator get_coordinator() throws org.omg.CosTransactions.Unavailable {
				if (_cont == this) {
				   throw new org.omg.CORBA.NO_IMPLEMENT("Method get_coordinator not implemented by servant.");				}
				return _cont.get_coordinator();
	}

	public String[] _ids() {
		return _ids;
	}

	public void _setContinuation(java.lang.Object continuation) {
	_cont = (ControlOperations) continuation;
	}
}
