FileDocCategorySizeDatePackage
AskServer.javaAPI DocExample1756Thu Nov 08 00:23:28 GMT 2001com.ora.rmibook.chapter21.bank

AskServer

public abstract class AskServer extends Object implements Runnable

Fields Summary
private AccountIterator
_accountIterator
private String
_salesHelperName
private Money
_threshhold
private AccountList
_currentAccounts
private int
_fetchSize
Constructors Summary
public AskServer(String salesHelperName, Money threshhold, int fetchSize)

        _salesHelperName = salesHelperName;
        _threshhold = threshhold;
        _fetchSize = fetchSize;
    
Methods Summary
protected abstract voidhandleResponseSet(java.util.ArrayList nextSetOfResponses)

private voidmakeInitialRequest()

        SalesHelper salesHelper = (SalesHelper) Naming.lookup(_salesHelperName);
        QueryResponse queryResponse = salesHelper.getAllAccountsWithBalanceOver(_threshhold);

        _currentAccounts = queryResponse;
        _accountIterator = queryResponse.accountIterator;
        handleResponseSet(_currentAccounts.accounts);
    
public voidperformQuery()

        try {
            makeInitialRequest();
        } catch (Exception e) {
            System.out.println("Error in connecting to server");
            e.printStackTrace();
            return;
        }
        new Thread(this).start();
    
public voidrun()

        while (_currentAccounts.areThereMoreAccountsToFetch) {
            try {
                _currentAccounts = _accountIterator.getNext(_fetchSize);
                handleResponseSet(_currentAccounts.accounts);
            } catch (RemoteException e) {
                // insert exception handling here
            }
        }