Package edu.pdx.cs410J.rmi
Class MovieDatabaseImpl
java.lang.Object
edu.pdx.cs410J.rmi.MovieDatabaseImpl
- All Implemented Interfaces:
MovieDatabase
,Remote
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.-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
A comparator that sorts movies based on the year in which they were released. -
Field Summary
Fields inherited from interface edu.pdx.cs410J.rmi.MovieDatabase
RMI_OBJECT_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
createMovie
(String title, int year) Creates a newMovie
object on the server.void
deleteMovie
(long movieId) executeQuery
(Query query, Comparator<Movie> sorter) Performs a query on the database.getFilmography
(long actorId) Returns the movie in which a given actor acted.getMovie
(long id) Returns theMovie
with the given id.Returns all of the movies in the databasestatic void
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 thisMovieDatabaseImpl
with the RMI registry.
-
Constructor Details
-
MovieDatabaseImpl
public MovieDatabaseImpl()Creates a newMovieDatabaseImpl
.
-
-
Method Details
-
createMovie
Creates a newMovie
object on the server. It returns the id of the movie that was created.- Specified by:
createMovie
in interfaceMovieDatabase
- Parameters:
title
- The title of the movieyear
- The year in which the movie was released
-
getMovie
Returns theMovie
with the given id.- Specified by:
getMovie
in interfaceMovieDatabase
-
noteCharacter
Makes note of a character in a given movie played by a given actor.- Specified by:
noteCharacter
in interfaceMovieDatabase
- Throws:
IllegalArgumentException
- There is no movie withmovieId
or the character is already played by someone else
-
getFilmography
Returns the movie in which a given actor acted. The movies are sorted by release date.- Specified by:
getFilmography
in interfaceMovieDatabase
-
executeQuery
Performs a query on the database. The movies that match the query are sorted using the given comparator.- Specified by:
executeQuery
in interfaceMovieDatabase
-
shutdown
Unregisters thisMovieDatabaseImpl
with the RMI registry.- Specified by:
shutdown
in interfaceMovieDatabase
- Throws:
RemoteException
-
getMovies
Description copied from interface:MovieDatabase
Returns all of the movies in the database- Specified by:
getMovies
in interfaceMovieDatabase
-
deleteMovie
- Specified by:
deleteMovie
in interfaceMovieDatabase
-
main
This main program registers an instance of MovieDatabaseImpl in an RMI registry.
-