edu.pdx.cs399J.rmi
Class MovieDatabaseImpl

java.lang.Object
  extended by edu.pdx.cs399J.rmi.MovieDatabaseImpl
All Implemented Interfaces:
MovieDatabase, Remote

public class MovieDatabaseImpl
extends Object
implements MovieDatabase

This class provides an implementation of the remote MovieDatabase interface. Note that this class does not extened UnicastRemoteObject. Therefore, we have to invoke UnicastRemoteObject.exportObject(java.rmi.Remote) in the constructor.


Constructor Summary
MovieDatabaseImpl()
          Creates a new MovieDatabaseImpl.
 
Method Summary
 long createMovie(String title, int year)
          Creates a new Movie object on the server.
 SortedSet<Movie> executeQuery(Query query, Comparator<Movie> sorter)
          Performs a query on the database.
 SortedSet<Movie> getFilmography(long actorId)
          Returns the movie in which a given actor acted.
 Movie getMovie(long id)
          Returns the Movie with the given id.
 Collection<Movie> getMovies()
          Returns all of the movies in the database
static void main(String[] args)
          This main program registers an instance of MovieDatabaseImpl in an RMI registry.
 void noteCharacter(long movieId, String character, long actorId)
          Makes note of a character in a given movie played by a given actor.
 void shutdown()
          Unregisters this MovieDatabseImpl with the RMI registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MovieDatabaseImpl

public MovieDatabaseImpl()
                  throws RemoteException
Creates a new MovieDatabaseImpl.

Throws:
RemoteException
Method Detail

createMovie

public long createMovie(String title,
                        int year)
                 throws RemoteException
Creates a new Movie object on the server. It returns the id of the movie that was created.

Specified by:
createMovie in interface MovieDatabase
Parameters:
title - The title of the movie
year - The year in which the movie was released
Throws:
RemoteException

getMovie

public Movie getMovie(long id)
               throws RemoteException
Returns the Movie with the given id.

Specified by:
getMovie in interface MovieDatabase
Throws:
RemoteException

noteCharacter

public void noteCharacter(long movieId,
                          String character,
                          long actorId)
                   throws RemoteException
Makes note of a character in a given movie played by a given actor.

Specified by:
noteCharacter in interface MovieDatabase
Throws:
IllegalArgumentException - There is no movie with movieId or the character is already played by someone else
RemoteException

getFilmography

public SortedSet<Movie> getFilmography(long actorId)
                                throws RemoteException
Returns the movie in which a given actor acted. The movies are sorted by release date.

Specified by:
getFilmography in interface MovieDatabase
Throws:
RemoteException

executeQuery

public SortedSet<Movie> executeQuery(Query query,
                                     Comparator<Movie> sorter)
                              throws RemoteException
Performs a query on the database. The movies that match the query are sorted using the given comparator.

Specified by:
executeQuery in interface MovieDatabase
Throws:
RemoteException

shutdown

public void shutdown()
              throws RemoteException
Unregisters this MovieDatabseImpl with the RMI registry.

Specified by:
shutdown in interface MovieDatabase
Throws:
RemoteException

getMovies

public Collection<Movie> getMovies()
                            throws RemoteException
Description copied from interface: MovieDatabase
Returns all of the movies in the database

Specified by:
getMovies in interface MovieDatabase
Throws:
RemoteException

main

public static void main(String[] args)
This main program registers an instance of MovieDatabaseImpl in an RMI registry.



Copyright © 2000-2009 Portland State University. All Rights Reserved.