001package edu.pdx.cs410J.rmi;
002
003import java.rmi.NotBoundException;
004import java.rmi.RemoteException;
005import java.rmi.registry.LocateRegistry;
006
007/**
008 * This program contacts the remote movie database and creates a new
009 * movie in it.  The id of the movie is printed out.
010 */
011public class CreateMovie {
012
013  public static void main(String[] args) {
014    String host = args[0];
015    int port = Integer.parseInt(args[1]);
016    String title = args[2];
017    int year = Integer.parseInt(args[3]);
018
019    try {
020      MovieDatabase db = (MovieDatabase) LocateRegistry.getRegistry(host, port).lookup(MovieDatabase.RMI_OBJECT_NAME);
021      long id = db.createMovie(title, year);
022      System.out.println("Created movie " + id);
023
024    } catch (RemoteException | NotBoundException ex) {
025      ex.printStackTrace(System.err);
026    }
027
028  }
029
030}