FileDocCategorySizeDatePackage
_AccountStub.javaAPI DocExample4300Thu Nov 08 00:23:42 GMT 2001com.ora.rmibook.chapter23.corbaaccounts

_AccountStub.java

package com.ora.rmibook.chapter23.corbaaccounts;


/**
 * _AccountStub.java
 * Generated by the IDL-to-Java compiler (portable), version "3.0"
 * from Account.idl
 * Saturday, December 16, 2000 10:18:17 PM PST
 */

public class _AccountStub extends org.omg.CORBA.portable.ObjectImpl implements Account {
    // Constructors
    // NOTE:  If the default constructor is used, the
    //        object is useless until _set_delegate (...)
    //        is called.
    public _AccountStub () {
        super ();
    }

    public _AccountStub (org.omg.CORBA.portable.Delegate delegate) {
        super ();
        _set_delegate(delegate);
    }

    public Money getBalance() {
        org.omg.CORBA.portable.InputStream _in = null;

        try {
            org.omg.CORBA.portable.OutputStream _out = _request("getBalance", true);

            _in = _invoke(_out);
            Money __result = MoneyHelper.read(_in);

            return __result;
        } catch (org.omg.CORBA.portable.ApplicationException _ex) {
            _in = _ex.getInputStream();
            String _id = _ex.getId();

            throw new org.omg.CORBA.MARSHAL (_id);
        } catch (org.omg.CORBA.portable.RemarshalException _rm) {
            return getBalance();
        } finally {
            _releaseReply(_in);
        }
    } // getBalance

    public void makeDeposit(Money amount) throws NegativeAmountException {
        org.omg.CORBA.portable.InputStream _in = null;

        try {
            org.omg.CORBA.portable.OutputStream _out = _request("makeDeposit", true);

            MoneyHelper.write(_out, amount);
            _in = _invoke(_out);
        } catch (org.omg.CORBA.portable.ApplicationException _ex) {
            _in = _ex.getInputStream();
            String _id = _ex.getId();

            if (_id.equals("IDL:com.ora.rmibook.chapter23.corbaaccounts/NegativeAmountException:1.0"))
                throw NegativeAmountExceptionHelper.read(_in);
            else
                throw new org.omg.CORBA.MARSHAL (_id);
        } catch (org.omg.CORBA.portable.RemarshalException _rm) {
            makeDeposit(amount);
        } finally {
            _releaseReply(_in);
        }
    } // makeDeposit

    public void makeWithdrawal(Money amount) throws NegativeAmountException, OverdraftException {
        org.omg.CORBA.portable.InputStream _in = null;

        try {
            org.omg.CORBA.portable.OutputStream _out = _request("makeWithdrawal", true);

            MoneyHelper.write(_out, amount);
            _in = _invoke(_out);
        } catch (org.omg.CORBA.portable.ApplicationException _ex) {
            _in = _ex.getInputStream();
            String _id = _ex.getId();

            if (_id.equals("IDL:com.ora.rmibook.chapter23.corbaaccounts/NegativeAmountException:1.0"))
                throw NegativeAmountExceptionHelper.read(_in);
            else if (_id.equals("IDL:com.ora.rmibook.chapter23.corbaaccounts/OverdraftException:1.0"))
                throw OverdraftExceptionHelper.read(_in);
            else
                throw new org.omg.CORBA.MARSHAL (_id);
        } catch (org.omg.CORBA.portable.RemarshalException _rm) {
            makeWithdrawal(amount);
        } finally {
            _releaseReply(_in);
        }
    } // makeWithdrawal

    // Type-specific CORBA::Object operations
    private static String[] __ids = {
            "IDL:com.ora.rmibook.chapter23.corbaaccounts/Account:1.0"};

    public String[] _ids() {
        return (String[]) __ids.clone();
    }

    private void readObject(java.io.ObjectInputStream s) {
        try {
            String str = s.readUTF();
            org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init().string_to_object(str);
            org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate();

            _set_delegate(delegate);
        } catch (java.io.IOException e) {
        }
    }

    private void writeObject(java.io.ObjectOutputStream s) {
        try {
            String str = org.omg.CORBA.ORB.init().object_to_string(this);

            s.writeUTF(str);
        } catch (java.io.IOException e) {
        }
    }
} // class _AccountStub