package org.omg.CosTransactions;

import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.ServantObject;
import org.omg.CORBA.portable.ApplicationException;
import org.omg.CORBA.portable.RemarshalException;
import org.omg.CORBA.UNKNOWN;

/**
 * org.omg.CosTransactions.Terminator Client Stub generated by the Idl2Java Compiler 3.1 of Jonathan
 */



public class _TerminatorStub extends ObjectImpl implements Terminator {
	private static String[] _ids = { org.omg.CosTransactions.TerminatorHelper.id()};
	public _TerminatorStub() {}
	public void commit(boolean report_heuristics) throws org.omg.CosTransactions.HeuristicMixed,org.omg.CosTransactions.HeuristicHazard	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"commit",TerminatorOperations.class);
			if (_servant != null) {
				try {
					((TerminatorOperations) _servant.servant).commit(report_heuristics);
					return;
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"commit",true);
		// argument .... marshalling
		_ostream.write_boolean(report_heuristics);
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			_d.releaseReply(this,_istream);
			return ;
		} catch (ApplicationException _e) {
			InputStream _istream = _e.getInputStream();
			String _id = _istream.read_string();
			if (_id.equals("IDL:omg.org/CosTransactions/HeuristicMixed:1.0")) {
				org.omg.CosTransactions.HeuristicMixed _user_excep;
				_user_excep =  org.omg.CosTransactions.HeuristicMixedHelper.read(_istream);
				_d.releaseReply(this,_istream);
				throw _user_excep;
			}
			else if (_id.equals("IDL:omg.org/CosTransactions/HeuristicHazard:1.0")) {
				org.omg.CosTransactions.HeuristicHazard _user_excep;
				_user_excep =  org.omg.CosTransactions.HeuristicHazardHelper.read(_istream);
				_d.releaseReply(this,_istream);
				throw _user_excep;
			}
			_d.releaseReply(this,_istream);
			throw new org.omg.CORBA.UNKNOWN("Unknown exception identifier");
		} catch (RemarshalException _e) {
			commit(report_heuristics);
		}
	
}

	public void rollback()	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"rollback",TerminatorOperations.class);
			if (_servant != null) {
				try {
					((TerminatorOperations) _servant.servant).rollback();
					return;
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"rollback",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			_d.releaseReply(this,_istream);
			return ;
		} catch (ApplicationException _e) {
			InputStream _istream = _e.getInputStream();
			String _id = _istream.read_string();
			_d.releaseReply(this,_istream);
			throw new org.omg.CORBA.UNKNOWN("Unknown exception identifier");
		} catch (RemarshalException _e) {
			rollback();
		}
	
}

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