home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / Hello7Server.java < prev    next >
Text File  |  1997-09-06  |  1KB  |  49 lines

  1. /*
  2.  *  Hello7Server.java
  3.  *
  4.  *  class Hello7Server implements the remote interface
  5.  *  Hello7 to identify it as a remote object.
  6.  *  Methods printHello() and getTime() are remote methods
  7.  *  for clients to call.
  8.  */
  9.  
  10. package samples.rmi1;
  11.  
  12. import java.rmi.*;
  13. import java.rmi.registry.*;
  14. import java.rmi.server.UnicastRemoteObject;
  15. import java.util.Date;
  16.  
  17. public class Hello7Server extends UnicastRemoteObject implements Hello7
  18. {
  19.     public Hello7Server() throws RemoteException
  20.     {
  21.         super();
  22.     }
  23.  
  24.     public String printHello() throws RemoteException
  25.     {
  26.         return( "Howdy!" );
  27.     }
  28.  
  29.     public Date getTime() throws RemoteException
  30.     {
  31.         return( new Date( System.currentTimeMillis() ) );
  32.     }
  33.  
  34.     public static void main( String args[] )
  35.     {
  36.         try
  37.         {
  38.             System.setSecurityManager( new RMISecurityManager() );
  39.  
  40.             Hello7Server server = new Hello7Server();
  41.             Naming.rebind( "Hello7Server", server );
  42.             System.out.println( "Hello7Server :  bound in registry" );
  43.         }
  44.         catch( Exception e )
  45.         {
  46.             System.out.println( e.toString() );
  47.         }
  48.     }
  49. }