Code for Class ObserverAppl






package therm;
 
import java.rmi.*;
import java.awt.*;
 
public class ObserverAppl extends Frame
{
    public static void main( String arg[] )
    {
        // Check the command line
        if ( arg.length < 1 )
        {
            System.err.println("Usage:");
            System.err.println("java ObserverAppl ");
            System.exit(1);
        }
 
        // Create and install a security manager
        System.setSecurityManager( new RMISecurityManager() );
 
        // Obtain reference to thermometer object and register observer
        try
        {
            String url = new String( "//" + arg[0] +"/thermometer" );
            System.out.println( "Observer: lookup Thermometer, url = " +
                                url );
            Thermometer T = (Thermometer)Naming.lookup( url );
            System.out.println( "Remote therm T = " + T );
            ThermObserverImpl O = new ThermObserverImpl( T );
 
            ObserverAppl F = new ObserverAppl(); // Frame for display
            F.setLayout( new BorderLayout() );
            F.add( "Center",O );
            F.setSize( 200,400 );
            F.show();
        }
        catch (Exception e){
            System.out.println( "Exception in getting thermometer " + e );
        }
    }
}