import IE.Iona.Orbix2.CORBA.SystemException; import IE.Iona.Orbix2._CORBA; import java.util.Vector; /** * @author Martin Andrews@ * @version 4.0 August 12th, 1997@ */ public class AccountImp implements _AccountOperations { private String id; // ID number of the account private Vector refs; // list of object referencing this Account /** * Constructor for the Account class * * @param anId@ * @param aRef@ */ public AccountImp(String anId, _CheckableRef aRef) { id = anId; refs = new Vector(1, 1); refs.addElement(aRef); } /** * Returns the id of the Account * * @return Account ID number@ */ public String getId() { return id; } /** * Checks all referencing objects to see if they are still alive. Any * one still being alive will result in a true return value. * * @return true if an object is referencing this Account, otherwise false@ */ public boolean gcCheck() { int count = 0; boolean check = false; do { try { check = ((_CheckableRef)refs.elementAt(count)).stillLive(); } catch (SystemException se) { check = false; // assume object dead if it can't be reached } } while (count < refs.size() && !check); return check; } /** * Adds an object to the list of objects already referencing this Account * * @param aRef@ * @return true if aRef was added successfully, otherwise false@ */ public boolean attach(_CheckableRef aRef) { refs.addElement(aRef); return true; } /** * Removes an object from the list of objects referencing this Account * * @param aRef@ * @return true if aRef was removed successfully, otherwise false@ */ public boolean detach(_CheckableRef aRef) { return (refs.removeElement(aRef)); } /** * Displays a string upon finalization of the Account (just before garbage collection) */ protected void finalize() { System.out.println("*********************************************"); System.out.println("*** Finalizing Account ***"); System.out.println("*********************************************"); } }