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.Control Client Stub generated by the Idl2Java Compiler 3.1 of Jonathan
 */



public class _ControlStub extends ObjectImpl implements Control {
	private static String[] _ids = { org.omg.CosTransactions.ControlHelper.id()};
	public _ControlStub() {}
	public org.omg.CosTransactions.Terminator get_terminator() throws org.omg.CosTransactions.Unavailable	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"get_terminator",ControlOperations.class);
			if (_servant != null) {
				try {
					return ((ControlOperations) _servant.servant).get_terminator();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"get_terminator",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			org.omg.CosTransactions.Terminator _ret;
			_ret =  org.omg.CosTransactions.TerminatorHelper.narrow(_istream.read_Object());
			_d.releaseReply(this,_istream);
			return _ret;
		} catch (ApplicationException _e) {
			InputStream _istream = _e.getInputStream();
			String _id = _istream.read_string();
			if (_id.equals("IDL:omg.org/CosTransactions/Unavailable:1.0")) {
				org.omg.CosTransactions.Unavailable _user_excep;
				_user_excep =  org.omg.CosTransactions.UnavailableHelper.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) {
			return get_terminator();
		}
	
}

	public org.omg.CosTransactions.Coordinator get_coordinator() throws org.omg.CosTransactions.Unavailable	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"get_coordinator",ControlOperations.class);
			if (_servant != null) {
				try {
					return ((ControlOperations) _servant.servant).get_coordinator();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"get_coordinator",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			org.omg.CosTransactions.Coordinator _ret;
			_ret =  org.omg.CosTransactions.CoordinatorHelper.narrow(_istream.read_Object());
			_d.releaseReply(this,_istream);
			return _ret;
		} catch (ApplicationException _e) {
			InputStream _istream = _e.getInputStream();
			String _id = _istream.read_string();
			if (_id.equals("IDL:omg.org/CosTransactions/Unavailable:1.0")) {
				org.omg.CosTransactions.Unavailable _user_excep;
				_user_excep =  org.omg.CosTransactions.UnavailableHelper.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) {
			return get_coordinator();
		}
	
}

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