home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 2.0 KB | 51 lines |
- /*
- * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
- *
- * This SOURCE CODE FILE, which has been provided by Borland as part
- * of a Borland product for use ONLY by licensed users of the product,
- * includes CONFIDENTIAL and PROPRIETARY information of Borland.
- *
- * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
- * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
- * THE PRODUCT.
- *
- * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
- * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
- * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
- * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
- * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
- * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
- * CODE FILE.
- */
- package visibroker.samples.bank;
-
- import java.util.*;
-
- public class AccountManagerImpl extends Bank._AccountManagerImplBase {
- public AccountManagerImpl(String name) {
- super(name);
- }
- public synchronized Bank.Account open(String name) {
- // Lookup the account in the account dictionary.
- Bank.Account account = (Bank.Account) _accounts.get(name);
- // If there was no account in the dictionary, create one.
- if(account == null) {
- // Make up the account's balance, between 0 and 1000 dollars.
- float balance = Math.abs(_random.nextInt()) % 100000 / 100f;
- // Create the account implementation, given the balance.
- account = new AccountImpl(balance);
- // Make the object available to the ORB.
- _boa().obj_is_ready(account);
- // Print out the new account.
- System.out.println("Created " + name + "'s account: " + account);
- // Save the account in the account dictionary.
- _accounts.put(name, account);
- }
- // Return the account.
- return account;
- }
- private Dictionary _accounts = new Hashtable();
- private Random _random = new Random();
- }
-
-