sunw.demo.quote
Class QuoteServerImpl

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--sunw.demo.quote.QuoteServerImpl

public class QuoteServerImpl
extends java.rmi.server.UnicastRemoteObject
implements QuoteServer

The QuoteServer implementation. The QuoteServer object starts a thread that polls a quote source and delivers QuoteEvents to QuoteListeners.

Stock information can be collected from one of two sources: "Local" or "Yahoo". The latter is a real (delayed) data feed that reports quotes in a format that can be easily parsed. The "Local" quote source is just a random number generator. The advantage of the local source is that it can produce quotes quickly, this can make demos more interesting.

See Also:
Serialized Form

Fields inherited from class java.rmi.server.RemoteObject
ref
 
Method Summary
 void addQuoteListener(QuoteListener x)
          The specified QuoteListeners quoteChanged method will be called each time new quote data is available.
 HttpProxy getHttpProxy()
          The HTTP proxy host and port number are stored in the System property list under "http.proxyHost" and "http.proxyPort".
 int getQuoteEventRate()
           
 java.lang.String getQuoteSource()
           
 void removeQuoteListener(QuoteListener x)
          Remove this QuoteListener from the servers internal list.
 void setHttpProxy(HttpProxy x)
          If the specified host is valid and the port number is positive then set the System properties: "http.proxyHost" and "http.proxyPort".
 void setQuoteEventRate(int x)
          Sets the quote source polling rate.
 void setQuoteSource(java.lang.String x)
          Specify where quote data will come from.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getQuoteEventRate

public int getQuoteEventRate()
Returns:
the quote source polling rate in seconds

setQuoteEventRate

public void setQuoteEventRate(int x)
Sets the quote source polling rate.
Parameters:
x - the polling rate in seconds

addQuoteListener

public void addQuoteListener(QuoteListener x)
                      throws java.rmi.RemoteException
The specified QuoteListeners quoteChanged method will be called each time new quote data is available. The QuoteListener object is added to a list of QuoteListeners managed by this server, it can be removed with removeQuoteListener.
Specified by:
addQuoteListener in interface QuoteServer
Parameters:
l - the QuoteListener
See Also:
removeQuoteListener(sunw.demo.quote.QuoteListener)

removeQuoteListener

public void removeQuoteListener(QuoteListener x)
                         throws java.rmi.RemoteException
Remove this QuoteListener from the servers internal list. If the QuoteListener isn't on the list, silently do nothing.
Specified by:
removeQuoteListener in interface QuoteServer
Parameters:
l - the QuoteListener
See Also:
addQuoteListener(sunw.demo.quote.QuoteListener)

getHttpProxy

public HttpProxy getHttpProxy()
                       throws java.rmi.RemoteException
The HTTP proxy host and port number are stored in the System property list under "http.proxyHost" and "http.proxyPort". We just combine the two values into a single object here.
Specified by:
getHttpProxy in interface QuoteServer
Returns:
the HTTP proxy host and port number for this server
See Also:
setHttpProxy(sunw.demo.quote.HttpProxy)

setHttpProxy

public void setHttpProxy(HttpProxy x)
                  throws java.rmi.RemoteException
If the specified host is valid and the port number is positive then set the System properties: "http.proxyHost" and "http.proxyPort". Otherwise throw a RemoteException. The HTTP proxy values only matter if the quote source is "Yahoo", i.e. if we're going to the internet for data.
Specified by:
setHttpProxy in interface QuoteServer
Parameters:
x - the new values for host and port
See Also:
getHttpProxy()

getQuoteSource

public java.lang.String getQuoteSource()
                                throws java.rmi.RemoteException
Returns:
a string that represents the source for quote data
See Also:
setQuoteSource(java.lang.String)

setQuoteSource

public void setQuoteSource(java.lang.String x)
                    throws java.rmi.RemoteException
Specify where quote data will come from. If quoteSource is "Local" then the sunw.demo.LocalQuote is used, it generates moderately random data. If quoteSource is "Yahoo" then the sunw.demo.YahooQuote class is used, it collects quote data from the YahooQuote web site.
Parameters:
x - must be "Yahoo" or "Local"
See Also:
getQuoteSource()