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



public class _CoordinatorStub extends ObjectImpl implements Coordinator {
	private static String[] _ids = { org.omg.CosTransactions.CoordinatorHelper.id()};
	public _CoordinatorStub() {}
	public org.omg.CosTransactions.Status get_status()	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"get_status",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).get_status();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"get_status",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			org.omg.CosTransactions.Status _ret;
			_ret =  org.omg.CosTransactions.StatusHelper.read(_istream);
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return get_status();
		}
	
}

	public org.omg.CosTransactions.Status get_parent_status()	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"get_parent_status",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).get_parent_status();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"get_parent_status",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			org.omg.CosTransactions.Status _ret;
			_ret =  org.omg.CosTransactions.StatusHelper.read(_istream);
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return get_parent_status();
		}
	
}

	public org.omg.CosTransactions.Status get_top_level_status()	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"get_top_level_status",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).get_top_level_status();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"get_top_level_status",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			org.omg.CosTransactions.Status _ret;
			_ret =  org.omg.CosTransactions.StatusHelper.read(_istream);
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return get_top_level_status();
		}
	
}

	public boolean is_same_transaction(org.omg.CosTransactions.Coordinator tc)	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"is_same_transaction",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).is_same_transaction(tc);
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"is_same_transaction",true);
		// argument .... marshalling
		_ostream.write_Object(tc);
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			boolean _ret;
			_ret =  _istream.read_boolean();
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return is_same_transaction(tc);
		}
	
}

	public boolean is_related_transaction(org.omg.CosTransactions.Coordinator tc)	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"is_related_transaction",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).is_related_transaction(tc);
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"is_related_transaction",true);
		// argument .... marshalling
		_ostream.write_Object(tc);
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			boolean _ret;
			_ret =  _istream.read_boolean();
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return is_related_transaction(tc);
		}
	
}

	public boolean is_ancestor_transaction(org.omg.CosTransactions.Coordinator tc)	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"is_ancestor_transaction",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).is_ancestor_transaction(tc);
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"is_ancestor_transaction",true);
		// argument .... marshalling
		_ostream.write_Object(tc);
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			boolean _ret;
			_ret =  _istream.read_boolean();
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return is_ancestor_transaction(tc);
		}
	
}

	public boolean is_descendant_transaction(org.omg.CosTransactions.Coordinator tc)	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"is_descendant_transaction",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).is_descendant_transaction(tc);
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"is_descendant_transaction",true);
		// argument .... marshalling
		_ostream.write_Object(tc);
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			boolean _ret;
			_ret =  _istream.read_boolean();
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return is_descendant_transaction(tc);
		}
	
}

	public boolean is_top_level_transaction()	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"is_top_level_transaction",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).is_top_level_transaction();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"is_top_level_transaction",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			boolean _ret;
			_ret =  _istream.read_boolean();
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return is_top_level_transaction();
		}
	
}

	public int hash_transaction()	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"hash_transaction",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).hash_transaction();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"hash_transaction",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			int _ret;
			_ret =  _istream.read_ulong();
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return hash_transaction();
		}
	
}

	public int hash_top_level_tran()	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"hash_top_level_tran",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).hash_top_level_tran();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"hash_top_level_tran",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			int _ret;
			_ret =  _istream.read_ulong();
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return hash_top_level_tran();
		}
	
}

	public org.omg.CosTransactions.RecoveryCoordinator register_resource(org.omg.CosTransactions.Resource r) throws org.omg.CosTransactions.Inactive	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"register_resource",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).register_resource(r);
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"register_resource",true);
		// argument .... marshalling
		_ostream.write_Object(r);
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			org.omg.CosTransactions.RecoveryCoordinator _ret;
			_ret =  org.omg.CosTransactions.RecoveryCoordinatorHelper.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/Inactive:1.0")) {
				org.omg.CosTransactions.Inactive _user_excep;
				_user_excep =  org.omg.CosTransactions.InactiveHelper.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 register_resource(r);
		}
	
}

	public void register_synchronization(org.omg.CosTransactions.Synchronization sync) throws org.omg.CosTransactions.Inactive,org.omg.CosTransactions.SynchronizationUnavailable	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"register_synchronization",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					((CoordinatorOperations) _servant.servant).register_synchronization(sync);
					return;
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"register_synchronization",true);
		// argument .... marshalling
		_ostream.write_Object(sync);
		//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/Inactive:1.0")) {
				org.omg.CosTransactions.Inactive _user_excep;
				_user_excep =  org.omg.CosTransactions.InactiveHelper.read(_istream);
				_d.releaseReply(this,_istream);
				throw _user_excep;
			}
			else if (_id.equals("IDL:omg.org/CosTransactions/SynchronizationUnavailable:1.0")) {
				org.omg.CosTransactions.SynchronizationUnavailable _user_excep;
				_user_excep =  org.omg.CosTransactions.SynchronizationUnavailableHelper.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) {
			register_synchronization(sync);
		}
	
}

	public void register_subtran_aware(org.omg.CosTransactions.SubtransactionAwareResource r) throws org.omg.CosTransactions.Inactive,org.omg.CosTransactions.NotSubtransaction	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"register_subtran_aware",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					((CoordinatorOperations) _servant.servant).register_subtran_aware(r);
					return;
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"register_subtran_aware",true);
		// argument .... marshalling
		_ostream.write_Object(r);
		//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/Inactive:1.0")) {
				org.omg.CosTransactions.Inactive _user_excep;
				_user_excep =  org.omg.CosTransactions.InactiveHelper.read(_istream);
				_d.releaseReply(this,_istream);
				throw _user_excep;
			}
			else if (_id.equals("IDL:omg.org/CosTransactions/NotSubtransaction:1.0")) {
				org.omg.CosTransactions.NotSubtransaction _user_excep;
				_user_excep =  org.omg.CosTransactions.NotSubtransactionHelper.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) {
			register_subtran_aware(r);
		}
	
}

	public void rollback_only() throws org.omg.CosTransactions.Inactive	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"rollback_only",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					((CoordinatorOperations) _servant.servant).rollback_only();
					return;
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"rollback_only",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();
			if (_id.equals("IDL:omg.org/CosTransactions/Inactive:1.0")) {
				org.omg.CosTransactions.Inactive _user_excep;
				_user_excep =  org.omg.CosTransactions.InactiveHelper.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) {
			rollback_only();
		}
	
}

	public String get_transaction_name()	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"get_transaction_name",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).get_transaction_name();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"get_transaction_name",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			String _ret;
			_ret =  _istream.read_string();
			_d.releaseReply(this,_istream);
			return _ret;
		} 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) {
			return get_transaction_name();
		}
	
}

	public org.omg.CosTransactions.Control create_subtransaction() throws org.omg.CosTransactions.SubtransactionsUnavailable,org.omg.CosTransactions.Inactive	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"create_subtransaction",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).create_subtransaction();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"create_subtransaction",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			org.omg.CosTransactions.Control _ret;
			_ret =  org.omg.CosTransactions.ControlHelper.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/SubtransactionsUnavailable:1.0")) {
				org.omg.CosTransactions.SubtransactionsUnavailable _user_excep;
				_user_excep =  org.omg.CosTransactions.SubtransactionsUnavailableHelper.read(_istream);
				_d.releaseReply(this,_istream);
				throw _user_excep;
			}
			else if (_id.equals("IDL:omg.org/CosTransactions/Inactive:1.0")) {
				org.omg.CosTransactions.Inactive _user_excep;
				_user_excep =  org.omg.CosTransactions.InactiveHelper.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 create_subtransaction();
		}
	
}

	public org.omg.CosTransactions.PropagationContext get_txcontext() throws org.omg.CosTransactions.Unavailable	{
		Delegate _d = _get_delegate();
		if (_d.is_local(this)) {
			ServantObject _servant = _d.servant_preinvoke(this,"get_txcontext",CoordinatorOperations.class);
			if (_servant != null) {
				try {
					return ((CoordinatorOperations) _servant.servant).get_txcontext();
				} finally {
					_d.servant_postinvoke(this,_servant);
				}
			}
		}
		OutputStream _ostream = _d.request(this,"get_txcontext",true);
		// argument .... marshalling
		//reply
		try {
			InputStream _istream = _d.invoke(this,_ostream);
			org.omg.CosTransactions.PropagationContext _ret;
			_ret =  org.omg.CosTransactions.PropagationContextHelper.read(_istream);
			_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_txcontext();
		}
	
}

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