Source of TickerClient.java


  1: 
  2: import java.awt.*;
  3: import java.util.*;
  4: import java.io.*;
  5: import java.rmi.*;
  6: import java.rmi.server.*;
  7: 
  8: public class TickerClient extends Ticker 
  9:     implements QuoteClient {
 10: 
 11:   public void initQuotes() {
 12:     try {
 13:       System.out.println("StockApplet.init: exporting remote object");
 14:       UnicastRemoteObject.exportObject(this);
 15: 
 16:       QuotePushServer obj = (QuotePushServer)
 17:           Naming.lookup("//" + getCodeBase().getHost() + "/QuotePushServer");
 18:       obj.watch(this, symbol); 
 19:       StockQuote newquote[] = obj.getQuote();
 20:       for (int j = 0; j < newquote.length; j ++) {
 21:         for (int i = 0; i < n; i++) {
 22:           if (newquote[j].name.equals(symbol[i])) {
 23:             quote[i] = Integer.toString(newquote[j].quote); 
 24:           }
 25:         } 
 26:       }
 27:     } catch (Exception e) {
 28:       System.err.println(e); 
 29:     }
 30:   }
 31: 
 32:   public void newQuote(StockQuote newquote) throws java.rmi.RemoteException {
 33:     for (int i = 0; i < n; i++) {
 34:       if (newquote.name.equals(symbol[i])) {
 35:         quote[i] = Integer.toString(newquote.quote); 
 36:       }
 37:     }
 38:   }
 39: 
 40: }