Yurttas/PL/OOL/Java/F/08/01/01/00/PhoneBookRMIServer00.java

Revision as of 16:04, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="java" line start="1" enclose="div">/** * Copyright(C) 1999 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. * * P...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 1/**
 2 *  Copyright(C) 1999
 3 *  All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4 *
 5 *  Permission to use, copy, modify, and distribute this
 6 *  software and its documentation for EDUCATIONAL purposes
 7 *  and without fee is hereby granted provided that this
 8 *  copyright notice appears in all copies.
 9 *
10 *  @date   : July 1, 1999.
11 *  @author : Salih Yurttas.
12 */
13
14
15import java.rmi.*;
16import java.rmi.server.*;
17
18import java.net.*;
19
20public class PhoneBookRMIServer00 extends UnicastRemoteObject
21                                  implements PhoneBookRMIServerInterface00 {
22
23  private static final int N = 256;
24
25  private static String[] name = new String[N];
26  private static String[] phone = new String[N];
27  private int count = 0;
28
29  public PhoneBookRMIServer00(final String filename)
30    throws Exception
31  {
32    super();
33    PhoneBookFileIO pBFIO = new PhoneBookFileIO();
34    count = pBFIO.namePhoneFileInput(filename,
35                                     name,
36                                     phone);
37  }
38
39  public String[] getNames() {
40    return name;
41  }
42
43  public String[] getPhones() {
44    return phone;
45  }
46
47  public static void main(String args[]) {
48    System.out.println("\nInstalling security manager . . . ");
49
50    if(System.getSecurityManager()==null)
51      System.setSecurityManager(new RMISecurityManager());
52
53    try {
54      System.out.println("\nBinding server . . . ");
55
56      PhoneBookRMIServer00 server = new PhoneBookRMIServer00(args[0]);
57
58      String hostname = InetAddress.getLocalHost().getHostName();
59
60      System.out.println("Hostname is "+hostname+"\n");
61
62      Naming.rebind("//localhost/PhoneBookRMIServer00",server);
63    }
64    catch(Exception e) {
65      e.printStackTrace(); 
66    }
67
68    System.out.println("\nReady!");
69  }
70
71}